--- old/src/share/vm/opto/parse3.cpp 2017-06-22 15:11:25.866014897 +0200 +++ new/src/share/vm/opto/parse3.cpp 2017-06-22 15:11:25.782014894 +0200 @@ -177,6 +177,8 @@ ciType* field_klass = field->type(); bool is_vol = field->is_volatile(); + // TODO change this when we support non-flattened value type fields that are non-static + bool flattened = (bt == T_VALUETYPE) && !field->is_static(); // Compute address and memory type. int offset = field->offset_in_bytes(); @@ -204,6 +206,21 @@ assert(type != NULL, "field singleton type must be consistent"); } else { type = TypeOopPtr::make_from_klass(field_klass->as_klass()); + if (bt == T_VALUETYPE && !flattened) { + // A non-flattened value type field may be NULL + bool maybe_null = true; + if (field->is_static()) { + // Check if static field is already initialized + ciInstance* mirror = field->holder()->java_mirror(); + ciObject* val = mirror->field_value(field).as_object(); + if (!val->is_null_object()) { + maybe_null = false; + } + } + if (maybe_null) { + type = type->is_valuetypeptr()->cast_to_ptr_type(TypePtr::BotPTR); + } + } } } else { type = Type::get_const_basic_type(bt); @@ -217,8 +234,8 @@ MemNode::MemOrd mo = is_vol ? MemNode::acquire : MemNode::unordered; bool needs_atomic_access = is_vol || AlwaysAtomicAccesses; Node* ld = NULL; - if (bt == T_VALUETYPE && !field->is_static()) { - // Load flattened value type from non-static field + if (flattened) { + // Load flattened value type ld = ValueTypeNode::make(_gvn, field_klass->as_value_klass(), map()->memory(), obj, obj, field->holder(), offset); } else { ld = make_load(NULL, adr, type, bt, adr_type, mo, LoadNode::DependsOnlyOnTest, needs_atomic_access);