Skip to content

Commit 654ad27

Browse files
committed
8256392: C2: Various Node cleanups
Reviewed-by: neliasso, thartmann, vlivanov
1 parent 9dbbe83 commit 654ad27

File tree

3 files changed

+51
-103
lines changed

3 files changed

+51
-103
lines changed

src/hotspot/share/opto/c2_globals.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@
9393
\
9494
develop(intx, OptoNodeListSize, 4, \
9595
"Starting allocation size of Node_List data structures") \
96-
range(0, max_jint) \
96+
range(1, max_jint) \
9797
\
9898
develop(intx, OptoBlockListSize, 8, \
9999
"Starting allocation size of Block_List data structures") \
100-
range(0, max_jint) \
100+
range(1, max_jint) \
101101
\
102102
develop(intx, OptoPeepholeAt, -1, \
103103
"Apply peephole optimizations to this peephole rule") \

src/hotspot/share/opto/node.cpp

Lines changed: 40 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ void Node::destruct(PhaseValues* phase) {
657657

658658
//------------------------------grow-------------------------------------------
659659
// Grow the input array, making space for more edges
660-
void Node::grow( uint len ) {
660+
void Node::grow(uint len) {
661661
Arena* arena = Compile::current()->node_arena();
662662
uint new_max = _max;
663663
if( new_max == 0 ) {
@@ -2263,95 +2263,55 @@ void Node::verify(Node* n, int verify_depth) {
22632263
}
22642264
#endif // not PRODUCT
22652265

2266-
//------------------------------walk-------------------------------------------
2267-
// Graph walk, with both pre-order and post-order functions
2268-
void Node::walk(NFunc pre, NFunc post, void *env) {
2269-
VectorSet visited; // Setup for local walk
2270-
walk_(pre, post, env, visited);
2271-
}
2272-
2273-
void Node::walk_(NFunc pre, NFunc post, void *env, VectorSet &visited) {
2274-
if( visited.test_set(_idx) ) return;
2275-
pre(*this,env); // Call the pre-order walk function
2276-
for( uint i=0; i<_max; i++ )
2277-
if( in(i) ) // Input exists and is not walked?
2278-
in(i)->walk_(pre,post,env,visited); // Walk it with pre & post functions
2279-
post(*this,env); // Call the post-order walk function
2280-
}
2281-
2282-
void Node::nop(Node &, void*) {}
2283-
22842266
//------------------------------Registers--------------------------------------
22852267
// Do we Match on this edge index or not? Generally false for Control
22862268
// and true for everything else. Weird for calls & returns.
22872269
uint Node::match_edge(uint idx) const {
22882270
return idx; // True for other than index 0 (control)
22892271
}
22902272

2291-
static RegMask _not_used_at_all;
22922273
// Register classes are defined for specific machines
22932274
const RegMask &Node::out_RegMask() const {
22942275
ShouldNotCallThis();
2295-
return _not_used_at_all;
2276+
return RegMask::Empty;
22962277
}
22972278

22982279
const RegMask &Node::in_RegMask(uint) const {
22992280
ShouldNotCallThis();
2300-
return _not_used_at_all;
2281+
return RegMask::Empty;
23012282
}
23022283

2303-
//=============================================================================
2304-
//-----------------------------------------------------------------------------
2305-
void Node_Array::reset( Arena *new_arena ) {
2306-
_a->Afree(_nodes,_max*sizeof(Node*));
2307-
_max = 0;
2308-
_nodes = NULL;
2309-
_a = new_arena;
2310-
}
2311-
2312-
//------------------------------clear------------------------------------------
23132284
// Clear all entries in _nodes to NULL but keep storage
23142285
void Node_Array::clear() {
23152286
Copy::zero_to_bytes( _nodes, _max*sizeof(Node*) );
23162287
}
23172288

2318-
//-----------------------------------------------------------------------------
2319-
void Node_Array::grow( uint i ) {
2320-
if( !_max ) {
2321-
_max = 1;
2322-
_nodes = (Node**)_a->Amalloc( _max * sizeof(Node*) );
2323-
_nodes[0] = NULL;
2324-
}
2289+
void Node_Array::grow(uint i) {
2290+
assert(_max > 0, "invariant");
23252291
uint old = _max;
23262292
_max = next_power_of_2(i);
23272293
_nodes = (Node**)_a->Arealloc( _nodes, old*sizeof(Node*),_max*sizeof(Node*));
23282294
Copy::zero_to_bytes( &_nodes[old], (_max-old)*sizeof(Node*) );
23292295
}
23302296

2331-
//-----------------------------------------------------------------------------
2332-
void Node_Array::insert( uint i, Node *n ) {
2333-
if( _nodes[_max-1] ) grow(_max); // Get more space if full
2334-
Copy::conjoint_words_to_higher((HeapWord*)&_nodes[i], (HeapWord*)&_nodes[i+1], ((_max-i-1)*sizeof(Node*)));
2297+
void Node_Array::insert(uint i, Node* n) {
2298+
if (_nodes[_max - 1]) {
2299+
grow(_max);
2300+
}
2301+
Copy::conjoint_words_to_higher((HeapWord*)&_nodes[i], (HeapWord*)&_nodes[i + 1], ((_max - i - 1) * sizeof(Node*)));
23352302
_nodes[i] = n;
23362303
}
23372304

2338-
//-----------------------------------------------------------------------------
2339-
void Node_Array::remove( uint i ) {
2340-
Copy::conjoint_words_to_lower((HeapWord*)&_nodes[i+1], (HeapWord*)&_nodes[i], ((_max-i-1)*sizeof(Node*)));
2341-
_nodes[_max-1] = NULL;
2342-
}
2343-
2344-
//-----------------------------------------------------------------------------
2345-
void Node_Array::sort( C_sort_func_t func) {
2346-
qsort( _nodes, _max, sizeof( Node* ), func );
2305+
void Node_Array::remove(uint i) {
2306+
Copy::conjoint_words_to_lower((HeapWord*)&_nodes[i + 1], (HeapWord*)&_nodes[i], ((_max - i - 1) * sizeof(Node*)));
2307+
_nodes[_max - 1] = NULL;
23472308
}
23482309

2349-
//-----------------------------------------------------------------------------
23502310
void Node_Array::dump() const {
23512311
#ifndef PRODUCT
2352-
for( uint i = 0; i < _max; i++ ) {
2353-
Node *nn = _nodes[i];
2354-
if( nn != NULL ) {
2312+
for (uint i = 0; i < _max; i++) {
2313+
Node* nn = _nodes[i];
2314+
if (nn != NULL) {
23552315
tty->print("%5d--> ",i); nn->dump();
23562316
}
23572317
}
@@ -2414,7 +2374,9 @@ Node* Node::unique_ctrl_out() const {
24142374
for (uint i = 0; i < outcnt(); i++) {
24152375
Node* use = raw_out(i);
24162376
if (use->is_CFG() && use != this) {
2417-
if (found != NULL) return NULL;
2377+
if (found != NULL) {
2378+
return NULL;
2379+
}
24182380
found = use;
24192381
}
24202382
}
@@ -2457,33 +2419,38 @@ bool Node::is_dead_loop_safe() const {
24572419
// Find and remove
24582420
void Node_List::yank( Node *n ) {
24592421
uint i;
2460-
for( i = 0; i < _cnt; i++ )
2461-
if( _nodes[i] == n )
2422+
for (i = 0; i < _cnt; i++) {
2423+
if (_nodes[i] == n) {
24622424
break;
2425+
}
2426+
}
24632427

2464-
if( i < _cnt )
2428+
if (i < _cnt) {
24652429
_nodes[i] = _nodes[--_cnt];
2430+
}
24662431
}
24672432

24682433
//------------------------------dump-------------------------------------------
24692434
void Node_List::dump() const {
24702435
#ifndef PRODUCT
2471-
for( uint i = 0; i < _cnt; i++ )
2472-
if( _nodes[i] ) {
2473-
tty->print("%5d--> ",i);
2436+
for (uint i = 0; i < _cnt; i++) {
2437+
if (_nodes[i]) {
2438+
tty->print("%5d--> ", i);
24742439
_nodes[i]->dump();
24752440
}
2441+
}
24762442
#endif
24772443
}
24782444

24792445
void Node_List::dump_simple() const {
24802446
#ifndef PRODUCT
2481-
for( uint i = 0; i < _cnt; i++ )
2447+
for (uint i = 0; i < _cnt; i++) {
24822448
if( _nodes[i] ) {
24832449
tty->print(" %d", _nodes[i]->_idx);
24842450
} else {
24852451
tty->print(" NULL");
24862452
}
2453+
}
24872454
#endif
24882455
}
24892456

@@ -2505,17 +2472,12 @@ void Unique_Node_List::remove(Node* n) {
25052472
//-----------------------remove_useless_nodes----------------------------------
25062473
// Remove useless nodes from worklist
25072474
void Unique_Node_List::remove_useless_nodes(VectorSet &useful) {
2508-
25092475
for (uint i = 0; i < size(); ++i) {
25102476
Node *n = at(i);
25112477
assert( n != NULL, "Did not expect null entries in worklist");
25122478
if (!useful.test(n->_idx)) {
25132479
_in_worklist.remove(n->_idx);
2514-
map(i,Node_List::pop());
2515-
// Node *replacement = Node_List::pop();
2516-
// if( i != size() ) { // Check if removing last entry
2517-
// _nodes[i] = replacement;
2518-
// }
2480+
map(i, Node_List::pop());
25192481
--i; // Visit popped node
25202482
// If it was last entry, loop terminates since size() was also reduced
25212483
}
@@ -2535,9 +2497,10 @@ void Node_Stack::grow() {
25352497
// Node_Stack is used to map nodes.
25362498
Node* Node_Stack::find(uint idx) const {
25372499
uint sz = size();
2538-
for (uint i=0; i < sz; i++) {
2539-
if (idx == index_at(i) )
2500+
for (uint i = 0; i < sz; i++) {
2501+
if (idx == index_at(i)) {
25402502
return node_at(i);
2503+
}
25412504
}
25422505
return NULL;
25432506
}
@@ -2546,7 +2509,7 @@ Node* Node_Stack::find(uint idx) const {
25462509
uint TypeNode::size_of() const { return sizeof(*this); }
25472510
#ifndef PRODUCT
25482511
void TypeNode::dump_spec(outputStream *st) const {
2549-
if( !Verbose && !WizardMode ) {
2512+
if (!Verbose && !WizardMode) {
25502513
// standard dump does this in Verbose and WizardMode
25512514
st->print(" #"); _type->dump_on(st);
25522515
}
@@ -2560,9 +2523,10 @@ void TypeNode::dump_compact_spec(outputStream *st) const {
25602523
uint TypeNode::hash() const {
25612524
return Node::hash() + _type->hash();
25622525
}
2563-
bool TypeNode::cmp( const Node &n ) const
2564-
{ return !Type::cmp( _type, ((TypeNode&)n)._type ); }
2565-
const Type *TypeNode::bottom_type() const { return _type; }
2526+
bool TypeNode::cmp(const Node& n) const {
2527+
return !Type::cmp(_type, ((TypeNode&)n)._type);
2528+
}
2529+
const Type* TypeNode::bottom_type() const { return _type; }
25662530
const Type* TypeNode::Value(PhaseGVN* phase) const { return _type; }
25672531

25682532
//------------------------------ideal_reg--------------------------------------

src/hotspot/share/opto/node.hpp

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ class StoreVectorNode;
159159
class StoreVectorScatterNode;
160160
class VectorMaskCmpNode;
161161
class VectorSet;
162-
typedef void (*NFunc)(Node&,void*);
163-
extern "C" {
164-
typedef int (*C_sort_func_t)(const void *, const void *);
165-
}
166162

167163
// The type of all node counts and indexes.
168164
// It must hold at least 16 bits, but must also be fast to load and store.
@@ -1120,18 +1116,9 @@ class Node {
11201116
virtual int cisc_operand() const { return AdlcVMDeps::Not_cisc_spillable; }
11211117
bool is_cisc_alternate() const { return (_flags & Flag_is_cisc_alternate) != 0; }
11221118

1123-
//----------------- Graph walking
1124-
public:
1125-
// Walk and apply member functions recursively.
1126-
// Supplied (this) pointer is root.
1127-
void walk(NFunc pre, NFunc post, void *env);
1128-
static void nop(Node &, void*); // Dummy empty function
1129-
static void packregion( Node &n, void* );
1130-
private:
1131-
void walk_(NFunc pre, NFunc post, void *env, VectorSet &visited);
1132-
11331119
//----------------- Printing, etc
11341120
#ifndef PRODUCT
1121+
private:
11351122
int _indent;
11361123

11371124
public:
@@ -1485,29 +1472,27 @@ class SimpleDUIterator : public StackObj {
14851472
class Node_Array : public ResourceObj {
14861473
friend class VMStructs;
14871474
protected:
1488-
Arena *_a; // Arena to allocate in
1475+
Arena* _a; // Arena to allocate in
14891476
uint _max;
1490-
Node **_nodes;
1477+
Node** _nodes;
14911478
void grow( uint i ); // Grow array node to fit
14921479
public:
1493-
Node_Array(Arena *a) : _a(a), _max(OptoNodeListSize) {
1494-
_nodes = NEW_ARENA_ARRAY( a, Node *, OptoNodeListSize );
1495-
for( int i = 0; i < OptoNodeListSize; i++ ) {
1480+
Node_Array(Arena* a) : _a(a), _max(OptoNodeListSize) {
1481+
_nodes = NEW_ARENA_ARRAY(a, Node*, OptoNodeListSize);
1482+
for (int i = 0; i < OptoNodeListSize; i++) {
14961483
_nodes[i] = NULL;
14971484
}
14981485
}
14991486

1500-
Node_Array(Node_Array *na) : _a(na->_a), _max(na->_max), _nodes(na->_nodes) {}
1487+
Node_Array(Node_Array* na) : _a(na->_a), _max(na->_max), _nodes(na->_nodes) {}
15011488
Node *operator[] ( uint i ) const // Lookup, or NULL for not mapped
15021489
{ return (i<_max) ? _nodes[i] : (Node*)NULL; }
1503-
Node *at( uint i ) const { assert(i<_max,"oob"); return _nodes[i]; }
1504-
Node **adr() { return _nodes; }
1490+
Node* at(uint i) const { assert(i<_max,"oob"); return _nodes[i]; }
1491+
Node** adr() { return _nodes; }
15051492
// Extend the mapping: index i maps to Node *n.
15061493
void map( uint i, Node *n ) { if( i>=_max ) grow(i); _nodes[i] = n; }
15071494
void insert( uint i, Node *n );
15081495
void remove( uint i ); // Remove, preserving order
1509-
void sort( C_sort_func_t func);
1510-
void reset( Arena *new_a ); // Zap mapping to empty; reclaim storage
15111496
void clear(); // Set all entries to NULL, keep storage
15121497
uint Size() const { return _max; }
15131498
void dump() const;
@@ -1530,7 +1515,6 @@ class Node_List : public Node_Array {
15301515
void push( Node *b ) { map(_cnt++,b); }
15311516
void yank( Node *n ); // Find and remove
15321517
Node *pop() { return _nodes[--_cnt]; }
1533-
Node *rpop() { Node *b = _nodes[0]; _nodes[0]=_nodes[--_cnt]; return b;}
15341518
void clear() { _cnt = 0; Node_Array::clear(); } // retain storage
15351519
uint size() const { return _cnt; }
15361520
void dump() const;

0 commit comments

Comments
 (0)