[rvm-research] Disable VM shutdown/GC in the end of VM execution

Erik Brangs <[email protected]> Mon, 12 Nov 2018 23:44:37 +0100
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
Hi,

On 12.11.2018 20:00, Kenan Liu wrote:
> We tried inserted our profiling collection in the org.jikesrvm.VM.shutdown() and org.jikesrvm.VM.sysExit() before the shutdown() method. In both situations the data only can be partially printed out. It looks like the collection would be destroyed before it finishes.
I had a similar problem once. In my case, printing the data using shutdown hooks worked.

> We are trying to figure out the shutdown point that Jikes RVM normally executes instead of shut down by exception or error signal.
For a normal shutdown or a shutdown by Java exception, look at terminate() in RVMThread. For both theses cases, System.exit(..) will be called to make sure that shutdown hooks run.

> We haven't tried Java API to shutdown VM because don't want to interrupt the current Jikes RVM behavior.
Shutdown hooks are part of the standard Java API and therefore part of the normal VM behaviour. They're implemented by the Java class library. For GNU Classpath (the default class library for Jikes RVM), the path is roughly as follows:
java.lang.System.exit(..) -> java.lang.Runtime.exit(..) -> java.lang.Runtime.runShutdownHooks() -> java.lang.Runtime.halt(..) -> java.lang.VMRuntime.exit(..) from the libraryInterface directory -> org.jikesrvm.VM.sysExit(..) -> org.jikesrvm.VM.shutdown(..) -> SysCall.sysCall.sysExit(..) -> sysExit(..) implementation in C in tools/bootloader/sysThread.c

> I read the Oracle article about the Design of Shutdown Hooks API <https://docs.oracle.com/javase/8/docs/technotes/guides/lang/hook-design.html>. It looks like the shutdown hooks are usually run concurrently. Is that the case in Jikes RVM?
IIRC shutdown hooks are run concurrently with each other in Jikes RVM. However, the VM doesn't terminate until the shutdown hooks have finished.


Kind regards,

Erik Brangs