From 89b3c375ac55f960dbeac8a2355e528450e610a1 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Thu, 25 May 2023 16:26:26 +0000 Subject: [PATCH] 8307125: compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java hits assert(!Continuation::is_frame_in_continuation(thread(), fr())) failed: No support for deferred values in continuations Reviewed-by: never --- .../jdk/vm/ci/code/stack/InspectedFrame.java | 4 +++ .../vm/ci/code/stack/StackIntrospection.java | 8 ++++++ .../hotspot/HotSpotStackFrameReference.java | 3 +++ .../ci/hotspot/HotSpotStackIntrospection.java | 6 +++++ test/hotspot/jtreg/ProblemList-Virtual.txt | 1 - .../jdk/vm/ci/hotspot/CompilerToVMHelper.java | 5 ---- .../MaterializeVirtualObjectTest.java | 25 ++++++++++++++++--- 7 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrame.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrame.java index eeb8ffb8400..f307b24eead 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrame.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrame.java @@ -51,6 +51,10 @@ public interface InspectedFrame { /** * This method will materialize all virtual objects, deoptimize the stack frame and make sure * that subsequent execution of the deoptimized frame uses the materialized values. + * + * @see StackIntrospection#canMaterializeVirtualObjects + * @throws IllegalArgumentException if stack introspection does not support + * materialization of virtual objects for this frame */ void materializeVirtualObjects(boolean invalidateCode); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/StackIntrospection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/StackIntrospection.java index b8d2efd5bf2..bdc0a1c3f62 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/StackIntrospection.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/StackIntrospection.java @@ -43,4 +43,12 @@ public interface StackIntrospection { * should stop), or null if the whole stack was iterated. */ T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor visitor); + + /** + * Determines if {@link InspectedFrame#materializeVirtualObjects(boolean)} can be called for frames + * visited by {@link #iterateFrames}. + */ + default boolean canMaterializeVirtualObjects() { + return true; + } } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java index 07933f3a64e..db91175fc8d 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java @@ -63,6 +63,9 @@ public class HotSpotStackFrameReference implements InspectedFrame { @Override public void materializeVirtualObjects(boolean invalidateCode) { + if (Thread.currentThread().isVirtual()) { + throw new IllegalArgumentException("cannot materialize frames of a virtual thread"); + } compilerToVM.materializeVirtualObjects(this, invalidateCode); } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java index d7241cfa2f3..0b18bcbea5f 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java @@ -39,4 +39,10 @@ public class HotSpotStackIntrospection implements StackIntrospection { CompilerToVM compilerToVM = runtime.getCompilerToVM(); return compilerToVM.iterateFrames(initialMethods, matchingMethods, initialSkip, visitor); } + + @Override + public boolean canMaterializeVirtualObjects() { + // Virtual threads do not support materializing locals (JDK-8307125) + return !Thread.currentThread().isVirtual(); + } } diff --git a/test/hotspot/jtreg/ProblemList-Virtual.txt b/test/hotspot/jtreg/ProblemList-Virtual.txt index 1ddeb75ef35..d9fb18ae319 100644 --- a/test/hotspot/jtreg/ProblemList-Virtual.txt +++ b/test/hotspot/jtreg/ProblemList-Virtual.txt @@ -24,7 +24,6 @@ #### # Bugs -compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java 8307125 generic-all serviceability/AsyncGetCallTrace/MyPackage/ASGCTBaseTest.java 8308026 generic-all serviceability/jvmti/GetThreadListStackTraces/OneGetThreadListStackTraces.java 8308027 generic-all serviceability/jvmti/Heap/IterateHeapWithEscapeAnalysisEnabled.java 8264699 generic-all diff --git a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java b/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java index e66f4d1f2e4..452a92a4909 100644 --- a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java +++ b/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java @@ -277,11 +277,6 @@ public class CompilerToVMHelper { return CTVM.iterateFrames(initialMethods, matchingMethods, initialSkip, visitor); } - public static void materializeVirtualObjects( - HotSpotStackFrameReference stackFrame, boolean invalidate) { - CTVM.materializeVirtualObjects(stackFrame, invalidate); - } - public static int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectType type, HotSpotResolvedJavaMethod method) { return CTVM.getVtableIndexForInterfaceMethod((HotSpotResolvedObjectTypeImpl) type, (HotSpotResolvedJavaMethodImpl) method); diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java index 047f2877534..443dc9187d8 100644 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java @@ -157,7 +157,11 @@ public class MaterializeVirtualObjectTest { throw new SkippedException("Test needs compilation level 4"); } - new MaterializeVirtualObjectTest().test(); + try { + new MaterializeVirtualObjectTest().test(); + } catch (MaterializationNotSupported e) { + Asserts.assertTrue(Thread.currentThread().isVirtual()); + } } private static String getName() { @@ -168,7 +172,6 @@ public class MaterializeVirtualObjectTest { } private void test() { - System.out.println(getName()); Asserts.assertFalse(WB.isMethodCompiled(MATERIALIZED_METHOD), getName() + " : materialized method is compiled"); Asserts.assertFalse(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), @@ -230,6 +233,14 @@ public class MaterializeVirtualObjectTest { } } + private static void materializeVirtualObjects(InspectedFrame f, boolean invalidateCode) { + try { + f.materializeVirtualObjects(invalidateCode); + } catch (IllegalArgumentException e) { + throw new MaterializationNotSupported(e); + } + } + private void checkStructure(boolean materialize) { boolean[] framesSeen = new boolean[2]; Object[] helpers = new Object[1]; @@ -248,7 +259,7 @@ public class MaterializeVirtualObjectTest { Asserts.assertEQ(((Helper) f.getLocal(3)).string, "foo", "innerHelper.string should be foo"); helpers[0] = f.getLocal(1); if (materialize) { - f.materializeVirtualObjects(false); + materializeVirtualObjects(f, false); } return null; //continue } else { @@ -306,7 +317,7 @@ public class MaterializeVirtualObjectTest { Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName() + ": notMaterialized frame has no virtual object before materialization"); // materialize - CompilerToVMHelper.materializeVirtualObjects(materialized, INVALIDATE); + materializeVirtualObjects(materialized, INVALIDATE); // check that only not materialized frame has virtual objects Asserts.assertFalse(materialized.hasVirtualObjects(), getName() + " : materialized has virtual object after materialization"); @@ -331,4 +342,10 @@ public class MaterializeVirtualObjectTest { this.string = s; } } + + static class MaterializationNotSupported extends RuntimeException { + public MaterializationNotSupported(Throwable cause) { + super(cause); + } + } }