On Thu, 13 Jul 2023 21:25:17 GMT, Matias Saavedra Silva <matsa...@openjdk.org> wrote:
> Currently we exit the VM after static dumping with > `MetaspaceShared::exit_after_static_dump()`. > > > // We have finished dumping the static archive. At this point, there may be > pending VM > // operations. We have changed some global states (such as > vmClasses::_klasses) that > // may cause these VM operations to fail. For safety, forget these > operations and > // exit the VM directly. > void MetaspaceShared::exit_after_static_dump() { > os::_exit(0); > } > > > As the comment suggests, the VM state is altered when preparing and > performing the static dump, so this change aims to prevent these state > changes so the VM can exit normally after the static dump completes. There > are three major aspects to this change: > 1. Since the resolved references array in the Constant Pool is altered when > preparing for a static dump, a "scratch copy" is created and archived instead > 2. Symbols are sorted by address and have their hash recalculated. Similarly > to point 1, the copies of the symbols that are to be archived have their > hashes updated as opposed to the originals. > 3. The handling of -Xshare:dump during argument parsing such that the VM can > continue and exit normally with an exit code of 0. Hi Matias, I'm not keen on having to teach the launcher about `-Xshare:dump` and that it is a terminal operation. But after looking into it I have to admit it is a cleaner and more consistent termination strategy. That said you need to be aware that this will now do a clean shutdown of the VM after the dump, so shutdown hooks will now run. Lets see what core-libs folk think too. Thanks. src/hotspot/share/runtime/threads.cpp line 812: > 810: if (DumpSharedSpaces) { > 811: MetaspaceShared::preload_and_dump(); > 812: *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again This is only set when create_vm fails. A successful creation of the VM prevents subsequent re-creation attempts. ------------- PR Review: https://git.openjdk.org/jdk/pull/14879#pullrequestreview-1531828953 PR Review Comment: https://git.openjdk.org/jdk/pull/14879#discussion_r1264773183