@@ -3801,200 +3801,6 @@ encode %{
3801
3801
__ br(target_reg);
3802
3802
%}
3803
3803
3804
- enc_class aarch64_enc_fast_lock(iRegP object, iRegP box, iRegP tmp, iRegP tmp2) %{
3805
- C2_MacroAssembler _masm(&cbuf);
3806
- Register oop = as_Register($object$$reg);
3807
- Register box = as_Register($box$$reg);
3808
- Register disp_hdr = as_Register($tmp$$reg);
3809
- Register tmp = as_Register($tmp2$$reg);
3810
- Label cont;
3811
- Label object_has_monitor;
3812
- Label cas_failed;
3813
-
3814
- assert_different_registers(oop, box, tmp, disp_hdr);
3815
-
3816
- // Load markWord from object into displaced_header.
3817
- __ ldr(disp_hdr, Address(oop, oopDesc::mark_offset_in_bytes()));
3818
-
3819
- if (DiagnoseSyncOnValueBasedClasses != 0) {
3820
- __ load_klass(tmp, oop);
3821
- __ ldrw(tmp, Address(tmp, Klass::access_flags_offset()));
3822
- __ tstw(tmp, JVM_ACC_IS_VALUE_BASED_CLASS);
3823
- __ br(Assembler::NE, cont);
3824
- }
3825
-
3826
- if (UseBiasedLocking && !UseOptoBiasInlining) {
3827
- __ biased_locking_enter(box, oop, disp_hdr, tmp, true, cont);
3828
- }
3829
-
3830
- // Check for existing monitor
3831
- __ tbnz(disp_hdr, exact_log2(markWord::monitor_value), object_has_monitor);
3832
-
3833
- if (LockingMode == LM_MONITOR) {
3834
- __ tst(oop, oop); // Set NE to indicate 'failure' -> take slow-path. We know that oop != 0.
3835
- __ b(cont);
3836
- } else if (LockingMode == LM_LEGACY) {
3837
- // Set tmp to be (markWord of object | UNLOCK_VALUE).
3838
- __ orr(tmp, disp_hdr, markWord::unlocked_value);
3839
-
3840
- // Initialize the box. (Must happen before we update the object mark!)
3841
- __ str(tmp, Address(box, BasicLock::displaced_header_offset_in_bytes()));
3842
-
3843
- // Compare object markWord with an unlocked value (tmp) and if
3844
- // equal exchange the stack address of our box with object markWord.
3845
- // On failure disp_hdr contains the possibly locked markWord.
3846
- __ cmpxchg(oop, tmp, box, Assembler::xword, /*acquire*/ true,
3847
- /*release*/ true, /*weak*/ false, disp_hdr);
3848
- __ br(Assembler::EQ, cont);
3849
-
3850
- assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
3851
-
3852
- // If the compare-and-exchange succeeded, then we found an unlocked
3853
- // object, will have now locked it will continue at label cont
3854
-
3855
- __ bind(cas_failed);
3856
- // We did not see an unlocked object so try the fast recursive case.
3857
-
3858
- // Check if the owner is self by comparing the value in the
3859
- // markWord of object (disp_hdr) with the stack pointer.
3860
- __ mov(rscratch1, sp);
3861
- __ sub(disp_hdr, disp_hdr, rscratch1);
3862
- __ mov(tmp, (address) (~(os::vm_page_size()-1) | markWord::lock_mask_in_place));
3863
- // If condition is true we are cont and hence we can store 0 as the
3864
- // displaced header in the box, which indicates that it is a recursive lock.
3865
- __ ands(tmp/*==0?*/, disp_hdr, tmp); // Sets flags for result
3866
- __ str(tmp/*==0, perhaps*/, Address(box, BasicLock::displaced_header_offset_in_bytes()));
3867
- __ b(cont);
3868
- } else {
3869
- assert(LockingMode == LM_LIGHTWEIGHT, "must be");
3870
- __ lightweight_lock(oop, disp_hdr, tmp, rscratch1, cont);
3871
- __ b(cont);
3872
- }
3873
-
3874
- // Handle existing monitor.
3875
- __ bind(object_has_monitor);
3876
-
3877
- // The object's monitor m is unlocked iff m->owner == NULL,
3878
- // otherwise m->owner may contain a thread or a stack address.
3879
- //
3880
- // Try to CAS m->owner from NULL to current thread.
3881
- __ add(tmp, disp_hdr, (ObjectMonitor::owner_offset_in_bytes()-markWord::monitor_value));
3882
- __ cmpxchg(tmp, zr, rthread, Assembler::xword, /*acquire*/ true,
3883
- /*release*/ true, /*weak*/ false, rscratch1); // Sets flags for result
3884
-
3885
- if (LockingMode != LM_LIGHTWEIGHT) {
3886
- // Store a non-null value into the box to avoid looking like a re-entrant
3887
- // lock. The fast-path monitor unlock code checks for
3888
- // markWord::monitor_value so use markWord::unused_mark which has the
3889
- // relevant bit set, and also matches ObjectSynchronizer::enter.
3890
- __ mov(tmp, (address)markWord::unused_mark().value());
3891
- __ str(tmp, Address(box, BasicLock::displaced_header_offset_in_bytes()));
3892
- }
3893
- __ br(Assembler::EQ, cont); // CAS success means locking succeeded
3894
-
3895
- __ cmp(rscratch1, rthread);
3896
- __ br(Assembler::NE, cont); // Check for recursive locking
3897
-
3898
- // Recursive lock case
3899
- __ increment(Address(disp_hdr, ObjectMonitor::recursions_offset_in_bytes() - markWord::monitor_value), 1);
3900
- // flag == EQ still from the cmp above, checking if this is a reentrant lock
3901
-
3902
- __ bind(cont);
3903
- // flag == EQ indicates success
3904
- // flag == NE indicates failure
3905
- %}
3906
-
3907
- enc_class aarch64_enc_fast_unlock(iRegP object, iRegP box, iRegP tmp, iRegP tmp2) %{
3908
- C2_MacroAssembler _masm(&cbuf);
3909
- Register oop = as_Register($object$$reg);
3910
- Register box = as_Register($box$$reg);
3911
- Register disp_hdr = as_Register($tmp$$reg);
3912
- Register tmp = as_Register($tmp2$$reg);
3913
- Label cont;
3914
- Label object_has_monitor;
3915
-
3916
- assert_different_registers(oop, box, tmp, disp_hdr);
3917
-
3918
- if (UseBiasedLocking && !UseOptoBiasInlining) {
3919
- __ biased_locking_exit(oop, tmp, cont);
3920
- }
3921
-
3922
- if (LockingMode == LM_LEGACY) {
3923
- // Find the lock address and load the displaced header from the stack.
3924
- __ ldr(disp_hdr, Address(box, BasicLock::displaced_header_offset_in_bytes()));
3925
-
3926
- // If the displaced header is 0, we have a recursive unlock.
3927
- __ cmp(disp_hdr, zr);
3928
- __ br(Assembler::EQ, cont);
3929
- }
3930
-
3931
- // Handle existing monitor.
3932
- __ ldr(tmp, Address(oop, oopDesc::mark_offset_in_bytes()));
3933
- __ tbnz(tmp, exact_log2(markWord::monitor_value), object_has_monitor);
3934
-
3935
- if (LockingMode == LM_MONITOR) {
3936
- __ tst(oop, oop); // Set NE to indicate 'failure' -> take slow-path. We know that oop != 0.
3937
- __ b(cont);
3938
- } else if (LockingMode == LM_LEGACY) {
3939
- // Check if it is still a light weight lock, this is is true if we
3940
- // see the stack address of the basicLock in the markWord of the
3941
- // object.
3942
-
3943
- __ cmpxchg(oop, box, disp_hdr, Assembler::xword, /*acquire*/ false,
3944
- /*release*/ true, /*weak*/ false, tmp);
3945
- __ b(cont);
3946
- } else {
3947
- assert(LockingMode == LM_LIGHTWEIGHT, "must be");
3948
- __ lightweight_unlock(oop, tmp, box, disp_hdr, cont);
3949
- __ b(cont);
3950
- }
3951
-
3952
- assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
3953
-
3954
- // Handle existing monitor.
3955
- __ bind(object_has_monitor);
3956
- STATIC_ASSERT(markWord::monitor_value <= INT_MAX);
3957
- __ add(tmp, tmp, -(int)markWord::monitor_value); // monitor
3958
-
3959
- if (LockingMode == LM_LIGHTWEIGHT) {
3960
- // If the owner is anonymous, we need to fix it -- in an outline stub.
3961
- Register tmp2 = disp_hdr;
3962
- __ ldr(tmp2, Address(tmp, ObjectMonitor::owner_offset_in_bytes()));
3963
- // We cannot use tbnz here, the target might be too far away and cannot
3964
- // be encoded.
3965
- __ tst(tmp2, (uint64_t)ObjectMonitor::ANONYMOUS_OWNER);
3966
- C2HandleAnonOMOwnerStub* stub = new (Compile::current()->comp_arena()) C2HandleAnonOMOwnerStub(tmp, tmp2);
3967
- Compile::current()->output()->add_stub(stub);
3968
- __ br(Assembler::NE, stub->entry());
3969
- __ bind(stub->continuation());
3970
- }
3971
-
3972
- __ ldr(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes()));
3973
-
3974
- Label notRecursive;
3975
- __ cbz(disp_hdr, notRecursive);
3976
-
3977
- // Recursive lock
3978
- __ sub(disp_hdr, disp_hdr, 1u);
3979
- __ str(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes()));
3980
- __ cmp(disp_hdr, disp_hdr); // Sets flags for result
3981
- __ b(cont);
3982
-
3983
- __ bind(notRecursive);
3984
- __ ldr(rscratch1, Address(tmp, ObjectMonitor::EntryList_offset_in_bytes()));
3985
- __ ldr(disp_hdr, Address(tmp, ObjectMonitor::cxq_offset_in_bytes()));
3986
- __ orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if both are 0.
3987
- __ cmp(rscratch1, zr); // Sets flags for result
3988
- __ cbnz(rscratch1, cont);
3989
- // need a release store here
3990
- __ lea(tmp, Address(tmp, ObjectMonitor::owner_offset_in_bytes()));
3991
- __ stlr(zr, tmp); // set unowned
3992
-
3993
- __ bind(cont);
3994
- // flag == EQ indicates success
3995
- // flag == NE indicates failure
3996
- %}
3997
-
3998
3804
%}
3999
3805
4000
3806
//----------FRAME--------------------------------------------------------------
@@ -16740,7 +16546,9 @@ instruct cmpFastLock(rFlagsReg cr, iRegP object, iRegP box, iRegPNoSp tmp, iRegP
16740
16546
ins_cost(5 * INSN_COST);
16741
16547
format %{ "fastlock $object,$box\t! kills $tmp,$tmp2" %}
16742
16548
16743
- ins_encode(aarch64_enc_fast_lock(object, box, tmp, tmp2));
16549
+ ins_encode %{
16550
+ __ fast_lock($object$$Register, $box$$Register, $tmp$$Register, $tmp2$$Register);
16551
+ %}
16744
16552
16745
16553
ins_pipe(pipe_serial);
16746
16554
%}
@@ -16753,7 +16561,9 @@ instruct cmpFastUnlock(rFlagsReg cr, iRegP object, iRegP box, iRegPNoSp tmp, iRe
16753
16561
ins_cost(5 * INSN_COST);
16754
16562
format %{ "fastunlock $object,$box\t! kills $tmp, $tmp2" %}
16755
16563
16756
- ins_encode(aarch64_enc_fast_unlock(object, box, tmp, tmp2));
16564
+ ins_encode %{
16565
+ __ fast_unlock($object$$Register, $box$$Register, $tmp$$Register, $tmp2$$Register);
16566
+ %}
16757
16567
16758
16568
ins_pipe(pipe_serial);
16759
16569
%}
0 commit comments