changeset 11695:4be0cada20ad

8160360: Mismatched field loads are folded in LoadNode::Value Reviewed-by: kvn, thartmann
author vlivanov
date Wed, 06 Jul 2016 15:05:28 +0300
parents 20d1eb098cd0
children 2d20a13591ec
files src/share/vm/opto/library_call.cpp src/share/vm/opto/memnode.cpp src/share/vm/opto/type.hpp
diffstat 3 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/library_call.cpp	Tue Jul 05 17:57:20 2016 -0700
+++ b/src/share/vm/opto/library_call.cpp	Wed Jul 06 15:05:28 2016 +0300
@@ -2337,6 +2337,8 @@
       return false;
     }
     mismatched = (bt != type);
+  } else if (alias_type->adr_type() == TypeOopPtr::BOTTOM) {
+    mismatched = true; // conservatively mark all "wide" on-heap accesses as mismatched
   }
 
   // First guess at the value type.
--- a/src/share/vm/opto/memnode.cpp	Tue Jul 05 17:57:20 2016 -0700
+++ b/src/share/vm/opto/memnode.cpp	Wed Jul 06 15:05:28 2016 +0300
@@ -1713,9 +1713,6 @@
       }
     }
   } else if (tp->base() == Type::InstPtr) {
-    ciEnv* env = C->env();
-    const TypeInstPtr* tinst = tp->is_instptr();
-    ciKlass* klass = tinst->klass();
     assert( off != Type::OffsetBot ||
             // arrays can be cast to Objects
             tp->is_oopptr()->klass()->is_java_lang_Object() ||
@@ -1723,9 +1720,11 @@
             C->has_unsafe_access(),
             "Field accesses must be precise" );
     // For oop loads, we expect the _type to be precise.
-    // Optimizations for constant objects
+
+    // Optimize loads from constant fields.
+    const TypeInstPtr* tinst = tp->is_instptr();
     ciObject* const_oop = tinst->const_oop();
-    if (const_oop != NULL && const_oop->is_instance()) {
+    if (!is_mismatched_access() && off != Type::OffsetBot && const_oop != NULL && const_oop->is_instance()) {
       const Type* con_type = Type::make_constant_from_field(const_oop->as_instance(), off, is_unsigned(), memory_type());
       if (con_type != NULL) {
         return con_type;
--- a/src/share/vm/opto/type.hpp	Tue Jul 05 17:57:20 2016 -0700
+++ b/src/share/vm/opto/type.hpp	Wed Jul 06 15:05:28 2016 +0300
@@ -936,7 +936,7 @@
 };
 
 //------------------------------TypeOopPtr-------------------------------------
-// Some kind of oop (Java pointer), either klass or instance or array.
+// Some kind of oop (Java pointer), either instance or array.
 class TypeOopPtr : public TypePtr {
 protected:
   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,