comparison src/share/vm/opto/ifnode.cpp @ 6804:e626685e9f6c

7193318: C2: remove number of inputs requirement from Node's new operator Summary: Deleted placement new operator of Node - node(size_t, Compile *, int). Reviewed-by: kvn, twisti Contributed-by: bharadwaj.yadavalli@oracle.com
author kvn
date Thu, 27 Sep 2012 09:38:42 -0700
parents 5e990493719e
children b9a9ed0f8eeb
comparison
equal deleted inserted replaced
6803:06f52c4d0e18 6804:e626685e9f6c
236 } 236 }
237 Node* predicate_c = NULL; 237 Node* predicate_c = NULL;
238 Node* predicate_x = NULL; 238 Node* predicate_x = NULL;
239 bool counted_loop = r->is_CountedLoop(); 239 bool counted_loop = r->is_CountedLoop();
240 240
241 Node *region_c = new (igvn->C, req_c + 1) RegionNode(req_c + 1); 241 Node *region_c = new (igvn->C) RegionNode(req_c + 1);
242 Node *phi_c = con1; 242 Node *phi_c = con1;
243 uint len = r->req(); 243 uint len = r->req();
244 Node *region_x = new (igvn->C, len - req_c) RegionNode(len - req_c); 244 Node *region_x = new (igvn->C) RegionNode(len - req_c);
245 Node *phi_x = PhiNode::make_blank(region_x, phi); 245 Node *phi_x = PhiNode::make_blank(region_x, phi);
246 for (uint i = 1, i_c = 1, i_x = 1; i < len; i++) { 246 for (uint i = 1, i_c = 1, i_x = 1; i < len; i++) {
247 if (phi->in(i) == con1) { 247 if (phi->in(i) == con1) {
248 region_c->init_req( i_c++, r ->in(i) ); 248 region_c->init_req( i_c++, r ->in(i) );
249 if (r->in(i) == predicate_proj) 249 if (r->in(i) == predicate_proj)
270 igvn->register_new_node_with_optimizer( region_c ); 270 igvn->register_new_node_with_optimizer( region_c );
271 igvn->register_new_node_with_optimizer( region_x ); 271 igvn->register_new_node_with_optimizer( region_x );
272 // Prevent the untimely death of phi_x. Currently he has no uses. He is 272 // Prevent the untimely death of phi_x. Currently he has no uses. He is
273 // about to get one. If this only use goes away, then phi_x will look dead. 273 // about to get one. If this only use goes away, then phi_x will look dead.
274 // However, he will be picking up some more uses down below. 274 // However, he will be picking up some more uses down below.
275 Node *hook = new (igvn->C, 4) Node(4); 275 Node *hook = new (igvn->C) Node(4);
276 hook->init_req(0, phi_x); 276 hook->init_req(0, phi_x);
277 hook->init_req(1, phi_c); 277 hook->init_req(1, phi_c);
278 phi_x = phase->transform( phi_x ); 278 phi_x = phase->transform( phi_x );
279 279
280 // Make the compare 280 // Make the compare
282 Node *cmp_x = cmp->clone(); 282 Node *cmp_x = cmp->clone();
283 cmp_x->set_req(1,phi_x); 283 cmp_x->set_req(1,phi_x);
284 cmp_x->set_req(2,con2); 284 cmp_x->set_req(2,con2);
285 cmp_x = phase->transform(cmp_x); 285 cmp_x = phase->transform(cmp_x);
286 // Make the bool 286 // Make the bool
287 Node *b_c = phase->transform(new (igvn->C, 2) BoolNode(cmp_c,b->_test._test)); 287 Node *b_c = phase->transform(new (igvn->C) BoolNode(cmp_c,b->_test._test));
288 Node *b_x = phase->transform(new (igvn->C, 2) BoolNode(cmp_x,b->_test._test)); 288 Node *b_x = phase->transform(new (igvn->C) BoolNode(cmp_x,b->_test._test));
289 // Make the IfNode 289 // Make the IfNode
290 IfNode *iff_c = new (igvn->C, 2) IfNode(region_c,b_c,iff->_prob,iff->_fcnt); 290 IfNode *iff_c = new (igvn->C) IfNode(region_c,b_c,iff->_prob,iff->_fcnt);
291 igvn->set_type_bottom(iff_c); 291 igvn->set_type_bottom(iff_c);
292 igvn->_worklist.push(iff_c); 292 igvn->_worklist.push(iff_c);
293 hook->init_req(2, iff_c); 293 hook->init_req(2, iff_c);
294 294
295 IfNode *iff_x = new (igvn->C, 2) IfNode(region_x,b_x,iff->_prob, iff->_fcnt); 295 IfNode *iff_x = new (igvn->C) IfNode(region_x,b_x,iff->_prob, iff->_fcnt);
296 igvn->set_type_bottom(iff_x); 296 igvn->set_type_bottom(iff_x);
297 igvn->_worklist.push(iff_x); 297 igvn->_worklist.push(iff_x);
298 hook->init_req(3, iff_x); 298 hook->init_req(3, iff_x);
299 299
300 // Make the true/false arms 300 // Make the true/false arms
301 Node *iff_c_t = phase->transform(new (igvn->C, 1) IfTrueNode (iff_c)); 301 Node *iff_c_t = phase->transform(new (igvn->C) IfTrueNode (iff_c));
302 Node *iff_c_f = phase->transform(new (igvn->C, 1) IfFalseNode(iff_c)); 302 Node *iff_c_f = phase->transform(new (igvn->C) IfFalseNode(iff_c));
303 if (predicate_c != NULL) { 303 if (predicate_c != NULL) {
304 assert(predicate_x == NULL, "only one predicate entry expected"); 304 assert(predicate_x == NULL, "only one predicate entry expected");
305 // Clone loop predicates to each path 305 // Clone loop predicates to each path
306 iff_c_t = igvn->clone_loop_predicates(predicate_c, iff_c_t, !counted_loop); 306 iff_c_t = igvn->clone_loop_predicates(predicate_c, iff_c_t, !counted_loop);
307 iff_c_f = igvn->clone_loop_predicates(predicate_c, iff_c_f, !counted_loop); 307 iff_c_f = igvn->clone_loop_predicates(predicate_c, iff_c_f, !counted_loop);
308 } 308 }
309 Node *iff_x_t = phase->transform(new (igvn->C, 1) IfTrueNode (iff_x)); 309 Node *iff_x_t = phase->transform(new (igvn->C) IfTrueNode (iff_x));
310 Node *iff_x_f = phase->transform(new (igvn->C, 1) IfFalseNode(iff_x)); 310 Node *iff_x_f = phase->transform(new (igvn->C) IfFalseNode(iff_x));
311 if (predicate_x != NULL) { 311 if (predicate_x != NULL) {
312 assert(predicate_c == NULL, "only one predicate entry expected"); 312 assert(predicate_c == NULL, "only one predicate entry expected");
313 // Clone loop predicates to each path 313 // Clone loop predicates to each path
314 iff_x_t = igvn->clone_loop_predicates(predicate_x, iff_x_t, !counted_loop); 314 iff_x_t = igvn->clone_loop_predicates(predicate_x, iff_x_t, !counted_loop);
315 iff_x_f = igvn->clone_loop_predicates(predicate_x, iff_x_f, !counted_loop); 315 iff_x_f = igvn->clone_loop_predicates(predicate_x, iff_x_f, !counted_loop);
316 } 316 }
317 317
318 // Merge the TRUE paths 318 // Merge the TRUE paths
319 Node *region_s = new (igvn->C, 3) RegionNode(3); 319 Node *region_s = new (igvn->C) RegionNode(3);
320 igvn->_worklist.push(region_s); 320 igvn->_worklist.push(region_s);
321 region_s->init_req(1, iff_c_t); 321 region_s->init_req(1, iff_c_t);
322 region_s->init_req(2, iff_x_t); 322 region_s->init_req(2, iff_x_t);
323 igvn->register_new_node_with_optimizer( region_s ); 323 igvn->register_new_node_with_optimizer( region_s );
324 324
325 // Merge the FALSE paths 325 // Merge the FALSE paths
326 Node *region_f = new (igvn->C, 3) RegionNode(3); 326 Node *region_f = new (igvn->C) RegionNode(3);
327 igvn->_worklist.push(region_f); 327 igvn->_worklist.push(region_f);
328 region_f->init_req(1, iff_c_f); 328 region_f->init_req(1, iff_c_f);
329 region_f->init_req(2, iff_x_f); 329 region_f->init_req(2, iff_x_f);
330 igvn->register_new_node_with_optimizer( region_f ); 330 igvn->register_new_node_with_optimizer( region_f );
331 331
436 // Now remove the bogus extra edges used to keep things alive 436 // Now remove the bogus extra edges used to keep things alive
437 igvn->remove_dead_node( hook ); 437 igvn->remove_dead_node( hook );
438 438
439 // Must return either the original node (now dead) or a new node 439 // Must return either the original node (now dead) or a new node
440 // (Do not return a top here, since that would break the uniqueness of top.) 440 // (Do not return a top here, since that would break the uniqueness of top.)
441 return new (igvn->C, 1) ConINode(TypeInt::ZERO); 441 return new (igvn->C) ConINode(TypeInt::ZERO);
442 } 442 }
443 443
444 //------------------------------is_range_check--------------------------------- 444 //------------------------------is_range_check---------------------------------
445 // Return 0 if not a range check. Return 1 if a range check and set index and 445 // Return 0 if not a range check. Return 1 if a range check and set index and
446 // offset. Return 2 if we had to negate the test. Index is NULL if the check 446 // offset. Return 2 if we had to negate the test. Index is NULL if the check
539 539
540 Node *cmp = bol->in(1); 540 Node *cmp = bol->in(1);
541 // Compute a new check 541 // Compute a new check
542 Node *new_add = gvn->intcon(off_lo); 542 Node *new_add = gvn->intcon(off_lo);
543 if( index ) { 543 if( index ) {
544 new_add = off_lo ? gvn->transform(new (gvn->C, 3) AddINode( index, new_add )) : index; 544 new_add = off_lo ? gvn->transform(new (gvn->C) AddINode( index, new_add )) : index;
545 } 545 }
546 Node *new_cmp = (flip == 1) 546 Node *new_cmp = (flip == 1)
547 ? new (gvn->C, 3) CmpUNode( new_add, range ) 547 ? new (gvn->C) CmpUNode( new_add, range )
548 : new (gvn->C, 3) CmpUNode( range, new_add ); 548 : new (gvn->C) CmpUNode( range, new_add );
549 new_cmp = gvn->transform(new_cmp); 549 new_cmp = gvn->transform(new_cmp);
550 // See if no need to adjust the existing check 550 // See if no need to adjust the existing check
551 if( new_cmp == cmp ) return; 551 if( new_cmp == cmp ) return;
552 // Else, adjust existing check 552 // Else, adjust existing check
553 Node *new_bol = gvn->transform( new (gvn->C, 2) BoolNode( new_cmp, bol->as_Bool()->_test._test ) ); 553 Node *new_bol = gvn->transform( new (gvn->C) BoolNode( new_cmp, bol->as_Bool()->_test._test ) );
554 igvn->rehash_node_delayed( iff ); 554 igvn->rehash_node_delayed( iff );
555 iff->set_req_X( 1, new_bol, igvn ); 555 iff->set_req_X( 1, new_bol, igvn );
556 } 556 }
557 557
558 //------------------------------up_one_dom------------------------------------- 558 //------------------------------up_one_dom-------------------------------------
725 dom_bool->_test._test != BoolTest::ne && dom_bool->_test._test != BoolTest::eq) { 725 dom_bool->_test._test != BoolTest::ne && dom_bool->_test._test != BoolTest::eq) {
726 int bound = failtype->_hi - failtype->_lo + 1; 726 int bound = failtype->_hi - failtype->_lo + 1;
727 if (failtype->_hi != max_jint && failtype->_lo != min_jint && bound > 1) { 727 if (failtype->_hi != max_jint && failtype->_lo != min_jint && bound > 1) {
728 // Merge the two compares into a single unsigned compare by building (CmpU (n - lo) hi) 728 // Merge the two compares into a single unsigned compare by building (CmpU (n - lo) hi)
729 BoolTest::mask cond = fail->as_Proj()->_con ? BoolTest::lt : BoolTest::ge; 729 BoolTest::mask cond = fail->as_Proj()->_con ? BoolTest::lt : BoolTest::ge;
730 Node* adjusted = phase->transform(new (phase->C, 3) SubINode(n, phase->intcon(failtype->_lo))); 730 Node* adjusted = phase->transform(new (phase->C) SubINode(n, phase->intcon(failtype->_lo)));
731 Node* newcmp = phase->transform(new (phase->C, 3) CmpUNode(adjusted, phase->intcon(bound))); 731 Node* newcmp = phase->transform(new (phase->C) CmpUNode(adjusted, phase->intcon(bound)));
732 Node* newbool = phase->transform(new (phase->C, 2) BoolNode(newcmp, cond)); 732 Node* newbool = phase->transform(new (phase->C) BoolNode(newcmp, cond));
733 phase->is_IterGVN()->replace_input_of(dom_iff, 1, phase->intcon(ctrl->as_Proj()->_con)); 733 phase->is_IterGVN()->replace_input_of(dom_iff, 1, phase->intcon(ctrl->as_Proj()->_con));
734 phase->hash_delete(this); 734 phase->hash_delete(this);
735 set_req(1, newbool); 735 set_req(1, newbool);
736 return this; 736 return this;
737 } 737 }
1000 // Replace dominated IfNode 1000 // Replace dominated IfNode
1001 dominated_by( prev_dom, igvn ); 1001 dominated_by( prev_dom, igvn );
1002 1002
1003 // Must return either the original node (now dead) or a new node 1003 // Must return either the original node (now dead) or a new node
1004 // (Do not return a top here, since that would break the uniqueness of top.) 1004 // (Do not return a top here, since that would break the uniqueness of top.)
1005 return new (phase->C, 1) ConINode(TypeInt::ZERO); 1005 return new (phase->C) ConINode(TypeInt::ZERO);
1006 } 1006 }
1007 1007
1008 //------------------------------dominated_by----------------------------------- 1008 //------------------------------dominated_by-----------------------------------
1009 void IfNode::dominated_by( Node *prev_dom, PhaseIterGVN *igvn ) { 1009 void IfNode::dominated_by( Node *prev_dom, PhaseIterGVN *igvn ) {
1010 igvn->hash_delete(this); // Remove self to prevent spurious V-N 1010 igvn->hash_delete(this); // Remove self to prevent spurious V-N
1096 if( bt.is_canonical() ) 1096 if( bt.is_canonical() )
1097 return NULL; 1097 return NULL;
1098 1098
1099 // Flip test to be canonical. Requires flipping the IfFalse/IfTrue and 1099 // Flip test to be canonical. Requires flipping the IfFalse/IfTrue and
1100 // cloning the IfNode. 1100 // cloning the IfNode.
1101 Node* new_b = phase->transform( new (phase->C, 2) BoolNode(b->in(1), bt.negate()) ); 1101 Node* new_b = phase->transform( new (phase->C) BoolNode(b->in(1), bt.negate()) );
1102 if( !new_b->is_Bool() ) return NULL; 1102 if( !new_b->is_Bool() ) return NULL;
1103 b = new_b->as_Bool(); 1103 b = new_b->as_Bool();
1104 1104
1105 PhaseIterGVN *igvn = phase->is_IterGVN(); 1105 PhaseIterGVN *igvn = phase->is_IterGVN();
1106 assert( igvn, "Test is not canonical in parser?" ); 1106 assert( igvn, "Test is not canonical in parser?" );
1107 1107
1108 // The IF node never really changes, but it needs to be cloned 1108 // The IF node never really changes, but it needs to be cloned
1109 iff = new (phase->C, 2) IfNode( iff->in(0), b, 1.0-iff->_prob, iff->_fcnt); 1109 iff = new (phase->C) IfNode( iff->in(0), b, 1.0-iff->_prob, iff->_fcnt);
1110 1110
1111 Node *prior = igvn->hash_find_insert(iff); 1111 Node *prior = igvn->hash_find_insert(iff);
1112 if( prior ) { 1112 if( prior ) {
1113 igvn->remove_dead_node(iff); 1113 igvn->remove_dead_node(iff);
1114 iff = (IfNode*)prior; 1114 iff = (IfNode*)prior;
1117 igvn->set_type_bottom(iff); 1117 igvn->set_type_bottom(iff);
1118 } 1118 }
1119 igvn->_worklist.push(iff); 1119 igvn->_worklist.push(iff);
1120 1120
1121 // Now handle projections. Cloning not required. 1121 // Now handle projections. Cloning not required.
1122 Node* new_if_f = (Node*)(new (phase->C, 1) IfFalseNode( iff )); 1122 Node* new_if_f = (Node*)(new (phase->C) IfFalseNode( iff ));
1123 Node* new_if_t = (Node*)(new (phase->C, 1) IfTrueNode ( iff )); 1123 Node* new_if_t = (Node*)(new (phase->C) IfTrueNode ( iff ));
1124 1124
1125 igvn->register_new_node_with_optimizer(new_if_f); 1125 igvn->register_new_node_with_optimizer(new_if_f);
1126 igvn->register_new_node_with_optimizer(new_if_t); 1126 igvn->register_new_node_with_optimizer(new_if_t);
1127 // Flip test, so flip trailing control 1127 // Flip test, so flip trailing control
1128 igvn->replace_node(old_if_f, new_if_t); 1128 igvn->replace_node(old_if_f, new_if_t);