< prev index next >

src/share/vm/opto/valuetypenode.cpp

Print this page

        

@@ -58,11 +58,11 @@
   // values from a heap-allocated version and also save the oop.
   const TypeValueType* type = gvn.type(oop)->is_valuetypeptr()->value_type();
   ValueTypeNode* vt = new ValueTypeNode(type, oop);
   vt->load(gvn, mem, oop, oop, type->value_klass());
   assert(vt->is_allocated(&gvn), "value type should be allocated");
-  assert(oop->is_Con() || oop->is_CheckCastPP() || vt->is_loaded(&gvn, type) != NULL, "value type should be loaded");
+  assert(oop->is_Con() || oop->is_CheckCastPP() || vt->is_loaded(&gvn, type) == oop, "value type should be loaded");
   return gvn.transform(vt);
 }
 
 Node* ValueTypeNode::make(PhaseGVN& gvn, ciValueKlass* vk, Node* mem, Node* obj, Node* ptr, ciInstanceKlass* holder, int holder_offset) {
   // Create and initialize a ValueTypeNode by loading all field values from

@@ -70,13 +70,12 @@
   ValueTypeNode* vt = make(gvn, vk);
   // The value type is flattened into the object without an oop header. Subtract the
   // offset of the first field to account for the missing header when loading the values.
   holder_offset -= vk->first_field_offset();
   vt->load(gvn, mem, obj, ptr, holder, holder_offset);
-  vt = gvn.transform(vt)->as_ValueType();
-  assert(!vt->is_allocated(&gvn), "value type should not be allocated");
-  return vt;
+  assert(vt->is_loaded(&gvn, vt->type()->isa_valuetype()) != obj, "holder oop should not be used as flattened value type oop");
+  return gvn.transform(vt)->as_ValueType();
 }
 
 void ValueTypeNode::load(PhaseGVN& gvn, Node* mem, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset) {
   // Initialize the value type by loading its field values from
   // memory and adding the values as input edges to the node.

@@ -121,10 +120,15 @@
     set_field_value(i, gvn.transform(value));
   }
 }
 
 Node* ValueTypeNode::is_loaded(PhaseGVN* phase, const TypeValueType* t, Node* base, int holder_offset) {
+  if (field_count() == 0) {
+    assert(t->value_klass() == phase->C->env()->___Value_klass(), "unexpected value type klass");
+    assert(is_allocated(phase), "must be allocated");
+    return get_oop();
+  }
   for (uint i = 0; i < field_count(); ++i) {
     int offset = holder_offset + field_offset(i);
     Node* value = field_value(i);
     if (value->isa_DecodeN()) {
       // Skip DecodeN

@@ -464,10 +468,11 @@
     Node* base = is_loaded(phase, type()->is_valuetype());
     if (base != NULL) {
       // Save the oop
       set_oop(base);
       assert(is_allocated(phase), "should now be allocated");
+      return this;
     }
   }
 
   if (can_reshape) {
     PhaseIterGVN* igvn = phase->is_IterGVN();
< prev index next >