@Override public void beforeAnalysis(BeforeAnalysisAccess access) { RuntimeSupport.getRuntimeSupport().addStartupHook(SubstrateSegfaultHandler::install); } }
@Override public void beforeAnalysis(BeforeAnalysisAccess access) { RuntimeSupport.getRuntimeSupport().sortCommandPlugins(); } }
/** * Called only internally as part of the JDK shutdown process, use {@link #shutdown()} to * trigger the whoke JDK shutdown process. */ static void executeShutdownHooks() { executeHooks(getRuntimeSupport().shutdownHooks); }
/** * Called only internally as part of the isolate tear down process. These hooks clean up all * running threads to allow proper isolate tear down. * * Although public, this method should not go to the public API. */ public static void executeTearDownHooks() { executeHooks(getRuntimeSupport().tearDownHooks); }
@Override public void beforeAnalysis(BeforeAnalysisAccess access) { RuntimeSupport.getRuntimeSupport().addStartupHook(new Runnable() { @Override /** * Ignore SIGPIPE. Reading from a closed pipe, instead of delivering a process-wide * signal whose default action is to terminate the process, will instead return an error * code from the specific write operation. * * From pipe(7}: If all file descriptors referring to the read end of a pipe have been * closed, then a write(2) will cause a SIGPIPE signal to be generated for the calling * process. If the calling process is ignoring this signal, then write(2) fails with the * error EPIPE. */ public void run() { final Signal.SignalDispatcher signalResult = Signal.signal(Signal.SignalEnum.SIGPIPE.getCValue(), Signal.SIG_IGN()); VMError.guarantee(signalResult != Signal.SIG_ERR(), "IgnoreSIGPIPEFeature.run: Could not ignore SIGPIPE"); } }); } }
@Override public void afterRegistration(AfterRegistrationAccess access) { if (AllocationSite.Options.AllocationProfiling.getValue()) { RuntimeSupport.getRuntimeSupport().addShutdownHook(AllocationSite::dumpProfilingResults); } } }
@Override public void afterRegistration(AfterRegistrationAccess access) { RuntimeSupport.initializeRuntimeSupport(); ImageSingletons.add(VMRuntimeSupport.class, RuntimeSupport.getRuntimeSupport()); }
@Substitute static Object command(Object arg) { if (arg instanceof Object[]) { Object[] args = (Object[]) arg; if (args.length > 0) { Object arg0 = args[0]; if (arg0 instanceof String) { String cmd = (String) arg0; Object[] cmdargs = Arrays.copyOfRange(args, 1, args.length); RuntimeSupport rs = RuntimeSupport.getRuntimeSupport(); return rs.runCommand(cmd, cmdargs); } } } throw new IllegalArgumentException("Argument to java.lang.Compiler.command(Object) must be an Object[] " + "with the first element being a String providing the name of the SVM command to run " + "and subsequent elements being the arguments to the command"); } }
@Override public void afterRegistration(AfterRegistrationAccess access) { RuntimeSupport rs = RuntimeSupport.getRuntimeSupport(); rs.addCommandPlugin(new GetCRuntimeArgumentBlockLengthCommand()); rs.addCommandPlugin(new SetCRuntimeArgument0Command()); } }
@Override public void beforeAnalysis(BeforeAnalysisAccess access) { RuntimeSupport.getRuntimeSupport().addStartupHook(() -> { DumpAllStacks.install(); DumpHeapReport.install(); if (DeoptimizationSupport.enabled()) { DumpRuntimeCompilation.install(); } }); }
@Override public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) { com.oracle.svm.core.jdk.RuntimeSupport result = com.oracle.svm.core.jdk.RuntimeSupport.getRuntimeSupport(); JavaConstant constant = snippetReflection.forObject(result); ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph()); b.push(JavaKind.Object, node); b.notifyReplacedCall(targetMethod, node); return true; } @Override
public void initializeAtRuntime() { if (SubstrateOptions.MultiThreaded.getValue()) { compileQueue = new BackgroundCompileQueue(); RuntimeSupport.getRuntimeSupport().addTearDownHook(this::tearDown); } if (TruffleRuntimeOptions.getValue(SharedTruffleRuntimeOptions.TraceTruffleTransferToInterpreter)) { if (!SubstrateOptions.IncludeNodeSourcePositions.getValue()) { System.out.println("Warning: TraceTruffleTransferToInterpreter cannot print stack traces. Build image with -H:+IncludeNodeSourcePositions to enable stack traces."); } RuntimeOptionValues.singleton().update(Deoptimizer.Options.TraceDeoptimization, true); } updateGraalArchitectureWithHostCPUFeatures(getTruffleCompiler().getBackend()); installDefaultListeners(); }
dispatchThread.setDaemon(true); dispatchThread.start(); RuntimeSupport.getRuntimeSupport().addTearDownHook(() -> DispatchThread.interrupt(dispatchThread));
@Override public void afterRegistration(AfterRegistrationAccess access) { SubstrateRuntimeMXBean runtimeMXBean = new SubstrateRuntimeMXBean(); ImageSingletons.add(RuntimeMXBean.class, runtimeMXBean); ImageSingletons.add(ThreadMXBean.class, new SubstrateThreadMXBean()); ImageSingletons.add(ClassLoadingMXBean.class, new SubstrateClassLoadingMXBean()); ImageSingletons.add(CompilationMXBean.class, new SubstrateCompilationMXBean()); RuntimeSupport.getRuntimeSupport().addStartupHook(runtimeMXBean.startupHook()); }
public JNINativeInterface getGlobalFunctionTable() { JNINativeInterface functionTable = globalFunctionTable.get(); if (functionTable.isNull()) { functionTable = UnmanagedMemory.malloc(SizeOf.get(JNINativeInterface.class)); functionTableInitializer.initialize(functionTable); if (globalFunctionTable.compareAndSet(WordFactory.nullPointer(), functionTable)) { RuntimeSupport.getRuntimeSupport().addTearDownHook(() -> UnmanagedMemory.free(globalFunctionTable.get())); } else { // lost the race UnmanagedMemory.free(functionTable); functionTable = globalFunctionTable.get(); } } return functionTable; }
RuntimeSupport.getRuntimeSupport().executeStartupHooks(); RuntimeSupport.getRuntimeSupport().shutdown();
@CEntryPoint(name = "JNI_CreateJavaVM") @CEntryPointOptions(prologue = JNICreateJavaVMPrologue.class, publishAs = Publish.SymbolOnly, include = CEntryPointOptions.NotIncludedAutomatically.class) static int JNI_CreateJavaVM(JNIJavaVMPointer vmBuf, JNIEnvironmentPointer penv, JNIJavaVMInitArgs vmArgs) { // NOTE: could check version, extra options (-verbose etc.), hooks etc. if (vmArgs.isNonNull()) { Pointer p = (Pointer) vmArgs.getOptions(); int count = vmArgs.getNOptions(); ArrayList<String> options = new ArrayList<>(count); for (int i = 0; i < count; i++) { JNIJavaVMOption option = (JNIJavaVMOption) p.add(i * SizeOf.get(JNIJavaVMOption.class)); CCharPointer str = option.getOptionString(); if (str.isNonNull()) { options.add(CTypeConversion.toJavaString(option.getOptionString())); } } RuntimeOptionParser.parseAndConsumeAllOptions(options.toArray(new String[0])); } JNIJavaVM javavm = JNIFunctionTables.singleton().getGlobalJavaVM(); JNIJavaVMList.addJavaVM(javavm); RuntimeSupport.getRuntimeSupport().addTearDownHook(new Runnable() { @Override public void run() { JNIJavaVMList.removeJavaVM(javavm); } }); vmBuf.write(javavm); penv.write(JNIThreadLocalEnvironment.getAddress()); return JNIErrors.JNI_OK(); }
public JNIJavaVM getGlobalJavaVM() { if (globalJavaVM.isNull()) { JNIInvokeInterface invokes = UnmanagedMemory.calloc(SizeOf.get(JNIInvokeInterface.class)); invokesInitializer.initialize(invokes); invokes.setIsolate(CurrentIsolate.getIsolate()); globalJavaVM = UnmanagedMemory.calloc(SizeOf.get(JNIJavaVM.class)); globalJavaVM.setFunctions(invokes); RuntimeSupport.getRuntimeSupport().addTearDownHook(() -> { UnmanagedMemory.free(globalJavaVM.getFunctions()); UnmanagedMemory.free(globalJavaVM); globalJavaVM = WordFactory.nullPointer(); }); } return globalJavaVM; }
this.walkRegisteredMemoryTimer = new Timer("walkRegisteredMemory"); RuntimeSupport.getRuntimeSupport().addShutdownHook(this::printGCSummary);
objectReplacer.setGraalRuntime(graalRuntime); ImageSingletons.add(GraalRuntime.class, graalRuntime); RuntimeSupport.getRuntimeSupport().addShutdownHook(new GraalSupport.GraalShutdownHook());