RFR: 8250269: Replace ATTRIBUTE_ALIGNED with alignas [v15]

Julian Waters jwaters at openjdk.org
Sat Jun 3 14:27:11 UTC 2023


On Wed, 12 Apr 2023 01:36:01 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Julian Waters has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 15 additional commits since the last revision:
>> 
>>  - Merge branch 'openjdk:master' into alignas
>>  - alignas
>>  - Merge branch 'openjdk:master' into alignas
>>  - Merge branch 'openjdk:master' into alignas
>>  - Merge branch 'openjdk:master' into alignas
>>  - Merge branch 'openjdk:master' into alignas
>>  - Merge branch 'openjdk:master' into alignas
>>  - Merge branch 'openjdk:master' into alignas
>>  - Merge branch 'openjdk:master' into alignas
>>  - Merge branch 'openjdk:master' into alignas
>>  - ... and 5 more: https://git.openjdk.org/jdk/compare/11cb8426...a621bb62
>
> I've been meaning to review this but have been swamped.  Sorry.
> 
> I don't think this change to HotSpot should be combined with JDK-8305341 / PR#13258.
> 
> I'm concerned there might be uses of ATTRIBUTE_ALIGNED in other places than at
> the front of the declaration (like the fixed offset_of macro in the proposed changes).
> Obviously there aren't any that break compilation.  But is alignas in other
> places valid but with a different meaning?  For a discussion of the kind of
> thing I'm concerned about, see
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796

@kimbarrett Sorry for such a long period of absence, I was dealing with some things. I've written down all the usage sites excluding the globalDefinitions_gcc.hpp offset_of case as such (included the code affected for easy grepping as well):

macroAssembler_aarch64_log.cpp:
`ATTRIBUTE_ALIGNED(64) juint _L_tbl[] =`

stubRoutines_aarch64.cpp:

