2663 2664 // Get the handle (the 2nd argument) 2665 __ mov(oop_handle_reg, c_rarg1); 2666 2667 // Get address of the box 2668 2669 __ lea(lock_reg, Address(rsp, lock_slot_offset * VMRegImpl::stack_slot_size)); 2670 2671 // Load the oop from the handle 2672 __ movptr(obj_reg, Address(oop_handle_reg, 0)); 2673 2674 if (UseBiasedLocking) { 2675 __ biased_locking_enter(lock_reg, obj_reg, swap_reg, rscratch1, false, lock_done, &slow_path_lock); 2676 } 2677 2678 // Load immediate 1 into swap_reg %rax 2679 __ movl(swap_reg, 1); 2680 2681 // Load (object->mark() | 1) into swap_reg %rax 2682 __ orptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes())); 2683 2684 // Save (object->mark() | 1) into BasicLock's displaced header 2685 __ movptr(Address(lock_reg, mark_word_offset), swap_reg); 2686 2687 if (os::is_MP()) { 2688 __ lock(); 2689 } 2690 2691 // src -> dest iff dest == rax else rax <- dest 2692 __ cmpxchgptr(lock_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes())); 2693 __ jcc(Assembler::equal, lock_done); 2694 2695 // Hmm should this move to the slow path code area??? 2696 2697 // Test if the oopMark is an obvious stack pointer, i.e., 2698 // 1) (mark & 3) == 0, and 2699 // 2) rsp <= mark < mark + os::pagesize() 2700 // These 3 tests can be done by evaluating the following 2701 // expression: ((mark - rsp) & (3 - os::vm_page_size())), 2702 // assuming both stack pointer and pagesize have their | 2663 2664 // Get the handle (the 2nd argument) 2665 __ mov(oop_handle_reg, c_rarg1); 2666 2667 // Get address of the box 2668 2669 __ lea(lock_reg, Address(rsp, lock_slot_offset * VMRegImpl::stack_slot_size)); 2670 2671 // Load the oop from the handle 2672 __ movptr(obj_reg, Address(oop_handle_reg, 0)); 2673 2674 if (UseBiasedLocking) { 2675 __ biased_locking_enter(lock_reg, obj_reg, swap_reg, rscratch1, false, lock_done, &slow_path_lock); 2676 } 2677 2678 // Load immediate 1 into swap_reg %rax 2679 __ movl(swap_reg, 1); 2680 2681 // Load (object->mark() | 1) into swap_reg %rax 2682 __ orptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes())); 2683 if (EnableValhalla && !UseBiasedLocking) { 2684 // For slow path is_always_locked, using biased, which is never natural for !UseBiasLocking 2685 __ andptr(swap_reg, ~markOopDesc::biased_lock_bit_in_place); 2686 } 2687 2688 // Save (object->mark() | 1) into BasicLock's displaced header 2689 __ movptr(Address(lock_reg, mark_word_offset), swap_reg); 2690 2691 if (os::is_MP()) { 2692 __ lock(); 2693 } 2694 2695 // src -> dest iff dest == rax else rax <- dest 2696 __ cmpxchgptr(lock_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes())); 2697 __ jcc(Assembler::equal, lock_done); 2698 2699 // Hmm should this move to the slow path code area??? 2700 2701 // Test if the oopMark is an obvious stack pointer, i.e., 2702 // 1) (mark & 3) == 0, and 2703 // 2) rsp <= mark < mark + os::pagesize() 2704 // These 3 tests can be done by evaluating the following 2705 // expression: ((mark - rsp) & (3 - os::vm_page_size())), 2706 // assuming both stack pointer and pagesize have their |