5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "precompiled.hpp"
25 #include "memory/allocation.inline.hpp"
26 #include "memory/resourceArea.hpp"
27 #include "opto/block.hpp"
28 #include "opto/callnode.hpp"
29 #include "opto/castnode.hpp"
30 #include "opto/cfgnode.hpp"
31 #include "opto/idealGraphPrinter.hpp"
32 #include "opto/loopnode.hpp"
33 #include "opto/machnode.hpp"
34 #include "opto/opcodes.hpp"
35 #include "opto/phaseX.hpp"
36 #include "opto/regalloc.hpp"
37 #include "opto/rootnode.hpp"
38
39 //=============================================================================
40 #define NODE_HASH_MINIMUM_SIZE 255
41 //------------------------------NodeHash---------------------------------------
42 NodeHash::NodeHash(uint est_max_size) :
43 _max( round_up(est_max_size < NODE_HASH_MINIMUM_SIZE ? NODE_HASH_MINIMUM_SIZE : est_max_size) ),
44 _a(Thread::current()->resource_area()),
45 _table( NEW_ARENA_ARRAY( _a , Node* , _max ) ), // (Node**)_a->Amalloc(_max * sizeof(Node*)) ),
46 _inserts(0), _insert_limit( insert_limit() )
47 #ifndef PRODUCT
48 ,_look_probes(0), _lookup_hits(0), _lookup_misses(0),
49 _delete_probes(0), _delete_hits(0), _delete_misses(0),
50 _total_insert_probes(0), _total_inserts(0),
51 _insert_probes(0), _grows(0)
52 #endif
53 {
54 // _sentinel must be in the current node space
55 _sentinel = new ProjNode(NULL, TypeFunc::Control);
56 memset(_table,0,sizeof(Node*)*_max);
|
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "precompiled.hpp"
25 #include "gc/shared/barrierSet.hpp"
26 #include "gc/shared/c2/barrierSetC2.hpp"
27 #include "memory/allocation.inline.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "opto/block.hpp"
30 #include "opto/callnode.hpp"
31 #include "opto/castnode.hpp"
32 #include "opto/cfgnode.hpp"
33 #include "opto/idealGraphPrinter.hpp"
34 #include "opto/loopnode.hpp"
35 #include "opto/machnode.hpp"
36 #include "opto/opcodes.hpp"
37 #include "opto/phaseX.hpp"
38 #include "opto/regalloc.hpp"
39 #include "opto/rootnode.hpp"
40 #include "utilities/macros.hpp"
41
42 //=============================================================================
43 #define NODE_HASH_MINIMUM_SIZE 255
44 //------------------------------NodeHash---------------------------------------
45 NodeHash::NodeHash(uint est_max_size) :
46 _max( round_up(est_max_size < NODE_HASH_MINIMUM_SIZE ? NODE_HASH_MINIMUM_SIZE : est_max_size) ),
47 _a(Thread::current()->resource_area()),
48 _table( NEW_ARENA_ARRAY( _a , Node* , _max ) ), // (Node**)_a->Amalloc(_max * sizeof(Node*)) ),
49 _inserts(0), _insert_limit( insert_limit() )
50 #ifndef PRODUCT
51 ,_look_probes(0), _lookup_hits(0), _lookup_misses(0),
52 _delete_probes(0), _delete_hits(0), _delete_misses(0),
53 _total_insert_probes(0), _total_inserts(0),
54 _insert_probes(0), _grows(0)
55 #endif
56 {
57 // _sentinel must be in the current node space
58 _sentinel = new ProjNode(NULL, TypeFunc::Control);
59 memset(_table,0,sizeof(Node*)*_max);
|
1351 assert((nrep > 0), "sanity");
1352 if (in->outcnt() == 0) { // Made input go dead?
1353 _stack.push(in, PROCESS_INPUTS); // Recursively remove
1354 recurse = true;
1355 } else if (in->outcnt() == 1 &&
1356 in->has_special_unique_user()) {
1357 _worklist.push(in->unique_out());
1358 } else if (in->outcnt() <= 2 && dead->is_Phi()) {
1359 if (in->Opcode() == Op_Region) {
1360 _worklist.push(in);
1361 } else if (in->is_Store()) {
1362 DUIterator_Fast imax, i = in->fast_outs(imax);
1363 _worklist.push(in->fast_out(i));
1364 i++;
1365 if (in->outcnt() == 2) {
1366 _worklist.push(in->fast_out(i));
1367 i++;
1368 }
1369 assert(!(i < imax), "sanity");
1370 }
1371 }
1372 if (ReduceFieldZeroing && dead->is_Load() && i == MemNode::Memory &&
1373 in->is_Proj() && in->in(0) != NULL && in->in(0)->is_Initialize()) {
1374 // A Load that directly follows an InitializeNode is
1375 // going away. The Stores that follow are candidates
1376 // again to be captured by the InitializeNode.
1377 for (DUIterator_Fast jmax, j = in->fast_outs(jmax); j < jmax; j++) {
1378 Node *n = in->fast_out(j);
1379 if (n->is_Store()) {
1380 _worklist.push(n);
1381 }
1382 }
1383 }
1384 } // if (in != NULL && in != C->top())
1385 } // for (uint i = 0; i < dead->req(); i++)
1386 if (recurse) {
1387 continue;
1388 }
1389 } // if (!dead->is_Con())
|
1357 assert((nrep > 0), "sanity");
1358 if (in->outcnt() == 0) { // Made input go dead?
1359 _stack.push(in, PROCESS_INPUTS); // Recursively remove
1360 recurse = true;
1361 } else if (in->outcnt() == 1 &&
1362 in->has_special_unique_user()) {
1363 _worklist.push(in->unique_out());
1364 } else if (in->outcnt() <= 2 && dead->is_Phi()) {
1365 if (in->Opcode() == Op_Region) {
1366 _worklist.push(in);
1367 } else if (in->is_Store()) {
1368 DUIterator_Fast imax, i = in->fast_outs(imax);
1369 _worklist.push(in->fast_out(i));
1370 i++;
1371 if (in->outcnt() == 2) {
1372 _worklist.push(in->fast_out(i));
1373 i++;
1374 }
1375 assert(!(i < imax), "sanity");
1376 }
1377 } else {
1378 BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(_worklist, in);
1379 }
1380 if (ReduceFieldZeroing && dead->is_Load() && i == MemNode::Memory &&
1381 in->is_Proj() && in->in(0) != NULL && in->in(0)->is_Initialize()) {
1382 // A Load that directly follows an InitializeNode is
1383 // going away. The Stores that follow are candidates
1384 // again to be captured by the InitializeNode.
1385 for (DUIterator_Fast jmax, j = in->fast_outs(jmax); j < jmax; j++) {
1386 Node *n = in->fast_out(j);
1387 if (n->is_Store()) {
1388 _worklist.push(n);
1389 }
1390 }
1391 }
1392 } // if (in != NULL && in != C->top())
1393 } // for (uint i = 0; i < dead->req(); i++)
1394 if (recurse) {
1395 continue;
1396 }
1397 } // if (!dead->is_Con())
|
1406 // root is usually dead. However, sometimes reshaping walk makes
1407 // it reachable by adding use edges. So, we will NOT count Con nodes
1408 // as dead to be conservative about the dead node count at any
1409 // given time.
1410 if (!dead->is_Con()) {
1411 C->record_dead_node(dead->_idx);
1412 }
1413 if (dead->is_macro()) {
1414 C->remove_macro_node(dead);
1415 }
1416 if (dead->is_expensive()) {
1417 C->remove_expensive_node(dead);
1418 }
1419 CastIINode* cast = dead->isa_CastII();
1420 if (cast != NULL && cast->has_range_check()) {
1421 C->remove_range_check_cast(cast);
1422 }
1423 if (dead->Opcode() == Op_Opaque4) {
1424 C->remove_opaque4_node(dead);
1425 }
1426 }
1427 } // while (_stack.is_nonempty())
1428 }
1429
1430 //------------------------------subsume_node-----------------------------------
1431 // Remove users from node 'old' and add them to node 'nn'.
1432 void PhaseIterGVN::subsume_node( Node *old, Node *nn ) {
1433 assert( old != hash_find(old), "should already been removed" );
1434 assert( old != C->top(), "cannot subsume top node");
1435 // Copy debug or profile information to the new version:
1436 C->copy_node_notes_to(nn, old);
1437 // Move users of node 'old' to node 'nn'
1438 for (DUIterator_Last imin, i = old->last_outs(imin); i >= imin; ) {
1439 Node* use = old->last_out(i); // for each use...
1440 // use might need re-hashing (but it won't if it's a new node)
1441 rehash_node_delayed(use);
1442 // Update use-def info as well
1443 // We remove all occurrences of old within use->in,
1444 // so as to avoid rehashing any node more than once.
|
1414 // root is usually dead. However, sometimes reshaping walk makes
1415 // it reachable by adding use edges. So, we will NOT count Con nodes
1416 // as dead to be conservative about the dead node count at any
1417 // given time.
1418 if (!dead->is_Con()) {
1419 C->record_dead_node(dead->_idx);
1420 }
1421 if (dead->is_macro()) {
1422 C->remove_macro_node(dead);
1423 }
1424 if (dead->is_expensive()) {
1425 C->remove_expensive_node(dead);
1426 }
1427 CastIINode* cast = dead->isa_CastII();
1428 if (cast != NULL && cast->has_range_check()) {
1429 C->remove_range_check_cast(cast);
1430 }
1431 if (dead->Opcode() == Op_Opaque4) {
1432 C->remove_opaque4_node(dead);
1433 }
1434 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
1435 bs->unregister_potential_barrier_node(dead);
1436 }
1437 } // while (_stack.is_nonempty())
1438 }
1439
1440 //------------------------------subsume_node-----------------------------------
1441 // Remove users from node 'old' and add them to node 'nn'.
1442 void PhaseIterGVN::subsume_node( Node *old, Node *nn ) {
1443 assert( old != hash_find(old), "should already been removed" );
1444 assert( old != C->top(), "cannot subsume top node");
1445 // Copy debug or profile information to the new version:
1446 C->copy_node_notes_to(nn, old);
1447 // Move users of node 'old' to node 'nn'
1448 for (DUIterator_Last imin, i = old->last_outs(imin); i >= imin; ) {
1449 Node* use = old->last_out(i); // for each use...
1450 // use might need re-hashing (but it won't if it's a new node)
1451 rehash_node_delayed(use);
1452 // Update use-def info as well
1453 // We remove all occurrences of old within use->in,
1454 // so as to avoid rehashing any node more than once.
|