From 99a2cb069e37e063000eb8e88b9cd9aafda5d0a4 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Tue, 13 Aug 2024 16:34:45 +0200 Subject: [PATCH] 8336837: [lworld] Invalid monitor information in JVMState when buffering at return --- src/hotspot/share/opto/parse1.cpp | 20 +++++++++---------- .../valhalla/inlinetypes/TestLWorld.java | 12 +++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/hotspot/share/opto/parse1.cpp b/src/hotspot/share/opto/parse1.cpp index 6bd6e64a777..6e06c107a13 100644 --- a/src/hotspot/share/opto/parse1.cpp +++ b/src/hotspot/share/opto/parse1.cpp @@ -2399,17 +2399,6 @@ void Parse::return_current(Node* value) { call_register_finalizer(); } - // Do not set_parse_bci, so that return goo is credited to the return insn. - // vreturn can trigger an allocation so vreturn can throw. Setting - // the bci here breaks exception handling. Commenting this out - // doesn't seem to break anything. - // set_bci(InvocationEntryBci); - if (method()->is_synchronized() && GenerateSynchronizationCode) { - shared_unlock(_synch_lock->box_node(), _synch_lock->obj_node()); - } - if (C->env()->dtrace_method_probes()) { - make_dtrace_method_exit(method()); - } // frame pointer is always same, already captured if (value != nullptr) { Node* phi = _exits.argument(0); @@ -2445,6 +2434,15 @@ void Parse::return_current(Node* value) { phi->add_req(value); } + // Do not set_parse_bci, so that return goo is credited to the return insn. + set_bci(InvocationEntryBci); + if (method()->is_synchronized() && GenerateSynchronizationCode) { + shared_unlock(_synch_lock->box_node(), _synch_lock->obj_node()); + } + if (C->env()->dtrace_method_probes()) { + make_dtrace_method_exit(method()); + } + SafePointNode* exit_return = _exits.map(); exit_return->in( TypeFunc::Control )->add_req( control() ); exit_return->in( TypeFunc::I_O )->add_req( i_o () ); diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java index 0c597ca812c..d2943cf426a 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java @@ -4400,6 +4400,7 @@ static value class MyValue161 { int x = 0; } + // Test merging value classes with Object fields @Test public MyValueContainer test161(boolean b) { MyValueContainer res = b ? new MyValueContainer(new MyValue161()) : null; @@ -4483,4 +4484,15 @@ public void test166_verifier() { Asserts.assertEquals(test166(true), new MyValueContainer(42)); Asserts.assertEquals(test166(false), new MyValueContainer(new MyValue161())); } + + // Verify that monitor information in JVMState is correct at method exit + @Test + public synchronized Object test167() { + return MyValue1.createWithFieldsInline(rI, rL); // Might trigger buffering which requires JVMState + } + + @Run(test = "test167") + public void test167_verifier() { + Asserts.assertEquals(((MyValue1)test167()).hash(), hash()); + } }