RFR: 8261480: MetaspaceShared::preload_and_dump should check exceptions [v5]

David Holmes dholmes at openjdk.java.net
Wed Mar 17 23:12:49 UTC 2021


On Wed, 17 Mar 2021 20:48:59 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> `MetaspaceShared::preload_and_dump()`, as well as many of the functions that it calls, have extensive use of `THREAD` when calling functions that can potentially throw exceptions. Many of these call sites explicitly check for failure status, or assume that the caller would terminate the VM if an exception were to happen. This makes the code hard to understand and potentially unsafe.
>> 
>> I have make 3 types of changes:
>> 
>> 1. In most cases, replace THREAD with CHECK. Moved all the fatal error check to `MetaspaceShared::preload_and_dump()`, where it handles any uncaught exceptions and explicitly terminates the VM.
>> 2. If a `TRAPS` function can never throw, replace the `TRAPS` declaration with `Thread* current`
>> 3. In cases where an exception is handled and discarded, use `THREAD` immediately followed by  `HAS_PENDING_EXCEPTION` -> `CLEAR_PENDING_EXCEPTION` to make the code easy to understand. HandleMark is used to assert that no exception escapes.
>> 
>> (See `MetaspaceShared::try_link_class` for an example of 2 and 3).
>> 
>> Tested with tiers 1-4.
>
> Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 10 commits:
> 
>  - Merge branch 'master' of https://github.com/openjdk/jdk into 8261480-preload-and-dump-should-check-exceptions
>  - Merge branch 'master' into 8261480-preload-and-dump-should-check-exceptions
>  - @calvinccheung comments: restored PerfClassTraceTime
>  - @dholmes-ora comments
>  - @dholmes-ora comments
>  - added ExceptionMark
>  - Merge branch 'master' into 8261480-preload-and-dump-should-check-exceptions
>  - step3
>  - step2
>  - 8261480: MetaspaceShared::preload_and_dump should check exceptions

Marked as reviewed by dholmes (Reviewer).

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

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


More information about the hotspot-runtime-dev mailing list