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