< prev index next >

src/hotspot/share/c1/c1_GraphBuilder.cpp

Print this page

@@ -1854,11 +1854,10 @@
 void GraphBuilder::withfield(int field_index)
 {
   bool will_link;
   ciField* field_modify = stream()->get_field(will_link);
   ciInstanceKlass* holder = field_modify->holder();
-  assert(holder->is_valuetype(), "must be a value klass");
   BasicType field_type = field_modify->type()->basic_type();
   ValueType* type = as_ValueType(field_type);
 
   // call will_link again to determine if the field is valid.
   const bool needs_patching = !holder->is_loaded() ||

@@ -1868,15 +1867,24 @@
 
   scope()->set_wrote_final();
   scope()->set_wrote_fields();
 
   const int offset = !needs_patching ? field_modify->offset() : -1;
+
+  if (!holder->is_loaded()) {
+    ValueStack* state_before = copy_state_before();
   Value val = pop(type);
   Value obj = apop();
-
+    apush(append_split(new WithField(obj->type(), state_before)));
+    return;
+  }
   ValueStack* state_before = copy_state_for_exception();
 
+  Value val = pop(type);
+  Value obj = apop();
+
+  assert(holder->is_valuetype(), "must be a value klass");
   NewValueTypeInstance* new_instance = new NewValueTypeInstance(holder->as_value_klass(), state_before, false);
   _memory->new_instance(new_instance);
   apush(append_split(new_instance));
 
   for (int i = 0; i < holder->nof_nonstatic_fields(); i++) {

@@ -2299,18 +2307,23 @@
   _memory->new_instance(new_instance);
   apush(append_split(new_instance));
 }
 
 void GraphBuilder::new_value_type_instance(int klass_index) {
-  ValueStack* state_before = copy_state_exhandling();
   bool will_link;
   ciKlass* klass = stream()->get_klass(will_link);
+  if (klass->is_loaded()) {
   assert(klass->is_valuetype(), "must be a value klass");
+    ValueStack* state_before = copy_state_exhandling();
   NewValueTypeInstance* new_instance = new NewValueTypeInstance(klass->as_value_klass(),
       state_before, stream()->is_unresolved_klass());
   _memory->new_instance(new_instance);
   apush(append_split(new_instance));
+  } else {
+    ValueStack* state_before = copy_state_before();
+    apush(append_split(new DefaultValue(objectType, state_before)));
+  }
 }
 
 void GraphBuilder::new_type_array() {
   ValueStack* state_before = copy_state_exhandling();
   apush(append_split(new NewTypeArray(ipop(), (BasicType)stream()->get_index(), state_before)));
< prev index next >