Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge jdk-24+18 into rivos/main #194

Merged
merged 99 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
e2626db
8340899: Remove wildcard bound in PositionWindows.positionTestWindows
aivanov-jdk Sep 26, 2024
3762ec3
8340466: Add description for PassFailJFrame constructors
aivanov-jdk Sep 26, 2024
777c20c
8339542: compiler/codecache/CheckSegmentedCodeCache.java fails
RealLucy Sep 26, 2024
47fcf5a
8340687: Open source closed frame tests #1
Sep 26, 2024
95d3e9d
8339560: Unaddressed comments during code review of JDK-8337664
fguallini Sep 26, 2024
e36ce5f
8336942: Improve test coverage for class loading elements with annota…
cushon Sep 26, 2024
376056c
8336468: Reflection and MethodHandles should use more precise initial…
shipilev Sep 26, 2024
aeaa4f7
8336895: BufferedReader doesn't read full \r\n line ending when it do…
Sep 26, 2024
aceae76
8339460: CDS error when module is located in a directory with space i…
Sep 26, 2024
8225a5f
8340981: Update citations to "Hacker's Delight"
jddarcy Sep 26, 2024
bb040ef
8340983: Use index and definition tags in Object and Double
jddarcy Sep 26, 2024
a02d895
8333403: Write a test to check various components events are triggere…
Sep 26, 2024
1447967
8339261: Logs truncated in test javax/net/ssl/DTLS/DTLSRehandshakeTes…
fguallini Sep 26, 2024
5d062e2
8340576: Some JVMCI flags are inconsistent
Sep 26, 2024
2349bb7
8340974: Ambiguous name of jtreg property vm.libgraal.enabled
toddjonker Sep 26, 2024
e6373b5
8340679: Misc tests fail assert(!set || SafepointSynchronize::is_at_s…
coleenp Sep 26, 2024
1bc13a1
8340552: Harden TzdbZoneRulesCompiler against missing zone names
Sep 26, 2024
85dba47
8325090: javadoc fails when -subpackages option is used with non-modu…
hns Sep 27, 2024
2a2ecc9
8339475: Clean up return code handling for pthread calls in library c…
MBaesken Sep 27, 2024
9003e2c
8341027: Crash in java/runtime/Unsafe/InternalErrorTest when running …
stefank Sep 27, 2024
6587909
8341015: OopStorage location decoder crashes accessing non-initalized…
shipilev Sep 27, 2024
25e8929
8340620: Fix -Wzero-as-null-pointer-constant warnings for CompressedOops
Sep 27, 2024
12de4fb
8340826: Should not send unload notification for scratch classes
lmesnik Sep 27, 2024
68c4f36
8340024: In ClassReader, extract a constant for the superclass supert…
cushon Sep 27, 2024
5aae3d4
8341096: ProblemList compiler/cha/TypeProfileFinalMethod.java in Xcom…
Sep 27, 2024
824a297
8341057: Add 2 SSL.com TLS roots
rhalade Sep 27, 2024
65200a9
8340490: Shenandoah: Optimize ShenandoahPacer
Sep 27, 2024
f554c3f
8341059: Change Entrust TLS distrust date to November 12, 2024
rhalade Sep 27, 2024
a7bfced
8337679: Memset warning in src/hotspot/share/adlc/adlArena.cpp
nelanbu Sep 27, 2024
082125d
8340404: CharsetProvider specification updates
Sep 27, 2024
ed140f5
8341101: [ARM32] Error: ShouldNotReachHere() in TemplateInterpreterGe…
Sep 27, 2024
73ebb84
8340721: Clarify special case handling of unboxedType and getWildcard…
jddarcy Sep 27, 2024
ade17ec
8340560: Open Source several AWT/2D font and rendering tests
prrace Sep 29, 2024
dd56990
8340639: Open source few more AWT List tests
prsadhuk Sep 30, 2024
ae4d2f1
8340621: Open source several AWT List tests
prsadhuk Sep 30, 2024
6514aef
8340419: ZGC: Create an UseLargePages adaptation of TestAllocateHeapA…
xmas92 Sep 30, 2024
822a773
8340605: Open source several AWT PopupMenu tests
Sep 30, 2024
988a531
8340181: Shenandoah: Cleanup ShenandoahRuntime stubs
shipilev Sep 30, 2024
52ba728
8327114: Attach in Linux may have wrong behaviour when pid == ns_pid …
slovdahl Sep 30, 2024
475b894
8322770: Implement C2 VectorizedHashCode on AArch64
mikabl-arm Sep 30, 2024
1cf26a5
8341013: Optimize x86/aarch64 MD5 intrinsics by reducing data dependency
olivergillespie Sep 30, 2024
58b6fc5
8341197: [BACKOUT] 8322770: Implement C2 VectorizedHashCode on AArch64
TobiHartmann Sep 30, 2024
e19c7d8
8340874: Open source some of the AWT Geometry/Button tests
jayathirthrao Sep 30, 2024
180affc
8320318: ObjectMonitor Responsible thread
Sep 30, 2024
cff420d
8339711: ZipFile.Source.initCEN needlessly reads END header
Sep 30, 2024
860d49d
8211400: nsk.share.gc.Memory::getArrayLength returns wrong value
Sep 30, 2024
f1bf469
8341199: Use ClassFile's new API loadConstant(int)
wenshao Sep 30, 2024
4168faf
8341100: Add index entries for terms used in java.lang.Class
jddarcy Sep 30, 2024
5586f83
8341064: Define anchor point and index term for "wrapper classes"
jddarcy Sep 30, 2024
a6b3188
8337632: AES-GCM Algorithm optimization for x86_64
Sep 30, 2024
bfdeb33
8340332: Open source mixed AWT tests - Set3
Sep 30, 2024
31858fc
8340491: Thread stack-base assertion should report which thread has t…
Sep 30, 2024
a32c3b4
8340407: Open source a few more Component related tests
Sep 30, 2024
b11066b
8340719: Open source AWT List tests
prsadhuk Oct 1, 2024
988f13a
8340354: Open source AWT desktop properties and print related tests
Oct 1, 2024
9bd4785
8340437: Open source few more AWT Frame related tests
Oct 1, 2024
1b46fea
8341024: [test] build/AbsPathsInImage.java fails with OOM when using …
MBaesken Oct 1, 2024
ad5ffcc
8341168: Cleanup dead code after JDK-8322630
xmas92 Oct 1, 2024
2dc3b1a
8341201: Broken link in AbstractAnnotationValueVisitor7 due to extra …
nizarbenalla Oct 1, 2024
f7c7958
8340420: ZGC: Should call `vm_shutdown_during_initialization` if init…
xmas92 Oct 1, 2024
7cc7c08
8337493: [JVMCI] Number of libgraal threads might be too low
rmosaner Oct 1, 2024
684d246
8341242: Shenandoah: LRB node is not matched as GC barrier after JDK-…
shipilev Oct 1, 2024
2120a84
8341333: [JVMCI] Export JavaThread::_unlocked_inflated_monitor to JVMCI
Oct 1, 2024
7b1e6f8
8337389: Parallel: Remove unnecessary forward declarations in psScave…
jjacksonsnc Oct 1, 2024
f2a767f
8340907: Open source closed frame tests # 2
Oct 1, 2024
9a7817b
8340988: Update jdk/jfr/event/gc/collection tests to accept "CodeCach…
lmesnik Oct 1, 2024
021bf63
8340458: Open source additional Component tests (part 2)
Oct 1, 2024
0314973
8341060: Cleanup statics in HeapDumper
Oct 1, 2024
d2e7708
8341367: Problemlist ShapeNotSetSometimes.java on macOS
Oct 1, 2024
83dcb02
8340079: Modify rearrange/selectFrom Vector API methods to perform wr…
Oct 1, 2024
8d6d37f
8320308: C2 compilation crashes in LibraryCallKit::inline_unsafe_access
tobiasholenstein Oct 1, 2024
0f38113
8341243: Use ArraySupport.SOFT_MAX_ARRAY_LENGTH for max array size in…
Oct 2, 2024
39c17b3
8341277: Validate slot argument for instruction factories
liach Oct 2, 2024
90c944f
8340824: C2: Memory for TypeInterfaces not reclaimed by hashcons()
rwestrel Oct 2, 2024
52c2ea6
8340732: RISC-V: Refactor crc32 scalar version
Oct 2, 2024
efe3573
8340109: Ubsan: ciEnv.cpp:1660:65: runtime error: member call on null…
MBaesken Oct 2, 2024
c8c4ff2
8341135: Incorrect format string after JDK-8339475
MBaesken Oct 2, 2024
a4ca626
8341146: RISC-V: Unnecessary fences used for load-acquire in template…
feilongjiang Oct 2, 2024
d6820d1
8336274: MutableBigInteger.leftShift(int) optimization
fabioromano1 Oct 2, 2024
855c8a7
8334305: Remove all code for nsk.share.Log verbose mode
Oct 2, 2024
5e98007
8307532: Implement LM_LIGHTWEIGHT for Zero
rkennke Oct 2, 2024
8838048
8324259: Classes used by CDS at runtime should be archived
Oct 2, 2024
49501fe
8341412: Various test failures after JDK-8334305
Oct 2, 2024
85f0442
8317116: Provide layouts for multiple test UI in PassFailJFrame
aivanov-jdk Oct 2, 2024
5063494
8340785: Update description of PassFailJFrame and samples
aivanov-jdk Oct 2, 2024
9fc1c68
8339850: Restore the interrupt status in FileSystemPreferences.lockFi…
sbgoog Oct 2, 2024
0bdfe88
8328313: Archived module graph should allow identical --module-path t…
calvinccheung Oct 2, 2024
76283dd
8341246: Test com/sun/tools/attach/PermissionTest.java fails access d…
Oct 2, 2024
c43202b
8341037: Use standard layouts in DefaultFrameIconTest.java and MenuCr…
aivanov-jdk Oct 2, 2024
dc0ce1b
8341336: Fix -Wzero-as-null-pointer-constant warnings in PRODUCT-only…
Oct 2, 2024
57c1db5
8332697: ubsan: shenandoahSimpleBitMap.inline.hpp:68:23: runtime erro…
Oct 2, 2024
bdfb41f
8309841: Jarsigner should print a warning if an entry is removed
wangweij Oct 2, 2024
602408e
8341177: Opensource few List and a Window test
prsadhuk Oct 3, 2024
50ec169
8341191: Open source few more AWT FileDialog tests
Oct 3, 2024
ff3e849
8341239: Open source closed frame tests # 3
Oct 3, 2024
c6e7e55
8341091: CDS: Segmented roots array misses roots
shipilev Oct 3, 2024
0b467e9
8334060: Implementation of Late Barrier Expansion for G1
robcasloz Oct 3, 2024
19642bd
8341148: Open source several Choice related tests
Oct 3, 2024
5b3046c
Merge remote-tracking branch 'origin/rivos/main' into rivos/merge-jdk…
luhenry Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions make/hotspot/gensrc/GensrcAdlc.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ ifeq ($(call check-jvm-feature, compiler2), true)
)))
endif

