Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
/ jdk23u Public archive

Commit

Permalink
8334560: [PPC64]: postalloc_expand_java_dynamic_call_sched does not c…
Browse files Browse the repository at this point in the history
…opy all fields

Backport-of: 13dce29
  • Loading branch information
reinrich committed Oct 24, 2024
1 parent eacb0fb commit 26e077b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hotspot/cpu/ppc/ppc.ad
Original file line number Diff line number Diff line change
Expand Up @@ -3427,6 +3427,7 @@ encode %{
call->_oop_map = _oop_map;
call->_jvms = _jvms;
call->_jvmadj = _jvmadj;
call->_has_ea_local_in_scope = _has_ea_local_in_scope;
call->_in_rms = _in_rms;
call->_nesting = _nesting;
call->_override_symbolic_info = _override_symbolic_info;
Expand Down
91 changes: 91 additions & 0 deletions test/jdk/com/sun/jdi/EATests.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public static void main(String[] args) {
// Relocking test cases
new EARelockingSimpleTarget() .run();
new EARelockingSimpleWithAccessInOtherThreadTarget() .run();
new EARelockingSimpleWithAccessInOtherThread_02_DynamicCall_Target() .run();
new EARelockingRecursiveTarget() .run();
new EARelockingNestedInflatedTarget() .run();
new EARelockingNestedInflated_02Target() .run();
Expand Down Expand Up @@ -413,6 +414,7 @@ protected void runTests() throws Exception {
// Relocking test cases
new EARelockingSimple() .run(this);
new EARelockingSimpleWithAccessInOtherThread() .run(this);
new EARelockingSimpleWithAccessInOtherThread_02_DynamicCall() .run(this);
new EARelockingRecursive() .run(this);
new EARelockingNestedInflated() .run(this);
new EARelockingNestedInflated_02() .run(this);
Expand Down Expand Up @@ -1851,6 +1853,95 @@ public int getExpectedIResult() {

/////////////////////////////////////////////////////////////////////////////

// The debugger reads and publishes an object with eliminated locking to an instance field.
// A 2nd thread in the debuggee finds it there and changes its state using a synchronized method.
// Without eager relocking the accesses are unsynchronized which can be observed.
// This is a variant of EARelockingSimpleWithAccessInOtherThread with a dynamic call (not devirtualized).
class EARelockingSimpleWithAccessInOtherThread_02_DynamicCall extends EATestCaseBaseDebugger {

public void runTestCase() throws Exception {
BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
printStack(bpe.thread());
String l1ClassName = EARelockingSimpleWithAccessInOtherThread_02_DynamicCall_Target.SyncCounter.class.getName();
ObjectReference ctr = getLocalRef(bpe.thread().frame(2), l1ClassName, "l1");
setField(testCase, "sharedCounter", ctr);
terminateEndlessLoop();
}
}

class EARelockingSimpleWithAccessInOtherThread_02_DynamicCall_Target extends EATestCaseBaseTarget {

public static final BrkPtDispatchA[] disp =
{new BrkPtDispatchA(), new BrkPtDispatchB(), new BrkPtDispatchC(), new BrkPtDispatchD()};

public static class BrkPtDispatchA {
public EATestCaseBaseTarget testCase;
public void dontinline_brkpt() { testCase.dontinline_brkpt(); }
}

public static class BrkPtDispatchB extends BrkPtDispatchA {
@Override
public void dontinline_brkpt() { testCase.dontinline_brkpt(); }
}

public static class BrkPtDispatchC extends BrkPtDispatchA {
@Override
public void dontinline_brkpt() { testCase.dontinline_brkpt(); }
}

public static class BrkPtDispatchD extends BrkPtDispatchA {
@Override
public void dontinline_brkpt() {
testCase.dontinline_brkpt();
}
}

public static class SyncCounter {
private int val;
public synchronized int inc() { return val++; }
}

public volatile SyncCounter sharedCounter;

@Override
public void setUp() {
super.setUp();
testMethodDepth = 2;
for (BrkPtDispatchA d : disp) {
d.testCase = this;
}
doLoop = true;
new Thread(() -> {
while (doLoop) {
SyncCounter ctr = sharedCounter;
if (ctr != null) {
ctr.inc();
}
}
}).start();
}

public int dispCount;
public void dontinline_testMethod() {
SyncCounter l1 = new SyncCounter();
synchronized (l1) { // Eliminated locking
l1.inc();
// Use different types for the subsequent call to prevent devirtualization.
BrkPtDispatchA d = disp[(dispCount++) & 3];
d.dontinline_brkpt(); // Dynamic call. Debugger publishes l1 to sharedCounter.
iResult = l1.inc(); // Changes by the 2nd thread will be observed if l1
// was not relocked before passing it to the debugger.
}
}

@Override
public int getExpectedIResult() {
return 1;
}
}

/////////////////////////////////////////////////////////////////////////////

// Test recursive locking
class EARelockingRecursiveTarget extends EATestCaseBaseTarget {

Expand Down

1 comment on commit 26e077b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.