< prev index next >

src/hotspot/cpu/x86/templateTable_x86.cpp

Print this page

4039   //  If TLAB is enabled:
4040   //    Try to allocate in the TLAB.
4041   //    If fails, go to the slow path.
4042   //    Initialize the allocation.
4043   //    Exit.
4044   //
4045   //  Go to slow path.
4046 
4047   const Register thread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
4048 
4049   if (UseTLAB) {
4050     NOT_LP64(__ get_thread(thread);)
4051     __ tlab_allocate(thread, rax, rdx, 0, rcx, rbx, slow_case);
4052     if (ZeroTLAB) {
4053       // the fields have been already cleared
4054       __ jmp(initialize_header);
4055     }
4056 
4057     // The object is initialized before the header.  If the object size is
4058     // zero, go directly to the header initialization.
4059     __ decrement(rdx, sizeof(oopDesc));

4060     __ jcc(Assembler::zero, initialize_header);
4061 
4062     // Initialize topmost object field, divide rdx by 8, check if odd and
4063     // test if zero.
4064     __ xorl(rcx, rcx);    // use zero reg to clear memory (shorter code)
4065     __ shrl(rdx, LogBytesPerLong); // divide by 2*oopSize and set carry flag if odd
4066 
4067     // rdx must have been multiple of 8
4068 #ifdef ASSERT
4069     // make sure rdx was multiple of 8
4070     Label L;
4071     // Ignore partial flag stall after shrl() since it is debug VM
4072     __ jcc(Assembler::carryClear, L);
4073     __ stop("object size is not multiple of 2 - adjust this code");
4074     __ bind(L);
4075     // rdx must be > 0, no extra check needed here
4076 #endif
4077 
4078     // initialize remaining object fields: rdx was a multiple of 8
4079     { Label loop;
4080     __ bind(loop);
4081     __ movptr(Address(rax, rdx, Address::times_8, sizeof(oopDesc) - 1*oopSize), rcx);
4082     NOT_LP64(__ movptr(Address(rax, rdx, Address::times_8, sizeof(oopDesc) - 2*oopSize), rcx));
4083     __ decrement(rdx);
4084     __ jcc(Assembler::notZero, loop);
4085     }
4086 
4087     // initialize object header only.
4088     __ bind(initialize_header);
4089     __ movptr(Address(rax, oopDesc::mark_offset_in_bytes()),
4090               (intptr_t)markWord::prototype().value()); // header
4091     __ pop(rcx);   // get saved klass back in the register.





4092 #ifdef _LP64
4093     __ xorl(rsi, rsi); // use zero reg to clear memory (shorter code)
4094     __ store_klass_gap(rax, rsi);  // zero klass gap for compressed oops
4095 #endif
4096     __ store_klass(rax, rcx, rscratch1);  // klass

4097 
4098     {
4099       SkipIfEqual skip_if(_masm, &DTraceAllocProbes, 0, rscratch1);
4100       // Trigger dtrace event for fastpath
4101       __ push(atos);
4102       __ call_VM_leaf(
4103            CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), rax);
4104       __ pop(atos);
4105     }
4106 
4107     __ jmp(done);
4108   }
4109 
4110   // slow case
4111   __ bind(slow_case);
4112   __ pop(rcx);   // restore stack pointer to what it was when we came in.
4113   __ bind(slow_case_no_pop);
4114 
4115   Register rarg1 = LP64_ONLY(c_rarg1) NOT_LP64(rax);
4116   Register rarg2 = LP64_ONLY(c_rarg2) NOT_LP64(rdx);

4039   //  If TLAB is enabled:
4040   //    Try to allocate in the TLAB.
4041   //    If fails, go to the slow path.
4042   //    Initialize the allocation.
4043   //    Exit.
4044   //
4045   //  Go to slow path.
4046 
4047   const Register thread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
4048 
4049   if (UseTLAB) {
4050     NOT_LP64(__ get_thread(thread);)
4051     __ tlab_allocate(thread, rax, rdx, 0, rcx, rbx, slow_case);
4052     if (ZeroTLAB) {
4053       // the fields have been already cleared
4054       __ jmp(initialize_header);
4055     }
4056 
4057     // The object is initialized before the header.  If the object size is
4058     // zero, go directly to the header initialization.
4059     int header_size = align_up(oopDesc::base_offset_in_bytes(), BytesPerLong);
4060     __ decrement(rdx, header_size);
4061     __ jcc(Assembler::zero, initialize_header);
4062 
4063     // Initialize topmost object field, divide rdx by 8, check if odd and
4064     // test if zero.
4065     __ xorl(rcx, rcx);    // use zero reg to clear memory (shorter code)
4066     __ shrl(rdx, LogBytesPerLong); // divide by 2*oopSize and set carry flag if odd
4067 
4068     // rdx must have been multiple of 8
4069 #ifdef ASSERT
4070     // make sure rdx was multiple of 8
4071     Label L;
4072     // Ignore partial flag stall after shrl() since it is debug VM
4073     __ jcc(Assembler::carryClear, L);
4074     __ stop("object size is not multiple of 2 - adjust this code");
4075     __ bind(L);
4076     // rdx must be > 0, no extra check needed here
4077 #endif
4078 
4079     // initialize remaining object fields: rdx was a multiple of 8
4080     { Label loop;
4081     __ bind(loop);
4082     __ movptr(Address(rax, rdx, Address::times_8, header_size - 1*oopSize), rcx);
4083     NOT_LP64(__ movptr(Address(rax, rdx, Address::times_8, header_size - 2*oopSize), rcx));
4084     __ decrement(rdx);
4085     __ jcc(Assembler::notZero, loop);
4086     }
4087 
4088     // initialize object header only.
4089     __ bind(initialize_header);
4090     if (UseCompactObjectHeaders) {
4091       __ pop(rcx);   // get saved klass back in the register.
4092       __ movptr(rbx, Address(rcx, Klass::prototype_header_offset()));
4093       __ movptr(Address(rax, oopDesc::mark_offset_in_bytes ()), rbx);
4094     } else {
4095       __ movptr(Address(rax, oopDesc::mark_offset_in_bytes()),
4096                 (intptr_t)markWord::prototype().value()); // header
4097       __ pop(rcx);   // get saved klass back in the register.
4098 #ifdef _LP64
4099       __ xorl(rsi, rsi); // use zero reg to clear memory (shorter code)
4100       __ store_klass_gap(rax, rsi);  // zero klass gap for compressed oops
4101 #endif
4102       __ store_klass(rax, rcx, rscratch1);  // klass
4103     }
4104 
4105     {
4106       SkipIfEqual skip_if(_masm, &DTraceAllocProbes, 0, rscratch1);
4107       // Trigger dtrace event for fastpath
4108       __ push(atos);
4109       __ call_VM_leaf(
4110            CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), rax);
4111       __ pop(atos);
4112     }
4113 
4114     __ jmp(done);
4115   }
4116 
4117   // slow case
4118   __ bind(slow_case);
4119   __ pop(rcx);   // restore stack pointer to what it was when we came in.
4120   __ bind(slow_case_no_pop);
4121 
4122   Register rarg1 = LP64_ONLY(c_rarg1) NOT_LP64(rax);
4123   Register rarg2 = LP64_ONLY(c_rarg2) NOT_LP64(rdx);
< prev index next >