RFR: 8260341: CDS dump VM init code does not check exceptions [v3]

Ioi Lam iklam at openjdk.java.net
Thu Feb 11 04:03:53 UTC 2021


> When CDS dumping is enabled, special initialization happens during VM init. However, many of these calls do not properly check for exception. Instead, they rely on the implicit knowledge that `metaspace::allocate()` will exit the VM when allocation fails during CDS dumping. This makes the code hard to understand and tightly coupled to `metaspace::allocate()`.
> 
> The fix is: all code that makes allocation should be using CHECK macros, so each block of code can be individually understood without considering the behavior of `metaspace::allocate()`.
> 
> I added `TRAPS` to a bunch of CDS-related functions that are called during VM init. In some cases, I changed `Thread* THREAD` to `TRAPS`. This also eliminated a few `Thread* THREAD = Thread::current()` calls.
> 
> The "root" of these calls, such as `MetaspaceShared::prepare_for_dumping()`, now follows this pattern:
> 
>   EXCEPTION_MARK;
>   ClassLoader::initialize_shared_path(THREAD);
>   if (HAS_PENDING_EXCEPTION) {
>     java_lang_Throwable::print(PENDING_EXCEPTION, tty);
>     vm_exit_during_initialization("ClassLoader::initialize_shared_path() failed unexpectedly");
>   }

Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:

 - Merge branch 'master' into 8260341-cds-dump-vm-init-does-not-check-exceptions
 - Changed THREAD in tail calls to CHECK
 - 8260341: CDS dump VM init code does not check exceptions

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/2494/files
  - new: https://git.openjdk.java.net/jdk/pull/2494/files/218af58f..dd3c7e08

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2494&range=02
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2494&range=01-02

  Stats: 1017 lines in 43 files changed: 425 ins; 347 del; 245 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2494.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2494/head:pull/2494

PR: https://git.openjdk.java.net/jdk/pull/2494


More information about the hotspot-dev mailing list