Skip to content

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

Reviewed-by: mbaesken, mdoerr
  • Loading branch information
reinrich committed Jun 24, 2024
1 parent 863b2a9 commit 13dce29
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 @@ -3429,6 +3429,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

5 comments on commit 13dce29

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@reinrich
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk23u

@openjdk
Copy link

@openjdk openjdk bot commented on 13dce29 Oct 17, 2024

Choose a reason for hiding this comment

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

@reinrich the backport was successfully created on the branch backport-reinrich-13dce296-master in my personal fork of openjdk/jdk23u. To create a pull request with this backport targeting openjdk/jdk23u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 13dce296 from the openjdk/jdk repository.

The commit being backported was authored by Richard Reingruber on 24 Jun 2024 and was reviewed by Matthias Baesken and Martin Doerr.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk23u:

$ git fetch https://github.com/openjdk-bots/jdk23u.git backport-reinrich-13dce296-master:backport-reinrich-13dce296-master
$ git checkout backport-reinrich-13dce296-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk23u.git backport-reinrich-13dce296-master

⚠️ @reinrich You are not yet a collaborator in my fork openjdk-bots/jdk23u. An invite will be sent out and you need to accept it before you can proceed.

@reinrich
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 13dce29 Oct 24, 2024

Choose a reason for hiding this comment

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

@reinrich the backport was successfully created on the branch backport-reinrich-13dce296-master in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 13dce296 from the openjdk/jdk repository.

The commit being backported was authored by Richard Reingruber on 24 Jun 2024 and was reviewed by Matthias Baesken and Martin Doerr.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-reinrich-13dce296-master:backport-reinrich-13dce296-master
$ git checkout backport-reinrich-13dce296-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-reinrich-13dce296-master

Please sign in to comment.