提交 ed613285 编写于 作者: P poonam

8038348: Instance field load is replaced by wrong data Phi

Summary: Store additional information in PhiNodes corresponding to known instance field values to avoid incorrect reusage.
Reviewed-by: kvn, thartmann
上级 a83cbf89
...@@ -119,6 +119,9 @@ class JProjNode : public ProjNode { ...@@ -119,6 +119,9 @@ class JProjNode : public ProjNode {
// input in slot 0. // input in slot 0.
class PhiNode : public TypeNode { class PhiNode : public TypeNode {
const TypePtr* const _adr_type; // non-null only for Type::MEMORY nodes. const TypePtr* const _adr_type; // non-null only for Type::MEMORY nodes.
// The following fields are only used for data PhiNodes to indicate
// that the PhiNode represents the value of a known instance field.
int _inst_mem_id; // Instance memory id (node index of the memory Phi)
const int _inst_id; // Instance id of the memory slice. const int _inst_id; // Instance id of the memory slice.
const int _inst_index; // Alias index of the instance memory slice. const int _inst_index; // Alias index of the instance memory slice.
// Array elements references have the same alias_idx but different offset. // Array elements references have the same alias_idx but different offset.
...@@ -138,11 +141,13 @@ public: ...@@ -138,11 +141,13 @@ public:
}; };
PhiNode( Node *r, const Type *t, const TypePtr* at = NULL, PhiNode( Node *r, const Type *t, const TypePtr* at = NULL,
const int imid = -1,
const int iid = TypeOopPtr::InstanceTop, const int iid = TypeOopPtr::InstanceTop,
const int iidx = Compile::AliasIdxTop, const int iidx = Compile::AliasIdxTop,
const int ioffs = Type::OffsetTop ) const int ioffs = Type::OffsetTop )
: TypeNode(t,r->req()), : TypeNode(t,r->req()),
_adr_type(at), _adr_type(at),
_inst_mem_id(imid),
_inst_id(iid), _inst_id(iid),
_inst_index(iidx), _inst_index(iidx),
_inst_offset(ioffs) _inst_offset(ioffs)
...@@ -187,11 +192,14 @@ public: ...@@ -187,11 +192,14 @@ public:
virtual bool pinned() const { return in(0) != 0; } virtual bool pinned() const { return in(0) != 0; }
virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; } virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; }
void set_inst_mem_id(int inst_mem_id) { _inst_mem_id = inst_mem_id; }
const int inst_mem_id() const { return _inst_mem_id; }
const int inst_id() const { return _inst_id; } const int inst_id() const { return _inst_id; }
const int inst_index() const { return _inst_index; } const int inst_index() const { return _inst_index; }
const int inst_offset() const { return _inst_offset; } const int inst_offset() const { return _inst_offset; }
bool is_same_inst_field(const Type* tp, int id, int index, int offset) { bool is_same_inst_field(const Type* tp, int mem_id, int id, int index, int offset) {
return type()->basic_type() == tp->basic_type() && return type()->basic_type() == tp->basic_type() &&
inst_mem_id() == mem_id &&
inst_id() == id && inst_id() == id &&
inst_index() == index && inst_index() == index &&
inst_offset() == offset && inst_offset() == offset &&
......
...@@ -401,7 +401,7 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type * ...@@ -401,7 +401,7 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type *
for (DUIterator_Fast kmax, k = region->fast_outs(kmax); k < kmax; k++) { for (DUIterator_Fast kmax, k = region->fast_outs(kmax); k < kmax; k++) {
Node* phi = region->fast_out(k); Node* phi = region->fast_out(k);
if (phi->is_Phi() && phi != mem && if (phi->is_Phi() && phi != mem &&
phi->as_Phi()->is_same_inst_field(phi_type, instance_id, alias_idx, offset)) { phi->as_Phi()->is_same_inst_field(phi_type, (int)mem->_idx, instance_id, alias_idx, offset)) {
return phi; return phi;
} }
} }
...@@ -420,7 +420,7 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type * ...@@ -420,7 +420,7 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type *
GrowableArray <Node *> values(length, length, NULL, false); GrowableArray <Node *> values(length, length, NULL, false);
// create a new Phi for the value // create a new Phi for the value
PhiNode *phi = new (C) PhiNode(mem->in(0), phi_type, NULL, instance_id, alias_idx, offset); PhiNode *phi = new (C) PhiNode(mem->in(0), phi_type, NULL, mem->_idx, instance_id, alias_idx, offset);
transform_later(phi); transform_later(phi);
value_phis->push(phi, mem->_idx); value_phis->push(phi, mem->_idx);
......
...@@ -1155,7 +1155,7 @@ Node *LoadNode::Identity( PhaseTransform *phase ) { ...@@ -1155,7 +1155,7 @@ Node *LoadNode::Identity( PhaseTransform *phase ) {
for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) { for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
Node* phi = region->fast_out(i); Node* phi = region->fast_out(i);
if (phi->is_Phi() && phi != mem && if (phi->is_Phi() && phi != mem &&
phi->as_Phi()->is_same_inst_field(this_type, this_iid, this_index, this_offset)) { phi->as_Phi()->is_same_inst_field(this_type, (int)mem->_idx, this_iid, this_index, this_offset)) {
return phi; return phi;
} }
} }
...@@ -1400,7 +1400,7 @@ Node *LoadNode::split_through_phi(PhaseGVN *phase) { ...@@ -1400,7 +1400,7 @@ Node *LoadNode::split_through_phi(PhaseGVN *phase) {
this_iid = base->_idx; this_iid = base->_idx;
} }
PhaseIterGVN* igvn = phase->is_IterGVN(); PhaseIterGVN* igvn = phase->is_IterGVN();
Node* phi = new (C) PhiNode(region, this_type, NULL, this_iid, this_index, this_offset); Node* phi = new (C) PhiNode(region, this_type, NULL, mem->_idx, this_iid, this_index, this_offset);
for (uint i = 1; i < region->req(); i++) { for (uint i = 1; i < region->req(); i++) {
Node* x; Node* x;
Node* the_clone = NULL; Node* the_clone = NULL;
......
...@@ -481,6 +481,8 @@ PhaseRenumberLive::PhaseRenumberLive(PhaseGVN* gvn, ...@@ -481,6 +481,8 @@ PhaseRenumberLive::PhaseRenumberLive(PhaseGVN* gvn,
uint current_idx = 0; // The current new node ID. Incremented after every assignment. uint current_idx = 0; // The current new node ID. Incremented after every assignment.
for (uint i = 0; i < _useful.size(); i++) { for (uint i = 0; i < _useful.size(); i++) {
Node* n = _useful.at(i); Node* n = _useful.at(i);
// Sanity check that fails if we ever decide to execute this phase after EA
assert(!n->is_Phi() || n->as_Phi()->inst_mem_id() == -1, "should not be linked to data Phi");
const Type* type = gvn->type_or_null(n); const Type* type = gvn->type_or_null(n);
new_type_array.map(current_idx, type); new_type_array.map(current_idx, type);
...@@ -1378,6 +1380,18 @@ void PhaseIterGVN::subsume_node( Node *old, Node *nn ) { ...@@ -1378,6 +1380,18 @@ void PhaseIterGVN::subsume_node( Node *old, Node *nn ) {
i -= num_edges; // we deleted 1 or more copies of this edge i -= num_edges; // we deleted 1 or more copies of this edge
} }
// Search for instance field data PhiNodes in the same region pointing to the old
// memory PhiNode and update their instance memory ids to point to the new node.
if (old->is_Phi() && old->as_Phi()->type()->has_memory() && old->in(0) != NULL) {
Node* region = old->in(0);
for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
PhiNode* phi = region->fast_out(i)->isa_Phi();
if (phi != NULL && phi->inst_mem_id() == (int)old->_idx) {
phi->set_inst_mem_id((int)nn->_idx);
}
}
}
// Smash all inputs to 'old', isolating him completely // Smash all inputs to 'old', isolating him completely
Node *temp = new (C) Node(1); Node *temp = new (C) Node(1);
temp->init_req(0,nn); // Add a use to nn to prevent him from dying temp->init_req(0,nn); // Add a use to nn to prevent him from dying
......
...@@ -882,7 +882,7 @@ protected: ...@@ -882,7 +882,7 @@ protected:
// If not InstanceTop or InstanceBot, indicates that this is // If not InstanceTop or InstanceBot, indicates that this is
// a particular instance of this type which is distinct. // a particular instance of this type which is distinct.
// This is the the node index of the allocation node creating this instance. // This is the node index of the allocation node creating this instance.
int _instance_id; int _instance_id;
// Extra type information profiling gave us. We propagate it the // Extra type information profiling gave us. We propagate it the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册