changeset 51276:0ab71209f7f1 lworld

8207844: [lworld] Crash during method resolution because value type holder is not linked Reviewed-by: roland
author thartmann
date Thu, 19 Jul 2018 16:27:57 +0200
parents 9f1c2791c71f
children 129128ab7c0f
files src/hotspot/share/opto/parseHelper.cpp test/hotspot/jtreg/compiler/valhalla/valuetypes/TestLWorld.java
diffstat 2 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/opto/parseHelper.cpp	Thu Jul 19 16:26:35 2018 +0200
+++ b/src/hotspot/share/opto/parseHelper.cpp	Thu Jul 19 16:27:57 2018 +0200
@@ -349,6 +349,17 @@
   bool will_link;
   ciValueKlass* vk = iter().get_klass(will_link)->as_value_klass();
   assert(will_link, "defaultvalue: typeflow responsibility");
+
+  // Should initialize, or throw an InstantiationError?
+  if (!vk->is_initialized() && !vk->is_being_initialized()) {
+    uncommon_trap(Deoptimization::Reason_uninitialized,
+                  Deoptimization::Action_reinterpret,
+                  vk);
+    return;
+  } else if (vk->is_being_initialized()) {
+    emit_guard_for_new(vk);
+  }
+
   // Create and push a new default ValueTypeNode
   push(ValueTypeNode::make_default(_gvn, vk));
 }
--- a/test/hotspot/jtreg/compiler/valhalla/valuetypes/TestLWorld.java	Thu Jul 19 16:26:35 2018 +0200
+++ b/test/hotspot/jtreg/compiler/valhalla/valuetypes/TestLWorld.java	Thu Jul 19 16:27:57 2018 +0200
@@ -2221,4 +2221,28 @@
         MyValue1 vt = test85();
         Asserts.assertEquals(vt.hash(), hash());
     }
+
+    // Test calling a method on an uninitialized value type
+    __ByValue final class Test86Value {
+        final int x = 42;
+        public int get() {
+            return x;
+        }
+    }
+
+    // Make sure Test86Value is loaded but not initialized
+    public void unused(Test86Value vt) { }
+
+    @Test
+    @Warmup(0)
+    public int test86() {
+        Test86Value vt = __MakeDefault Test86Value();
+        return vt.get();
+    }
+
+    @DontCompile
+    public void test86_verifier(boolean warmup) {
+        int result = test86();
+        Asserts.assertEquals(result, 0);
+    }
 }