|
26 | 26 | #include "code/codeBlob.hpp" |
27 | 27 | #include "code/nativeInst.hpp" |
28 | 28 | #include "code/nmethod.hpp" |
| 29 | +#include "gc/shared/barrierSetAssembler.hpp" |
29 | 30 | #include "gc/shared/barrierSetNMethod.hpp" |
30 | 31 | #include "utilities/debug.hpp" |
31 | 32 |
|
32 | 33 | class NativeMethodBarrier: public NativeInstruction { |
33 | 34 | private: |
34 | | - static const int PATCHABLE_INSTRUCTION_OFFSET = 3*6; // bytes |
35 | 35 |
|
36 | 36 | address get_barrier_start_address() const { |
37 | 37 | return NativeInstruction::addr_at(0); |
38 | 38 | } |
39 | 39 |
|
40 | 40 | 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; |
42 | 44 |
|
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; |
45 | 51 | } |
46 | 52 |
|
47 | 53 | 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; |
49 | 55 |
|
50 | 56 | int get_guard_value() const { |
51 | 57 | address data_addr = get_patchable_data_address(); |
@@ -77,23 +83,30 @@ class NativeMethodBarrier: public NativeInstruction { |
77 | 83 |
|
78 | 84 | #ifdef ASSERT |
79 | 85 | void verify() const { |
| 86 | + unsigned long instr = 0; |
80 | 87 | int offset = 0; // bytes |
81 | 88 | const address start = get_barrier_start_address(); |
82 | 89 |
|
83 | | - MacroAssembler::is_load_const(/* address */ start + offset); // two instructions |
| 90 | + assert(MacroAssembler::is_load_const(/* address */ start + offset), "sanity check"); // two instructions |
84 | 91 | offset += Assembler::instr_len(&start[offset]); |
85 | 92 | offset += Assembler::instr_len(&start[offset]); |
86 | 93 |
|
87 | | - Assembler::is_z_lg(*((long*)(start + offset))); |
| 94 | + Assembler::get_instruction(start + offset, &instr); |
| 95 | + assert(Assembler::is_z_lg(instr), "sanity check"); |
88 | 96 | offset += Assembler::instr_len(&start[offset]); |
89 | 97 |
|
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"); |
91 | 102 | offset += Assembler::instr_len(&start[offset]); |
92 | 103 |
|
93 | | - Assembler::is_z_larl(*((long*)(start + offset))); |
| 104 | + Assembler::get_instruction(start + offset, &instr); |
| 105 | + assert(Assembler::is_z_larl(instr), "sanity check"); |
94 | 106 | offset += Assembler::instr_len(&start[offset]); |
95 | 107 |
|
96 | | - Assembler::is_z_bcr(*((long*)(start + offset))); |
| 108 | + Assembler::get_instruction(start + offset, &instr); |
| 109 | + assert(Assembler::is_z_bcr(instr), "sanity check"); |
97 | 110 | offset += Assembler::instr_len(&start[offset]); |
98 | 111 |
|
99 | 112 | assert(offset == BARRIER_TOTAL_LENGTH, "check offset == barrier length constant"); |
|
0 commit comments