Skip to content

Commit f55ae95

Browse files
committed
8256858: C2: Devirtualize PhaseIterGVN-specific methods
Reviewed-by: kvn, thartmann
1 parent 7b3d095 commit f55ae95

File tree

5 files changed

+46
-44
lines changed

5 files changed

+46
-44
lines changed

src/hotspot/share/opto/addnode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Node *AddNode::Ideal(PhaseGVN *phase, bool can_reshape) {
191191
set_req(1, addx);
192192
set_req(2, a22);
193193
progress = this;
194-
PhaseIterGVN *igvn = phase->is_IterGVN();
194+
PhaseIterGVN* igvn = phase->is_IterGVN();
195195
if (add2->outcnt() == 0 && igvn) {
196196
// add disconnected.
197197
igvn->_worklist.push(add2);
@@ -627,7 +627,7 @@ Node *AddPNode::Ideal(PhaseGVN *phase, bool can_reshape) {
627627
if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant?
628628
set_req(Address, phase->transform(new AddPNode(in(Base),in(Address),add->in(1))));
629629
set_req(Offset, add->in(2));
630-
PhaseIterGVN *igvn = phase->is_IterGVN();
630+
PhaseIterGVN* igvn = phase->is_IterGVN();
631631
if (add->outcnt() == 0 && igvn) {
632632
// add disconnected.
633633
igvn->_worklist.push((Node*)add);

src/hotspot/share/opto/memnode.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Node *MemNode::Ideal_common(PhaseGVN *phase, bool can_reshape) {
307307
(cmp != NULL && igvn->_worklist.member(cmp)) ) {
308308
// This control path may be dead.
309309
// Delay this memory node transformation until the control is processed.
310-
phase->is_IterGVN()->_worklist.push(this);
310+
igvn->_worklist.push(this);
311311
return NodeSentinel; // caller will return NULL
312312
}
313313
}
@@ -319,7 +319,7 @@ Node *MemNode::Ideal_common(PhaseGVN *phase, bool can_reshape) {
319319
if (can_reshape && igvn != NULL && igvn->_worklist.member(mem)) {
320320
// This memory slice may be dead.
321321
// Delay this mem node transformation until the memory is processed.
322-
phase->is_IterGVN()->_worklist.push(this);
322+
igvn->_worklist.push(this);
323323
return NodeSentinel; // caller will return NULL
324324
}
325325

@@ -350,7 +350,7 @@ Node *MemNode::Ideal_common(PhaseGVN *phase, bool can_reshape) {
350350
(igvn->_worklist.size() > 0 && t_adr != adr_type())) ) {
351351
// The address's base and type may change when the address is processed.
352352
// Delay this mem node transformation until the address is processed.
353-
phase->is_IterGVN()->_worklist.push(this);
353+
igvn->_worklist.push(this);
354354
return NodeSentinel; // caller will return NULL
355355
}
356356

@@ -1721,7 +1721,7 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) {
17211721
PhaseIterGVN *igvn = phase->is_IterGVN();
17221722
if (igvn != NULL && igvn->_worklist.member(opt_mem)) {
17231723
// Delay this transformation until memory Phi is processed.
1724-
phase->is_IterGVN()->_worklist.push(this);
1724+
igvn->_worklist.push(this);
17251725
return NULL;
17261726
}
17271727
// Split instance field load through Phi.
@@ -2632,7 +2632,9 @@ Node *StoreNode::Ideal(PhaseGVN *phase, bool can_reshape) {
26322632
if (st->in(MemNode::Address)->eqv_uncast(address) &&
26332633
st->as_Store()->memory_size() <= this->memory_size()) {
26342634
Node* use = st->raw_out(0);
2635-
phase->igvn_rehash_node_delayed(use);
2635+
if (phase->is_IterGVN()) {
2636+
phase->is_IterGVN()->rehash_node_delayed(use);
2637+
}
26362638
if (can_reshape) {
26372639
use->set_req_X(MemNode::Memory, st->in(MemNode::Memory), phase->is_IterGVN());
26382640
} else {
@@ -2746,14 +2748,14 @@ Node* StoreNode::Identity(PhaseGVN* phase) {
27462748
}
27472749
}
27482750

2749-
if (result != this && phase->is_IterGVN() != NULL) {
2751+
PhaseIterGVN* igvn = phase->is_IterGVN();
2752+
if (result != this && igvn != NULL) {
27502753
MemBarNode* trailing = trailing_membar();
27512754
if (trailing != NULL) {
27522755
#ifdef ASSERT
27532756
const TypeOopPtr* t_oop = phase->type(in(Address))->isa_oopptr();
27542757
assert(t_oop == NULL || t_oop->is_known_instance_field(), "only for non escaping objects");
27552758
#endif
2756-
PhaseIterGVN* igvn = phase->is_IterGVN();
27572759
trailing->remove(igvn);
27582760
}
27592761
}
@@ -3951,7 +3953,10 @@ Node* InitializeNode::capture_store(StoreNode* st, intptr_t start,
39513953
// if it redundantly stored the same value (or zero to fresh memory).
39523954

39533955
// In any case, wire it in:
3954-
phase->igvn_rehash_node_delayed(this);
3956+
PhaseIterGVN* igvn = phase->is_IterGVN();
3957+
if (igvn) {
3958+
igvn->rehash_node_delayed(this);
3959+
}
39553960
set_req(i, new_st);
39563961

39573962
// The caller may now kill the old guy.

src/hotspot/share/opto/mulnode.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,10 @@ static int maskShiftAmount(PhaseGVN *phase, Node *shiftNode, int nBits) {
654654

655655
if (shift != maskedShift) {
656656
shiftNode->set_req(2, phase->intcon(maskedShift)); // Replace shift count with masked value.
657-
phase->igvn_rehash_node_delayed(shiftNode);
657+
PhaseIterGVN* igvn = phase->is_IterGVN();
658+
if (igvn) {
659+
igvn->rehash_node_delayed(shiftNode);
660+
}
658661
}
659662

660663
return maskedShift;

src/hotspot/share/opto/phaseX.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -690,14 +690,15 @@ void PhaseTransform::dump_nodes_and_types_recur( const Node *n, uint depth, bool
690690
//=============================================================================
691691
//------------------------------PhaseValues------------------------------------
692692
// Set minimum table size to "255"
693-
PhaseValues::PhaseValues( Arena *arena, uint est_max_size ) : PhaseTransform(arena, GVN), _table(arena, est_max_size) {
693+
PhaseValues::PhaseValues( Arena *arena, uint est_max_size )
694+
: PhaseTransform(arena, GVN), _table(arena, est_max_size), _iterGVN(false) {
694695
NOT_PRODUCT( clear_new_values(); )
695696
}
696697

697698
//------------------------------PhaseValues------------------------------------
698699
// Set minimum table size to "255"
699-
PhaseValues::PhaseValues( PhaseValues *ptv ) : PhaseTransform( ptv, GVN ),
700-
_table(&ptv->_table) {
700+
PhaseValues::PhaseValues(PhaseValues* ptv)
701+
: PhaseTransform(ptv, GVN), _table(&ptv->_table), _iterGVN(false) {
701702
NOT_PRODUCT( clear_new_values(); )
702703
}
703704

@@ -932,24 +933,26 @@ void PhaseGVN::dead_loop_check( Node *n ) {
932933
//=============================================================================
933934
//------------------------------PhaseIterGVN-----------------------------------
934935
// Initialize with previous PhaseIterGVN info; used by PhaseCCP
935-
PhaseIterGVN::PhaseIterGVN( PhaseIterGVN *igvn ) : PhaseGVN(igvn),
936-
_delay_transform(igvn->_delay_transform),
937-
_stack( igvn->_stack ),
938-
_worklist( igvn->_worklist )
936+
PhaseIterGVN::PhaseIterGVN(PhaseIterGVN* igvn) : PhaseGVN(igvn),
937+
_delay_transform(igvn->_delay_transform),
938+
_stack(igvn->_stack ),
939+
_worklist(igvn->_worklist)
939940
{
941+
_iterGVN = true;
940942
}
941943

942944
//------------------------------PhaseIterGVN-----------------------------------
943945
// Initialize with previous PhaseGVN info from Parser
944-
PhaseIterGVN::PhaseIterGVN( PhaseGVN *gvn ) : PhaseGVN(gvn),
945-
_delay_transform(false),
946+
PhaseIterGVN::PhaseIterGVN(PhaseGVN* gvn) : PhaseGVN(gvn),
947+
_delay_transform(false),
946948
// TODO: Before incremental inlining it was allocated only once and it was fine. Now that
947949
// the constructor is used in incremental inlining, this consumes too much memory:
948950
// _stack(C->live_nodes() >> 1),
949951
// So, as a band-aid, we replace this by:
950-
_stack(C->comp_arena(), 32),
951-
_worklist(*C->for_igvn())
952+
_stack(C->comp_arena(), 32),
953+
_worklist(*C->for_igvn())
952954
{
955+
_iterGVN = true;
953956
uint max;
954957

955958
// Dead nodes in the hash table inherited from GVN were not treated as

src/hotspot/share/opto/phaseX.hpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,6 @@ class PhaseTransform : public Phase {
335335
const Type* limit_type) const
336336
{ ShouldNotCallThis(); return NULL; }
337337

338-
// Delayed node rehash if this is an IGVN phase
339-
virtual void igvn_rehash_node_delayed(Node* n) {}
340-
341338
// true if CFG node d dominates CFG node n
342339
virtual bool is_dominator(Node *d, Node *n) { fatal("unimplemented for this pass"); return false; };
343340

@@ -369,18 +366,18 @@ class PhaseTransform : public Phase {
369366
class PhaseValues : public PhaseTransform {
370367
protected:
371368
NodeHash _table; // Hash table for value-numbering
372-
369+
bool _iterGVN;
373370
public:
374-
PhaseValues( Arena *arena, uint est_max_size );
375-
PhaseValues( PhaseValues *pt );
376-
NOT_PRODUCT( ~PhaseValues(); )
377-
virtual PhaseIterGVN *is_IterGVN() { return 0; }
371+
PhaseValues(Arena* arena, uint est_max_size);
372+
PhaseValues(PhaseValues* pt);
373+
NOT_PRODUCT(~PhaseValues();)
374+
PhaseIterGVN* is_IterGVN() { return (_iterGVN) ? (PhaseIterGVN*)this : NULL; }
378375

379376
// Some Ideal and other transforms delete --> modify --> insert values
380-
bool hash_delete(Node *n) { return _table.hash_delete(n); }
381-
void hash_insert(Node *n) { _table.hash_insert(n); }
382-
Node *hash_find_insert(Node *n){ return _table.hash_find_insert(n); }
383-
Node *hash_find(const Node *n) { return _table.hash_find(n); }
377+
bool hash_delete(Node* n) { return _table.hash_delete(n); }
378+
void hash_insert(Node* n) { _table.hash_insert(n); }
379+
Node* hash_find_insert(Node* n){ return _table.hash_find_insert(n); }
380+
Node* hash_find(const Node* n) { return _table.hash_find(n); }
384381

385382
// Used after parsing to eliminate values that are no longer in program
386383
void remove_useless_nodes(VectorSet &useful) {
@@ -391,8 +388,8 @@ class PhaseValues : public PhaseTransform {
391388

392389
virtual ConNode* uncached_makecon(const Type* t); // override from PhaseTransform
393390

394-
virtual const Type* saturate(const Type* new_type, const Type* old_type,
395-
const Type* limit_type) const
391+
const Type* saturate(const Type* new_type, const Type* old_type,
392+
const Type* limit_type) const
396393
{ return new_type; }
397394

398395
#ifndef PRODUCT
@@ -463,15 +460,13 @@ class PhaseIterGVN : public PhaseGVN {
463460
// improvement, such that it would take many (>>10) steps to reach 2**32.
464461

465462
public:
466-
PhaseIterGVN( PhaseIterGVN *igvn ); // Used by CCP constructor
467-
PhaseIterGVN( PhaseGVN *gvn ); // Used after Parser
463+
PhaseIterGVN(PhaseIterGVN* igvn); // Used by CCP constructor
464+
PhaseIterGVN(PhaseGVN* gvn); // Used after Parser
468465

469466
// Idealize new Node 'n' with respect to its inputs and its value
470467
virtual Node *transform( Node *a_node );
471468
virtual void record_for_igvn(Node *n) { }
472469

473-
virtual PhaseIterGVN *is_IterGVN() { return this; }
474-
475470
Unique_Node_List _worklist; // Iterative worklist
476471

477472
// Given def-use info and an initial worklist, apply Node::Ideal,
@@ -527,10 +522,6 @@ class PhaseIterGVN : public PhaseGVN {
527522
_worklist.push(n);
528523
}
529524

530-
void igvn_rehash_node_delayed(Node* n) {
531-
rehash_node_delayed(n);
532-
}
533-
534525
// Replace ith edge of "n" with "in"
535526
void replace_input_of(Node* n, int i, Node* in) {
536527
rehash_node_delayed(n);

0 commit comments

Comments
 (0)