use of org.robovm.compiler.llvm.Function in project robovm by robovm.
the class TrampolineCompiler method createMultianewarray.
private FunctionRef createMultianewarray(Multianewarray t) {
String fnName = Symbols.multianewarraySymbol(t.getTarget());
if (!mb.hasSymbol(fnName)) {
Function fn = new FunctionBuilder(t).name(fnName).linkage(weak).build();
Value arrayClass = callLdcArray(fn, t.getTarget());
Value result = call(fn, BC_NEW_MULTI_ARRAY, fn.getParameterRef(0), fn.getParameterRef(1), fn.getParameterRef(2), arrayClass);
fn.add(new Ret(result));
mb.addFunction(fn);
}
return new FunctionRef(fnName, t.getFunctionType());
}
use of org.robovm.compiler.llvm.Function 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;
}
use of org.robovm.compiler.llvm.Function 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;
}
use of org.robovm.compiler.llvm.Function 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());
}
Aggregations