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 "libadt/vectset.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "memory/resourceArea.hpp"
28 #include "opto/castnode.hpp"
29 #include "opto/cfgnode.hpp"
30 #include "opto/connode.hpp"
31 #include "opto/loopnode.hpp"
32 #include "opto/machnode.hpp"
33 #include "opto/matcher.hpp"
34 #include "opto/node.hpp"
35 #include "opto/opcodes.hpp"
36 #include "opto/regmask.hpp"
37 #include "opto/type.hpp"
38 #include "utilities/copy.hpp"
39
40 class RegMask;
41 // #include "phase.hpp"
42 class PhaseTransform;
43 class PhaseGVN;
44
45 // Arena we are currently building Nodes in
46 const uint Node::NotAMachineReg = 0xffff0000;
47
48 #ifndef PRODUCT
49 extern int nodes_created;
50 #endif
51 #ifdef __clang__
52 #pragma clang diagnostic push
53 #pragma GCC diagnostic ignored "-Wuninitialized"
54 #endif
55
56 #ifdef ASSERT
57
|
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 "libadt/vectset.hpp"
28 #include "memory/allocation.inline.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "opto/castnode.hpp"
31 #include "opto/cfgnode.hpp"
32 #include "opto/connode.hpp"
33 #include "opto/loopnode.hpp"
34 #include "opto/machnode.hpp"
35 #include "opto/matcher.hpp"
36 #include "opto/node.hpp"
37 #include "opto/opcodes.hpp"
38 #include "opto/regmask.hpp"
39 #include "opto/type.hpp"
40 #include "utilities/copy.hpp"
41 #include "utilities/macros.hpp"
42
43 class RegMask;
44 // #include "phase.hpp"
45 class PhaseTransform;
46 class PhaseGVN;
47
48 // Arena we are currently building Nodes in
49 const uint Node::NotAMachineReg = 0xffff0000;
50
51 #ifndef PRODUCT
52 extern int nodes_created;
53 #endif
54 #ifdef __clang__
55 #pragma clang diagnostic push
56 #pragma GCC diagnostic ignored "-Wuninitialized"
57 #endif
58
59 #ifdef ASSERT
60
|
481 // Set the new input pointer array
482 n->_in = (Node**)(((char*)n)+s);
483 // Cannot share the old output pointer array, so kill it
484 n->_out = NO_OUT_ARRAY;
485 // And reset the counters to 0
486 n->_outcnt = 0;
487 n->_outmax = 0;
488 // Unlock this guy, since he is not in any hash table.
489 debug_only(n->_hash_lock = 0);
490 // Walk the old node's input list to duplicate its edges
491 uint i;
492 for( i = 0; i < len(); i++ ) {
493 Node *x = in(i);
494 n->_in[i] = x;
495 if (x != NULL) x->add_out(n);
496 }
497 if (is_macro())
498 C->add_macro_node(n);
499 if (is_expensive())
500 C->add_expensive_node(n);
501 // If the cloned node is a range check dependent CastII, add it to the list.
502 CastIINode* cast = n->isa_CastII();
503 if (cast != NULL && cast->has_range_check()) {
504 C->add_range_check_cast(cast);
505 }
506 if (n->Opcode() == Op_Opaque4) {
507 C->add_opaque4_node(n);
508 }
509
510 n->set_idx(C->next_unique()); // Get new unique index as well
511 debug_only( n->verify_construction() );
512 NOT_PRODUCT(nodes_created++);
513 // Do not patch over the debug_idx of a clone, because it makes it
514 // impossible to break on the clone's moment of creation.
515 //debug_only( n->set_debug_idx( debug_idx() ) );
516
517 C->copy_node_notes_to(n, (Node*) this);
518
519 // MachNode clone
|
484 // Set the new input pointer array
485 n->_in = (Node**)(((char*)n)+s);
486 // Cannot share the old output pointer array, so kill it
487 n->_out = NO_OUT_ARRAY;
488 // And reset the counters to 0
489 n->_outcnt = 0;
490 n->_outmax = 0;
491 // Unlock this guy, since he is not in any hash table.
492 debug_only(n->_hash_lock = 0);
493 // Walk the old node's input list to duplicate its edges
494 uint i;
495 for( i = 0; i < len(); i++ ) {
496 Node *x = in(i);
497 n->_in[i] = x;
498 if (x != NULL) x->add_out(n);
499 }
500 if (is_macro())
501 C->add_macro_node(n);
502 if (is_expensive())
503 C->add_expensive_node(n);
504 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
505 bs->register_potential_barrier_node(n);
506 // If the cloned node is a range check dependent CastII, add it to the list.
507 CastIINode* cast = n->isa_CastII();
508 if (cast != NULL && cast->has_range_check()) {
509 C->add_range_check_cast(cast);
510 }
511 if (n->Opcode() == Op_Opaque4) {
512 C->add_opaque4_node(n);
513 }
514
515 n->set_idx(C->next_unique()); // Get new unique index as well
516 debug_only( n->verify_construction() );
517 NOT_PRODUCT(nodes_created++);
518 // Do not patch over the debug_idx of a clone, because it makes it
519 // impossible to break on the clone's moment of creation.
520 //debug_only( n->set_debug_idx( debug_idx() ) );
521
522 C->copy_node_notes_to(n, (Node*) this);
523
524 // MachNode clone
|
604 compile->node_arena()->Afree(this,node_size);
605 #endif
606 }
607 if (is_macro()) {
608 compile->remove_macro_node(this);
609 }
610 if (is_expensive()) {
611 compile->remove_expensive_node(this);
612 }
613 CastIINode* cast = isa_CastII();
614 if (cast != NULL && cast->has_range_check()) {
615 compile->remove_range_check_cast(cast);
616 }
617 if (Opcode() == Op_Opaque4) {
618 compile->remove_opaque4_node(this);
619 }
620
621 if (is_SafePoint()) {
622 as_SafePoint()->delete_replaced_nodes();
623 }
624 #ifdef ASSERT
625 // We will not actually delete the storage, but we'll make the node unusable.
626 *(address*)this = badAddress; // smash the C++ vtbl, probably
627 _in = _out = (Node**) badAddress;
628 _max = _cnt = _outmax = _outcnt = 0;
629 compile->remove_modified_node(this);
630 #endif
631 }
632
633 //------------------------------grow-------------------------------------------
634 // Grow the input array, making space for more edges
635 void Node::grow( uint len ) {
636 Arena* arena = Compile::current()->node_arena();
637 uint new_max = _max;
638 if( new_max == 0 ) {
639 _max = 4;
640 _in = (Node**)arena->Amalloc(4*sizeof(Node*));
641 Node** to = _in;
642 to[0] = NULL;
|
609 compile->node_arena()->Afree(this,node_size);
610 #endif
611 }
612 if (is_macro()) {
613 compile->remove_macro_node(this);
614 }
615 if (is_expensive()) {
616 compile->remove_expensive_node(this);
617 }
618 CastIINode* cast = isa_CastII();
619 if (cast != NULL && cast->has_range_check()) {
620 compile->remove_range_check_cast(cast);
621 }
622 if (Opcode() == Op_Opaque4) {
623 compile->remove_opaque4_node(this);
624 }
625
626 if (is_SafePoint()) {
627 as_SafePoint()->delete_replaced_nodes();
628 }
629 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
630 bs->unregister_potential_barrier_node(this);
631 #ifdef ASSERT
632 // We will not actually delete the storage, but we'll make the node unusable.
633 *(address*)this = badAddress; // smash the C++ vtbl, probably
634 _in = _out = (Node**) badAddress;
635 _max = _cnt = _outmax = _outcnt = 0;
636 compile->remove_modified_node(this);
637 #endif
638 }
639
640 //------------------------------grow-------------------------------------------
641 // Grow the input array, making space for more edges
642 void Node::grow( uint len ) {
643 Arena* arena = Compile::current()->node_arena();
644 uint new_max = _max;
645 if( new_max == 0 ) {
646 _max = 4;
647 _in = (Node**)arena->Amalloc(4*sizeof(Node*));
648 Node** to = _in;
649 to[0] = NULL;
|
1343 }
1344 } else { // (dead->outcnt() == 0)
1345 // Done with outputs.
1346 igvn->hash_delete(dead);
1347 igvn->_worklist.remove(dead);
1348 igvn->C->remove_modified_node(dead);
1349 igvn->set_type(dead, Type::TOP);
1350 if (dead->is_macro()) {
1351 igvn->C->remove_macro_node(dead);
1352 }
1353 if (dead->is_expensive()) {
1354 igvn->C->remove_expensive_node(dead);
1355 }
1356 CastIINode* cast = dead->isa_CastII();
1357 if (cast != NULL && cast->has_range_check()) {
1358 igvn->C->remove_range_check_cast(cast);
1359 }
1360 if (dead->Opcode() == Op_Opaque4) {
1361 igvn->C->remove_range_check_cast(dead);
1362 }
1363 igvn->C->record_dead_node(dead->_idx);
1364 // Kill all inputs to the dead guy
1365 for (uint i=0; i < dead->req(); i++) {
1366 Node *n = dead->in(i); // Get input to dead guy
1367 if (n != NULL && !n->is_top()) { // Input is valid?
1368 dead->set_req(i, top); // Smash input away
1369 if (n->outcnt() == 0) { // Input also goes dead?
1370 if (!n->is_Con())
1371 nstack.push(n); // Clear it out as well
1372 } else if (n->outcnt() == 1 &&
1373 n->has_special_unique_user()) {
1374 igvn->add_users_to_worklist( n );
1375 } else if (n->outcnt() <= 2 && n->is_Store()) {
1376 // Push store's uses on worklist to enable folding optimization for
1377 // store/store and store/load to the same address.
1378 // The restriction (outcnt() <= 2) is the same as in set_req_X()
1379 // and remove_globally_dead_node().
1380 igvn->add_users_to_worklist( n );
1381 }
1382 }
1383 }
1384 } // (dead->outcnt() == 0)
1385 } // while (nstack.size() > 0) for outputs
1386 return;
1387 }
1388
1389 //------------------------------remove_dead_region-----------------------------
1390 bool Node::remove_dead_region(PhaseGVN *phase, bool can_reshape) {
1391 Node *n = in(0);
1392 if( !n ) return false;
1393 // Lost control into this guy? I.e., it became unreachable?
1394 // Aggressively kill all unreachable code.
1395 if (can_reshape && n->is_top()) {
1396 kill_dead_code(this, phase->is_IterGVN());
1397 return false; // Node is dead.
1398 }
1399
|
1350 }
1351 } else { // (dead->outcnt() == 0)
1352 // Done with outputs.
1353 igvn->hash_delete(dead);
1354 igvn->_worklist.remove(dead);
1355 igvn->C->remove_modified_node(dead);
1356 igvn->set_type(dead, Type::TOP);
1357 if (dead->is_macro()) {
1358 igvn->C->remove_macro_node(dead);
1359 }
1360 if (dead->is_expensive()) {
1361 igvn->C->remove_expensive_node(dead);
1362 }
1363 CastIINode* cast = dead->isa_CastII();
1364 if (cast != NULL && cast->has_range_check()) {
1365 igvn->C->remove_range_check_cast(cast);
1366 }
1367 if (dead->Opcode() == Op_Opaque4) {
1368 igvn->C->remove_range_check_cast(dead);
1369 }
1370 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
1371 bs->unregister_potential_barrier_node(dead);
1372 igvn->C->record_dead_node(dead->_idx);
1373 // Kill all inputs to the dead guy
1374 for (uint i=0; i < dead->req(); i++) {
1375 Node *n = dead->in(i); // Get input to dead guy
1376 if (n != NULL && !n->is_top()) { // Input is valid?
1377 dead->set_req(i, top); // Smash input away
1378 if (n->outcnt() == 0) { // Input also goes dead?
1379 if (!n->is_Con())
1380 nstack.push(n); // Clear it out as well
1381 } else if (n->outcnt() == 1 &&
1382 n->has_special_unique_user()) {
1383 igvn->add_users_to_worklist( n );
1384 } else if (n->outcnt() <= 2 && n->is_Store()) {
1385 // Push store's uses on worklist to enable folding optimization for
1386 // store/store and store/load to the same address.
1387 // The restriction (outcnt() <= 2) is the same as in set_req_X()
1388 // and remove_globally_dead_node().
1389 igvn->add_users_to_worklist( n );
1390 } else {
1391 BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(igvn->_worklist, n);
1392 }
1393 }
1394 }
1395 } // (dead->outcnt() == 0)
1396 } // while (nstack.size() > 0) for outputs
1397 return;
1398 }
1399
1400 //------------------------------remove_dead_region-----------------------------
1401 bool Node::remove_dead_region(PhaseGVN *phase, bool can_reshape) {
1402 Node *n = in(0);
1403 if( !n ) return false;
1404 // Lost control into this guy? I.e., it became unreachable?
1405 // Aggressively kill all unreachable code.
1406 if (can_reshape && n->is_top()) {
1407 kill_dead_code(this, phase->is_IterGVN());
1408 return false; // Node is dead.
1409 }
1410
|