ifeq ($(call check-jvm-feature, g1gc), true)
AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/g1/g1_$(HOTSPOT_TARGET_CPU).ad \
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/g1/g1_$(HOTSPOT_TARGET_CPU_ARCH).ad \
)))
endif

SINGLE_AD_SRCFILE := $(ADLC_SUPPORT_DIR)/all-ad-src.ad

INSERT_FILENAME_AWK_SCRIPT := \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -273,16 +273,16 @@ private void outputFile(Path dstFile, String version,
// link version-region-rules
out.writeShort(builtZones.size());
for (Map.Entry<String, ZoneRules> entry : builtZones.entrySet()) {
int regionIndex = Arrays.binarySearch(regionArray, entry.getKey());
int regionIndex = findRegionIndex(regionArray, entry.getKey());
int rulesIndex = rulesList.indexOf(entry.getValue());
out.writeShort(regionIndex);
out.writeShort(rulesIndex);
}
// alias-region
out.writeShort(links.size());
for (Map.Entry<String, String> entry : links.entrySet()) {
int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey());
int regionIndex = Arrays.binarySearch(regionArray, entry.getValue());
int aliasIndex = findRegionIndex(regionArray, entry.getKey());
int regionIndex = findRegionIndex(regionArray, entry.getValue());
out.writeShort(aliasIndex);
out.writeShort(regionIndex);
}
Expand All @@ -294,6 +294,14 @@ private void outputFile(Path dstFile, String version,
}
}

