src/share/vm/opto/matcher.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8137160 Sdiff src/share/vm/opto

src/share/vm/opto/matcher.cpp

Print this page




 309   // to avoid false sharing if the corresponding mach node is not used.
 310   // The corresponding mach node is only used in rare cases for derived
 311   // pointers.
 312   Node* new_ideal_null = ConNode::make(TypePtr::NULL_PTR);
 313 
 314   // Swap out to old-space; emptying new-space
 315   Arena *old = C->node_arena()->move_contents(C->old_arena());
 316 
 317   // Save debug and profile information for nodes in old space:
 318   _old_node_note_array = C->node_note_array();
 319   if (_old_node_note_array != NULL) {
 320     C->set_node_note_array(new(C->comp_arena()) GrowableArray<Node_Notes*>
 321                            (C->comp_arena(), _old_node_note_array->length(),
 322                             0, NULL));
 323   }
 324 
 325   // Pre-size the new_node table to avoid the need for range checks.
 326   grow_new_node_array(C->unique());
 327 
 328   // Reset node counter so MachNodes start with _idx at 0
 329   int nodes = C->unique(); // save value
 330   C->set_unique(0);
 331   C->reset_dead_node_list();
 332 
 333   // Recursively match trees from old space into new space.
 334   // Correct leaves of new-space Nodes; they point to old-space.
 335   _visited.Clear();             // Clear visit bits for xform call
 336   C->set_cached_top_node(xform( C->top(), nodes ));
 337   if (!C->failing()) {
 338     Node* xroot =        xform( C->root(), 1 );
 339     if (xroot == NULL) {
 340       Matcher::soft_match_failure();  // recursive matching process failed
 341       C->record_method_not_compilable("instruction match failed");
 342     } else {
 343       // During matching shared constants were attached to C->root()
 344       // because xroot wasn't available yet, so transfer the uses to
 345       // the xroot.
 346       for( DUIterator_Fast jmax, j = C->root()->fast_outs(jmax); j < jmax; j++ ) {
 347         Node* n = C->root()->fast_out(j);
 348         if (C->node_arena()->contains(n)) {
 349           assert(n->in(0) == C->root(), "should be control user");
 350           n->set_req(0, xroot);
 351           --j;
 352           --jmax;
 353         }
 354       }
 355 
 356       // Generate new mach node for ConP #NULL


 984     }
 985     Node *parent() {
 986       pop();
 987       return node();
 988     }
 989     Node_State state() const {
 990       return (Node_State)index();
 991     }
 992     void set_state(Node_State ns) {
 993       set_index((uint)ns);
 994     }
 995 };
 996 
 997 
 998 //------------------------------xform------------------------------------------
 999 // Given a Node in old-space, Match him (Label/Reduce) to produce a machine
