< prev index next >

src/hotspot/share/opto/parse3.cpp

Print this page

        

@@ -84,16 +84,15 @@
   ciField* field = iter().get_field(will_link);
   assert(will_link, "getfield: typeflow responsibility");
 
   ciInstanceKlass* field_holder = field->holder();
 
-  if (is_field && field_holder->is_valuetype()) {
+  if (is_field && field_holder->is_valuetype() && peek()->is_ValueType()) {
     assert(is_get, "value type field store not supported");
-    BasicType bt = field->layout_type();
     ValueTypeNode* vt = pop()->as_ValueType();
     Node* value = vt->field_value_by_offset(field->offset());
-    push_node(bt, value);
+    push_node(field->layout_type(), value);
     return;
   }
 
   if (is_field == field->is_static()) {
     // Interpreter will throw java_lang_IncompatibleClassChangeError

@@ -231,11 +230,15 @@
     DecoratorSet decorators = IN_HEAP;
     decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
     ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
     if (bt == T_VALUETYPE) {
       // Load a non-flattened value type from memory
+      if (field_klass->as_value_klass()->is_scalarizable()) {
       ld = ValueTypeNode::make_from_oop(this, ld, field_klass->as_value_klass(), /* buffer_check */ false, /* null2default */ flattenable, iter().next_bci());
+      } else if (gvn().type(ld)->maybe_null()){
+        ld = filter_null(ld, flattenable, field_klass->as_value_klass(), iter().next_bci());
+      }
     }
   }
 
   // Adjust Java stack
   if (type2size[bt] == 1)

@@ -291,18 +294,22 @@
       field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
     } else {
       field_type = Type::BOTTOM;
     }
   }
-  if (field->is_flattenable() && !val->is_ValueType()) {
+  if (field->is_flattenable() && !val->is_ValueType() && gvn().type(val)->maybe_null()) {
     // We can see a null constant here
     assert(val->bottom_type()->remove_speculative() == TypePtr::NULL_PTR, "Anything other than null?");
     push(null());
     uncommon_trap(Deoptimization::Reason_null_check, Deoptimization::Action_none);
     assert(stopped(), "dead path");
     return;
   } else if (field->is_flattened()) {
+    if (!val->is_ValueType()) {
+      assert(!gvn().type(val)->maybe_null(), "should never be null");
+      val = ValueTypeNode::make_from_oop(this, val, field->type()->as_value_klass());
+    }
     // Store flattened value type to a non-static field
     assert(bt == T_VALUETYPE, "flattening is only supported for value type fields");
     val->as_ValueType()->store_flattened(this, obj, obj, field->holder(), offset);
   } else {
     access_store_at(control(), obj, adr, adr_type, val, field_type, bt, decorators);
< prev index next >