private static int findRegionIndex(String[] regionArray, String region) {
int index = Arrays.binarySearch(regionArray, region);
if (index < 0) {
throw new IllegalArgumentException("Unknown region: " + region);
}
return index;
}

/** Whether to output verbose messages. */
private boolean verbose;

Expand Down
24 changes: 16 additions & 8 deletions src/hotspot/cpu/aarch64/aarch64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -2620,7 +2620,8 @@ static bool is_vector_bitwise_not_pattern(Node* n, Node* m) {
bool Matcher::pd_clone_node(Node* n, Node* m, Matcher::MStack& mstack) {
if (is_vshift_con_pattern(n, m) ||
is_vector_bitwise_not_pattern(n, m) ||
is_valid_sve_arith_imm_pattern(n, m)) {
is_valid_sve_arith_imm_pattern(n, m) ||
is_encode_and_store_pattern(n, m)) {
mstack.push(m, Visit);
return true;
}
Expand Down Expand Up @@ -6410,7 +6411,7 @@ instruct loadP(iRegPNoSp dst, memory mem)
instruct loadN(iRegNNoSp dst, memory mem)
%{
match(Set dst (LoadN mem));
predicate(!needs_acquiring_load(n));
predicate(!needs_acquiring_load(n) && n->as_Load()->barrier_data() == 0);

ins_cost(4 * INSN_COST);
format %{ "ldrw $dst, $mem\t# compressed ptr" %}
Expand Down Expand Up @@ -6839,7 +6840,7 @@ instruct storeimmP0(immP0 zero, memory mem)
instruct storeN(iRegN src, memory mem)
%{
match(Set mem (StoreN mem src));
predicate(!needs_releasing_store(n));
predicate(!needs_releasing_store(n) && n->as_Store()->barrier_data() == 0);

ins_cost(INSN_COST);
format %{ "strw $src, $mem\t# compressed ptr" %}
Expand All @@ -6852,7 +6853,7 @@ instruct storeN(iRegN src, memory mem)
instruct storeImmN0(immN0 zero, memory mem)
%{
match(Set mem (StoreN mem zero));
predicate(!needs_releasing_store(n));
predicate(!needs_releasing_store(n) && n->as_Store()->barrier_data() == 0);

ins_cost(INSN_COST);
format %{ "strw zr, $mem\t# compressed ptr" %}
Expand Down Expand Up @@ -7086,6 +7087,7 @@ instruct loadP_volatile(iRegPNoSp dst, /* sync_memory*/indirect mem)
instruct loadN_volatile(iRegNNoSp dst, /* sync_memory*/indirect mem)
%{
match(Set dst (LoadN mem));
predicate(n->as_Load()->barrier_data() == 0);

ins_cost(VOLATILE_REF_COST);
format %{ "ldarw $dst, $mem\t# compressed ptr" %}
Expand Down Expand Up @@ -7253,6 +7255,7 @@ instruct storeimmP0_volatile(immP0 zero, /* sync_memory*/indirect mem)
instruct storeN_volatile(iRegN src, /* sync_memory*/indirect mem)
%{
match(Set mem (StoreN mem src));
predicate(n->as_Store()->barrier_data() == 0);

ins_cost(VOLATILE_REF_COST);
format %{ "stlrw $src, $mem\t# compressed ptr" %}
Expand All @@ -7265,6 +7268,7 @@ instruct storeN_volatile(iRegN src, /* sync_memory*/indirect mem)
instruct storeimmN0_volatile(immN0 zero, /* sync_memory*/indirect mem)
%{
match(Set mem (StoreN mem zero));
predicate(n->as_Store()->barrier_data() == 0);

ins_cost(VOLATILE_REF_COST);
format %{ "stlrw zr, $mem\t# compressed ptr" %}
Expand Down Expand Up @@ -8061,6 +8065,7 @@ instruct compareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval
instruct compareAndSwapN(iRegINoSp res, indirect mem, iRegNNoSp oldval, iRegNNoSp newval, rFlagsReg cr) %{

match(Set res (CompareAndSwapN mem (Binary oldval newval)));
predicate(n->as_LoadStore()->barrier_data() == 0);
ins_cost(2 * VOLATILE_REF_COST);

effect(KILL cr);
Expand Down Expand Up @@ -8175,7 +8180,7 @@ instruct compareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP new

instruct compareAndSwapNAcq(iRegINoSp res, indirect mem, iRegNNoSp oldval, iRegNNoSp newval, rFlagsReg cr) %{

predicate(needs_acquiring_load_exclusive(n));
predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0);
match(Set res (CompareAndSwapN mem (Binary oldval newval)));
ins_cost(VOLATILE_REF_COST);

Expand Down Expand Up @@ -8280,6 +8285,7 @@ instruct compareAndExchangeL(iRegLNoSp res, indirect mem, iRegL oldval, iRegL ne
// This pattern is generated automatically from cas.m4.
// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
instruct compareAndExchangeN(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, rFlagsReg cr) %{
predicate(n->as_LoadStore()->barrier_data() == 0);
match(Set res (CompareAndExchangeN mem (Binary oldval newval)));
ins_cost(2 * VOLATILE_REF_COST);
effect(TEMP_DEF res, KILL cr);
Expand Down Expand Up @@ -8389,7 +8395,7 @@ instruct compareAndExchangeLAcq(iRegLNoSp res, indirect mem, iRegL oldval, iRegL
// This pattern is generated automatically from cas.m4.
// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
instruct compareAndExchangeNAcq(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, rFlagsReg cr) %{
predicate(needs_acquiring_load_exclusive(n));
predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0);
match(Set res (CompareAndExchangeN mem (Binary oldval newval)));
ins_cost(VOLATILE_REF_COST);
effect(TEMP_DEF res, KILL cr);
Expand Down Expand Up @@ -8501,6 +8507,7 @@ instruct weakCompareAndSwapL(iRegINoSp res, indirect mem, iRegL oldval, iRegL ne
// This pattern is generated automatically from cas.m4.
// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
instruct weakCompareAndSwapN(iRegINoSp res, indirect mem, iRegN oldval, iRegN newval, rFlagsReg cr) %{
predicate(n->as_LoadStore()->barrier_data() == 0);
match(Set res (WeakCompareAndSwapN mem (Binary oldval newval)));
ins_cost(2 * VOLATILE_REF_COST);
effect(KILL cr);
Expand Down Expand Up @@ -8620,7 +8627,7 @@ instruct weakCompareAndSwapLAcq(iRegINoSp res, indirect mem, iRegL oldval, iRegL
// This pattern is generated automatically from cas.m4.
// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
instruct weakCompareAndSwapNAcq(iRegINoSp res, indirect mem, iRegN oldval, iRegN newval, rFlagsReg cr) %{
predicate(needs_acquiring_load_exclusive(n));
predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0);
match(Set res (WeakCompareAndSwapN mem (Binary oldval newval)));
ins_cost(VOLATILE_REF_COST);
effect(KILL cr);
Expand Down Expand Up @@ -8681,6 +8688,7 @@ instruct get_and_setL(indirect mem, iRegL newv, iRegLNoSp prev) %{
%}

instruct get_and_setN(indirect mem, iRegN newv, iRegINoSp prev) %{
predicate(n->as_LoadStore()->barrier_data() == 0);
match(Set prev (GetAndSetN mem newv));
ins_cost(2 * VOLATILE_REF_COST);
format %{ "atomic_xchgw $prev, $newv, [$mem]" %}
Expand Down Expand Up @@ -8724,7 +8732,7 @@ instruct get_and_setLAcq(indirect mem, iRegL newv, iRegLNoSp prev) %{
%}

instruct get_and_setNAcq(indirect mem, iRegN newv, iRegINoSp prev) %{
predicate(needs_acquiring_load_exclusive(n));
predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0);
match(Set prev (GetAndSetN mem newv));
ins_cost(VOLATILE_REF_COST);
format %{ "atomic_xchgw_acq $prev, $newv, [$mem]" %}
Expand Down
72 changes: 54 additions & 18 deletions src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Registe
Register oop = objectReg;
Register box = boxReg;
Register disp_hdr = tmpReg;
Register owner_addr = tmpReg;
Register tmp = tmp2Reg;
Label cont;
Label object_has_monitor;
Label count, no_count;
Label unlocked;

assert(LockingMode != LM_LIGHTWEIGHT, "lightweight locking should use fast_unlock_lightweight");
assert_different_registers(oop, box, tmp, disp_hdr);
Expand Down Expand Up @@ -204,14 +206,40 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Registe
b(cont);

bind(notRecursive);

// Compute owner address.
lea(owner_addr, Address(tmp, ObjectMonitor::owner_offset()));

// Set owner to null.
// Release to satisfy the JMM
stlr(zr, owner_addr);
// We need a full fence after clearing owner to avoid stranding.
// StoreLoad achieves this.
membar(StoreLoad);

// Check if the entry lists are empty.
ldr(rscratch1, Address(tmp, ObjectMonitor::EntryList_offset()));
ldr(disp_hdr, Address(tmp, ObjectMonitor::cxq_offset()));
orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if both are 0.
cmp(rscratch1, zr); // Sets flags for result
cbnz(rscratch1, cont);
// need a release store here
lea(tmp, Address(tmp, ObjectMonitor::owner_offset()));
stlr(zr, tmp); // set unowned
ldr(tmpReg, Address(tmp, ObjectMonitor::cxq_offset()));
orr(rscratch1, rscratch1, tmpReg);
cmp(rscratch1, zr);
br(Assembler::EQ, cont); // If so we are done.

// Check if there is a successor.
ldr(rscratch1, Address(tmp, ObjectMonitor::succ_offset()));
cmp(rscratch1, zr);
br(Assembler::NE, unlocked); // If so we are done.

// Save the monitor pointer in the current thread, so we can try to
// reacquire the lock in SharedRuntime::monitor_exit_helper().
str(tmp, Address(rthread, JavaThread::unlocked_inflated_monitor_offset()));

cmp(zr, rthread); // Set Flag to NE => slow path
b(cont);

bind(unlocked);
cmp(zr, zr); // Set Flag to EQ => fast path

// Intentional fall-through

bind(cont);
// flag == EQ indicates success
Expand Down Expand Up @@ -498,33 +526,41 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, Regi

bind(not_recursive);

Label release;
const Register t2_owner_addr = t2;

// Compute owner address.
lea(t2_owner_addr, Address(t1_monitor, ObjectMonitor::owner_offset()));

// Set owner to null.
// Release to satisfy the JMM
stlr(zr, t2_owner_addr);
// We need a full fence after clearing owner to avoid stranding.
// StoreLoad achieves this.
membar(StoreLoad);

// Check if the entry lists are empty.
ldr(rscratch1, Address(t1_monitor, ObjectMonitor::EntryList_offset()));
ldr(t3_t, Address(t1_monitor, ObjectMonitor::cxq_offset()));
orr(rscratch1, rscratch1, t3_t);
cmp(rscratch1, zr);
br(Assembler::EQ, release);
br(Assembler::EQ, unlocked); // If so we are done.

// The owner may be anonymous and we removed the last obj entry in
// the lock-stack. This loses the information about the owner.
// Write the thread to the owner field so the runtime knows the owner.
str(rthread, Address(t2_owner_addr));
b(slow_path);
// Check if there is a successor.
ldr(rscratch1, Address(t1_monitor, ObjectMonitor::succ_offset()));
cmp(rscratch1, zr);
br(Assembler::NE, unlocked); // If so we are done.

bind(release);
// Set owner to null.
// Release to satisfy the JMM
stlr(zr, t2_owner_addr);
// Save the monitor pointer in the current thread, so we can try to
// reacquire the lock in SharedRuntime::monitor_exit_helper().
str(t1_monitor, Address(rthread, JavaThread::unlocked_inflated_monitor_offset()));

cmp(zr, rthread); // Set Flag to NE => slow path
b(slow_path);
}

bind(unlocked);
decrement(Address(rthread, JavaThread::held_monitor_count_offset()));
cmp(zr, zr); // Set Flags to EQ => fast path

#ifdef ASSERT
// Check that unlocked label is reached with Flags == EQ.
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/aarch64/cas.m4
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ define(`CAS_INSN',
// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
instruct compareAndExchange$1$6(iReg$2NoSp res, indirect mem, iReg$2 oldval, iReg$2 newval, rFlagsReg cr) %{
ifelse($1$6,PAcq,INDENT(predicate(needs_acquiring_load_exclusive(n) && (n->as_LoadStore()->barrier_data() == 0));),
$1$6,NAcq,INDENT(predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0);),
$1,P,INDENT(predicate(n->as_LoadStore()->barrier_data() == 0);),
$1,N,INDENT(predicate(n->as_LoadStore()->barrier_data() == 0);),
$6,Acq,INDENT(predicate(needs_acquiring_load_exclusive(n));),
`dnl')
match(Set res (CompareAndExchange$1 mem (Binary oldval newval)));
Expand Down Expand Up @@ -122,7 +124,9 @@ define(`CAS_INSN3',
// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
instruct weakCompareAndSwap$1$6(iRegINoSp res, indirect mem, iReg$2 oldval, iReg$2 newval, rFlagsReg cr) %{
ifelse($1$6,PAcq,INDENT(predicate(needs_acquiring_load_exclusive(n) && (n->as_LoadStore()->barrier_data() == 0));),
$1$6,NAcq,INDENT(predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0);),
$1,P,INDENT(predicate(n->as_LoadStore()->barrier_data() == 0);),
$1,N,INDENT(predicate(n->as_LoadStore()->barrier_data() == 0);),
$6,Acq,INDENT(predicate(needs_acquiring_load_exclusive(n));),
`dnl')
match(Set res (WeakCompareAndSwap$1 mem (Binary oldval newval)));
Expand Down
Loading