1000 // Node in new-space.  Given a new-space Node, recursively walk his children.
1001 Node *Matcher::transform( Node *n ) { ShouldNotCallThis(); return n; }
1002 Node *Matcher::xform( Node *n, int max_stack ) {
1003   // Use one stack to keep both: child's node/state and parent's node/index
1004   MStack mstack(max_stack * 2 * 2); // C->unique() * 2 * 2
1005   mstack.push(n, Visit, NULL, -1);  // set NULL as parent to indicate root
1006 
1007   while (mstack.is_nonempty()) {
1008     C->check_node_count(NodeLimitFudgeFactor, "too many nodes matching instructions");
1009     if (C->failing()) return NULL;
1010     n = mstack.node();          // Leave node on stack
1011     Node_State nstate = mstack.state();
1012     if (nstate == Visit) {
1013       mstack.set_state(Post_Visit);
1014       Node *oldn = n;
1015       // Old-space or new-space check
1016       if (!C->node_arena()->contains(n)) {
1017         // Old space!
1018         Node* m;
1019         if (has_new_node(n)) {  // Not yet Label/Reduced
1020           m = new_node(n);
1021         } else {
1022           if (!is_dontcare(n)) { // Matcher can match this guy
1023             // Calls match special.  They match alone with no children.
1024             // Their children, the incoming arguments, match normally.


2059     // ConvI2L operation for an array index on LP64
2060     // if the index value is positive.
2061     if (conv->Opcode() == Op_ConvI2L &&
2062         conv->as_Type()->type()->is_long()->_lo >= 0 &&
2063         // Are there other uses besides address expressions?
2064         !matcher->is_visited(conv)) {
2065       address_visited.set(conv->_idx); // Flag as address_visited
2066       mstack.push(conv->in(1), Pre_Visit);
2067     } else
2068 #endif
2069       mstack.push(conv, Pre_Visit);
2070     return true;
2071   }
2072   return false;
2073 }
2074 
2075 
2076 //------------------------------find_shared------------------------------------
2077 // Set bits if Node is shared or otherwise a root
2078 void Matcher::find_shared( Node *n ) {
2079   // Allocate stack of size C->unique() * 2 to avoid frequent realloc
2080   MStack mstack(C->live_nodes() * 2);
2081   // Mark nodes as address_visited if they are inputs to an address expression
2082   VectorSet address_visited(Thread::current()->resource_area());
2083   mstack.push(n, Visit);     // Don't need to pre-visit root node
2084   while (mstack.is_nonempty()) {
2085     n = mstack.node();       // Leave node on stack
2086     Node_State nstate = mstack.state();
2087     uint nop = n->Opcode();
2088     if (nstate == Pre_Visit) {
2089       if (address_visited.test(n->_idx)) { // Visited in address already?
2090         // Flag as visited and shared now.
2091         set_visited(n);
2092       }
2093       if (is_visited(n)) {   // Visited already?
2094         // Node is shared and has no reason to clone.  Flag it as shared.
2095         // This causes it to match into a register for the sharing.
2096         set_shared(n);       // Flag as shared and
2097         mstack.pop();        // remove node from stack
2098         continue;
2099       }




 309   // to avoid false sharing if the corresponding mach node is not used.
 310   // The corresponding mach node is only used in rare cases for derived
 311   // pointers.
 312   Node* new_ideal_null = ConNode::make(TypePtr::NULL_PTR);
 313 
 314   // Swap out to old-space; emptying new-space
 315   Arena *old = C->node_arena()->move_contents(C->old_arena());
 316 
 317   // Save debug and profile information for nodes in old space:
 318   _old_node_note_array = C->node_note_array();
 319   if (_old_node_note_array != NULL) {
 320     C->set_node_note_array(new(C->comp_arena()) GrowableArray<Node_Notes*>
 321                            (C->comp_arena(), _old_node_note_array->length(),
 322                             0, NULL));
 323   }
 324 
 325   // Pre-size the new_node table to avoid the need for range checks.
 326   grow_new_node_array(C->unique());
 327 
 328   // Reset node counter so MachNodes start with _idx at 0
 329   int live_nodes = C->live_nodes();
 330   C->set_unique(0);
 331   C->reset_dead_node_list();
 332 
 333   // Recursively match trees from old space into new space.
 334   // Correct leaves of new-space Nodes; they point to old-space.
 335   _visited.Clear();             // Clear visit bits for xform call
 336   C->set_cached_top_node(xform( C->top(), live_nodes ));
 337   if (!C->failing()) {
 338     Node* xroot =        xform( C->root(), 1 );
 339     if (xroot == NULL) {
 340       Matcher::soft_match_failure();  // recursive matching process failed
 341       C->record_method_not_compilable("instruction match failed");
 342     } else {
 343       // During matching shared constants were attached to C->root()
 344       // because xroot wasn't available yet, so transfer the uses to
 345       // the xroot.
 346       for( DUIterator_Fast jmax, j = C->root()->fast_outs(jmax); j < jmax; j++ ) {
 347         Node* n = C->root()->fast_out(j);
 348         if (C->node_arena()->contains(n)) {
 349           assert(n->in(0) == C->root(), "should be control user");
 350           n->set_req(0, xroot);
 351           --j;
 352           --jmax;
 353         }
 354       }
 355 
 356       // Generate new mach node for ConP #NULL


 984     }
 985     Node *parent() {
 986       pop();
 987       return node();
 988     }
 989     Node_State state() const {
 990       return (Node_State)index();
 991     }
 992     void set_state(Node_State ns) {
 993       set_index((uint)ns);
 994     }
 995 };
 996 
 997 
 998 //------------------------------xform------------------------------------------
 999 // Given a Node in old-space, Match him (Label/Reduce) to produce a machine
1000 // Node in new-space.  Given a new-space Node, recursively walk his children.
1001 Node *Matcher::transform( Node *n ) { ShouldNotCallThis(); return n; }
1002 Node *Matcher::xform( Node *n, int max_stack ) {
1003   // Use one stack to keep both: child's node/state and parent's node/index
1004   MStack mstack(max_stack * 2 * 2); // usually: C->live_nodes() * 2 * 2
1005   mstack.push(n, Visit, NULL, -1);  // set NULL as parent to indicate root
1006 
1007   while (mstack.is_nonempty()) {
1008     C->check_node_count(NodeLimitFudgeFactor, "too many nodes matching instructions");
1009     if (C->failing()) return NULL;
1010     n = mstack.node();          // Leave node on stack
1011     Node_State nstate = mstack.state();
1012     if (nstate == Visit) {
1013       mstack.set_state(Post_Visit);
1014       Node *oldn = n;
1015       // Old-space or new-space check
1016       if (!C->node_arena()->contains(n)) {
1017         // Old space!
1018         Node* m;
1019         if (has_new_node(n)) {  // Not yet Label/Reduced
1020           m = new_node(n);
1021         } else {
1022           if (!is_dontcare(n)) { // Matcher can match this guy
1023             // Calls match special.  They match alone with no children.
1024             // Their children, the incoming arguments, match normally.


2059     // ConvI2L operation for an array index on LP64
2060     // if the index value is positive.
2061     if (conv->Opcode() == Op_ConvI2L &&
2062         conv->as_Type()->type()->is_long()->_lo >= 0 &&
2063         // Are there other uses besides address expressions?
2064         !matcher->is_visited(conv)) {
2065       address_visited.set(conv->_idx); // Flag as address_visited
2066       mstack.push(conv->in(1), Pre_Visit);
2067     } else
2068 #endif
2069       mstack.push(conv, Pre_Visit);
2070     return true;
2071   }
2072   return false;
2073 }
2074 
2075 
2076 //------------------------------find_shared------------------------------------
2077 // Set bits if Node is shared or otherwise a root
2078 void Matcher::find_shared( Node *n ) {
2079   // Allocate stack of size C->live_nodes() * 2 to avoid frequent realloc
2080   MStack mstack(C->live_nodes() * 2);
2081   // Mark nodes as address_visited if they are inputs to an address expression
2082   VectorSet address_visited(Thread::current()->resource_area());
2083   mstack.push(n, Visit);     // Don't need to pre-visit root node
2084   while (mstack.is_nonempty()) {
2085     n = mstack.node();       // Leave node on stack
2086     Node_State nstate = mstack.state();
2087     uint nop = n->Opcode();
2088     if (nstate == Pre_Visit) {
2089       if (address_visited.test(n->_idx)) { // Visited in address already?
2090         // Flag as visited and shared now.
2091         set_visited(n);
2092       }
2093       if (is_visited(n)) {   // Visited already?
2094         // Node is shared and has no reason to clone.  Flag it as shared.
2095         // This causes it to match into a register for the sharing.
2096         set_shared(n);       // Flag as shared and
2097         mstack.pop();        // remove node from stack
2098         continue;
2099       }


src/share/vm/opto/matcher.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File