3496
3497 // Allocate the instance:
3498 // If TLAB is enabled:
3499 // Try to allocate in the TLAB.
3500 // If fails, go to the slow path.
3501 // Initialize the allocation.
3502 // Exit.
3503 //
3504 // Go to slow path.
3505
3506 if (UseTLAB) {
3507 __ tlab_allocate(r0, r3, 0, noreg, r1, slow_case);
3508
3509 if (ZeroTLAB) {
3510 // the fields have been already cleared
3511 __ b(initialize_header);
3512 }
3513
3514 // The object is initialized before the header. If the object size is
3515 // zero, go directly to the header initialization.
3516 __ sub(r3, r3, sizeof(oopDesc));
3517 __ cbz(r3, initialize_header);
3518
3519 // Initialize object fields
3520 {
3521 __ add(r2, r0, sizeof(oopDesc));
3522 Label loop;
3523 __ bind(loop);
3524 __ str(zr, Address(__ post(r2, BytesPerLong)));
3525 __ sub(r3, r3, BytesPerLong);
3526 __ cbnz(r3, loop);
3527 }
3528
3529 // initialize object header only.
3530 __ bind(initialize_header);
3531 __ mov(rscratch1, (intptr_t)markWord::prototype().value());
3532 __ str(rscratch1, Address(r0, oopDesc::mark_offset_in_bytes()));
3533 __ store_klass_gap(r0, zr); // zero klass gap for compressed oops
3534 __ store_klass(r0, r4); // store klass last
3535
3536 {
3537 SkipIfEqual skip(_masm, &DTraceAllocProbes, false);
3538 // Trigger dtrace event for fastpath
3539 __ push(atos); // save the return value
3540 __ call_VM_leaf(
3541 CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), r0);
3542 __ pop(atos); // restore the return value
3543
3544 }
3545 __ b(done);
3546 }
3547
3548 // slow case
3549 __ bind(slow_case);
3550 __ get_constant_pool(c_rarg1);
3551 __ get_unsigned_2_byte_index_at_bcp(c_rarg2, 1);
3552 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), c_rarg1, c_rarg2);
3553 __ verify_oop(r0);
3554
3555 // continue
|
3496
3497 // Allocate the instance:
3498 // If TLAB is enabled:
3499 // Try to allocate in the TLAB.
3500 // If fails, go to the slow path.
3501 // Initialize the allocation.
3502 // Exit.
3503 //
3504 // Go to slow path.
3505
3506 if (UseTLAB) {
3507 __ tlab_allocate(r0, r3, 0, noreg, r1, slow_case);
3508
3509 if (ZeroTLAB) {
3510 // the fields have been already cleared
3511 __ b(initialize_header);
3512 }
3513
3514 // The object is initialized before the header. If the object size is
3515 // zero, go directly to the header initialization.
3516 __ sub(r3, r3, oopDesc::base_offset_in_bytes());
3517 __ cbz(r3, initialize_header);
3518
3519 // Initialize object fields
3520 {
3521 __ add(r2, r0, oopDesc::base_offset_in_bytes());
3522 if (!is_aligned(oopDesc::base_offset_in_bytes(), BytesPerLong)) {
3523 __ strw(zr, Address(__ post(r2, BytesPerInt)));
3524 __ sub(r3, r3, BytesPerInt);
3525 __ cbz(r3, initialize_header);
3526 }
3527 Label loop;
3528 __ bind(loop);
3529 __ str(zr, Address(__ post(r2, BytesPerLong)));
3530 __ sub(r3, r3, BytesPerLong);
3531 __ cbnz(r3, loop);
3532 }
3533
3534 // initialize object header only.
3535 __ bind(initialize_header);
3536 if (UseCompactObjectHeaders) {
3537 __ ldr(rscratch1, Address(r4, Klass::prototype_header_offset()));
3538 __ str(rscratch1, Address(r0, oopDesc::mark_offset_in_bytes()));
3539 } else {
3540 __ mov(rscratch1, (intptr_t)markWord::prototype().value());
3541 __ str(rscratch1, Address(r0, oopDesc::mark_offset_in_bytes()));
3542 __ store_klass(r0, r4); // store klass last
3543 }
3544 {
3545 SkipIfEqual skip(_masm, &DTraceAllocProbes, false);
3546 // Trigger dtrace event for fastpath
3547 __ push(atos); // save the return value
3548 __ call_VM_leaf(
3549 CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), r0);
3550 __ pop(atos); // restore the return value
3551
3552 }
3553 __ b(done);
3554 }
3555
3556 // slow case
3557 __ bind(slow_case);
3558 __ get_constant_pool(c_rarg1);
3559 __ get_unsigned_2_byte_index_at_bcp(c_rarg2, 1);
3560 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), c_rarg1, c_rarg2);
3561 __ verify_oop(r0);
3562
3563 // continue
|