# HG changeset patch # User rkennke # Date 1529676435 -7200 # Fri Jun 22 16:07:15 2018 +0200 # Node ID fabe1e902429e130c217632438a2cdd3948657a9 # Parent 2230bb152a9fe0fa2e32bb943d086d55556500c4 8205523: Explicit barriers for interpreter diff --git a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp --- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp @@ -48,6 +48,14 @@ virtual void obj_equals(MacroAssembler* masm, Register obj1, Register obj2); + virtual void resolve_for_read(MacroAssembler* masm, DecoratorSet decorators, Register obj) { + // Default implementation does not need to do anything. + } + + virtual void resolve_for_write(MacroAssembler* masm, DecoratorSet decorators, Register obj) { + // Default implementation does not need to do anything. + } + virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, Register obj, Register tmp, Label& slowpath); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -3984,6 +3984,16 @@ } } +void MacroAssembler::resolve_for_read(DecoratorSet decorators, Register obj) { + BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); + return bs->resolve_for_read(this, decorators, obj); +} + +void MacroAssembler::resolve_for_write(DecoratorSet decorators, Register obj) { + BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); + return bs->resolve_for_write(this, decorators, obj); +} + void MacroAssembler::load_heap_oop(Register dst, Address src, Register tmp1, Register thread_tmp, DecoratorSet decorators) { access_load_at(T_OBJECT, IN_HEAP | decorators, dst, src, tmp1, thread_tmp); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -795,6 +795,14 @@ void access_store_at(BasicType type, DecoratorSet decorators, Address dst, Register src, Register tmp1, Register tmp_thread); + // Resolves obj for read access. Result is placed in the same register. + // All other registers are preserved. + void resolve_for_read(DecoratorSet decorators, Register obj); + + // Resolves obj for write access. Result is placed in the same register. + // All other registers are preserved. + void resolve_for_write(DecoratorSet decorators, Register obj); + void load_heap_oop(Register dst, Address src, Register tmp1 = noreg, Register thread_tmp = noreg, DecoratorSet decorators = 0); diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -1839,6 +1839,8 @@ // Load the oop from the handle __ ldr(obj_reg, Address(oop_handle_reg, 0)); + __ resolve_for_write(OOP_NOT_NULL, obj_reg); + if (UseBiasedLocking) { __ biased_locking_enter(lock_reg, obj_reg, swap_reg, tmp, false, lock_done, &slow_path_lock); } @@ -2001,6 +2003,8 @@ // Get locked oop from the handle we passed to jni __ ldr(obj_reg, Address(oop_handle_reg, 0)); + __ resolve_for_write(OOP_NOT_NULL, obj_reg); + Label done; if (UseBiasedLocking) { diff --git a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp --- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp @@ -808,6 +808,7 @@ #endif // ASSERT __ bind(done); + __ resolve_for_write(OOP_NOT_NULL, r0); } // add space for monitor & lock @@ -1034,6 +1035,7 @@ __ ldrw(crc, Address(esp, 4*wordSize)); // Initial CRC } else { __ ldr(buf, Address(esp, 2*wordSize)); // byte[] array + __ resolve_for_read(OOP_NOT_NULL, buf); __ add(buf, buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size __ ldrw(off, Address(esp, wordSize)); // offset __ add(buf, buf, off); // + offset @@ -1078,6 +1080,9 @@ __ ldrw(off, Address(esp, wordSize)); // int offset __ sub(len, end, off); __ ldr(buf, Address(esp, 2*wordSize)); // byte[] buf | long buf + if (kind == Interpreter::java_util_zip_CRC32C_updateBytes) { + __ resolve_for_read(OOP_NOT_NULL, buf); + } __ add(buf, buf, off); // + offset if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { __ ldrw(crc, Address(esp, 4*wordSize)); // long crc diff --git a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp --- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp @@ -3817,6 +3817,8 @@ // check for NULL object __ null_check(r0); + __ resolve_for_write(OOP_NOT_NULL, r0); + const Address monitor_block_top( rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize); const Address monitor_block_bot( @@ -3916,6 +3918,8 @@ // check for NULL object __ null_check(r0); + __ resolve_for_write(OOP_NOT_NULL, r0); + const Address monitor_block_top( rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize); const Address monitor_block_bot( diff --git a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp --- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp @@ -61,6 +61,14 @@ virtual void obj_equals(MacroAssembler* masm, Register obj1, Address obj2); + virtual void resolve_for_read(MacroAssembler* masm, DecoratorSet decorators, Register obj) { + // Default implementation does not need to do anything. + } + + virtual void resolve_for_write(MacroAssembler* masm, DecoratorSet decorators, Register obj) { + // Default implementation does not need to do anything. + } + // Support for jniFastGetField to try resolving a jobject/jweak in native virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, Register obj, Register tmp, Label& slowpath); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -6279,6 +6279,16 @@ } } +void MacroAssembler::resolve_for_read(DecoratorSet decorators, Register obj) { + BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); + return bs->resolve_for_read(this, decorators, obj); +} + +void MacroAssembler::resolve_for_write(DecoratorSet decorators, Register obj) { + BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); + return bs->resolve_for_write(this, decorators, obj); +} + void MacroAssembler::load_heap_oop(Register dst, Address src, Register tmp1, Register thread_tmp, DecoratorSet decorators) { access_load_at(T_OBJECT, IN_HEAP | decorators, dst, src, tmp1, thread_tmp); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.hpp b/src/hotspot/cpu/x86/macroAssembler_x86.hpp --- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp @@ -319,6 +319,14 @@ void access_store_at(BasicType type, DecoratorSet decorators, Address dst, Register src, Register tmp1, Register tmp2); + // Resolves obj for read access. Result is placed in the same register. + // All other registers are preserved. + void resolve_for_read(DecoratorSet decorators, Register obj); + + // Resolves obj for write access. Result is placed in the same register. + // All other registers are preserved. + void resolve_for_write(DecoratorSet decorators, Register obj); + void load_heap_oop(Register dst, Address src, Register tmp1 = noreg, Register thread_tmp = noreg, DecoratorSet decorators = 0); void load_heap_oop_not_null(Register dst, Address src, Register tmp1 = noreg, diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp --- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp @@ -2369,6 +2369,7 @@ // Load the oop from the handle __ movptr(obj_reg, Address(oop_handle_reg, 0)); + __ resolve_for_write(OOP_NOT_NULL, obj_reg); if (UseBiasedLocking) { __ biased_locking_enter(lock_reg, obj_reg, swap_reg, rscratch1, false, lock_done, &slow_path_lock); } @@ -2536,6 +2537,7 @@ // Get locked oop from the handle we passed to jni __ movptr(obj_reg, Address(oop_handle_reg, 0)); + __ resolve_for_write(OOP_NOT_NULL, obj_reg); Label done; diff --git a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp --- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp +++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp @@ -634,6 +634,7 @@ #endif // ASSERT __ bind(done); + __ resolve_for_write(OOP_NOT_NULL, rax); } // add space for monitor & lock diff --git a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp --- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp +++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp @@ -256,6 +256,7 @@ __ movl(crc, Address(rsp, 5*wordSize)); // Initial CRC } else { __ movptr(buf, Address(rsp, 3*wordSize)); // byte[] array + __ resolve_for_read(OOP_NOT_NULL, buf); __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size __ movl2ptr(off, Address(rsp, 2*wordSize)); // offset __ addq(buf, off); // + offset @@ -311,6 +312,7 @@ // "When calculating operand stack length, values of type long and double have length two." } else { __ movptr(buf, Address(rsp, 3 * wordSize)); // byte[] array + __ resolve_for_read(OOP_NOT_NULL, buf); __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset __ addq(buf, off); // + offset diff --git a/src/hotspot/cpu/x86/templateTable_x86.cpp b/src/hotspot/cpu/x86/templateTable_x86.cpp --- a/src/hotspot/cpu/x86/templateTable_x86.cpp +++ b/src/hotspot/cpu/x86/templateTable_x86.cpp @@ -4324,6 +4324,8 @@ // check for NULL object __ null_check(rax); + __ resolve_for_write(OOP_NOT_NULL, rax); + const Address monitor_block_top( rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); const Address monitor_block_bot( @@ -4421,6 +4423,8 @@ // check for NULL object __ null_check(rax); + __ resolve_for_write(OOP_NOT_NULL, rax); + const Address monitor_block_top( rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); const Address monitor_block_bot(