Search in sources :

Example 26 with Ret

use of org.robovm.compiler.llvm.Ret in project robovm by robovm.

the class Linker method createCheckcast.

private Function createCheckcast(ModuleBuilder mb, Clazz clazz, TypeInfo typeInfo) {
    Function fn = FunctionBuilder.checkcast(clazz);
    Value info = getInfoStruct(mb, fn, clazz);
    if (typeInfo.error) {
        // This will trigger an exception
        call(fn, BC_LDC_CLASS, fn.getParameterRef(0), info);
        fn.add(new Ret(new NullConstant(Types.OBJECT_PTR)));
    } else if (!clazz.getClazzInfo().isInterface()) {
        Value result = call(fn, CHECKCAST_CLASS, fn.getParameterRef(0), info, fn.getParameterRef(1), new IntegerConstant((typeInfo.classTypes.length - 1) * 4 + 5 * 4), new IntegerConstant(typeInfo.id));
        fn.add(new Ret(result));
    } else {
        Value result = call(fn, CHECKCAST_INTERFACE, fn.getParameterRef(0), info, fn.getParameterRef(1), new IntegerConstant(typeInfo.id));
        fn.add(new Ret(result));
    }
    return fn;
}
Also used : Ret(org.robovm.compiler.llvm.Ret) ModifiedUtf8HashFunction(org.robovm.compiler.hash.ModifiedUtf8HashFunction) Function(org.robovm.compiler.llvm.Function) Value(org.robovm.compiler.llvm.Value) NullConstant(org.robovm.compiler.llvm.NullConstant) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Example 27 with Ret

use of org.robovm.compiler.llvm.Ret in project robovm by robovm.

the class ClassCompiler method createLdcClass.

private Function createLdcClass() {
    Function fn = FunctionBuilder.ldcInternal(sootClass);
    Value info = getInfoStruct(fn, sootClass);
    Value result = call(fn, BC_LDC_CLASS, fn.getParameterRef(0), info);
    fn.add(new Ret(result));
    return fn;
}
Also used : Ret(org.robovm.compiler.llvm.Ret) Function(org.robovm.compiler.llvm.Function) Value(org.robovm.compiler.llvm.Value)

Example 28 with Ret

use of org.robovm.compiler.llvm.Ret in project robovm by robovm.

the class AbstractMethodCompiler method compileSynchronizedWrapper.

private void compileSynchronizedWrapper(ModuleBuilder moduleBuilder, SootMethod method) {
    String targetName = Symbols.methodSymbol(method);
    Function syncFn = FunctionBuilder.synchronizedWrapper(method);
    moduleBuilder.addFunction(syncFn);
    FunctionType functionType = syncFn.getType();
    FunctionRef target = new FunctionRef(targetName, functionType);
    Value monitor = null;
    if (method.isStatic()) {
        FunctionRef fn = FunctionBuilder.ldcInternal(sootMethod.getDeclaringClass()).ref();
        monitor = call(syncFn, fn, syncFn.getParameterRef(0));
    } else {
        monitor = syncFn.getParameterRef(1);
    }
    call(syncFn, MONITORENTER, syncFn.getParameterRef(0), monitor);
    BasicBlockRef bbSuccess = syncFn.newBasicBlockRef(new Label("success"));
    BasicBlockRef bbFailure = syncFn.newBasicBlockRef(new Label("failure"));
    trycatchAllEnter(syncFn, bbSuccess, bbFailure);
    syncFn.newBasicBlock(bbSuccess.getLabel());
    Value result = call(syncFn, target, syncFn.getParameterRefs());
    trycatchLeave(syncFn);
    call(syncFn, MONITOREXIT, syncFn.getParameterRef(0), monitor);
    syncFn.add(new Ret(result));
    syncFn.newBasicBlock(bbFailure.getLabel());
    trycatchLeave(syncFn);
    call(syncFn, MONITOREXIT, syncFn.getParameterRef(0), monitor);
    call(syncFn, BC_THROW_IF_EXCEPTION_OCCURRED, syncFn.getParameterRef(0));
    syncFn.add(new Unreachable());
}
Also used : Ret(org.robovm.compiler.llvm.Ret) Function(org.robovm.compiler.llvm.Function) BasicBlockRef(org.robovm.compiler.llvm.BasicBlockRef) Unreachable(org.robovm.compiler.llvm.Unreachable) FunctionType(org.robovm.compiler.llvm.FunctionType) Value(org.robovm.compiler.llvm.Value) Label(org.robovm.compiler.llvm.Label) FunctionRef(org.robovm.compiler.llvm.FunctionRef)

Aggregations

Ret (org.robovm.compiler.llvm.Ret)28 Value (org.robovm.compiler.llvm.Value)26 Function (org.robovm.compiler.llvm.Function)24 FunctionRef (org.robovm.compiler.llvm.FunctionRef)14 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)9 Variable (org.robovm.compiler.llvm.Variable)8 FunctionType (org.robovm.compiler.llvm.FunctionType)7 Global (org.robovm.compiler.llvm.Global)7 Label (org.robovm.compiler.llvm.Label)7 NullConstant (org.robovm.compiler.llvm.NullConstant)7 PointerType (org.robovm.compiler.llvm.PointerType)7 ArrayList (java.util.ArrayList)6 Bitcast (org.robovm.compiler.llvm.Bitcast)6 ConstantBitcast (org.robovm.compiler.llvm.ConstantBitcast)6 Load (org.robovm.compiler.llvm.Load)6 Type (org.robovm.compiler.llvm.Type)6 Br (org.robovm.compiler.llvm.Br)5 StructureType (org.robovm.compiler.llvm.StructureType)5 BasicBlockRef (org.robovm.compiler.llvm.BasicBlockRef)4 FunctionDeclaration (org.robovm.compiler.llvm.FunctionDeclaration)4