diff --git a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp index 617bc7cd00c..881fb613114 100644 --- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp @@ -281,6 +281,7 @@ void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorator if (on_oop && on_reference && L_handle_null == nullptr) { L_handle_null = &done; } CardTableBarrierSetAssembler::load_at(masm, decorators, type, src, dst, tmp1, tmp2, L_handle_null); if (on_oop && on_reference) { + assert(tmp1 != noreg && tmp2 != noreg, "need temp registers for G1 pre-barrier"); // Generate the G1 pre-barrier code to log the value of // the referent field in an SATB buffer. g1_write_barrier_pre(masm, decorators | IS_NOT_NULL, diff --git a/src/hotspot/cpu/s390/interp_masm_s390.cpp b/src/hotspot/cpu/s390/interp_masm_s390.cpp index d5239898dd7..7327e2a13f2 100644 --- a/src/hotspot/cpu/s390/interp_masm_s390.cpp +++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp @@ -411,7 +411,7 @@ void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result // Load pointer for resolved_references[] objArray. z_lg(result, in_bytes(ConstantPool::cache_offset()), result); z_lg(result, in_bytes(ConstantPoolCache::resolved_references_offset()), result); - resolve_oop_handle(result); // Load resolved references array itself. + resolve_oop_handle(result, Z_R0_scratch, Z_R1_scratch); // Load resolved references array itself. #ifdef ASSERT NearLabel index_ok; z_lgf(Z_R0, Address(result, arrayOopDesc::length_offset_in_bytes())); diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index de3608e74ba..b5898648014 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -4705,16 +4705,8 @@ void MacroAssembler::oop_decoder(Register Rdst, Register Rsrc, bool maybenull, R } // ((OopHandle)result).resolve(); -void MacroAssembler::resolve_oop_handle(Register result) { - // OopHandle::resolve is an indirection. - z_lg(result, 0, result); -} - -void MacroAssembler::load_mirror_from_const_method(Register mirror, Register const_method) { - mem2reg_opt(mirror, Address(const_method, ConstMethod::constants_offset())); - mem2reg_opt(mirror, Address(mirror, ConstantPool::pool_holder_offset())); - mem2reg_opt(mirror, Address(mirror, Klass::java_mirror_offset())); - resolve_oop_handle(mirror); +void MacroAssembler::resolve_oop_handle(Register result, Register tmp1, Register tmp2) { + access_load_at(T_OBJECT, IN_NATIVE, Address(result, 0), result, tmp1, tmp2); } void MacroAssembler::load_method_holder(Register holder, Register method) { @@ -5886,6 +5878,28 @@ void MacroAssembler::asm_assert_frame_size(Register expected_size, Register tmp, #endif // ASSERT } +#ifdef ASSERT +bool is_excluded(Register excluded_register[], Register reg, int n) { + for (int i = 0; i < n; i++) { + if (excluded_register[i] == reg) { + return true; + } + } + return false; +} + +void MacroAssembler::clobber_volatile_registers(Register excluded_register[], int n) { + const int magic_number = 0x82; + + for (int i = 0; i < 6 /* R0 to R5 */; i++) { + Register reg = as_Register(i); + if (!is_excluded(excluded_register, reg, n)) { + load_const_optimized(reg, magic_number); + } + } +} +#endif // ASSERT + // Save and restore functions: Exclude Z_R0. void MacroAssembler::save_volatile_regs(Register dst, int offset, bool include_fp, bool include_flags) { z_stmg(Z_R1, Z_R5, offset, dst); offset += 5 * BytesPerWord; diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index 32e484d4790..34389917cef 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -484,6 +484,10 @@ class MacroAssembler: public Assembler { // Pop current C frame and restore return PC register (Z_R14). void pop_frame_restore_retPC(int frame_size_in_bytes); +#ifdef ASSERT + void clobber_volatile_registers(Register excluded_register[], int n); +#endif // ASSERT + // // Calls // @@ -885,8 +889,7 @@ class MacroAssembler: public Assembler { void oop_decoder(Register Rdst, Register Rsrc, bool maybenull, Register Rbase = Z_R1, int pow2_offset = -1); - void resolve_oop_handle(Register result); - void load_mirror_from_const_method(Register mirror, Register const_method); + void resolve_oop_handle(Register result, Register tmp1, Register tmp2); void load_method_holder(Register holder, Register method); //-------------------------- diff --git a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp index 2da21f08bbc..dba04fc0e85 100644 --- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp @@ -1113,6 +1113,7 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { { // locals const Register local_addr = Z_ARG4; + const Register constants_addr = Z_ARG2; BLOCK_COMMENT("generate_fixed_frame: initialize interpreter state {"); @@ -1128,8 +1129,8 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { __ z_stg(Z_R10, _z_ijava_state_neg(sender_sp), fp); // Load cp cache and save it at the end of this block. - __ z_lg(Z_R1_scratch, Address(const_method, ConstMethod::constants_offset())); - __ z_lg(Z_R1_scratch, Address(Z_R1_scratch, ConstantPool::cache_offset())); + __ z_lg(constants_addr, Address(const_method, ConstMethod::constants_offset())); + __ z_lg(Z_R1_scratch, Address(constants_addr, ConstantPool::cache_offset())); // z_ijava_state->method = method; __ z_stg(Z_method, _z_ijava_state_neg(method), fp); @@ -1192,7 +1193,9 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { __ z_stg(Z_R1_scratch, _z_ijava_state_neg(cpoolCache), fp); // Get mirror and store it in the frame as GC root for this Method*. - __ load_mirror_from_const_method(Z_R1_scratch, const_method); + __ mem2reg_opt(Z_R1_scratch, Address(constants_addr, ConstantPool::pool_holder_offset())); + __ mem2reg_opt(Z_R1_scratch, Address(Z_R1_scratch, Klass::java_mirror_offset())); + __ resolve_oop_handle(Z_R1_scratch, Z_R0_scratch, Z_R1_scratch); __ z_stg(Z_R1_scratch, _z_ijava_state_neg(mirror), fp); BLOCK_COMMENT("} generate_fixed_frame: initialize interpreter state"); @@ -2028,7 +2031,7 @@ address TemplateInterpreterGenerator::generate_currentThread() { uint64_t entry_off = __ offset(); __ z_lg(Z_RET, Address(Z_thread, JavaThread::threadObj_offset())); - __ resolve_oop_handle(Z_RET); + __ resolve_oop_handle(Z_RET, Z_R0_scratch, Z_R1_scratch); // Restore caller sp for c2i case. __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started. diff --git a/src/hotspot/cpu/s390/templateTable_s390.cpp b/src/hotspot/cpu/s390/templateTable_s390.cpp index 647915ef4fa..3b0929608a3 100644 --- a/src/hotspot/cpu/s390/templateTable_s390.cpp +++ b/src/hotspot/cpu/s390/templateTable_s390.cpp @@ -480,8 +480,9 @@ void TemplateTable::fast_aldc(LdcType type) { // Convert null sentinel to null. __ load_const_optimized(Z_R1_scratch, (intptr_t)Universe::the_null_sentinel_addr()); - __ resolve_oop_handle(Z_R1_scratch); - __ z_cg(Z_tos, Address(Z_R1_scratch)); + __ z_lg(Z_R1_scratch, Address(Z_R1_scratch)); + __ resolve_oop_handle(Z_R1_scratch, Z_R0_scratch, Z_R1_scratch); + __ z_cgr(Z_tos, Z_R1_scratch); __ z_brne(L_resolved); __ clear_reg(Z_tos); __ z_bru(L_resolved); @@ -2478,7 +2479,7 @@ void TemplateTable::load_resolved_field_entry(Register obj, if (is_static) { __ load_sized_value(obj, Address(cache, ResolvedFieldEntry::field_holder_offset()), sizeof(void*), false); __ load_sized_value(obj, Address(obj, in_bytes(Klass::java_mirror_offset())), sizeof(void*), false); - __ resolve_oop_handle(obj); + __ resolve_oop_handle(obj, Z_R0_scratch, Z_R1_scratch); } }