8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "libadt/vectset.hpp"
27 #include "memory/allocation.inline.hpp"
28 #include "opto/cfgnode.hpp"
29 #include "opto/connode.hpp"
30 #include "opto/loopnode.hpp"
31 #include "opto/machnode.hpp"
32 #include "opto/matcher.hpp"
33 #include "opto/node.hpp"
34 #include "opto/opcodes.hpp"
35 #include "opto/regmask.hpp"
36 #include "opto/type.hpp"
37 #include "utilities/copy.hpp"
38
39 class RegMask;
40 // #include "phase.hpp"
41 class PhaseTransform;
42 class PhaseGVN;
43
44 // Arena we are currently building Nodes in
45 const uint Node::NotAMachineReg = 0xffff0000;
46
47 #ifndef PRODUCT
499 // Set the new input pointer array
500 n->_in = (Node**)(((char*)n)+s);
501 // Cannot share the old output pointer array, so kill it
502 n->_out = NO_OUT_ARRAY;
503 // And reset the counters to 0
504 n->_outcnt = 0;
505 n->_outmax = 0;
506 // Unlock this guy, since he is not in any hash table.
507 debug_only(n->_hash_lock = 0);
508 // Walk the old node's input list to duplicate its edges
509 uint i;
510 for( i = 0; i < len(); i++ ) {
511 Node *x = in(i);
512 n->_in[i] = x;
513 if (x != NULL) x->add_out(n);
514 }
515 if (is_macro())
516 C->add_macro_node(n);
517 if (is_expensive())
518 C->add_expensive_node(n);
519
520 n->set_idx(C->next_unique()); // Get new unique index as well
521 debug_only( n->verify_construction() );
522 NOT_PRODUCT(nodes_created++);
523 // Do not patch over the debug_idx of a clone, because it makes it
524 // impossible to break on the clone's moment of creation.
525 //debug_only( n->set_debug_idx( debug_idx() ) );
526
527 C->copy_node_notes_to(n, (Node*) this);
528
529 // MachNode clone
530 uint nopnds;
531 if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
532 MachNode *mach = n->as_Mach();
533 MachNode *mthis = this->as_Mach();
534 // Get address of _opnd_array.
535 // It should be the same offset since it is the clone of this node.
536 MachOper **from = mthis->_opnds;
537 MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
538 pointer_delta((const void*)from,
627 #ifdef ASSERT
628 if( edge_end == compile->node_arena()->hwm() )
629 reclaim_in += edge_size;
630 #endif
631 compile->node_arena()->Afree(_in,edge_size);
632
633 // Free just the object
634 #ifdef ASSERT
635 if( ((char*)this) + node_size == compile->node_arena()->hwm() )
636 reclaim_node+= node_size;
637 #else
638 compile->node_arena()->Afree(this,node_size);
639 #endif
640 }
641 if (is_macro()) {
642 compile->remove_macro_node(this);
643 }
644 if (is_expensive()) {
645 compile->remove_expensive_node(this);
646 }
647 if (is_SafePoint()) {
648 as_SafePoint()->delete_replaced_nodes();
649 }
650 #ifdef ASSERT
651 // We will not actually delete the storage, but we'll make the node unusable.
652 *(address*)this = badAddress; // smash the C++ vtbl, probably
653 _in = _out = (Node**) badAddress;
654 _max = _cnt = _outmax = _outcnt = 0;
655 compile->remove_modified_node(this);
656 #endif
657 }
658
659 //------------------------------grow-------------------------------------------
660 // Grow the input array, making space for more edges
661 void Node::grow( uint len ) {
662 Arena* arena = Compile::current()->node_arena();
663 uint new_max = _max;
664 if( new_max == 0 ) {
665 _max = 4;
666 _in = (Node**)arena->Amalloc(4*sizeof(Node*));
1362 nstack.push(use);
1363 } else {
1364 igvn->_worklist.push(use);
1365 }
1366 }
1367 // Refresh the iterator, since any number of kills might have happened.
1368 k = dead->last_outs(kmin);
1369 }
1370 } else { // (dead->outcnt() == 0)
1371 // Done with outputs.
1372 igvn->hash_delete(dead);
1373 igvn->_worklist.remove(dead);
1374 igvn->C->remove_modified_node(dead);
1375 igvn->set_type(dead, Type::TOP);
1376 if (dead->is_macro()) {
1377 igvn->C->remove_macro_node(dead);
1378 }
1379 if (dead->is_expensive()) {
1380 igvn->C->remove_expensive_node(dead);
1381 }
1382 igvn->C->record_dead_node(dead->_idx);
1383 // Kill all inputs to the dead guy
1384 for (uint i=0; i < dead->req(); i++) {
1385 Node *n = dead->in(i); // Get input to dead guy
1386 if (n != NULL && !n->is_top()) { // Input is valid?
1387 dead->set_req(i, top); // Smash input away
1388 if (n->outcnt() == 0) { // Input also goes dead?
1389 if (!n->is_Con())
1390 nstack.push(n); // Clear it out as well
1391 } else if (n->outcnt() == 1 &&
1392 n->has_special_unique_user()) {
1393 igvn->add_users_to_worklist( n );
1394 } else if (n->outcnt() <= 2 && n->is_Store()) {
1395 // Push store's uses on worklist to enable folding optimization for
1396 // store/store and store/load to the same address.
1397 // The restriction (outcnt() <= 2) is the same as in set_req_X()
1398 // and remove_globally_dead_node().
1399 igvn->add_users_to_worklist( n );
1400 }
1401 }
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "libadt/vectset.hpp"
27 #include "memory/allocation.inline.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
500 // Set the new input pointer array
501 n->_in = (Node**)(((char*)n)+s);
502 // Cannot share the old output pointer array, so kill it
503 n->_out = NO_OUT_ARRAY;
504 // And reset the counters to 0
505 n->_outcnt = 0;
506 n->_outmax = 0;
507 // Unlock this guy, since he is not in any hash table.
508 debug_only(n->_hash_lock = 0);
509 // Walk the old node's input list to duplicate its edges
510 uint i;
511 for( i = 0; i < len(); i++ ) {
512 Node *x = in(i);
513 n->_in[i] = x;
514 if (x != NULL) x->add_out(n);
515 }
516 if (is_macro())
517 C->add_macro_node(n);
518 if (is_expensive())
519 C->add_expensive_node(n);
520 #ifdef _LP64
521 // If the cloned node is a range check dependent CastII, add it to the list.
522 CastIINode* cast = n->isa_CastII();
523 if (cast != NULL && cast->has_range_check()) {
524 C->add_range_check_cast(cast);
525 }
526 #endif
527
528 n->set_idx(C->next_unique()); // Get new unique index as well
529 debug_only( n->verify_construction() );
530 NOT_PRODUCT(nodes_created++);
531 // Do not patch over the debug_idx of a clone, because it makes it
532 // impossible to break on the clone's moment of creation.
533 //debug_only( n->set_debug_idx( debug_idx() ) );
534
535 C->copy_node_notes_to(n, (Node*) this);
536
537 // MachNode clone
538 uint nopnds;
539 if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
540 MachNode *mach = n->as_Mach();
541 MachNode *mthis = this->as_Mach();
542 // Get address of _opnd_array.
543 // It should be the same offset since it is the clone of this node.
544 MachOper **from = mthis->_opnds;
545 MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
546 pointer_delta((const void*)from,
635 #ifdef ASSERT
636 if( edge_end == compile->node_arena()->hwm() )
637 reclaim_in += edge_size;
638 #endif
639 compile->node_arena()->Afree(_in,edge_size);
640
641 // Free just the object
642 #ifdef ASSERT
643 if( ((char*)this) + node_size == compile->node_arena()->hwm() )
644 reclaim_node+= node_size;
645 #else
646 compile->node_arena()->Afree(this,node_size);
647 #endif
648 }
649 if (is_macro()) {
650 compile->remove_macro_node(this);
651 }
652 if (is_expensive()) {
653 compile->remove_expensive_node(this);
654 }
655 #ifdef _LP64
656 CastIINode* cast = isa_CastII();
657 if (cast != NULL && cast->has_range_check()) {
658 compile->remove_range_check_cast(cast);
659 }
660 #endif
661
662 if (is_SafePoint()) {
663 as_SafePoint()->delete_replaced_nodes();
664 }
665 #ifdef ASSERT
666 // We will not actually delete the storage, but we'll make the node unusable.
667 *(address*)this = badAddress; // smash the C++ vtbl, probably
668 _in = _out = (Node**) badAddress;
669 _max = _cnt = _outmax = _outcnt = 0;
670 compile->remove_modified_node(this);
671 #endif
672 }
673
674 //------------------------------grow-------------------------------------------
675 // Grow the input array, making space for more edges
676 void Node::grow( uint len ) {
677 Arena* arena = Compile::current()->node_arena();
678 uint new_max = _max;
679 if( new_max == 0 ) {
680 _max = 4;
681 _in = (Node**)arena->Amalloc(4*sizeof(Node*));
1377 nstack.push(use);
1378 } else {
1379 igvn->_worklist.push(use);
1380 }
1381 }
1382 // Refresh the iterator, since any number of kills might have happened.
1383 k = dead->last_outs(kmin);
1384 }
1385 } else { // (dead->outcnt() == 0)
1386 // Done with outputs.
1387 igvn->hash_delete(dead);
1388 igvn->_worklist.remove(dead);
1389 igvn->C->remove_modified_node(dead);
1390 igvn->set_type(dead, Type::TOP);
1391 if (dead->is_macro()) {
1392 igvn->C->remove_macro_node(dead);
1393 }
1394 if (dead->is_expensive()) {
1395 igvn->C->remove_expensive_node(dead);
1396 }
1397 #ifdef _LP64
1398 CastIINode* cast = dead->isa_CastII();
1399 if (cast != NULL && cast->has_range_check()) {
1400 igvn->C->remove_range_check_cast(cast);
1401 }
1402 #endif
1403 igvn->C->record_dead_node(dead->_idx);
1404 // Kill all inputs to the dead guy
1405 for (uint i=0; i < dead->req(); i++) {
1406 Node *n = dead->in(i); // Get input to dead guy
1407 if (n != NULL && !n->is_top()) { // Input is valid?
1408 dead->set_req(i, top); // Smash input away
1409 if (n->outcnt() == 0) { // Input also goes dead?
1410 if (!n->is_Con())
1411 nstack.push(n); // Clear it out as well
1412 } else if (n->outcnt() == 1 &&
1413 n->has_special_unique_user()) {
1414 igvn->add_users_to_worklist( n );
1415 } else if (n->outcnt() <= 2 && n->is_Store()) {
1416 // Push store's uses on worklist to enable folding optimization for
1417 // store/store and store/load to the same address.
1418 // The restriction (outcnt() <= 2) is the same as in set_req_X()
1419 // and remove_globally_dead_node().
1420 igvn->add_users_to_worklist( n );
1421 }
1422 }
|