comparison src/share/vm/opto/parse1.cpp @ 1172:b2b6a9bf6238

6894779: Loop Predication for Loop Optimizer in C2 Summary: Loop predication implementation Reviewed-by: never, kvn
author cfang
date Tue, 12 Jan 2010 14:37:35 -0800
parents 87b2fdd4bf98
children 106f41e88c85
comparison
equal deleted inserted replaced
1160:f24201449cac 1172:b2b6a9bf6238
1381 1381
1382 // Learn the current bci from the iterator: 1382 // Learn the current bci from the iterator:
1383 set_parse_bci(iter().cur_bci()); 1383 set_parse_bci(iter().cur_bci());
1384 1384
1385 if (bci() == block()->limit()) { 1385 if (bci() == block()->limit()) {
1386 // insert a predicate if it falls through to a loop head block
1387 if (should_add_predicate(bci())){
1388 add_predicate();
1389 }
1386 // Do not walk into the next block until directed by do_all_blocks. 1390 // Do not walk into the next block until directed by do_all_blocks.
1387 merge(bci()); 1391 merge(bci());
1388 break; 1392 break;
1389 } 1393 }
1390 assert(bci() < block()->limit(), "bci still in block"); 1394 assert(bci() < block()->limit(), "bci still in block");
2081 assert(C->root() != NULL, "Expect parse is still valid"); 2085 assert(C->root() != NULL, "Expect parse is still valid");
2082 C->root()->add_prec(transformed_sfpnt); 2086 C->root()->add_prec(transformed_sfpnt);
2083 } 2087 }
2084 } 2088 }
2085 2089
2090 //------------------------------should_add_predicate--------------------------
2091 bool Parse::should_add_predicate(int target_bci) {
2092 if (!UseLoopPredicate) return false;
2093 Block* target = successor_for_bci(target_bci);
2094 if (target != NULL &&
2095 target->is_loop_head() &&
2096 block()->rpo() < target->rpo()) {
2097 return true;
2098 }
2099 return false;
2100 }
2101
2102 //------------------------------add_predicate---------------------------------
2103 void Parse::add_predicate() {
2104 assert(UseLoopPredicate,"use only for loop predicate");
2105 Node *cont = _gvn.intcon(1);
2106 Node* opq = _gvn.transform(new (C, 2) Opaque1Node(C, cont));
2107 Node *bol = _gvn.transform(new (C, 2) Conv2BNode(opq));
2108 IfNode* iff = create_and_map_if(control(), bol, PROB_MAX, COUNT_UNKNOWN);
2109 Node* iffalse = _gvn.transform(new (C, 1) IfFalseNode(iff));
2110 C->add_predicate_opaq(opq);
2111 {
2112 PreserveJVMState pjvms(this);
2113 set_control(iffalse);
2114 uncommon_trap(Deoptimization::Reason_predicate,
2115 Deoptimization::Action_maybe_recompile);
2116 }
2117 Node* iftrue = _gvn.transform(new (C, 1) IfTrueNode(iff));
2118 set_control(iftrue);
2119 }
2120
2086 #ifndef PRODUCT 2121 #ifndef PRODUCT
2087 //------------------------show_parse_info-------------------------------------- 2122 //------------------------show_parse_info--------------------------------------
2088 void Parse::show_parse_info() { 2123 void Parse::show_parse_info() {
2089 InlineTree* ilt = NULL; 2124 InlineTree* ilt = NULL;
2090 if (C->ilt() != NULL) { 2125 if (C->ilt() != NULL) {