changeset 55904:79ba063a282e lworld

8225374: [lworld][c1] TestMethodHandles.java fails with -XX:+StressValueTypeReturnedAsFields Reviewed-by: thartmann
author iklam
date Sun, 16 Jun 2019 21:24:15 -0700
parents 1f5a0a9b8eb6
children 2315f0cda727
files src/hotspot/share/c1/c1_LIRAssembler.cpp test/hotspot/jtreg/compiler/valhalla/valuetypes/TestMethodHandles.java
diffstat 2 files changed, 20 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/c1/c1_LIRAssembler.cpp	Fri Jun 14 09:59:41 2019 +0200
+++ b/src/hotspot/share/c1/c1_LIRAssembler.cpp	Sun Jun 16 21:24:15 2019 -0700
@@ -482,13 +482,26 @@
     compilation()->set_has_method_handle_invokes(true);
   }
 
-  ciMethod* method = op->method();
-  if (ValueTypeReturnedAsFields && method->signature()->returns_never_null()) {
-    ciType* return_type = method->return_type();
-    if (return_type->is_valuetype()) {
-      ciValueKlass* vk = return_type->as_value_klass();
-      if (vk->can_be_returned_as_fields()) {
-        store_value_type_fields_to_buf(vk);
+  if (ValueTypeReturnedAsFields) {
+    ciMethod* method = op->method();
+    if (method->signature()->returns_never_null()) {
+      ciType* return_type = method->return_type();
+      if (return_type->is_valuetype()) {
+        ciValueKlass* vk = return_type->as_value_klass();
+        if (vk->can_be_returned_as_fields()) {
+          store_value_type_fields_to_buf(vk);
+        }
+      }
+    } else if (op->is_method_handle_invoke()) {
+      BasicType bt = method->return_type()->basic_type();
+      if (bt == T_OBJECT || bt == T_VALUETYPE) {
+        // A value type might be returned from the call but we don't know its
+        // type. Either we get a buffered value (and nothing needs to be done)
+        // or one of the values being returned is the klass of the value type
+        // (RAX on x64, with LSB set to 1) and we need to allocate a value
+        // type instance of that type and initialize it with other values being
+        // returned (in other registers).
+        store_value_type_fields_to_buf(NULL);
       }
     }
   }
--- a/test/hotspot/jtreg/compiler/valhalla/valuetypes/TestMethodHandles.java	Fri Jun 14 09:59:41 2019 +0200
+++ b/test/hotspot/jtreg/compiler/valhalla/valuetypes/TestMethodHandles.java	Sun Jun 16 21:24:15 2019 -0700
@@ -344,7 +344,6 @@
     static MethodHandle test8_mh2;
 
     @Test
-    @TempSkipForC1(reason = "JDK-8225374: C1 fails with -XX:+StressValueTypeReturnedAsFields")
     public long test8() throws Throwable {
         return ((MyValue2)test8_mh.invokeExact(test8_mh2)).hash();
     }
@@ -439,7 +438,6 @@
     static MethodHandle test10_mh3;
 
     @Test
-    @TempSkipForC1(reason = "JDK-8225374: C1 fails with -XX:+StressValueTypeReturnedAsFields")
     public long test10() throws Throwable {
         return ((MyValue2)test10_mh.invokeExact(test10_mh2, test10_mh3)).hash();
     }
@@ -481,7 +479,6 @@
     // is properly handled by the caller.
     @Test
     @Warmup(11000)
-    @TempSkipForC1(reason = "JDK-8225374: C1 fails with -XX:+StressValueTypeReturnedAsFields")
     public long test11() throws Throwable {
         return ((MyValue2)test11_mh.invokeExact(test11_mh2)).hash();
     }