Skip to content

Commit ce4e780

Browse files
committed
8244949: [PPC64] Reengineer assembler stop function
Reviewed-by: lucy, xliu
1 parent ad940d3 commit ce4e780

23 files changed

Lines changed: 139 additions & 128 deletions

src/hotspot/cpu/ppc/assembler_ppc.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,13 +1933,23 @@ class Assembler : public AbstractAssembler {
19331933
inline void td( int tobits, Register a, Register b); // asserts UseSIGTRAP
19341934
inline void tw( int tobits, Register a, Register b); // asserts UseSIGTRAP
19351935

1936+
public:
19361937
static bool is_tdi(int x, int tobits, int ra, int si16) {
19371938
return (TDI_OPCODE == (x & TDI_OPCODE_MASK))
19381939
&& (tobits == inv_to_field(x))
19391940
&& (ra == -1/*any reg*/ || ra == inv_ra_field(x))
19401941
&& (si16 == inv_si_field(x));
19411942
}
19421943

1944+
static int tdi_get_si16(int x, int tobits, int ra) {
1945+
if (TDI_OPCODE == (x & TDI_OPCODE_MASK)
1946+
&& (tobits == inv_to_field(x))
1947+
&& (ra == -1/*any reg*/ || ra == inv_ra_field(x))) {
1948+
return inv_si_field(x);
1949+
}
1950+
return -1; // No valid tdi instruction.
1951+
}
1952+
19431953
static bool is_twi(int x, int tobits, int ra, int si16) {
19441954
return (TWI_OPCODE == (x & TWI_OPCODE_MASK))
19451955
&& (tobits == inv_to_field(x))
@@ -1967,7 +1977,6 @@ class Assembler : public AbstractAssembler {
19671977
&& (rb == -1/*any reg*/ || rb == inv_rb_field(x));
19681978
}
19691979

1970-
public:
19711980
// PPC floating point instructions
19721981
// PPC 1, section 4.6.2 Floating-Point Load Instructions
19731982
inline void lfs( FloatRegister d, int si16, Register a);

src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3086,7 +3086,7 @@ void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
30863086
} else {
30873087
__ cmpdi(CCR0, obj, 0);
30883088
__ bne(CCR0, Lupdate);
3089-
__ stop("unexpect null obj", 0x9652);
3089+
__ stop("unexpect null obj");
30903090
#endif
30913091
}
30923092

@@ -3103,7 +3103,7 @@ void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
31033103
metadata2reg(exact_klass->constant_encoding(), R0);
31043104
__ cmpd(CCR0, klass, R0);
31053105
__ beq(CCR0, ok);
3106-
__ stop("exact klass and actual klass differ", 0x8564);
3106+
__ stop("exact klass and actual klass differ");
31073107
__ bind(ok);
31083108
}
31093109
#endif
@@ -3170,7 +3170,7 @@ void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
31703170
__ clrrdi_(R0, tmp, exact_log2(-TypeEntries::type_mask));
31713171
__ beq(CCR0, ok); // First time here.
31723172

3173-
__ stop("unexpected profiling mismatch", 0x7865);
3173+
__ stop("unexpected profiling mismatch");
31743174
__ bind(ok);
31753175
}
31763176
#endif

src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void C1_MacroAssembler::initialize_object(
294294
} else {
295295
cmpwi(CCR0, t1, con_size_in_bytes);
296296
}
297-
asm_assert_eq("bad size in initialize_object", 0x753);
297+
asm_assert_eq("bad size in initialize_object");
298298
}
299299
#endif
300300

