RFR: 8263709: Cleanup THREAD/TRAPS/CHECK usage in JRT_ENTRY routines

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 8263709: Cleanup THREAD/TRAPS/CHECK usage in JRT_ENTRY routines

David Holmes-2
The existing JRT_ENTRY (and related) macros require the function to which they are applied to declare a parameter "JavaThread* thread" which represents the current thread. These functions are all implicitly "traps" functions as they can result in exceptions, but they are not declared with TRAPS because the only caller of these functions is the runtime itself (via call_VM) and no callers need to be aware to use CHECK; further they need a JavaThread. So the macro declares the THREAD variable for use with other exception-producing functions and assigns it from "thread".

The majority of this change replaces the parameter name "thread" with "current" so that it is clear that we are always dealing with the current thread. This affects the entry functions as well as the functions called therefrom.

We can then also replace the use of "THREAD" with "current", in contexts that are not related to exception processing.

Some methods called by entry functions were declared to have both a "thread" parameter and a "TRAPS" parameter - with nothing to tell you these are always the same, current, thread. So the "thread" parameter is removed and replaced with a local variable "current" obtained from THREAD->as_Java_thread().

Some missing CHECK_ uses were added.

Testing:
  - tiers 1-3

Thanks,
David

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

Commit messages:
 - 8263709: Cleanup THREAD/TRAPS/CHECK usage in JRT_ENTRY routines

Changes: https://git.openjdk.java.net/jdk/pull/3394/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3394&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263709
  Stats: 876 lines in 21 files changed: 15 ins; 27 del; 834 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3394.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3394/head:pull/3394

PR: https://git.openjdk.java.net/jdk/pull/3394
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8263709: Cleanup THREAD/TRAPS/CHECK usage in JRT_ENTRY routines [v2]

David Holmes-2
On Thu, 8 Apr 2021 13:00:03 GMT, Coleen Phillimore <[hidden email]> wrote:

>> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
>>
>>   Fixed CHECK on return statement.
>
> I think substituting "JavaThread* thread" for "JavaThread* current" is a good change and convention that makes the code more clear, so worth the dull code review and diffs.

Looks like I missed some definitions that aren't included in our test builds but have been found via GHA builds. I will rectify those and update.

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

PR: https://git.openjdk.java.net/jdk/pull/3394
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8263709: Cleanup THREAD/TRAPS/CHECK usage in JRT_ENTRY routines [v4]

David Holmes-2
In reply to this post by David Holmes-2
> The existing JRT_ENTRY (and related) macros require the function to which they are applied to declare a parameter "JavaThread* thread" which represents the current thread. These functions are all implicitly "traps" functions as they can result in exceptions, but they are not declared with TRAPS because the only caller of these functions is the runtime itself (via call_VM) and no callers need to be aware to use CHECK; further they need a JavaThread. So the macro declares the THREAD variable for use with other exception-producing functions and assigns it from "thread".
>
> The majority of this change replaces the parameter name "thread" with "current" so that it is clear that we are always dealing with the current thread. This affects the entry functions as well as the functions called therefrom.
>
> We can then also replace the use of "THREAD" with "current", in contexts that are not related to exception processing.
>
> Some methods called by entry functions were declared to have both a "thread" parameter and a "TRAPS" parameter - with nothing to tell you these are always the same, current, thread. So the "thread" parameter is removed and replaced with a local variable "current" obtained from THREAD->as_Java_thread().
>
> Some missing CHECK_ uses were added.
>
> Testing:
>   - tiers 1-3
>
> Thanks,
> David

David Holmes has updated the pull request incrementally with one additional commit since the last revision:

  Fix search&replace mistake

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3394/files
  - new: https://git.openjdk.java.net/jdk/pull/3394/files/041d7ef5..9cfc43c2

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

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3394.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3394/head:pull/3394

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