--- old/src/share/vm/opto/valuetypenode.cpp 2017-07-06 17:29:00.222267912 +0200 +++ new/src/share/vm/opto/valuetypenode.cpp 2017-07-06 17:28:55.381289648 +0200 @@ -60,7 +60,7 @@ 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) == oop, "value type should be loaded"); + assert(oop->is_Con() || oop->is_CheckCastPP() || oop->Opcode() == Op_ValueTypePtr || vt->is_loaded(&gvn, type) == oop, "value type should be loaded"); return gvn.transform(vt); } @@ -264,12 +264,12 @@ // Clones the values type to handle control flow merges involving multiple value types. // The inputs are replaced by PhiNodes to represent the merged values for the given region. -ValueTypeNode* ValueTypeNode::clone_with_phis(PhaseGVN* gvn, Node* region) { +ValueTypeBaseNode* ValueTypeBaseNode::clone_with_phis(PhaseGVN* gvn, Node* region) { assert(!has_phi_inputs(region), "already cloned with phis"); - ValueTypeNode* vt = clone()->as_ValueType(); + ValueTypeBaseNode* vt = clone()->as_ValueTypeBase(); // Create a PhiNode for merging the oop values - const TypeValueTypePtr* vtptr = TypeValueTypePtr::make(vt->bottom_type()->isa_valuetype()); + const TypeValueTypePtr* vtptr = value_type_ptr(); PhiNode* oop = PhiNode::make(region, vt->get_oop(), vtptr); gvn->set_type(oop, vtptr); vt->set_oop(oop); @@ -292,9 +292,9 @@ return vt; } -// Checks if the inputs of the ValueTypeNode were replaced by PhiNodes -// for the given region (see ValueTypeNode::clone_with_phis). -bool ValueTypeNode::has_phi_inputs(Node* region) { +// Checks if the inputs of the ValueBaseTypeNode were replaced by PhiNodes +// for the given region (see ValueBaseTypeNode::clone_with_phis). +bool ValueTypeBaseNode::has_phi_inputs(Node* region) { // Check oop input bool result = get_oop()->is_Phi() && get_oop()->as_Phi()->region() == region; #ifdef ASSERT @@ -302,8 +302,8 @@ // Check all field value inputs for consistency for (uint i = Oop; i < field_count(); ++i) { Node* n = in(i); - if (n->is_ValueType()) { - assert(n->as_ValueType()->has_phi_inputs(region), "inconsistent phi inputs"); + if (n->is_ValueTypeBase()) { + assert(n->as_ValueTypeBase()->has_phi_inputs(region), "inconsistent phi inputs"); } else { assert(n->is_Phi() && n->as_Phi()->region() == region, "inconsistent phi inputs"); } @@ -314,7 +314,7 @@ } // Merges 'this' with 'other' by updating the input PhiNodes added by 'clone_with_phis' -ValueTypeNode* ValueTypeNode::merge_with(PhaseGVN* gvn, const ValueTypeNode* other, int pnum, bool transform) { +ValueTypeBaseNode* ValueTypeBaseNode::merge_with(PhaseGVN* gvn, const ValueTypeBaseNode* other, int pnum, bool transform) { // Merge oop inputs PhiNode* phi = get_oop()->as_Phi(); phi->set_req(pnum, other->get_oop()); @@ -341,14 +341,14 @@ return this; } -Node* ValueTypeNode::field_value(uint index) const { +Node* ValueTypeBaseNode::field_value(uint index) const { assert(index < field_count(), "index out of bounds"); return in(Values + index); } // Get the value of the field at the given offset. // If 'recursive' is true, flattened value type fields will be resolved recursively. -Node* ValueTypeNode::field_value_by_offset(int offset, bool recursive) const { +Node* ValueTypeBaseNode::field_value_by_offset(int offset, bool recursive) const { // If the field at 'offset' belongs to a flattened value type field, 'index' refers to the // corresponding ValueTypeNode input and 'sub_offset' is the offset in flattened value type. int index = value_klass()->field_index_by_offset(offset); @@ -365,53 +365,60 @@ return value; } -void ValueTypeNode::set_field_value(uint index, Node* value) { +void ValueTypeBaseNode::set_field_value(uint index, Node* value) { assert(index < field_count(), "index out of bounds"); set_req(Values + index, value); } -int ValueTypeNode::field_offset(uint index) const { +int ValueTypeBaseNode::field_offset(uint index) const { assert(index < field_count(), "index out of bounds"); return value_klass()->field_offset_by_index(index); } -ciType* ValueTypeNode::field_type(uint index) const { +ciType* ValueTypeBaseNode::field_type(uint index) const { assert(index < field_count(), "index out of bounds"); return value_klass()->field_type_by_index(index); } -void ValueTypeNode::make_scalar_in_safepoints(Compile* C) { - const TypeValueTypePtr* res_type = TypeValueTypePtr::make(bottom_type()->isa_valuetype(), TypePtr::NotNull); +int ValueTypeBaseNode::make_scalar_in_safepoint(SafePointNode* sfpt, Node* root, PhaseGVN* gvn) { ciValueKlass* vk = value_klass(); uint nfields = vk->flattened_field_count(); + JVMState* jvms = sfpt->jvms(); + int start = jvms->debug_start(); + int end = jvms->debug_end(); + // Replace safepoint edge by SafePointScalarObjectNode and add field values + assert(jvms != NULL, "missing JVMS"); + uint first_ind = (sfpt->req() - jvms->scloff()); + const TypeValueTypePtr* res_type = value_type_ptr(); + SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type, +#ifdef ASSERT + NULL, +#endif + first_ind, nfields); + sobj->init_req(0, root); + // Iterate over the value type fields in order of increasing + // offset and add the field values to the safepoint. + for (uint j = 0; j < nfields; ++j) { + int offset = vk->nonstatic_field_at(j)->offset(); + Node* value = field_value_by_offset(offset, true /* include flattened value type fields */); + sfpt->add_req(value); + } + jvms->set_endoff(sfpt->req()); + if (gvn != NULL) { + sobj = gvn->transform(sobj)->as_SafePointScalarObject(); + } + return sfpt->replace_edges_in_range(this, sobj, start, end); +} + +void ValueTypeNode::make_scalar_in_safepoints(Compile* C) { for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) { Node* u = fast_out(i); if (u->is_SafePoint() && (!u->is_Call() || u->as_Call()->has_debug_use(this))) { + SafePointNode* sfpt = u->as_SafePoint(); Node* in_oop = get_oop(); const Type* oop_type = in_oop->bottom_type(); - SafePointNode* sfpt = u->as_SafePoint(); - JVMState* jvms = sfpt->jvms(); - int start = jvms->debug_start(); - int end = jvms->debug_end(); assert(TypePtr::NULL_PTR->higher_equal(oop_type), "already heap allocated value type should be linked directly"); - // Replace safepoint edge by SafePointScalarObjectNode and add field values - assert(jvms != NULL, "missing JVMS"); - uint first_ind = (sfpt->req() - jvms->scloff()); - SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type, -#ifdef ASSERT - NULL, -#endif - first_ind, nfields); - sobj->init_req(0, C->root()); - // Iterate over the value type fields in order of increasing - // offset and add the field values to the safepoint. - for (uint j = 0; j < nfields; ++j) { - int offset = vk->nonstatic_field_at(j)->offset(); - Node* value = field_value_by_offset(offset, true /* include flattened value type fields */); - sfpt->add_req(value); - } - jvms->set_endoff(sfpt->req()); - int nb = sfpt->replace_edges_in_range(this, sobj, start, end); + int nb = make_scalar_in_safepoint(sfpt, C->root(), NULL); --i; imax -= nb; } }