< prev index next >

src/share/vm/opto/memnode.cpp

Print this page

        

@@ -40,10 +40,11 @@
 #include "opto/memnode.hpp"
 #include "opto/mulnode.hpp"
 #include "opto/narrowptrnode.hpp"
 #include "opto/phaseX.hpp"
 #include "opto/regmask.hpp"
+#include "opto/valuetypenode.hpp"
 #include "utilities/copy.hpp"
 
 // Portions of code courtesy of Clifford Click
 
 // Optimization - Graph Style

@@ -1090,10 +1091,24 @@
 }
 
 //------------------------------Identity---------------------------------------
 // Loads are identity if previous store is to same address
 Node* LoadNode::Identity(PhaseGVN* phase) {
+  // Loading from a ValueTypePtr? The ValueTypePtr has the values of
+  // all fields as input. Look for the field with matching offset.
+  Node* addr = in(Address);
+  intptr_t offset;
+  Node* base = AddPNode::Ideal_base_and_offset(addr, phase, offset);
+  if (base != NULL && base->is_ValueTypePtr()) {
+    Node* value = base->as_ValueTypePtr()->field_value_by_offset((int)offset, true);
+    if (bottom_type()->isa_narrowoop()) {
+      assert(!phase->type(value)->isa_narrowoop(), "should already be decoded");
+      value = phase->transform(new EncodePNode(value, bottom_type()));
+    }
+    return value;
+  }
+
   // If the previous store-maker is the right kind of Store, and the store is
   // to the same address, then we are equal to the value stored.
   Node* mem = in(Memory);
   Node* value = can_see_stored_value(mem, phase);
   if( value ) {
< prev index next >