Skip to content

Commit 4c37370

Browse files
author
Jatin Bhateja
committed
8354668: Missing REX2 prefix accounting in ZGC barriers leads to incorrect encoding
Reviewed-by: aboldtch, sviswanathan
1 parent 5392488 commit 4c37370

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ void ZBarrierSetAssembler::store_barrier_fast(MacroAssembler* masm,
391391
if (rnew_zaddress != noreg) {
392392
// noreg means null; no need to color
393393
__ movptr(rnew_zpointer, rnew_zaddress);
394-
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl);
395394
__ shlq(rnew_zpointer, barrier_Relocation::unpatched);
395+
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX);
396396
__ orq_imm32(rnew_zpointer, barrier_Relocation::unpatched);
397397
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr);
398398
}
@@ -969,13 +969,13 @@ void ZBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm,
969969
#define __ ce->masm()->
970970

971971
static void z_uncolor(LIR_Assembler* ce, LIR_Opr ref) {
972-
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl);
973972
__ shrq(ref->as_register(), barrier_Relocation::unpatched);
973+
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX);
974974
}
975975

976976
static void z_color(LIR_Assembler* ce, LIR_Opr ref) {
977-
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl);
978977
__ shlq(ref->as_register(), barrier_Relocation::unpatched);
978+
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX);
979979
__ orq_imm32(ref->as_register(), barrier_Relocation::unpatched);
980980
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr);
981981
}
@@ -1278,8 +1278,8 @@ void ZBarrierSetAssembler::generate_c2_store_barrier_stub(MacroAssembler* masm,
12781278

12791279
static int patch_barrier_relocation_offset(int format) {
12801280
switch (format) {
1281-
case ZBarrierRelocationFormatLoadGoodBeforeShl:
1282-
return 3;
1281+
case ZBarrierRelocationFormatLoadGoodAfterShX:
1282+
return -1;
12831283

12841284
case ZBarrierRelocationFormatStoreGoodAfterCmp:
12851285
return -2;
@@ -1300,7 +1300,7 @@ static int patch_barrier_relocation_offset(int format) {
13001300

13011301
static uint16_t patch_barrier_relocation_value(int format) {
13021302
switch (format) {
1303-
case ZBarrierRelocationFormatLoadGoodBeforeShl:
1303+
case ZBarrierRelocationFormatLoadGoodAfterShX:
13041304
return (uint16_t)ZPointerLoadShift;
13051305

13061306
case ZBarrierRelocationFormatMarkBadAfterTest:
@@ -1327,7 +1327,7 @@ void ZBarrierSetAssembler::patch_barrier_relocation(address addr, int format) {
13271327
const int offset = patch_barrier_relocation_offset(format);
13281328
const uint16_t value = patch_barrier_relocation_value(format);
13291329
uint8_t* const patch_addr = (uint8_t*)addr + offset;
1330-
if (format == ZBarrierRelocationFormatLoadGoodBeforeShl) {
1330+
if (format == ZBarrierRelocationFormatLoadGoodAfterShX) {
13311331
*patch_addr = (uint8_t)value;
13321332
} else {
13331333
*(uint16_t*)patch_addr = value;

src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ZLoadBarrierStubC2;
4949
class ZStoreBarrierStubC2;
5050
#endif // COMPILER2
5151

52-
const int ZBarrierRelocationFormatLoadGoodBeforeShl = 0;
52+
const int ZBarrierRelocationFormatLoadGoodAfterShX = 0;
5353
const int ZBarrierRelocationFormatLoadBadAfterTest = 1;
5454
const int ZBarrierRelocationFormatMarkBadAfterTest = 2;
5555
const int ZBarrierRelocationFormatStoreGoodAfterCmp = 3;

src/hotspot/cpu/x86/gc/z/z_x86_64.ad

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ source %{
3535
#include "gc/z/zBarrierSetAssembler.hpp"
3636

3737
static void z_color(MacroAssembler* masm, const MachNode* node, Register ref) {
38-
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl);
3938
__ shlq(ref, barrier_Relocation::unpatched);
39+
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX);
4040
__ orq_imm32(ref, barrier_Relocation::unpatched);
4141
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr);
4242
}
4343

4444
static void z_uncolor(MacroAssembler* masm, const MachNode* node, Register ref) {
45-
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl);
4645
__ shrq(ref, barrier_Relocation::unpatched);
46+
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX);
4747
}
4848

4949
static void z_keep_alive_load_barrier(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref) {

src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ bool CodeInstaller::pd_relocate(address pc, jint mark) {
221221
return true;
222222
#if INCLUDE_ZGC
223223
case Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_SHL:
224-
_instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl);
224+
_instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX);
225225
return true;
226226
case Z_BARRIER_RELOCATION_FORMAT_LOAD_BAD_AFTER_TEST:
227227
_instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadBadAfterTest);

0 commit comments

Comments
 (0)