Search in sources :

Example 1 with RuntimeSupport

use of com.oracle.svm.core.jdk.RuntimeSupport 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;
}
Also used : RuntimeSupport(com.oracle.svm.core.jdk.RuntimeSupport) Architecture(jdk.vm.ci.code.Architecture) TargetDescription(jdk.vm.ci.code.TargetDescription) AllocationSite(com.oracle.svm.core.allocationprofile.AllocationSite) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Aggregations

AllocationSite (com.oracle.svm.core.allocationprofile.AllocationSite)1 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)1 RuntimeSupport (com.oracle.svm.core.jdk.RuntimeSupport)1 Architecture (jdk.vm.ci.code.Architecture)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)1