RFR: 8276563: Undefined Behaviour in class Assembler [v2]

Andrew Haley aph at openjdk.java.net
Thu Nov 11 11:44:38 UTC 2021


On Tue, 9 Nov 2021 12:52:20 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Andrew Haley has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Cleanup, constify.
>>  - Cleanup, constify.
>
> src/hotspot/cpu/aarch64/register_aarch64.hpp line 44:
> 
>> 42: extern name all_ ## type ## s[name::number_of_declared_registers] INTERNAL_VISIBILITY; \
>> 43: constexpr type first_ ## type = all_ ## type ## s;                      \
>> 44: inline constexpr type name::first() { return all_ ## type ## s; }
> 
> Same here:
> 
> Suggestion:
> 
> // Macros to help define all kinds of registers
> 
> #define REGISTER_IMPL_DECLARATION(type, impl_type)                           \
> inline const type as_ ## type(int encoding) {                           \
>   assert(encoding <= impl_type::number_of_declared_registers, "invalid register"); \
>   return encoding == -1 ? impl_type::invalid() : impl_type::first() + encoding;   \
> }                                                                       \
> extern impl_type all_ ## type ## s[impl_type::number_of_declared_registers] INTERNAL_VISIBILITY; \
> constexpr type first_ ## type = all_ ## type ## s;                      \
> inline constexpr type impl_type::first() { return all_ ## type ## s; }

Done.

> src/hotspot/cpu/aarch64/register_aarch64.hpp line 47:
> 
>> 45: 
>> 46: #define REGISTER_IMPL_DEFINITION(type, name)                    \
>> 47: name all_ ## type ## s[name::number_of_declared_registers];
> 
> The use of the macro parameters `type` and `name` here, is a bit confusing since they mean something else in the `CONSTANT_REGISTER_DECLARATION` macro below.
> 
> I'd suggest changing the parameter names to `type` and `impl_type` instead, to reflect that they are `<regtype>` and `<regtype>Impl`
> 
> Suggestion:
> 
> #define REGISTER_IMPL_DEFINITION(type, impl_type)                    \
> impl_type all_ ## type ## s[impl_type::number_of_declared_registers];

Done.

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

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


More information about the hotspot-compiler-dev mailing list