Skip to content

Commit 898fcff

Browse files
committed
8367325: [s390x] build failure due to JDK-8361376
Reviewed-by: mdoerr, dlong
1 parent 5855fd2 commit 898fcff

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Re
171171

172172
void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) {
173173
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
174+
__ align(4, __ offset() + OFFSET_TO_PATCHABLE_DATA); // must align the following block which requires atomic updates
174175
__ block_comment("nmethod_entry_barrier (nmethod_entry_barrier) {");
175176

176177
// Load jump addr:

src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ class BarrierSetAssembler: public CHeapObj<mtGC> {
6666
OptoReg::Name refine_register(const Node* node,
6767
OptoReg::Name opto_reg) const;
6868
#endif // COMPILER2
69+
70+
static const int OFFSET_TO_PATCHABLE_DATA_INSTRUCTION = 6 + 6 + 6; // iihf(6) + iilf(6) + lg(6)
71+
static const int BARRIER_TOTAL_LENGTH = OFFSET_TO_PATCHABLE_DATA_INSTRUCTION + 6 + 6 + 2; // cfi(6) + larl(6) + bcr(2)
72+
73+
// first 2 bytes are for cfi instruction opcode and next 4 bytes will be the value/data to be patched,
74+
// so we are skipping first 2 bytes and returning the address of value/data field
75+
static const int OFFSET_TO_PATCHABLE_DATA = 6 + 6 + 6 + 2; // iihf(6) + iilf(6) + lg(6) + CFI_OPCODE(2)
76+
6977
};
7078

7179
#ifdef COMPILER2

src/hotspot/cpu/s390/gc/shared/barrierSetNMethod_s390.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,32 @@
2626
#include "code/codeBlob.hpp"
2727
#include "code/nativeInst.hpp"
2828
#include "code/nmethod.hpp"
29+
#include "gc/shared/barrierSetAssembler.hpp"
2930
#include "gc/shared/barrierSetNMethod.hpp"
3031
#include "utilities/debug.hpp"
3132

3233
class NativeMethodBarrier: public NativeInstruction {
3334
private:
34-
static const int PATCHABLE_INSTRUCTION_OFFSET = 3*6; // bytes
3535

3636
address get_barrier_start_address() const {
3737
return NativeInstruction::addr_at(0);
3838
}
3939

4040
address get_patchable_data_address() const {
41-
address inst_addr = get_barrier_start_address() + PATCHABLE_INSTRUCTION_OFFSET;
41+
address start_address = get_barrier_start_address();
42+
#ifdef ASSERT
43+
address inst_addr = start_address + BarrierSetAssembler::OFFSET_TO_PATCHABLE_DATA_INSTRUCTION;
4244

43-
DEBUG_ONLY(Assembler::is_z_cfi(*((long*)inst_addr)));
44-
return inst_addr + 2;
45+
unsigned long instr = 0;
46+
Assembler::get_instruction(inst_addr, &instr);
47+
assert(Assembler::is_z_cfi(instr), "sanity check");
48+
#endif // ASSERT
49+
50+
return start_address + BarrierSetAssembler::OFFSET_TO_PATCHABLE_DATA;
4551
}
4652

4753
public:
48-
static const int BARRIER_TOTAL_LENGTH = PATCHABLE_INSTRUCTION_OFFSET + 2*6 + 2; // bytes
54+
static const int BARRIER_TOTAL_LENGTH = BarrierSetAssembler::BARRIER_TOTAL_LENGTH;
4955

5056
int get_guard_value() const {
5157
address data_addr = get_patchable_data_address();
@@ -77,23 +83,30 @@ class NativeMethodBarrier: public NativeInstruction {
7783

7884
#ifdef ASSERT
7985
void verify() const {
86+
unsigned long instr = 0;
8087
int offset = 0; // bytes
8188
const address start = get_barrier_start_address();
8289

83-
MacroAssembler::is_load_const(/* address */ start + offset); // two instructions
90+
assert(MacroAssembler::is_load_const(/* address */ start + offset), "sanity check"); // two instructions
8491
offset += Assembler::instr_len(&start[offset]);
8592
offset += Assembler::instr_len(&start[offset]);
8693

87-
Assembler::is_z_lg(*((long*)(start + offset)));
94+
Assembler::get_instruction(start + offset, &instr);
95+
assert(Assembler::is_z_lg(instr), "sanity check");
8896
offset += Assembler::instr_len(&start[offset]);
8997

90-
Assembler::is_z_cfi(*((long*)(start + offset)));
98+
// it will be assignment operation, So it doesn't matter what value is already present in instr
99+
// hence, no need to 0 it out.
100+
Assembler::get_instruction(start + offset, &instr);
101+
assert(Assembler::is_z_cfi(instr), "sanity check");
91102
offset += Assembler::instr_len(&start[offset]);
92103

93-
Assembler::is_z_larl(*((long*)(start + offset)));
104+
Assembler::get_instruction(start + offset, &instr);
105+
assert(Assembler::is_z_larl(instr), "sanity check");
94106
offset += Assembler::instr_len(&start[offset]);
95107

96-
Assembler::is_z_bcr(*((long*)(start + offset)));
108+
Assembler::get_instruction(start + offset, &instr);
109+
assert(Assembler::is_z_bcr(instr), "sanity check");
97110
offset += Assembler::instr_len(&start[offset]);
98111

99112
assert(offset == BARRIER_TOTAL_LENGTH, "check offset == barrier length constant");

0 commit comments

Comments
 (0)