RFR: 8357396: Refactor nmethod::make_not_entrant to use Enum instead of "const char*" [v3]

Aleksey Shipilev shade at openjdk.org
Tue Jun 3 17:52:05 UTC 2025


On Tue, 3 Jun 2025 17:44:30 GMT, Cesar Soares Lucas <cslucas at openjdk.org> wrote:

>> Please review this refactor to transform the reasons for making an nmethod not entrant from `const char*` into enum values.
>> 
>> Tested on Linux x64 with JTREG tier1-3 in fastdebug and release mode.
>
> Cesar Soares Lucas has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Address PR feedback: more refactoring / renamings

Almost there, more cosmetics.

src/hotspot/share/code/nmethod.hpp line 500:

> 498:   static const char* change_reason_to_string(ChangeReason change_reason) {
> 499:     switch (change_reason) {
> 500:         case ChangeReason::C1_codepatch:                            return "C1 code patch";

Indenting: should be two spaces everywhere. Also, I think this kind of indenting forces us to re-align the switch for the largest enum label. Let's just break them. Plus, any multi-line blocks should be braced. So, in total:


switch (change_reason) {
  case ChangeReason::C1_codepatch: 
    return "C1 code patch";
  ...
  default: {
    assert(false, "Unhandled reason");
    return "Unknown";
  }
}

src/hotspot/share/code/nmethod.hpp line 691:

> 689:   // another thread performed the transition.
> 690:   bool  make_not_entrant(ChangeReason change_reason);
> 691:   bool  make_not_used()    { return make_not_entrant(ChangeReason::not_used); }

Suggestion:

  bool  make_not_used() { return make_not_entrant(ChangeReason::not_used); }

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

PR Review: https://git.openjdk.org/jdk/pull/25338#pullrequestreview-2893478002
PR Review Comment: https://git.openjdk.org/jdk/pull/25338#discussion_r2124511959
PR Review Comment: https://git.openjdk.org/jdk/pull/25338#discussion_r2124514702


More information about the hotspot-dev mailing list