< prev index next >

src/share/vm/opto/valuetypenode.cpp

Print this page

        

*** 58,68 **** // 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) == 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 --- 58,68 ---- // 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() || oop->Opcode() == Op_ValueTypePtr || 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
*** 262,277 **** return oop_type->meet(TypePtr::NULL_PTR) != oop_type; } // 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) { assert(!has_phi_inputs(region), "already cloned with phis"); ! ValueTypeNode* vt = clone()->as_ValueType(); // Create a PhiNode for merging the oop values ! const TypeValueTypePtr* vtptr = TypeValueTypePtr::make(vt->bottom_type()->isa_valuetype()); PhiNode* oop = PhiNode::make(region, vt->get_oop(), vtptr); gvn->set_type(oop, vtptr); vt->set_oop(oop); // Create a PhiNode each for merging the field values --- 262,277 ---- return oop_type->meet(TypePtr::NULL_PTR) != oop_type; } // 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. ! ValueTypeBaseNode* ValueTypeBaseNode::clone_with_phis(PhaseGVN* gvn, Node* region) { assert(!has_phi_inputs(region), "already cloned with phis"); ! ValueTypeBaseNode* vt = clone()->as_ValueTypeBase(); // Create a PhiNode for merging the oop values ! const TypeValueTypePtr* vtptr = value_type_ptr(); PhiNode* oop = PhiNode::make(region, vt->get_oop(), vtptr); gvn->set_type(oop, vtptr); vt->set_oop(oop); // Create a PhiNode each for merging the field values
*** 290,322 **** } gvn->set_type(vt, vt->bottom_type()); 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) { // Check oop input bool result = get_oop()->is_Phi() && get_oop()->as_Phi()->region() == region; #ifdef ASSERT if (result) { // 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"); } else { assert(n->is_Phi() && n->as_Phi()->region() == region, "inconsistent phi inputs"); } } } #endif return result; } // 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) { // Merge oop inputs PhiNode* phi = get_oop()->as_Phi(); phi->set_req(pnum, other->get_oop()); if (transform) { set_oop(gvn->transform(phi)); --- 290,322 ---- } gvn->set_type(vt, vt->bottom_type()); return vt; } ! // 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 if (result) { // Check all field value inputs for consistency for (uint i = Oop; i < field_count(); ++i) { Node* n = in(i); ! 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"); } } } #endif return result; } // Merges 'this' with 'other' by updating the input PhiNodes added by 'clone_with_phis' ! 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()); if (transform) { set_oop(gvn->transform(phi));
*** 339,356 **** } } return this; } ! Node* ValueTypeNode::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 { // 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); int sub_offset = offset - field_offset(index); Node* value = field_value(index); --- 339,356 ---- } } return this; } ! 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* 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); int sub_offset = offset - field_offset(index); Node* value = field_value(index);
*** 363,419 **** assert(!(recursive && value->is_ValueType()), "should not be a value type"); assert(sub_offset == 0, "offset mismatch"); return value; } ! void ValueTypeNode::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 { assert(index < field_count(), "index out of bounds"); return value_klass()->field_offset_by_index(index); } ! ciType* ValueTypeNode::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); ciValueKlass* vk = value_klass(); uint nfields = vk->flattened_field_count(); - 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))) { - 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); --i; imax -= nb; } } } --- 363,426 ---- assert(!(recursive && value->is_ValueType()), "should not be a value type"); assert(sub_offset == 0, "offset mismatch"); return value; } ! void ValueTypeBaseNode::set_field_value(uint index, Node* value) { assert(index < field_count(), "index out of bounds"); set_req(Values + index, value); } ! int ValueTypeBaseNode::field_offset(uint index) const { assert(index < field_count(), "index out of bounds"); return value_klass()->field_offset_by_index(index); } ! ciType* ValueTypeBaseNode::field_type(uint index) const { assert(index < field_count(), "index out of bounds"); return value_klass()->field_type_by_index(index); } ! 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(); ! assert(TypePtr::NULL_PTR->higher_equal(oop_type), "already heap allocated value type should be linked directly"); ! int nb = make_scalar_in_safepoint(sfpt, C->root(), NULL); --i; imax -= nb; } } }
< prev index next >