changeset 5730:c6b5db6389c9

8025644: java/util/stream/test/org/openjdk/tests/java/util/stream/ToArrayOpTest.java fails with TestData): failure java.lang.AssertionError: expected [true] but found [false] Summary: In GraphKit::gen_checkcast() provide only exact superklass to GraphKit::maybe_cast_profiled_receiver() Reviewed-by: iveresov
author sgabdura
date Fri, 05 Sep 2014 10:19:30 +0200
parents 6547c22e85df
children 5fd0a42e71aa
files src/share/vm/opto/graphKit.cpp
diffstat 1 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/graphKit.cpp	Thu Sep 04 09:04:21 2014 +0200
+++ b/src/share/vm/opto/graphKit.cpp	Fri Sep 05 10:19:30 2014 +0200
@@ -2746,17 +2746,23 @@
   }
 
   Node* cast_obj = NULL;
-  if (data != NULL &&
-      // Counter has never been decremented (due to cast failure).
-      // ...This is a reasonable thing to expect.  It is true of
-      // all casts inserted by javac to implement generic types.
-      data->as_CounterData()->count() >= 0) {
-    cast_obj = maybe_cast_profiled_receiver(not_null_obj, data, tk->klass());
-    if (cast_obj != NULL) {
-      if (failure_control != NULL) // failure is now impossible
-        (*failure_control) = top();
-      // adjust the type of the phi to the exact klass:
-      phi->raise_bottom_type(_gvn.type(cast_obj)->meet(TypePtr::NULL_PTR));
+  if (tk->klass_is_exact()) {
+    // The following optimization tries to statically cast the speculative type of the object
+    // (for example obtained during profiling) to the type of the superklass and then do a
+    // dynamic check that the type of the object is what we expect. To work correctly
+    // for checkcast and aastore the type of superklass should be exact.
+    if (data != NULL &&
+        // Counter has never been decremented (due to cast failure).
+        // ...This is a reasonable thing to expect.  It is true of
+        // all casts inserted by javac to implement generic types.
+        data->as_CounterData()->count() >= 0) {
+      cast_obj = maybe_cast_profiled_receiver(not_null_obj, data, tk->klass());
+      if (cast_obj != NULL) {
+        if (failure_control != NULL) // failure is now impossible
+          (*failure_control) = top();
+        // adjust the type of the phi to the exact klass:
+        phi->raise_bottom_type(_gvn.type(cast_obj)->meet(TypePtr::NULL_PTR));
+      }
     }
   }