src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,10 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) {
796796
// empty before writing to them.
797797
__ ld(R0, in_bytes(JavaThread::exception_oop_offset()), R16_thread);
798798
__ cmpdi(CCR0, R0, 0);
799-
__ asm_assert_eq("exception oop already set", 0x963);
799+
__ asm_assert_eq("exception oop already set");
800800
__ ld(R0, in_bytes(JavaThread::exception_pc_offset() ), R16_thread);
801801
__ cmpdi(CCR0, R0, 0);
802-
__ asm_assert_eq("exception pc already set", 0x962);
802+
__ asm_assert_eq("exception pc already set");
803803
#endif
804804

805805
// Save the exception and issuing pc in the thread.

src/hotspot/cpu/ppc/disassembler_ppc.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ void Disassembler::annotate(address here, outputStream* st) {
164164
const uint pos = st->position();
165165
const uint aligned_pos = ((pos+tabspacing-1)/tabspacing)*tabspacing;
166166

167+
int stop_type = -1;
168+
167169
if (MacroAssembler::is_bcxx(instruction)) {
168170
st->print(",bo=0b");
169171
print_instruction_bits(st, instruction, 6, 10);
@@ -180,9 +182,6 @@ void Disassembler::annotate(address here, outputStream* st) {
180182
print_decoded_bh_bits(st, instruction, 20,
181183
!(MacroAssembler::is_bctr(instruction) ||
182184
MacroAssembler::is_bctrl(instruction)));
183-
} else if (MacroAssembler::is_trap_should_not_reach_here(instruction)) {
184-
st->fill_to(aligned_pos + tabspacing);
185-
st->print(";trap: should not reach here");
186185
} else if (MacroAssembler::is_trap_null_check(instruction)) {
187186
st->fill_to(aligned_pos + tabspacing);
188187
st->print(";trap: null check");
@@ -192,8 +191,8 @@ void Disassembler::annotate(address here, outputStream* st) {
192191
} else if (MacroAssembler::is_trap_ic_miss_check(instruction)) {
193192
st->fill_to(aligned_pos + tabspacing);
194193
st->print(";trap: ic miss check");
195-
} else if (MacroAssembler::is_trap_zombie_not_entrant(instruction)) {
194+
} else if ((stop_type = MacroAssembler::tdi_get_si16(instruction, Assembler::traptoUnconditional, 0)) != -1) {
196195
st->fill_to(aligned_pos + tabspacing);
197-
st->print(";trap: zombie");
196+
st->print(";trap: stop type %d", stop_type);
198197
}
199198
}

src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator
152152
if (preloaded && not_null) {
153153
#ifdef ASSERT
154154
__ cmpdi(CCR0, pre_val, 0);
155-
__ asm_assert_ne("null oop not allowed (G1 pre)", 0x321); // Checked by caller.
155+
__ asm_assert_ne("null oop not allowed (G1 pre)"); // Checked by caller.
156156
#endif
157157
} else {
158158
__ cmpdi(CCR0, pre_val, 0);
@@ -223,7 +223,7 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Decorato
223223
if (not_null) {
224224
#ifdef ASSERT
225225
__ cmpdi(CCR0, new_val, 0);
226-
__ asm_assert_ne("null oop not allowed (G1 post)", 0x322); // Checked by caller.
226+
__ asm_assert_ne("null oop not allowed (G1 post)"); // Checked by caller.
227227
#endif
228228
} else {
229229
__ cmpdi(CCR0, new_val, 0);

src/hotspot/cpu/ppc/globals_ppc.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,6 @@ define_pd_global(intx, InitArrayShortSize, 9*BytesPerLong);
147147
"switch off all optimizations requiring SIGTRAP.") \
148148
product(bool, TrapBasedICMissChecks, true, \
149149
"Raise and handle SIGTRAP if inline cache miss detected.") \
150-
product(bool, TrapBasedNotEntrantChecks, true, \
151-
"Raise and handle SIGTRAP if calling not entrant or zombie" \
152-
" method.") \
153150
product(bool, TraceTraps, false, "Trace all traps the signal handler" \
154151
"handles.") \
155152
\

src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result
490490
sldi(R0, R0, LogBytesPerHeapOop);
491491
cmpd(CCR0, tmp, R0);
492492
blt(CCR0, index_ok);
493-
stop("resolved reference index out of bounds", 0x09256);
493+
stop("resolved reference index out of bounds");
494494
bind(index_ok);
495495
#endif
496496
// Add in the index.
@@ -1143,7 +1143,7 @@ void InterpreterMacroAssembler::call_from_interpreter(Register Rtarget_method, R
11431143
#ifdef ASSERT
11441144
ld(Rscratch1, _ijava_state_neg(top_frame_sp), Rscratch2); // Rscratch2 contains fp
11451145
cmpd(CCR0, R21_sender_SP, Rscratch1);
1146-
asm_assert_eq("top_frame_sp incorrect", 0x951);
1146+
asm_assert_eq("top_frame_sp incorrect");
11471147
#endif
11481148

11491149
bctr();
@@ -2251,7 +2251,7 @@ void InterpreterMacroAssembler::restore_interpreter_state(Register scratch, bool
22512251
subf(R0, R1_SP, scratch);
22522252
cmpdi(CCR0, R0, frame::abi_reg_args_size + frame::ijava_state_size);
22532253
bge(CCR0, Lok);
2254-
stop("frame too small (restore istate)", 0x5432);
2254+
stop("frame too small (restore istate)");
22552255
bind(Lok);
22562256
}
22572257
#endif

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ void MacroAssembler::resize_frame(Register offset, Register tmp) {
902902
#ifdef ASSERT
903903
assert_different_registers(offset, tmp, R1_SP);
904904
andi_(tmp, offset, frame::alignment_in_bytes-1);
905-
asm_assert_eq("resize_frame: unaligned", 0x204);
905+
asm_assert_eq("resize_frame: unaligned");
906906
#endif
907907

908908
// tmp <- *(SP)
@@ -941,7 +941,7 @@ void MacroAssembler::push_frame(Register bytes, Register tmp) {
941941
#ifdef ASSERT
942942
assert(bytes != R0, "r0 not allowed here");
943943
andi_(R0, bytes, frame::alignment_in_bytes-1);
944-
asm_assert_eq("push_frame(Reg, Reg): unaligned", 0x203);
944+
asm_assert_eq("push_frame(Reg, Reg): unaligned");
945945
#endif
946946
neg(tmp, bytes);
947947
stdux(R1_SP, R1_SP, tmp);
@@ -2313,7 +2313,7 @@ void MacroAssembler::tlab_allocate(
23132313
Label L;
23142314
andi_(R0, new_top, MinObjAlignmentInBytesMask);
23152315
beq(CCR0, L);
2316-
stop("updated TLAB free is not properly aligned", 0x934);
2316+
stop("updated TLAB free is not properly aligned");
23172317
bind(L);
23182318
}
23192319
#endif // ASSERT
@@ -2792,7 +2792,7 @@ void MacroAssembler::rtm_inflated_locking(ConditionRegister flag,
27922792
ld(mark_word, oopDesc::mark_offset_in_bytes(), obj);
27932793
#ifdef ASSERT
27942794
andi_(R0, mark_word, markWord::monitor_value);
2795-
asm_assert_ne("must be inflated", 0xa754); // Deflating only allowed at safepoint.
2795+
asm_assert_ne("must be inflated"); // Deflating only allowed at safepoint.
27962796
#endif
27972797
addi(owner_addr_Reg, mark_word, owner_offset);
27982798
}
@@ -2929,7 +2929,7 @@ void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register
29292929
// Invariant 1: _recursions should be 0.
29302930
//assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size");
29312931
asm_assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), temp,
2932-
"monitor->_recursions should be 0", -1);
2932+
"monitor->_recursions should be 0");
29332933
# endif
29342934

29352935
#if INCLUDE_RTM_OPT
@@ -3058,7 +3058,7 @@ void MacroAssembler::set_last_Java_frame(Register last_Java_sp, Register last_Ja
30583058

30593059
// Verify that last_Java_pc was zeroed on return to Java
30603060
asm_assert_mem8_is_zero(in_bytes(JavaThread::last_Java_pc_offset()), R16_thread,
3061-
"last_Java_pc not zeroed before leaving Java", 0x200);
3061+
"last_Java_pc not zeroed before leaving Java");
30623062

30633063
// When returning from calling out from Java mode the frame anchor's
30643064
// last_Java_pc will always be set to NULL. It is set here so that
@@ -3074,7 +3074,7 @@ void MacroAssembler::set_last_Java_frame(Register last_Java_sp, Register last_Ja
30743074

30753075
void MacroAssembler::reset_last_Java_frame(void) {
30763076
asm_assert_mem8_isnot_zero(in_bytes(JavaThread::last_Java_sp_offset()),
3077-
R16_thread, "SP was not set, still zero", 0x202);
3077+
R16_thread, "SP was not set, still zero");
30783078

30793079
BLOCK_COMMENT("reset_last_Java_frame {");
30803080
li(R0, 0);
@@ -4327,21 +4327,21 @@ void MacroAssembler::multiply_to_len(Register x, Register xlen,
43274327
bind(L_done);
43284328
} // multiply_to_len
43294329

4330-
void MacroAssembler::asm_assert(bool check_equal, const char *msg, int id) {
4330+
void MacroAssembler::asm_assert(bool check_equal, const char *msg) {
43314331
#ifdef ASSERT
43324332
Label ok;
43334333
if (check_equal) {
43344334
beq(CCR0, ok);
43354335
} else {
43364336
bne(CCR0, ok);
43374337
}
4338-
stop(msg, id);
4338+
stop(msg);
43394339
bind(ok);
43404340
#endif
43414341
}
43424342

43434343
void MacroAssembler::asm_assert_mems_zero(bool check_equal, int size, int mem_offset,
4344-
Register mem_base, const char* msg, int id) {
4344+
Register mem_base, const char* msg) {
43454345
#ifdef ASSERT
43464346
switch (size) {
43474347
case 4:
@@ -4355,7 +4355,7 @@ void MacroAssembler::asm_assert_mems_zero(bool check_equal, int size, int mem_of
43554355
default:
43564356
ShouldNotReachHere();
43574357
}
4358-
asm_assert(check_equal, msg, id);
4358+
asm_assert(check_equal, msg);
43594359
#endif // ASSERT
43604360
}
43614361

@@ -4430,32 +4430,20 @@ void MacroAssembler::verify_oop_addr(RegisterOrConstant offs, Register base, con
44304430
restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
44314431
}
44324432

4433-
const char* stop_types[] = {
4434-
"stop",
4435-
"untested",
4436-
"unimplemented",
4437-
"shouldnotreachhere"
4438-
};
4439-
4440-
static void stop_on_request(int tp, const char* msg) {
4441-
tty->print("PPC assembly code requires stop: (%s) %s\n", stop_types[tp%/*stop_end*/4], msg);
4442-
guarantee(false, "PPC assembly code requires stop: %s", msg);
4443-
}
4444-
44454433
// Call a C-function that prints output.
4446-
void MacroAssembler::stop(int type, const char* msg, int id) {
4434+
void MacroAssembler::stop(int type, const char* msg) {
44474435
#ifndef PRODUCT
4448-
block_comment(err_msg("stop: %s %s {", stop_types[type%stop_end], msg));
4436+
block_comment(err_msg("stop(type %d): %s {", type, msg));
44494437
#else
44504438
block_comment("stop {");
44514439
#endif
44524440

4453-
// setup arguments
4454-
load_const_optimized(R3_ARG1, type);
4455-
load_const_optimized(R4_ARG2, (void *)msg, /*tmp=*/R0);
4456-
call_VM_leaf(CAST_FROM_FN_PTR(address, stop_on_request), R3_ARG1, R4_ARG2);
4457-
illtrap();
4458-
emit_int32(id);
4441+
if (type != stop_shouldnotreachhere) {
4442+
// Use R0 to pass msg. "shouldnotreachhere" preserves R0.
4443+
load_const_optimized(R0, (void*)msg);
4444+
}
4445+
tdi_unchecked(traptoUnconditional, 0/*reg 0*/, type);
4446+
44594447
block_comment("} stop;");
44604448
}
44614449

src/hotspot/cpu/ppc/macroAssembler_ppc.hpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,6 @@ class MacroAssembler: public Assembler {
673673
is_tdi(x, traptoGreaterThanUnsigned, -1/*any reg*/, 0);
674674
}
675675

676-
inline void trap_zombie_not_entrant();
677-
static bool is_trap_zombie_not_entrant(int x) { return is_tdi(x, traptoUnconditional, 0/*reg 0*/, 1); }
678-
679-
inline void trap_should_not_reach_here();
680-
static bool is_trap_should_not_reach_here(int x) { return is_tdi(x, traptoUnconditional, 0/*reg 0*/, 2); }
681-
682676
inline void trap_ic_miss_check(Register a, Register b);
683677
static bool is_trap_ic_miss_check(int x) {
684678
return is_td(x, traptoGreaterThanUnsigned | traptoLessThanUnsigned, -1/*any reg*/, -1/*any reg*/);
@@ -863,21 +857,21 @@ class MacroAssembler: public Assembler {
863857
//
864858

865859
// assert on cr0
866-
void asm_assert(bool check_equal, const char* msg, int id);
867-
void asm_assert_eq(const char* msg, int id) { asm_assert(true, msg, id); }
868-
void asm_assert_ne(const char* msg, int id) { asm_assert(false, msg, id); }
860+
void asm_assert(bool check_equal, const char* msg);
861+
void asm_assert_eq(const char* msg) { asm_assert(true, msg); }
862+
void asm_assert_ne(const char* msg) { asm_assert(false, msg); }
869863

870864
private:
871865
void asm_assert_mems_zero(bool check_equal, int size, int mem_offset, Register mem_base,
872-
const char* msg, int id);
866+
const char* msg);
873867

874868
public:
875869

876-
void asm_assert_mem8_is_zero(int mem_offset, Register mem_base, const char* msg, int id) {
877-
asm_assert_mems_zero(true, 8, mem_offset, mem_base, msg, id);
870+
void asm_assert_mem8_is_zero(int mem_offset, Register mem_base, const char* msg) {
871+
asm_assert_mems_zero(true, 8, mem_offset, mem_base, msg);
878872
}
879-
void asm_assert_mem8_isnot_zero(int mem_offset, Register mem_base, const char* msg, int id) {
880-
asm_assert_mems_zero(false, 8, mem_offset, mem_base, msg, id);
873+
void asm_assert_mem8_isnot_zero(int mem_offset, Register mem_base, const char* msg) {
874+
asm_assert_mems_zero(false, 8, mem_offset, mem_base, msg);
881875
}
882876

883877
// Verify R16_thread contents.
@@ -903,22 +897,21 @@ class MacroAssembler: public Assembler {
903897
#define verify_klass_ptr(reg) _verify_klass_ptr(reg, "broken klass " #reg, __FILE__, __LINE__)
904898

905899
private:
900+
void stop(int type, const char* msg);
906901

902+
public:
907903
enum {
908904
stop_stop = 0,
909905
stop_untested = 1,
910906
stop_unimplemented = 2,
911-
stop_shouldnotreachhere = 3,
912-
stop_end = 4
907+
stop_shouldnotreachhere = 3
913908
};
914-
void stop(int type, const char* msg, int id);
915909

916-
public:
917910
// Prints msg, dumps registers and stops execution.
918-
void stop (const char* msg = "", int id = 0) { stop(stop_stop, msg, id); }
919-
void untested (const char* msg = "", int id = 0) { stop(stop_untested, msg, id); }
920-
void unimplemented(const char* msg = "", int id = 0) { stop(stop_unimplemented, msg, id); }
921-
void should_not_reach_here() { stop(stop_shouldnotreachhere, "", -1); }
911+
void stop (const char* msg = NULL) { stop(stop_stop, msg ); }
912+
void untested (const char* msg = NULL) { stop(stop_untested, msg ); }
913+
void unimplemented(const char* msg = NULL) { stop(stop_unimplemented, msg ); }
914+
void should_not_reach_here() { stop(stop_shouldnotreachhere, NULL); }
922915

923916
void zap_from_to(Register low, int before, Register high, int after, Register val, Register addr) PRODUCT_RETURN;
924917
};

0 commit comments

Comments
 (0)