Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/parse1.cpp @ 2385:0e3ed5a14f73
Merge
author | jcoomes |
---|---|
date | Thu, 24 Mar 2011 23:04:36 -0700 |
parents | 9dc311b8473e |
children | 1d1603768966 |
comparison
equal
deleted
inserted
replaced
2381:f195ebb181b8 | 2385:0e3ed5a14f73 |
---|---|
635 if (block->is_loop_head() || block->is_handler() || has_irreducible && !block->is_ready()) { | 635 if (block->is_loop_head() || block->is_handler() || has_irreducible && !block->is_ready()) { |
636 // Not all preds have been parsed. We must build phis everywhere. | 636 // Not all preds have been parsed. We must build phis everywhere. |
637 // (Note that dead locals do not get phis built, ever.) | 637 // (Note that dead locals do not get phis built, ever.) |
638 ensure_phis_everywhere(); | 638 ensure_phis_everywhere(); |
639 | 639 |
640 if (block->is_SEL_head() && | |
641 UseLoopPredicate) { | |
642 // Add predicate to single entry (not irreducible) loop head. | |
643 assert(!block->has_merged_backedge(), "only entry paths should be merged for now"); | |
644 // Need correct bci for predicate. | |
645 // It is fine to set it here since do_one_block() will set it anyway. | |
646 set_parse_bci(block->start()); | |
647 add_predicate(); | |
648 // Add new region for back branches. | |
649 int edges = block->pred_count() - block->preds_parsed() + 1; // +1 for original region | |
650 RegionNode *r = new (C, edges+1) RegionNode(edges+1); | |
651 _gvn.set_type(r, Type::CONTROL); | |
652 record_for_igvn(r); | |
653 r->init_req(edges, control()); | |
654 set_control(r); | |
655 // Add new phis. | |
656 ensure_phis_everywhere(); | |
657 } | |
658 | |
640 // Leave behind an undisturbed copy of the map, for future merges. | 659 // Leave behind an undisturbed copy of the map, for future merges. |
641 set_map(clone_map()); | 660 set_map(clone_map()); |
642 } | 661 } |
643 | 662 |
644 if (control()->is_Region() && !block->is_loop_head() && !has_irreducible && !block->is_handler()) { | 663 if (control()->is_Region() && !block->is_loop_head() && !has_irreducible && !block->is_handler()) { |
1111 _flow = outer->flow()->rpo_at(rpo); | 1130 _flow = outer->flow()->rpo_at(rpo); |
1112 _pred_count = 0; | 1131 _pred_count = 0; |
1113 _preds_parsed = 0; | 1132 _preds_parsed = 0; |
1114 _count = 0; | 1133 _count = 0; |
1115 assert(pred_count() == 0 && preds_parsed() == 0, "sanity"); | 1134 assert(pred_count() == 0 && preds_parsed() == 0, "sanity"); |
1116 assert(!(is_merged() || is_parsed() || is_handler()), "sanity"); | 1135 assert(!(is_merged() || is_parsed() || is_handler() || has_merged_backedge()), "sanity"); |
1117 assert(_live_locals.size() == 0, "sanity"); | 1136 assert(_live_locals.size() == 0, "sanity"); |
1118 | 1137 |
1119 // entry point has additional predecessor | 1138 // entry point has additional predecessor |
1120 if (flow()->is_start()) _pred_count++; | 1139 if (flow()->is_start()) _pred_count++; |
1121 assert(flow()->is_start() == (this == outer->start_block()), ""); | 1140 assert(flow()->is_start() == (this == outer->start_block()), ""); |
1348 | 1367 |
1349 // Learn the current bci from the iterator: | 1368 // Learn the current bci from the iterator: |
1350 set_parse_bci(iter().cur_bci()); | 1369 set_parse_bci(iter().cur_bci()); |
1351 | 1370 |
1352 if (bci() == block()->limit()) { | 1371 if (bci() == block()->limit()) { |
1353 // insert a predicate if it falls through to a loop head block | |
1354 if (should_add_predicate(bci())){ | |
1355 add_predicate(); | |
1356 } | |
1357 // Do not walk into the next block until directed by do_all_blocks. | 1372 // Do not walk into the next block until directed by do_all_blocks. |
1358 merge(bci()); | 1373 merge(bci()); |
1359 break; | 1374 break; |
1360 } | 1375 } |
1361 assert(bci() < block()->limit(), "bci still in block"); | 1376 assert(bci() < block()->limit(), "bci still in block"); |
1496 // which must not be allowed into this block's map.) | 1511 // which must not be allowed into this block's map.) |
1497 if (pnum > PhiNode::Input // Known multiple inputs. | 1512 if (pnum > PhiNode::Input // Known multiple inputs. |
1498 || target->is_handler() // These have unpredictable inputs. | 1513 || target->is_handler() // These have unpredictable inputs. |
1499 || target->is_loop_head() // Known multiple inputs | 1514 || target->is_loop_head() // Known multiple inputs |
1500 || control()->is_Region()) { // We must hide this guy. | 1515 || control()->is_Region()) { // We must hide this guy. |
1516 | |
1517 int current_bci = bci(); | |
1518 set_parse_bci(target->start()); // Set target bci | |
1519 if (target->is_SEL_head()) { | |
1520 DEBUG_ONLY( target->mark_merged_backedge(block()); ) | |
1521 if (target->start() == 0) { | |
1522 // Add loop predicate for the special case when | |
1523 // there are backbranches to the method entry. | |
1524 add_predicate(); | |
1525 } | |
1526 } | |
1501 // Add a Region to start the new basic block. Phis will be added | 1527 // Add a Region to start the new basic block. Phis will be added |
1502 // later lazily. | 1528 // later lazily. |
1503 int edges = target->pred_count(); | 1529 int edges = target->pred_count(); |
1504 if (edges < pnum) edges = pnum; // might be a new path! | 1530 if (edges < pnum) edges = pnum; // might be a new path! |
1505 Node *r = new (C, edges+1) RegionNode(edges+1); | 1531 RegionNode *r = new (C, edges+1) RegionNode(edges+1); |
1506 gvn().set_type(r, Type::CONTROL); | 1532 gvn().set_type(r, Type::CONTROL); |
1507 record_for_igvn(r); | 1533 record_for_igvn(r); |
1508 // zap all inputs to NULL for debugging (done in Node(uint) constructor) | 1534 // zap all inputs to NULL for debugging (done in Node(uint) constructor) |
1509 // for (int j = 1; j < edges+1; j++) { r->init_req(j, NULL); } | 1535 // for (int j = 1; j < edges+1; j++) { r->init_req(j, NULL); } |
1510 r->init_req(pnum, control()); | 1536 r->init_req(pnum, control()); |
1511 set_control(r); | 1537 set_control(r); |
1538 set_parse_bci(current_bci); // Restore bci | |
1512 } | 1539 } |
1513 | 1540 |
1514 // Convert the existing Parser mapping into a mapping at this bci. | 1541 // Convert the existing Parser mapping into a mapping at this bci. |
1515 store_state_to(target); | 1542 store_state_to(target); |
1516 assert(target->is_merged(), "do not come here twice"); | 1543 assert(target->is_merged(), "do not come here twice"); |
1517 | 1544 |
1518 } else { // Prior mapping at this bci | 1545 } else { // Prior mapping at this bci |
1519 if (TraceOptoParse) { tty->print(" with previous state"); } | 1546 if (TraceOptoParse) { tty->print(" with previous state"); } |
1520 | 1547 #ifdef ASSERT |
1548 if (target->is_SEL_head()) { | |
1549 target->mark_merged_backedge(block()); | |
1550 } | |
1551 #endif | |
1521 // We must not manufacture more phis if the target is already parsed. | 1552 // We must not manufacture more phis if the target is already parsed. |
1522 bool nophi = target->is_parsed(); | 1553 bool nophi = target->is_parsed(); |
1523 | 1554 |
1524 SafePointNode* newin = map();// Hang on to incoming mapping | 1555 SafePointNode* newin = map();// Hang on to incoming mapping |
1525 Block* save_block = block(); // Hang on to incoming block; | 1556 Block* save_block = block(); // Hang on to incoming block; |
2052 assert(C->root() != NULL, "Expect parse is still valid"); | 2083 assert(C->root() != NULL, "Expect parse is still valid"); |
2053 C->root()->add_prec(transformed_sfpnt); | 2084 C->root()->add_prec(transformed_sfpnt); |
2054 } | 2085 } |
2055 } | 2086 } |
2056 | 2087 |
2057 //------------------------------should_add_predicate-------------------------- | |
2058 bool Parse::should_add_predicate(int target_bci) { | |
2059 if (!UseLoopPredicate) return false; | |
2060 Block* target = successor_for_bci(target_bci); | |
2061 if (target != NULL && | |
2062 target->is_loop_head() && | |
2063 block()->rpo() < target->rpo()) { | |
2064 return true; | |
2065 } | |
2066 return false; | |
2067 } | |
2068 | |
2069 //------------------------------add_predicate--------------------------------- | |
2070 void Parse::add_predicate() { | |
2071 assert(UseLoopPredicate,"use only for loop predicate"); | |
2072 Node *cont = _gvn.intcon(1); | |
2073 Node* opq = _gvn.transform(new (C, 2) Opaque1Node(C, cont)); | |
2074 Node *bol = _gvn.transform(new (C, 2) Conv2BNode(opq)); | |
2075 IfNode* iff = create_and_map_if(control(), bol, PROB_MAX, COUNT_UNKNOWN); | |
2076 Node* iffalse = _gvn.transform(new (C, 1) IfFalseNode(iff)); | |
2077 C->add_predicate_opaq(opq); | |
2078 { | |
2079 PreserveJVMState pjvms(this); | |
2080 set_control(iffalse); | |
2081 uncommon_trap(Deoptimization::Reason_predicate, | |
2082 Deoptimization::Action_maybe_recompile); | |
2083 } | |
2084 Node* iftrue = _gvn.transform(new (C, 1) IfTrueNode(iff)); | |
2085 set_control(iftrue); | |
2086 } | |
2087 | |
2088 #ifndef PRODUCT | 2088 #ifndef PRODUCT |
2089 //------------------------show_parse_info-------------------------------------- | 2089 //------------------------show_parse_info-------------------------------------- |
2090 void Parse::show_parse_info() { | 2090 void Parse::show_parse_info() { |
2091 InlineTree* ilt = NULL; | 2091 InlineTree* ilt = NULL; |
2092 if (C->ilt() != NULL) { | 2092 if (C->ilt() != NULL) { |