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

Cesar Soares Lucas cslucas at openjdk.org
Tue Jun 3 17:06:56 UTC 2025


On Tue, 3 Jun 2025 08:40:41 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> src/hotspot/share/code/nmethod.hpp line 498:
>> 
>>> 496: 
>>> 497: 
>>> 498:   static const char* NMethodChangeReason_to_string(NMethodChangeReason reason) {
>> 
>> Uh, use a switch:
>> 
>> 
>>  switch(reason) {
>>     case C1_deoptimize: return "C1 deoptimized";
>>     case C1_codepatch:  return "C1 code patch";
>>     ...
>>     default:
>>        assert(false, "Unhandled reason");
>>        return "Unknown";
>>  }
>
> Also, names: `change_reason_to_string(ChangeReason reason)`. Now that enum is scoped to `nmethod`, there is no need for `NMethod` prefix.

Makes sense, thanks!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25338#discussion_r2124446618


More information about the hotspot-dev mailing list