376 Node *x = new (C) GotoNode(NULL);
377 x->init_req(0, x);
378 _goto = matcher.match_tree(x);
379 assert(_goto != NULL, "");
380 _goto->set_req(0,_goto);
381
382 // Build the CFG in Reverse Post Order
383 _number_of_blocks = build_cfg();
384 _root_block = get_block_for_node(_root);
385 }
386
387 // Build a proper looking CFG. Make every block begin with either a StartNode
388 // or a RegionNode. Make every block end with either a Goto, If or Return.
389 // The RootNode both starts and ends it's own block. Do this with a recursive
390 // backwards walk over the control edges.
391 uint PhaseCFG::build_cfg() {
392 Arena *a = Thread::current()->resource_area();
393 VectorSet visited(a);
394
395 // Allocate stack with enough space to avoid frequent realloc
396 Node_Stack nstack(a, C->unique() >> 1);
397 nstack.push(_root, 0);
398 uint sum = 0; // Counter for blocks
399
400 while (nstack.is_nonempty()) {
401 // node and in's index from stack's top
402 // 'np' is _root (see above) or RegionNode, StartNode: we push on stack
403 // only nodes which point to the start of basic block (see below).
404 Node *np = nstack.node();
405 // idx > 0, except for the first node (_root) pushed on stack
406 // at the beginning when idx == 0.
407 // We will use the condition (idx == 0) later to end the build.
408 uint idx = nstack.index();
409 Node *proj = np->in(idx);
410 const Node *x = proj->is_block_proj();
411 // Does the block end with a proper block-ending Node? One of Return,
412 // If or Goto? (This check should be done for visited nodes also).
413 if (x == NULL) { // Does not end right...
414 Node *g = _goto->clone(); // Force it to end in a Goto
415 g->set_req(0, proj);
416 np->set_req(idx, g);
|
376 Node *x = new (C) GotoNode(NULL);
377 x->init_req(0, x);
378 _goto = matcher.match_tree(x);
379 assert(_goto != NULL, "");
380 _goto->set_req(0,_goto);
381
382 // Build the CFG in Reverse Post Order
383 _number_of_blocks = build_cfg();
384 _root_block = get_block_for_node(_root);
385 }
386
387 // Build a proper looking CFG. Make every block begin with either a StartNode
388 // or a RegionNode. Make every block end with either a Goto, If or Return.
389 // The RootNode both starts and ends it's own block. Do this with a recursive
390 // backwards walk over the control edges.
391 uint PhaseCFG::build_cfg() {
392 Arena *a = Thread::current()->resource_area();
393 VectorSet visited(a);
394
395 // Allocate stack with enough space to avoid frequent realloc
396 Node_Stack nstack(a, C->live_nodes() >> 1);
397 nstack.push(_root, 0);
398 uint sum = 0; // Counter for blocks
399
400 while (nstack.is_nonempty()) {
401 // node and in's index from stack's top
402 // 'np' is _root (see above) or RegionNode, StartNode: we push on stack
403 // only nodes which point to the start of basic block (see below).
404 Node *np = nstack.node();
405 // idx > 0, except for the first node (_root) pushed on stack
406 // at the beginning when idx == 0.
407 // We will use the condition (idx == 0) later to end the build.
408 uint idx = nstack.index();
409 Node *proj = np->in(idx);
410 const Node *x = proj->is_block_proj();
411 // Does the block end with a proper block-ending Node? One of Return,
412 // If or Goto? (This check should be done for visited nodes also).
413 if (x == NULL) { // Does not end right...
414 Node *g = _goto->clone(); // Force it to end in a Goto
415 g->set_req(0, proj);
416 np->set_req(idx, g);
|