ATTRIBUTE_ALIGNED(4096) juint StubRoutines::aarch64::_crc_table[] =
ATTRIBUTE_ALIGNED(64) jubyte StubRoutines::aarch64::_adler_table[] = {
ATTRIBUTE_ALIGNED(64) juint StubRoutines::aarch64::_npio2_hw[] = {
ATTRIBUTE_ALIGNED(64) jdouble StubRoutines::aarch64::_dsin_coef[] = {
ATTRIBUTE_ALIGNED(64) jdouble StubRoutines::aarch64::_dcos_coef[] = {
ATTRIBUTE_ALIGNED(64) jdouble StubRoutines::aarch64::_two_over_pi[] = {
ATTRIBUTE_ALIGNED(64) jdouble StubRoutines::aarch64::_pio2[] = {


macroAssembler_x86_32_constants.cpp:

ATTRIBUTE_ALIGNED(16) static const juint _ONES[] = {
ATTRIBUTE_ALIGNED(16) static const juint _PI4_INV[] = {
ATTRIBUTE_ALIGNED(16) static const juint _PI4X3[] = {
ATTRIBUTE_ALIGNED(16) static const juint _PI4X4[] = {
ATTRIBUTE_ALIGNED(16) static const juint _L_2IL0FLOATPACKET_0[] = {


macroAssembler_x86_32_cos.cpp:
`ATTRIBUTE_ALIGNED(16) static const juint _static_const_table_cos[] =`

macroAssembler_x86_32_exp.cpp:
`ATTRIBUTE_ALIGNED(16) static const juint _static_const_table[] =`

macroAssembler_x86_32_log.cpp:
`ATTRIBUTE_ALIGNED(16) static const juint _static_const_table_log[] =`

macroAssembler_x86_32_log10.cpp:
`ATTRIBUTE_ALIGNED(16) static const juint _static_const_table_log10[] =`

macroAssembler_x86_32_pow.cpp:

ATTRIBUTE_ALIGNED(16) static const juint _static_const_table_pow[] =
ATTRIBUTE_ALIGNED(8) static const double _DOUBLE2 = 2.0;
ATTRIBUTE_ALIGNED(8) static const double _DOUBLE0 = 0.0;
ATTRIBUTE_ALIGNED(8) static const double _DOUBLE0DOT5 = 0.5;


macroAssembler_x86_32_sin.cpp:

ATTRIBUTE_ALIGNED(8) static const juint _zero_none[] =
ATTRIBUTE_ALIGNED(4) static const juint __4onpi_d[] =
ATTRIBUTE_ALIGNED(4) static const juint _TWO_32H[] =
ATTRIBUTE_ALIGNED(4) static const juint _pi04_3d[] =
ATTRIBUTE_ALIGNED(4) static const juint _pi04_5d[] =
ATTRIBUTE_ALIGNED(4) static const juint _SCALE[] =
ATTRIBUTE_ALIGNED(4) static const juint _zeros[] =
ATTRIBUTE_ALIGNED(4) static const juint _pi04_2d[] =
ATTRIBUTE_ALIGNED(4) static const juint _TWO_12H[] =
ATTRIBUTE_ALIGNED(2) static const jushort __4onpi_31l[] =
ATTRIBUTE_ALIGNED(16) static const jushort _SP[] =
ATTRIBUTE_ALIGNED(16) static const jushort _CP[] =
ATTRIBUTE_ALIGNED(16) static const juint _static_const_table_sin[] =


macroAssembler_x86_32_tan.cpp:

ATTRIBUTE_ALIGNED(16) static const jushort _TP[] =
ATTRIBUTE_ALIGNED(16) static const jushort _TQ[] =
ATTRIBUTE_ALIGNED(16) static const jushort _GP[] =
ATTRIBUTE_ALIGNED(16) static const juint _static_const_table_tan[] =


stubGenerator_x86_32.cpp:

ATTRIBUTE_ALIGNED(16) static const uint32_t KEY_SHUFFLE_MASK[] = {
ATTRIBUTE_ALIGNED(16) static const uint32_t COUNTER_SHUFFLE_MASK[] = {
ATTRIBUTE_ALIGNED(16) static const uint32_t GHASH_BYTE_SWAP_MASK[] = {
ATTRIBUTE_ALIGNED(16) static const uint32_t GHASH_LONG_SWAP_MASK[] = {


stubGenerator_x86_64_adler.cpp:

ATTRIBUTE_ALIGNED(64) static const juint ADLER32_ASCALE_TABLE[] = {
ATTRIBUTE_ALIGNED(32) static const juint ADLER32_SHUF0_TABLE[] = {
ATTRIBUTE_ALIGNED(32) static const juint ADLER32_SHUF1_TABLE[] = {


stubGenerator_x86_64_aes.cpp:

ATTRIBUTE_ALIGNED(16) static const uint64_t KEY_SHUFFLE_MASK[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_SHUFFLE_MASK[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_MASK_LINC0[] = {
ATTRIBUTE_ALIGNED(16) static const uint64_t COUNTER_MASK_LINC1[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_MASK_LINC4[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_MASK_LINC8[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_MASK_LINC16[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_MASK_LINC32[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t GHASH_POLYNOMIAL_REDUCTION[] = {
ATTRIBUTE_ALIGNED(16) static const uint64_t GHASH_POLYNOMIAL_TWO_ONE[] = {


stubGenerator_x86_64_chacha.cpp:

ATTRIBUTE_ALIGNED(64) static const uint64_t CC20_COUNTER_ADD_AVX[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t CC20_COUNTER_ADD_AVX512[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t CC20_LROT_CONSTS[] = {


stubGenerator_x86_64_constants.cpp:

ATTRIBUTE_ALIGNED(8) static const juint _ONE[] = {
ATTRIBUTE_ALIGNED(16) static const juint _ONEHALF[] = {
ATTRIBUTE_ALIGNED(8) static const juint _SIGN_MASK[] = {
ATTRIBUTE_ALIGNED(8) static const juint _TWO_POW_55[] = {
ATTRIBUTE_ALIGNED(8) static const juint _TWO_POW_M55[] = {
ATTRIBUTE_ALIGNED(16) static const juint _SHIFTER[] = {
ATTRIBUTE_ALIGNED(4) static const juint _ZERO[] = {
ATTRIBUTE_ALIGNED(16) static const juint _SC_1[] = {
ATTRIBUTE_ALIGNED(16) static const juint _SC_2[] = {
ATTRIBUTE_ALIGNED(16) static const juint _SC_3[] = {
ATTRIBUTE_ALIGNED(16) static const juint _SC_4[] = {
ATTRIBUTE_ALIGNED(8) static const juint _PI_4[] = {
ATTRIBUTE_ALIGNED(8) static const juint _PI32INV[] = {
ATTRIBUTE_ALIGNED(8) static const juint _NEG_ZERO[] = {
ATTRIBUTE_ALIGNED(8) static const juint _P_1[] = {
ATTRIBUTE_ALIGNED(16) static const juint _P_2[] = {
ATTRIBUTE_ALIGNED(8) static const juint _P_3[] = {
ATTRIBUTE_ALIGNED(16) static const juint _PI_INV_TABLE[] = {
ATTRIBUTE_ALIGNED(16) static const juint _Ctable[] = {


stubGenerator_x86_64_exp.cpp:

ATTRIBUTE_ALIGNED(16) static const juint _cv[] =
ATTRIBUTE_ALIGNED(16) static const juint _mmask[] =
ATTRIBUTE_ALIGNED(16) static const juint _bias[] =
ATTRIBUTE_ALIGNED(16) static const juint _Tbl_addr[] =
ATTRIBUTE_ALIGNED(16) static const juint _ALLONES[] =
ATTRIBUTE_ALIGNED(16) static const juint _ebias[] =
ATTRIBUTE_ALIGNED(4) static const juint _XMAX[] =
ATTRIBUTE_ALIGNED(4) static const juint _XMIN[] =
ATTRIBUTE_ALIGNED(4) static const juint _INF[] =


stubGenerator_x86_64_ghash.cpp:

ATTRIBUTE_ALIGNED(16) static const uint64_t GHASH_SHUFFLE_MASK[] = {
ATTRIBUTE_ALIGNED(16) static const uint64_t GHASH_LONG_SWAP_MASK[] = {
ATTRIBUTE_ALIGNED(16) static const uint64_t GHASH_BYTE_SWAP_MASK[] = {
ATTRIBUTE_ALIGNED(16) static const uint64_t GHASH_POLYNOMIAL[] = {


stubGenerator_x86_64_log.cpp:

ATTRIBUTE_ALIGNED(16) static const juint _L_tbl[] =
ATTRIBUTE_ALIGNED(16) static const juint _log2[] =
ATTRIBUTE_ALIGNED(16) static const juint _coeff[] =
ATTRIBUTE_ALIGNED(16) static const juint _HIGHSIGMASK_log10[] = {
ATTRIBUTE_ALIGNED(16) static const juint _LOG10_E[] = {
ATTRIBUTE_ALIGNED(16) static const juint _L_tbl_log10[] = {
ATTRIBUTE_ALIGNED(16) static const juint _log2_log10[] =
ATTRIBUTE_ALIGNED(16) static const juint _coeff_log10[] =


stubGenerator_x86_64_poly.cpp:

ATTRIBUTE_ALIGNED(64) static const uint64_t POLY1305_PAD_MSG[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t POLY1305_MASK42[] = {
ATTRIBUTE_ALIGNED(64) static const uint64_t POLY1305_MASK44[] = {


stubGenerator_x86_64_pow.cpp:

ATTRIBUTE_ALIGNED(16) static const juint _HIGHSIGMASK[] = {
ATTRIBUTE_ALIGNED(16) static const juint _LOG2_E[] = {
ATTRIBUTE_ALIGNED(16) static const juint _HIGHMASK_Y[] = {
ATTRIBUTE_ALIGNED(16) static const juint _T_exp[] = {
ATTRIBUTE_ALIGNED(16) static const juint _e_coeff[] = {
ATTRIBUTE_ALIGNED(16) static const juint _coeff_h[] = {
ATTRIBUTE_ALIGNED(16) static const juint _HIGHMASK_LOG_X[] = {
ATTRIBUTE_ALIGNED(8) static const juint _HALFMASK[] = {
ATTRIBUTE_ALIGNED(16) static const juint _coeff_pow[] = {
ATTRIBUTE_ALIGNED(16) static const juint _L_tbl_pow[] = {
ATTRIBUTE_ALIGNED(8) static const juint _log2_pow[] = {
ATTRIBUTE_ALIGNED(8) static const juint _DOUBLE2[] = {
ATTRIBUTE_ALIGNED(8) static const juint _DOUBLE0[] = {
ATTRIBUTE_ALIGNED(8) static const juint _DOUBLE0DOT5[] = {


stubGenerator_x86_64_sin.cpp:
`ATTRIBUTE_ALIGNED(8) static const juint _ALL_ONES[] =`

stubGenerator_x86_64_tan.cpp:

ATTRIBUTE_ALIGNED(16) static const juint _MUL16[] =
ATTRIBUTE_ALIGNED(16) static const juint _sign_mask_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _PI32INV_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _P_1_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _P_2_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _P_3_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _Ctable_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _MASK_35_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _Q_11_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _Q_9_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _Q_7_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _Q_5_tan[] =
ATTRIBUTE_ALIGNED(16) static const juint _Q_3_tan[] =
ATTRIBUTE_ALIGNED(8) static const juint _PI_4_tan[] =
ATTRIBUTE_ALIGNED(8) static const juint _QQ_2_tan[] =


stubRoutines_x86.cpp:

ATTRIBUTE_ALIGNED(64) const juint StubRoutines::x86::_k256[] =
ATTRIBUTE_ALIGNED(64) juint StubRoutines::x86::_k256_W[2*sizeof(StubRoutines::x86::_k256)];
ATTRIBUTE_ALIGNED(64) const julong StubRoutines::x86::_k512_W[] =


For gc code that uses ATTRIBUTE_ALIGNED, since they define their own macros that use it:

xGlobals.hpp:
`#define           XCACHE_ALIGNED                ATTRIBUTE_ALIGNED(XCacheLineSize)`

zGlobals.hpp:
`#define           ZCACHE_ALIGNED                ATTRIBUTE_ALIGNED(ZCacheLineSize)`

xMarkStack.hpp:

XCACHE_ALIGNED XMarkStackList _published;
XCACHE_ALIGNED XMarkStackList _overflowed;


xMarkStackAllocator.hpp:

XCACHE_ALIGNED XMarkStackMagazineList _freelist;
XCACHE_ALIGNED XMarkStackSpace        _space;


xMarkTerminate.hpp
`XCACHE_ALIGNED volatile uint _nworking_stage0;`

xNMethodTableIteration.hpp:
`XCACHE_ALIGNED volatile size_t _claimed;`

zMarkStack.hpp:

ZCACHE_ALIGNED ZMarkStackList _published;
ZCACHE_ALIGNED ZMarkStackList _overflowed;


zMarkStackAllocator.hpp:

ZCACHE_ALIGNED ZMarkStackSpace        _space;
ZCACHE_ALIGNED ZMarkStackMagazineList _freelist;
ZCACHE_ALIGNED volatile bool          _expanded_recently;


zNMethodTableIteration.hpp:
`ZCACHE_ALIGNED volatile size_t _claimed;`

Fortunately, it seems like that mismatched offset_of macro in the globalDefinitions file really is the only code in HotSpot where the alignas specifier is in an area that is semantically different in the C++ Language

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

PR Comment: https://git.openjdk.org/jdk/pull/11431#issuecomment-1574985090


More information about the hotspot-dev mailing list