--- old/src/hotspot/cpu/x86/templateTable_x86.cpp 2018-09-14 10:57:18.442047090 -0400 +++ new/src/hotspot/cpu/x86/templateTable_x86.cpp 2018-09-14 10:57:18.218047099 -0400 @@ -2875,7 +2875,7 @@ const Address field(obj, off, Address::times_1, 0*wordSize); - Label Done, notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; + Label Done, notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj; __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); // Make sure we don't need to mask edx after the above shift @@ -2981,6 +2981,7 @@ __ bind(notFloat); #ifdef ASSERT + Label notDouble; __ cmpl(flags, dtos); __ jcc(Assembler::notEqual, notDouble); #endif @@ -2994,7 +2995,6 @@ #ifdef ASSERT __ jmp(Done); - __ bind(notDouble); __ stop("Bad state"); #endif @@ -3112,7 +3112,6 @@ const Register obj = rcx; const Register off = rbx; const Register flags = rax; - const Register bc = LP64_ONLY(c_rarg3) NOT_LP64(rcx); resolve_cache_and_index(byte_no, cache, index, sizeof(u2)); jvmti_post_field_mod(cache, index, is_static); @@ -3127,12 +3126,33 @@ __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift); __ andl(rdx, 0x1); + // Check for volatile store + __ testl(rdx, rdx); + __ jcc(Assembler::zero, notVolatile); + + putfield_or_static_helper(byte_no, is_static, rc, obj, off, flags); + volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | + Assembler::StoreStore)); + __ jmp(Done); + __ bind(notVolatile); + + putfield_or_static_helper(byte_no, is_static, rc, obj, off, flags); + + __ bind(Done); +} + +void TemplateTable::putfield_or_static_helper(int byte_no, bool is_static, RewriteControl rc, + Register obj, Register off, Register flags) { + // field addresses const Address field(obj, off, Address::times_1, 0*wordSize); NOT_LP64( const Address hi(obj, off, Address::times_1, 1*wordSize);) Label notByte, notBool, notInt, notShort, notChar, - notLong, notFloat, notObj, notDouble; + notLong, notFloat, notObj; + Label Done; + + const Register bc = LP64_ONLY(c_rarg3) NOT_LP64(rcx); __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); @@ -3232,42 +3252,17 @@ __ jcc(Assembler::notEqual, notLong); // ltos -#ifdef _LP64 { __ pop(ltos); if (!is_static) pop_and_check_object(obj); __ access_store_at(T_LONG, IN_HEAP, field, noreg /* ltos*/, noreg, noreg); +#ifdef _LP64 if (!is_static && rc == may_rewrite) { patch_bytecode(Bytecodes::_fast_lputfield, bc, rbx, true, byte_no); } +#endif // _LP64 __ jmp(Done); } -#else - { - Label notVolatileLong; - __ testl(rdx, rdx); - __ jcc(Assembler::zero, notVolatileLong); - - __ pop(ltos); // overwrites rdx, do this after testing volatile. - if (!is_static) pop_and_check_object(obj); - - // Replace with real volatile test - __ access_store_at(T_LONG, IN_HEAP | MO_RELAXED, field, noreg /* ltos */, noreg, noreg); - // volatile_barrier(); - volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | - Assembler::StoreStore)); - // Don't rewrite volatile version - __ jmp(notVolatile); - - __ bind(notVolatileLong); - - __ pop(ltos); // overwrites rdx - if (!is_static) pop_and_check_object(obj); - __ access_store_at(T_LONG, IN_HEAP, field, noreg /* ltos */, noreg, noreg); - // Don't rewrite to _fast_lputfield for potential volatile case. - __ jmp(notVolatile); - } -#endif // _LP64 __ bind(notLong); __ cmpl(flags, ftos); @@ -3286,6 +3281,7 @@ __ bind(notFloat); #ifdef ASSERT + Label notDouble; __ cmpl(flags, dtos); __ jcc(Assembler::notEqual, notDouble); #endif @@ -3308,13 +3304,6 @@ #endif __ bind(Done); - - // Check for volatile store - __ testl(rdx, rdx); - __ jcc(Assembler::zero, notVolatile); - volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | - Assembler::StoreStore)); - __ bind(notVolatile); } void TemplateTable::putfield(int byte_no) { @@ -3410,7 +3399,7 @@ // volatile_barrier(Assembler::Membar_mask_bits(Assembler::LoadStore | // Assembler::StoreStore)); - Label notVolatile; + Label notVolatile, Done; __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift); __ andl(rdx, 0x1); @@ -3420,6 +3409,23 @@ // field address const Address field(rcx, rbx, Address::times_1); + // Check for volatile store + __ testl(rdx, rdx); + __ jcc(Assembler::zero, notVolatile); + + fast_storefield_helper(field, rax); + volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | + Assembler::StoreStore)); + __ jmp(Done); + __ bind(notVolatile); + + fast_storefield_helper(field, rax); + + __ bind(Done); +} + +void TemplateTable::fast_storefield_helper(Address field, Register rax) { + // access field switch (bytecode()) { case Bytecodes::_fast_aputfield: @@ -3456,13 +3462,6 @@ default: ShouldNotReachHere(); } - - // Check for volatile store - __ testl(rdx, rdx); - __ jcc(Assembler::zero, notVolatile); - volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | - Assembler::StoreStore)); - __ bind(notVolatile); } void TemplateTable::fast_accessfield(TosState state) {