Skip to content

Commit a7cdb53

Browse files
author
David Holmes
committed
8364235: Fix for JDK-8361447 breaks the alignment requirements for GuardedMemory
Backport-of: 078d0d4968e26bb7a15417f1c4e891869c69dc6c
1 parent 7392e13 commit a7cdb53

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/hotspot/share/memory/guardedMemory.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,19 @@
4242
* |Offset | Content | Description |
4343
* |------------------------------------------------------------
4444
* |base_addr | 0xABABABABABABABAB | Head guard |
45-
* |+16 | <size_t:user_size> | User data size |
46-
* |+sizeof(uintptr_t) | <tag> | Tag word |
47-
* |+sizeof(uintptr_t) | <tag2> | Tag word |
45+
* |+GUARD_SIZE | <size_t:user_size> | User data size |
46+
* |+sizeof(size_t) | <tag> | Tag word |
47+
* |+sizeof(void*) | <tag2> | Tag word |
48+
* |+sizeof(void*) | <pad bytes> | Padding |
4849
* |+sizeof(void*) | 0xF1 <user_data> ( | User data |
4950
* |+user_size | 0xABABABABABABABAB | Tail guard |
5051
* -------------------------------------------------------------
5152
*
5253
* Where:
5354
* - guard padding uses "badResourceValue" (0xAB)
5455
* - tag word and tag2 word are general purpose
56+
* - padding is inserted as-needed by the compiler to ensure
57+
* the user data is aligned on a 16-byte boundary
5558
* - user data
5659
* -- initially padded with "uninitBlockPad" (0xF1),
5760
* -- to "freeBlockPad" (0xBA), when freed
@@ -132,12 +135,15 @@ class GuardedMemory : StackObj { // Wrapper on stack
132135

133136
/**
134137
* Header guard and size
138+
*
139+
* NB: the size and placement of the GuardHeader must be such that the
140+
* user-ptr is maximally aligned i.e. 16-byte alignment for x86 ABI for
141+
* stack alignment and use of vector (xmm) instructions. We use alignas
142+
* to achieve this.
135143
*/
136-
class GuardHeader : Guard {
144+
class alignas(16) GuardHeader : Guard {
137145
friend class GuardedMemory;
138146
protected:
139-
// Take care in modifying fields here, will effect alignment
140-
// e.g. x86 ABI 16 byte stack alignment
141147
union {
142148
uintptr_t __unused_full_word1;
143149
size_t _user_size;

0 commit comments

Comments
 (0)