Search in sources :

Example 11 with Unreachable

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

the class TrampolineCompiler method checkClassExists.

private boolean checkClassExists(Function f, Trampoline t) {
    String targetClassName = t.getTarget();
    if (isArray(targetClassName)) {
        if (isPrimitiveBaseType(targetClassName)) {
            return true;
        }
        targetClassName = getBaseType(targetClassName);
    }
    Clazz target = config.getClazzes().load(targetClassName);
    if (target != null) {
        Clazz caller = config.getClazzes().load(t.getCallingClass());
        // If caller is in the bootclasspath it only sees classes in the bootclasspath
        if (!caller.isInBootClasspath() || target.isInBootClasspath()) {
            return true;
        }
    }
    call(f, BC_THROW_NO_CLASS_DEF_FOUND_ERROR, f.getParameterRef(0), mb.getString(t.getTarget()));
    f.add(new Unreachable());
    return false;
}
Also used : Unreachable(org.robovm.compiler.llvm.Unreachable) Clazz(org.robovm.compiler.clazz.Clazz)

Example 12 with Unreachable

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

the class TrampolineCompiler method throwNoSuchFieldError.

private void throwNoSuchFieldError(Function f, FieldAccessor accessor) {
    call(f, BC_THROW_NO_SUCH_FIELD_ERROR, f.getParameterRef(0), mb.getString(String.format(NO_SUCH_FIELD_ERROR, accessor.getTarget().replace('/', '.'), accessor.getFieldName())));
    f.add(new Unreachable());
}
Also used : Unreachable(org.robovm.compiler.llvm.Unreachable)

Example 13 with Unreachable

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

the class MethodCompiler method throw_.

private void throw_(ThrowStmt stmt) {
    Value obj = immediate(stmt, (Immediate) stmt.getOp());
    checkNull(stmt, obj);
    call(stmt, BC_THROW, env, obj);
    function.add(new Unreachable()).attach(stmt);
}
Also used : Unreachable(org.robovm.compiler.llvm.Unreachable) Value(org.robovm.compiler.llvm.Value)

Example 14 with Unreachable

use of org.robovm.compiler.llvm.Unreachable 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

Unreachable (org.robovm.compiler.llvm.Unreachable)14 Function (org.robovm.compiler.llvm.Function)6 Clazz (org.robovm.compiler.clazz.Clazz)5 FunctionRef (org.robovm.compiler.llvm.FunctionRef)5 Value (org.robovm.compiler.llvm.Value)5 FunctionType (org.robovm.compiler.llvm.FunctionType)4 Label (org.robovm.compiler.llvm.Label)4 Ret (org.robovm.compiler.llvm.Ret)4 ArrayList (java.util.ArrayList)3 BasicBlockRef (org.robovm.compiler.llvm.BasicBlockRef)3 ConstantBitcast (org.robovm.compiler.llvm.ConstantBitcast)3 FunctionDeclaration (org.robovm.compiler.llvm.FunctionDeclaration)3 Global (org.robovm.compiler.llvm.Global)3 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)3 NullConstant (org.robovm.compiler.llvm.NullConstant)3 Type (org.robovm.compiler.llvm.Type)3 MarshalSite (org.robovm.compiler.MarshalerLookup.MarshalSite)2 MarshalerMethod (org.robovm.compiler.MarshalerLookup.MarshalerMethod)2 PointerMarshalerMethod (org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod)2 DataLayout (org.robovm.compiler.llvm.DataLayout)2