src/hotspot/cpu/ppc/templateTable_ppc_64.cpp
changeset 48476 ca9489245872
parent 48332 651a95f30dfb
child 48608 1dab70e20292
child 56021 864ee22719af
equal deleted inserted replaced
48475:18fb03624696 48476:ca9489245872
  3632 // Puts allocated obj ref onto the expression stack.
  3632 // Puts allocated obj ref onto the expression stack.
  3633 void TemplateTable::_new() {
  3633 void TemplateTable::_new() {
  3634   transition(vtos, atos);
  3634   transition(vtos, atos);
  3635 
  3635 
  3636   Label Lslow_case,
  3636   Label Lslow_case,
  3637         Ldone,
  3637         Ldone;
  3638         Linitialize_header,
       
  3639         Lallocate_shared,
       
  3640         Linitialize_object;  // Including clearing the fields.
       
  3641 
  3638 
  3642   const Register RallocatedObject = R17_tos,
  3639   const Register RallocatedObject = R17_tos,
  3643                  RinstanceKlass   = R9_ARG7,
  3640                  RinstanceKlass   = R9_ARG7,
  3644                  Rscratch         = R11_scratch1,
  3641                  Rscratch         = R11_scratch1,
  3645                  Roffset          = R8_ARG6,
  3642                  Roffset          = R8_ARG6,
  3646                  Rinstance_size   = Roffset,
  3643                  Rinstance_size   = Roffset,
  3647                  Rcpool           = R4_ARG2,
  3644                  Rcpool           = R4_ARG2,
  3648                  Rtags            = R3_ARG1,
  3645                  Rtags            = R3_ARG1,
  3649                  Rindex           = R5_ARG3;
  3646                  Rindex           = R5_ARG3;
  3650 
  3647 
  3651   const bool allow_shared_alloc = Universe::heap()->supports_inline_contig_alloc();
       
  3652 
       
  3653   // --------------------------------------------------------------------------
  3648   // --------------------------------------------------------------------------
  3654   // Check if fast case is possible.
  3649   // Check if fast case is possible.
  3655 
  3650 
  3656   // Load pointers to const pool and const pool's tags array.
  3651   // Load pointers to const pool and const pool's tags array.
  3657   __ get_cpool_and_tags(Rcpool, Rtags);
  3652   __ get_cpool_and_tags(Rcpool, Rtags);
  3658   // Load index of constant pool entry.
  3653   // Load index of constant pool entry.
  3659   __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
  3654   __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
  3660 
  3655 
       
  3656   // Note: compared to other architectures, PPC's implementation always goes
       
  3657   // to the slow path if TLAB is used and fails.
  3661   if (UseTLAB) {
  3658   if (UseTLAB) {
  3662     // Make sure the class we're about to instantiate has been resolved
  3659     // Make sure the class we're about to instantiate has been resolved
  3663     // This is done before loading instanceKlass to be consistent with the order
  3660     // This is done before loading instanceKlass to be consistent with the order
  3664     // how Constant Pool is updated (see ConstantPoolCache::klass_at_put).
  3661     // how Constant Pool is updated (see ConstantPoolCache::klass_at_put).
  3665     __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
  3662     __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
  3685 
  3682 
  3686     // --------------------------------------------------------------------------
  3683     // --------------------------------------------------------------------------
  3687     // Fast case:
  3684     // Fast case:
  3688     // Allocate the instance.
  3685     // Allocate the instance.
  3689     // 1) Try to allocate in the TLAB.
  3686     // 1) Try to allocate in the TLAB.
  3690     // 2) If fail, and the TLAB is not full enough to discard, allocate in the shared Eden.
  3687     // 2) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.).
  3691     // 3) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.).
       
  3692 
  3688 
  3693     Register RoldTopValue = RallocatedObject; // Object will be allocated here if it fits.
  3689     Register RoldTopValue = RallocatedObject; // Object will be allocated here if it fits.
  3694     Register RnewTopValue = R6_ARG4;
  3690     Register RnewTopValue = R6_ARG4;
  3695     Register RendValue    = R7_ARG5;
  3691     Register RendValue    = R7_ARG5;
  3696 
  3692 
  3700 
  3696 
  3701     __ add(RnewTopValue, Rinstance_size, RoldTopValue);
  3697     __ add(RnewTopValue, Rinstance_size, RoldTopValue);
  3702 
  3698 
  3703     // If there is enough space, we do not CAS and do not clear.
  3699     // If there is enough space, we do not CAS and do not clear.
  3704     __ cmpld(CCR0, RnewTopValue, RendValue);
  3700     __ cmpld(CCR0, RnewTopValue, RendValue);
  3705     __ bgt(CCR0, allow_shared_alloc ? Lallocate_shared : Lslow_case);
  3701     __ bgt(CCR0, Lslow_case);
  3706 
  3702 
  3707     __ std(RnewTopValue, in_bytes(JavaThread::tlab_top_offset()), R16_thread);
  3703     __ std(RnewTopValue, in_bytes(JavaThread::tlab_top_offset()), R16_thread);
  3708 
  3704 
  3709     if (ZeroTLAB) {
  3705     if (!ZeroTLAB) {
  3710       // The fields have already been cleared.
  3706       // --------------------------------------------------------------------------
  3711       __ b(Linitialize_header);
  3707       // Init1: Zero out newly allocated memory.
  3712     } else {
       
  3713       // Initialize both the header and fields.
       
  3714       __ b(Linitialize_object);
       
  3715     }
       
  3716 
       
  3717     // Fall through: TLAB was too small.
       
  3718     if (allow_shared_alloc) {
       
  3719       Register RtlabWasteLimitValue = R10_ARG8;
       
  3720       Register RfreeValue = RnewTopValue;
       
  3721 
       
  3722       __ bind(Lallocate_shared);
       
  3723       // Check if tlab should be discarded (refill_waste_limit >= free).
       
  3724       __ ld(RtlabWasteLimitValue, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), R16_thread);
       
  3725       __ subf(RfreeValue, RoldTopValue, RendValue);
       
  3726       __ srdi(RfreeValue, RfreeValue, LogHeapWordSize); // in dwords
       
  3727       __ cmpld(CCR0, RtlabWasteLimitValue, RfreeValue);
       
  3728       __ bge(CCR0, Lslow_case);
       
  3729 
       
  3730       // Increment waste limit to prevent getting stuck on this slow path.
       
  3731       __ add_const_optimized(RtlabWasteLimitValue, RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment());
       
  3732       __ std(RtlabWasteLimitValue, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), R16_thread);
       
  3733     }
       
  3734     // else: No allocation in the shared eden. // fallthru: __ b(Lslow_case);
       
  3735   }
       
  3736   // else: Always go the slow path.
       
  3737 
       
  3738   // --------------------------------------------------------------------------
       
  3739   // slow case
       
  3740   __ bind(Lslow_case);
       
  3741   call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), Rcpool, Rindex);
       
  3742 
       
  3743   if (UseTLAB) {
       
  3744     __ b(Ldone);
       
  3745     // --------------------------------------------------------------------------
       
  3746     // Init1: Zero out newly allocated memory.
       
  3747 
       
  3748     if (!ZeroTLAB || allow_shared_alloc) {
       
  3749       // Clear object fields.
       
  3750       __ bind(Linitialize_object);
       
  3751 
       
  3752       // Initialize remaining object fields.
  3708       // Initialize remaining object fields.
  3753       Register Rbase = Rtags;
  3709       Register Rbase = Rtags;
  3754       __ addi(Rinstance_size, Rinstance_size, 7 - (int)sizeof(oopDesc));
  3710       __ addi(Rinstance_size, Rinstance_size, 7 - (int)sizeof(oopDesc));
  3755       __ addi(Rbase, RallocatedObject, sizeof(oopDesc));
  3711       __ addi(Rbase, RallocatedObject, sizeof(oopDesc));
  3756       __ srdi(Rinstance_size, Rinstance_size, 3);
  3712       __ srdi(Rinstance_size, Rinstance_size, 3);
  3757 
  3713 
  3758       // Clear out object skipping header. Takes also care of the zero length case.
  3714       // Clear out object skipping header. Takes also care of the zero length case.
  3759       __ clear_memory_doubleword(Rbase, Rinstance_size);
  3715       __ clear_memory_doubleword(Rbase, Rinstance_size);
  3760       // fallthru: __ b(Linitialize_header);
       
  3761     }
  3716     }
  3762 
  3717 
  3763     // --------------------------------------------------------------------------
  3718     // --------------------------------------------------------------------------
  3764     // Init2: Initialize the header: mark, klass
  3719     // Init2: Initialize the header: mark, klass
  3765     __ bind(Linitialize_header);
       
  3766 
       
  3767     // Init mark.
  3720     // Init mark.
  3768     if (UseBiasedLocking) {
  3721     if (UseBiasedLocking) {
  3769       __ ld(Rscratch, in_bytes(Klass::prototype_header_offset()), RinstanceKlass);
  3722       __ ld(Rscratch, in_bytes(Klass::prototype_header_offset()), RinstanceKlass);
  3770     } else {
  3723     } else {
  3771       __ load_const_optimized(Rscratch, markOopDesc::prototype(), R0);
  3724       __ load_const_optimized(Rscratch, markOopDesc::prototype(), R0);
  3775     // Init klass.
  3728     // Init klass.
  3776     __ store_klass_gap(RallocatedObject);
  3729     __ store_klass_gap(RallocatedObject);
  3777     __ store_klass(RallocatedObject, RinstanceKlass, Rscratch); // klass (last for cms)
  3730     __ store_klass(RallocatedObject, RinstanceKlass, Rscratch); // klass (last for cms)
  3778 
  3731 
  3779     // Check and trigger dtrace event.
  3732     // Check and trigger dtrace event.
  3780     {
  3733     SkipIfEqualZero::skip_to_label_if_equal_zero(_masm, Rscratch, &DTraceAllocProbes, Ldone);
  3781       SkipIfEqualZero skip_if(_masm, Rscratch, &DTraceAllocProbes);
  3734     __ push(atos);
  3782       __ push(atos);
  3735     __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc));
  3783       __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc));
  3736     __ pop(atos);
  3784       __ pop(atos);
  3737 
  3785     }
  3738     __ b(Ldone);
  3786   }
  3739   }
       
  3740 
       
  3741   // --------------------------------------------------------------------------
       
  3742   // slow case
       
  3743   __ bind(Lslow_case);
       
  3744   call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), Rcpool, Rindex);
  3787 
  3745 
  3788   // continue
  3746   // continue
  3789   __ bind(Ldone);
  3747   __ bind(Ldone);
  3790 
  3748 
  3791   // Must prevent reordering of stores for object initialization with stores that publish the new object.
  3749   // Must prevent reordering of stores for object initialization with stores that publish the new object.