RFR: 8253402: Convert vmSymbols::SID to enum class [v4]

Ioi Lam iklam at openjdk.java.net
Tue Oct 13 18:15:12 UTC 2020


On Tue, 13 Oct 2020 15:42:41 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   added missing #include <limits> from enumIterator.hpp
>
> src/hotspot/share/classfile/vmSymbols.hpp line 732:
> 
>> 730:
>> 731:   enum {
>> 732:     log2_SID_LIMIT = 11         // checked by an assert at start-up
> 
> [pre-existing, could be followup]
> Why isn't this checked with a static assert right here?
> `SID_LIMIT <= (1 << log2_SID_LIMIT)`
> is (and always has been) compile-time checkable. And log2_SID_LIMIT should no longer be an enum. (Note that the value
> isn't currently constexpr-calculable because round_up_power_of_2 can't currently be constexpr.)

The existing code groups several asserts together. I think this makes the intention clearer. I'll leave it for now.

void vmSymbols::initialize(TRAPS) {
  assert(SID_LIMIT <= (1<<log2_SID_LIMIT), "must fit in this bitfield");
  assert(SID_LIMIT*5 > (1<<log2_SID_LIMIT), "make the bitfield smaller, please");
  assert(vmIntrinsics::FLAG_LIMIT <= (1 << vmIntrinsics::log2_FLAG_LIMIT), "must fit in this bitfield");

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

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


More information about the hotspot-dev mailing list