559 }
560
561 //---------------------------setup_is_top--------------------------------------
562 // Call this when changing the top node, to reassert the invariants
563 // required by Node::is_top. See Compile::set_cached_top_node.
564 void Node::setup_is_top() {
565 if (this == (Node*)Compile::current()->top()) {
566 // This node has just become top. Kill its out array.
567 _outcnt = _outmax = 0;
568 _out = NULL; // marker value for top
569 assert(is_top(), "must be top");
570 } else {
571 if (_out == NULL) _out = NO_OUT_ARRAY;
572 assert(!is_top(), "must not be top");
573 }
574 }
575
576
577 //------------------------------~Node------------------------------------------
578 // Fancy destructor; eagerly attempt to reclaim Node numberings and storage
579 extern int reclaim_idx ;
580 extern int reclaim_in ;
581 extern int reclaim_node;
582 void Node::destruct() {
583 // Eagerly reclaim unique Node numberings
584 Compile* compile = Compile::current();
585 if ((uint)_idx+1 == compile->unique()) {
586 compile->set_unique(compile->unique()-1);
587 #ifdef ASSERT
588 reclaim_idx++;
589 #endif
590 }
591 // Clear debug info:
592 Node_Notes* nn = compile->node_notes_at(_idx);
593 if (nn != NULL) nn->clear();
594 // Walk the input array, freeing the corresponding output edges
595 _cnt = _max; // forget req/prec distinction
596 uint i;
597 for( i = 0; i < _max; i++ ) {
598 set_req(i, NULL);
599 //assert(def->out(def->outcnt()-1) == (Node *)this,"bad def-use hacking in reclaim");
600 }
601 assert(outcnt() == 0, "deleting a node must not leave a dangling use");
602 // See if the input array was allocated just prior to the object
603 int edge_size = _max*sizeof(void*);
604 int out_edge_size = _outmax*sizeof(void*);
605 char *edge_end = ((char*)_in) + edge_size;
606 char *out_array = (char*)(_out == NO_OUT_ARRAY? NULL: _out);
607 char *out_edge_end = out_array + out_edge_size;
608 int node_size = size_of();
609
610 // Free the output edge array
611 if (out_edge_size > 0) {
612 #ifdef ASSERT
613 if( out_edge_end == compile->node_arena()->hwm() )
614 reclaim_in += out_edge_size; // count reclaimed out edges with in edges
615 #endif
616 compile->node_arena()->Afree(out_array, out_edge_size);
617 }
618
619 // Free the input edge array and the node itself
620 if( edge_end == (char*)this ) {
621 #ifdef ASSERT
622 if( edge_end+node_size == compile->node_arena()->hwm() ) {
623 reclaim_in += edge_size;
624 reclaim_node+= node_size;
625 }
626 #else
627 // It was; free the input array and object all in one hit
628 compile->node_arena()->Afree(_in,edge_size+node_size);
629 #endif
630 } else {
631
632 // Free just the input array
633 #ifdef ASSERT
634 if( edge_end == compile->node_arena()->hwm() )
635 reclaim_in += edge_size;
636 #endif
637 compile->node_arena()->Afree(_in,edge_size);
638
639 // Free just the object
640 #ifdef ASSERT
641 if( ((char*)this) + node_size == compile->node_arena()->hwm() )
642 reclaim_node+= node_size;
643 #else
644 compile->node_arena()->Afree(this,node_size);
645 #endif
646 }
647 if (is_macro()) {
648 compile->remove_macro_node(this);
649 }
650 if (is_expensive()) {
651 compile->remove_expensive_node(this);
652 }
653 CastIINode* cast = isa_CastII();
654 if (cast != NULL && cast->has_range_check()) {
655 compile->remove_range_check_cast(cast);
656 }
657
658 if (is_SafePoint()) {
659 as_SafePoint()->delete_replaced_nodes();
660 }
661 #ifdef ASSERT
662 // We will not actually delete the storage, but we'll make the node unusable.
663 *(address*)this = badAddress; // smash the C++ vtbl, probably
|
559 }
560
561 //---------------------------setup_is_top--------------------------------------
562 // Call this when changing the top node, to reassert the invariants
563 // required by Node::is_top. See Compile::set_cached_top_node.
564 void Node::setup_is_top() {
565 if (this == (Node*)Compile::current()->top()) {
566 // This node has just become top. Kill its out array.
567 _outcnt = _outmax = 0;
568 _out = NULL; // marker value for top
569 assert(is_top(), "must be top");
570 } else {
571 if (_out == NULL) _out = NO_OUT_ARRAY;
572 assert(!is_top(), "must not be top");
573 }
574 }
575
576
577 //------------------------------~Node------------------------------------------
578 // Fancy destructor; eagerly attempt to reclaim Node numberings and storage
579 void Node::destruct() {
580 // Eagerly reclaim unique Node numberings
581 Compile* compile = Compile::current();
582 if ((uint)_idx+1 == compile->unique()) {
583 compile->set_unique(compile->unique()-1);
584 }
585 // Clear debug info:
586 Node_Notes* nn = compile->node_notes_at(_idx);
587 if (nn != NULL) nn->clear();
588 // Walk the input array, freeing the corresponding output edges
589 _cnt = _max; // forget req/prec distinction
590 uint i;
591 for( i = 0; i < _max; i++ ) {
592 set_req(i, NULL);
593 //assert(def->out(def->outcnt()-1) == (Node *)this,"bad def-use hacking in reclaim");
594 }
595 assert(outcnt() == 0, "deleting a node must not leave a dangling use");
596 // See if the input array was allocated just prior to the object
597 int edge_size = _max*sizeof(void*);
598 int out_edge_size = _outmax*sizeof(void*);
599 char *edge_end = ((char*)_in) + edge_size;
600 char *out_array = (char*)(_out == NO_OUT_ARRAY? NULL: _out);
601 int node_size = size_of();
602
603 // Free the output edge array
604 if (out_edge_size > 0) {
605 compile->node_arena()->Afree(out_array, out_edge_size);
606 }
607
608 // Free the input edge array and the node itself
609 if( edge_end == (char*)this ) {
610 // It was; free the input array and object all in one hit
611 #ifndef ASSERT
612 compile->node_arena()->Afree(_in,edge_size+node_size);
613 #endif
614 } else {
615 // Free just the input array
616 compile->node_arena()->Afree(_in,edge_size);
617
618 // Free just the object
619 #ifndef ASSERT
620 compile->node_arena()->Afree(this,node_size);
621 #endif
622 }
623 if (is_macro()) {
624 compile->remove_macro_node(this);
625 }
626 if (is_expensive()) {
627 compile->remove_expensive_node(this);
628 }
629 CastIINode* cast = isa_CastII();
630 if (cast != NULL && cast->has_range_check()) {
631 compile->remove_range_check_cast(cast);
632 }
633
634 if (is_SafePoint()) {
635 as_SafePoint()->delete_replaced_nodes();
636 }
637 #ifdef ASSERT
638 // We will not actually delete the storage, but we'll make the node unusable.
639 *(address*)this = badAddress; // smash the C++ vtbl, probably
|