use of com.oracle.svm.core.c.function.CEntryPointOptions in project graal by oracle.
the class JavaMainWrapper method run.
@CEntryPoint
@CEntryPointOptions(prologue = EnterCreateIsolatePrologue.class, include = CEntryPointOptions.NotIncludedAutomatically.class)
public static int run(int paramArgc, CCharPointerPointer paramArgv) throws Exception {
JavaThreads.singleton().assignJavaThread(preallocatedThread, true);
JavaMainWrapper.argc = paramArgc;
JavaMainWrapper.argv = paramArgv;
Architecture imageArchitecture = ImageSingletons.lookup(TargetDescription.class).arch;
AMD64CPUFeatureAccess.verifyHostSupportsArchitecture(imageArchitecture);
String[] args = SubstrateUtil.getArgs(paramArgc, paramArgv);
if (SubstrateOptions.ParseRuntimeOptions.getValue()) {
args = RuntimeOptionParser.singleton().parse(args, DEFAULT_OPTION_PREFIX, PLUS_MINUS, true);
args = RuntimeOptionParser.singleton().parse(args, GRAAL_OPTION_PREFIX, NAME_VALUE, true);
args = XOptions.singleton().parse(args);
args = RuntimePropertyParser.parse(args);
}
mainArgs = args;
try {
final RuntimeSupport rs = RuntimeSupport.getRuntimeSupport();
if (AllocationSite.Options.AllocationProfiling.getValue()) {
rs.addShutdownHook(new AllocationSite.AllocationProfilingShutdownHook());
}
if (SubstrateOptions.PrintGCSummary.getValue()) {
rs.addShutdownHook(new PrintGCSummaryShutdownHook());
}
try {
JavaMainSupport.executeStartupHooks();
ImageSingletons.lookup(JavaMainSupport.class).getJavaMainMethod().invoke(null, (Object) mainArgs);
} finally {
// always execute the shutdown hooks
JavaMainSupport.executeShutdownHooks();
}
} catch (Throwable ex) {
SnippetRuntime.reportUnhandledExceptionJava(ex);
}
JavaThreads.singleton().joinAllNonDaemons();
Counter.logValues();
return 0;
}
use of com.oracle.svm.core.c.function.CEntryPointOptions in project graal by oracle.
the class NativeAPIImpl method releaseAndReturn.
@CEntryPoint
@CEntryPointOptions(prologue = EnterNativeTruffleEnvPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static TruffleObjectHandle releaseAndReturn(@SuppressWarnings("unused") NativeTruffleEnv env, TruffleObjectHandle handle) {
TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
Object object = support.resolveHandle(handle);
support.destroyGlobalHandle(handle);
return TruffleNFISupport.createLocalHandle(object);
}
use of com.oracle.svm.core.c.function.CEntryPointOptions in project graal by oracle.
the class NativeAPIImpl method newObjectRef.
@CEntryPoint
@CEntryPointOptions(prologue = EnterNativeTruffleEnvPrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static TruffleObjectHandle newObjectRef(@SuppressWarnings("unused") NativeTruffleEnv env, TruffleObjectHandle handle) {
TruffleNFISupport support = ImageSingletons.lookup(TruffleNFISupport.class);
Object object = support.resolveHandle(handle);
return support.createGlobalHandle(object);
}
use of com.oracle.svm.core.c.function.CEntryPointOptions in project graal by oracle.
the class NativeClosure method invokeClosureBufferRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureBufferRet(@SuppressWarnings("unused") ffi_cif cif, Pointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
NativeClosure closure = lookup(user);
ByteBuffer retBuffer = closure.createRetBuffer(ret);
Target_com_oracle_truffle_nfi_impl_LibFFIClosure_RetPatches patches = (Target_com_oracle_truffle_nfi_impl_LibFFIClosure_RetPatches) closure.call(args, retBuffer);
if (patches != null) {
for (int i = 0; i < patches.count; i++) {
Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag tag = getTag(patches.patches[i]);
int offset = getOffset(patches.patches[i]);
Object obj = patches.objects[i];
if (tag == Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag.OBJECT) {
WordBase handle = ImageSingletons.lookup(TruffleNFISupport.class).createGlobalHandle(obj);
ret.writeWord(offset, handle);
} else if (tag == Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag.STRING) {
ret.writeWord(offset, serializeStringRet(obj));
} else {
// nothing to do
}
}
}
} finally {
Errno.set_errno(errnoMirror.read());
}
}
use of com.oracle.svm.core.c.function.CEntryPointOptions in project graal by oracle.
the class NativeClosure method invokeClosureVoidRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureVoidRet(@SuppressWarnings("unused") ffi_cif cif, @SuppressWarnings("unused") WordPointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
lookup(user).call(args, null);
} finally {
Errno.set_errno(errnoMirror.read());
}
}
Aggregations