# HG changeset patch # User jcbeyler # Date 1513796407 28800 # Node ID ca9489245872beceadf4593b501abc178856bb14 # Parent 18fb0362469636edea3e949eb668eca3dc4a5aa9 8191987: JDK-8190862 work for arch ppc64 Summary: Cleanup interpreter TLAB code Reviewed-by: mdoerr, goetz diff -r 18fb03624696 -r ca9489245872 src/hotspot/cpu/ppc/macroAssembler_ppc.cpp --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp Thu Dec 21 00:07:38 2017 +0100 +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp Wed Dec 20 11:00:07 2017 -0800 @@ -5601,12 +5601,17 @@ #endif // !PRODUCT -SkipIfEqualZero::SkipIfEqualZero(MacroAssembler* masm, Register temp, const bool* flag_addr) : _masm(masm), _label() { +void SkipIfEqualZero::skip_to_label_if_equal_zero(MacroAssembler* masm, Register temp, + const bool* flag_addr, Label& label) { int simm16_offset = masm->load_const_optimized(temp, (address)flag_addr, R0, true); assert(sizeof(bool) == 1, "PowerPC ABI"); masm->lbz(temp, simm16_offset, temp); masm->cmpwi(CCR0, temp, 0); - masm->beq(CCR0, _label); + masm->beq(CCR0, label); +} + +SkipIfEqualZero::SkipIfEqualZero(MacroAssembler* masm, Register temp, const bool* flag_addr) : _masm(masm), _label() { + skip_to_label_if_equal_zero(masm, temp, flag_addr, _label); } SkipIfEqualZero::~SkipIfEqualZero() { diff -r 18fb03624696 -r ca9489245872 src/hotspot/cpu/ppc/macroAssembler_ppc.hpp --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp Thu Dec 21 00:07:38 2017 +0100 +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp Wed Dec 20 11:00:07 2017 -0800 @@ -979,6 +979,8 @@ public: // 'Temp' is a temp register that this object can use (and trash). explicit SkipIfEqualZero(MacroAssembler*, Register temp, const bool* flag_addr); + static void skip_to_label_if_equal_zero(MacroAssembler*, Register temp, + const bool* flag_addr, Label& label); ~SkipIfEqualZero(); }; diff -r 18fb03624696 -r ca9489245872 src/hotspot/cpu/ppc/templateTable_ppc_64.cpp --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp Thu Dec 21 00:07:38 2017 +0100 +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp Wed Dec 20 11:00:07 2017 -0800 @@ -3634,10 +3634,7 @@ transition(vtos, atos); Label Lslow_case, - Ldone, - Linitialize_header, - Lallocate_shared, - Linitialize_object; // Including clearing the fields. + Ldone; const Register RallocatedObject = R17_tos, RinstanceKlass = R9_ARG7, @@ -3648,8 +3645,6 @@ Rtags = R3_ARG1, Rindex = R5_ARG3; - const bool allow_shared_alloc = Universe::heap()->supports_inline_contig_alloc(); - // -------------------------------------------------------------------------- // Check if fast case is possible. @@ -3658,6 +3653,8 @@ // Load index of constant pool entry. __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned); + // Note: compared to other architectures, PPC's implementation always goes + // to the slow path if TLAB is used and fails. if (UseTLAB) { // Make sure the class we're about to instantiate has been resolved // This is done before loading instanceKlass to be consistent with the order @@ -3687,8 +3684,7 @@ // Fast case: // Allocate the instance. // 1) Try to allocate in the TLAB. - // 2) If fail, and the TLAB is not full enough to discard, allocate in the shared Eden. - // 3) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.). + // 2) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.). Register RoldTopValue = RallocatedObject; // Object will be allocated here if it fits. Register RnewTopValue = R6_ARG4; @@ -3702,53 +3698,13 @@ // If there is enough space, we do not CAS and do not clear. __ cmpld(CCR0, RnewTopValue, RendValue); - __ bgt(CCR0, allow_shared_alloc ? Lallocate_shared : Lslow_case); + __ bgt(CCR0, Lslow_case); __ std(RnewTopValue, in_bytes(JavaThread::tlab_top_offset()), R16_thread); - if (ZeroTLAB) { - // The fields have already been cleared. - __ b(Linitialize_header); - } else { - // Initialize both the header and fields. - __ b(Linitialize_object); - } - - // Fall through: TLAB was too small. - if (allow_shared_alloc) { - Register RtlabWasteLimitValue = R10_ARG8; - Register RfreeValue = RnewTopValue; - - __ bind(Lallocate_shared); - // Check if tlab should be discarded (refill_waste_limit >= free). - __ ld(RtlabWasteLimitValue, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), R16_thread); - __ subf(RfreeValue, RoldTopValue, RendValue); - __ srdi(RfreeValue, RfreeValue, LogHeapWordSize); // in dwords - __ cmpld(CCR0, RtlabWasteLimitValue, RfreeValue); - __ bge(CCR0, Lslow_case); - - // Increment waste limit to prevent getting stuck on this slow path. - __ add_const_optimized(RtlabWasteLimitValue, RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment()); - __ std(RtlabWasteLimitValue, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), R16_thread); - } - // else: No allocation in the shared eden. // fallthru: __ b(Lslow_case); - } - // else: Always go the slow path. - - // -------------------------------------------------------------------------- - // slow case - __ bind(Lslow_case); - call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), Rcpool, Rindex); - - if (UseTLAB) { - __ b(Ldone); - // -------------------------------------------------------------------------- - // Init1: Zero out newly allocated memory. - - if (!ZeroTLAB || allow_shared_alloc) { - // Clear object fields. - __ bind(Linitialize_object); - + if (!ZeroTLAB) { + // -------------------------------------------------------------------------- + // Init1: Zero out newly allocated memory. // Initialize remaining object fields. Register Rbase = Rtags; __ addi(Rinstance_size, Rinstance_size, 7 - (int)sizeof(oopDesc)); @@ -3757,13 +3713,10 @@ // Clear out object skipping header. Takes also care of the zero length case. __ clear_memory_doubleword(Rbase, Rinstance_size); - // fallthru: __ b(Linitialize_header); } // -------------------------------------------------------------------------- // Init2: Initialize the header: mark, klass - __ bind(Linitialize_header); - // Init mark. if (UseBiasedLocking) { __ ld(Rscratch, in_bytes(Klass::prototype_header_offset()), RinstanceKlass); @@ -3777,14 +3730,19 @@ __ store_klass(RallocatedObject, RinstanceKlass, Rscratch); // klass (last for cms) // Check and trigger dtrace event. - { - SkipIfEqualZero skip_if(_masm, Rscratch, &DTraceAllocProbes); - __ push(atos); - __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc)); - __ pop(atos); - } + SkipIfEqualZero::skip_to_label_if_equal_zero(_masm, Rscratch, &DTraceAllocProbes, Ldone); + __ push(atos); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc)); + __ pop(atos); + + __ b(Ldone); } + // -------------------------------------------------------------------------- + // slow case + __ bind(Lslow_case); + call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), Rcpool, Rindex); + // continue __ bind(Ldone);