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

Ioi Lam iklam at openjdk.java.net
Wed Feb 10 18:13:43 UTC 2021


On Wed, 10 Feb 2021 14:33:50 GMT, Harold Seigel <hseigel at openjdk.org> wrote:

> Hi Ioi,
> Do you avoid using CHECK if it's the last line of a function? For example, why is THREAD used instead of CHECK at line 1506?
> Thanks, Harold
> 
> 1503 void ClassLoader::initialize_module_path(TRAPS) {
> 1504 if (Arguments::is_dumping_archive()) {
> 1505 ClassLoaderExt::setup_module_paths(CHECK);
> 1506 FileMapInfo::allocate_shared_path_table(THREAD);
> 1507 }
> 1508 }

I thought it was a commonly used coding convention, but I could only find a few cases where the code wasn't written by me :-(

- https://github.com/openjdk/jdk/blame/b9d4211bc1aa92e257ddfe86c7a2b4e4e60598a0/src/hotspot/share/prims/jvm.cpp#L311
- https://github.com/openjdk/jdk/blame/f03e839e481f905358ce7d95a5d1f5179e7f46fe/src/hotspot/share/classfile/javaClasses.cpp#L2415

I will go back to `CHECK`, since the C++ compiler will elide the last `CHECK` anyway: in both cases, gcc compiles the last call to a direct branch to FileMapInfo::allocate_shared_path_table (i.e., a tail call).

Using `CHECK` makes the code easier to maintain (if you add new code below it).

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

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


More information about the hotspot-dev mailing list