comparison src/share/vm/opto/cfgnode.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 da91efe96a93
children 8e47bac5643a
comparison
equal deleted inserted replaced
6803:06f52c4d0e18 6804:e626685e9f6c
610 ConvF2INode *convf2i; 610 ConvF2INode *convf2i;
611 if( check_convf2i_clipping( phi, val_idx, convf2i, min, max ) && 611 if( check_convf2i_clipping( phi, val_idx, convf2i, min, max ) &&
612 convf2i->in(1) == bot_in ) { 612 convf2i->in(1) == bot_in ) {
613 // Matched pattern, including LShiftI; RShiftI, replace with integer compares 613 // Matched pattern, including LShiftI; RShiftI, replace with integer compares
614 // max test 614 // max test
615 Node *cmp = gvn->register_new_node_with_optimizer(new (phase->C, 3) CmpINode( convf2i, min )); 615 Node *cmp = gvn->register_new_node_with_optimizer(new (phase->C) CmpINode( convf2i, min ));
616 Node *boo = gvn->register_new_node_with_optimizer(new (phase->C, 2) BoolNode( cmp, BoolTest::lt )); 616 Node *boo = gvn->register_new_node_with_optimizer(new (phase->C) BoolNode( cmp, BoolTest::lt ));
617 IfNode *iff = (IfNode*)gvn->register_new_node_with_optimizer(new (phase->C, 2) IfNode( top_if->in(0), boo, PROB_UNLIKELY_MAG(5), top_if->_fcnt )); 617 IfNode *iff = (IfNode*)gvn->register_new_node_with_optimizer(new (phase->C) IfNode( top_if->in(0), boo, PROB_UNLIKELY_MAG(5), top_if->_fcnt ));
618 Node *if_min= gvn->register_new_node_with_optimizer(new (phase->C, 1) IfTrueNode (iff)); 618 Node *if_min= gvn->register_new_node_with_optimizer(new (phase->C) IfTrueNode (iff));
619 Node *ifF = gvn->register_new_node_with_optimizer(new (phase->C, 1) IfFalseNode(iff)); 619 Node *ifF = gvn->register_new_node_with_optimizer(new (phase->C) IfFalseNode(iff));
620 // min test 620 // min test
621 cmp = gvn->register_new_node_with_optimizer(new (phase->C, 3) CmpINode( convf2i, max )); 621 cmp = gvn->register_new_node_with_optimizer(new (phase->C) CmpINode( convf2i, max ));
622 boo = gvn->register_new_node_with_optimizer(new (phase->C, 2) BoolNode( cmp, BoolTest::gt )); 622 boo = gvn->register_new_node_with_optimizer(new (phase->C) BoolNode( cmp, BoolTest::gt ));
623 iff = (IfNode*)gvn->register_new_node_with_optimizer(new (phase->C, 2) IfNode( ifF, boo, PROB_UNLIKELY_MAG(5), bot_if->_fcnt )); 623 iff = (IfNode*)gvn->register_new_node_with_optimizer(new (phase->C) IfNode( ifF, boo, PROB_UNLIKELY_MAG(5), bot_if->_fcnt ));
624 Node *if_max= gvn->register_new_node_with_optimizer(new (phase->C, 1) IfTrueNode (iff)); 624 Node *if_max= gvn->register_new_node_with_optimizer(new (phase->C) IfTrueNode (iff));
625 ifF = gvn->register_new_node_with_optimizer(new (phase->C, 1) IfFalseNode(iff)); 625 ifF = gvn->register_new_node_with_optimizer(new (phase->C) IfFalseNode(iff));
626 // update input edges to region node 626 // update input edges to region node
627 set_req_X( min_idx, if_min, gvn ); 627 set_req_X( min_idx, if_min, gvn );
628 set_req_X( max_idx, if_max, gvn ); 628 set_req_X( max_idx, if_max, gvn );
629 set_req_X( val_idx, ifF, gvn ); 629 set_req_X( val_idx, ifF, gvn );
630 // remove unnecessary 'LShiftI; RShiftI' idiom 630 // remove unnecessary 'LShiftI; RShiftI' idiom
679 //----------------------------make--------------------------------------------- 679 //----------------------------make---------------------------------------------
680 // create a new phi with edges matching r and set (initially) to x 680 // create a new phi with edges matching r and set (initially) to x
681 PhiNode* PhiNode::make(Node* r, Node* x, const Type *t, const TypePtr* at) { 681 PhiNode* PhiNode::make(Node* r, Node* x, const Type *t, const TypePtr* at) {
682 uint preds = r->req(); // Number of predecessor paths 682 uint preds = r->req(); // Number of predecessor paths
683 assert(t != Type::MEMORY || at == flatten_phi_adr_type(at), "flatten at"); 683 assert(t != Type::MEMORY || at == flatten_phi_adr_type(at), "flatten at");
684 PhiNode* p = new (Compile::current(), preds) PhiNode(r, t, at); 684 PhiNode* p = new (Compile::current()) PhiNode(r, t, at);
685 for (uint j = 1; j < preds; j++) { 685 for (uint j = 1; j < preds; j++) {
686 // Fill in all inputs, except those which the region does not yet have 686 // Fill in all inputs, except those which the region does not yet have
687 if (r->in(j) != NULL) 687 if (r->in(j) != NULL)
688 p->init_req(j, x); 688 p->init_req(j, x);
689 } 689 }
697 } 697 }
698 PhiNode* PhiNode::make_blank(Node* r, Node* x) { 698 PhiNode* PhiNode::make_blank(Node* r, Node* x) {
699 const Type* t = x->bottom_type(); 699 const Type* t = x->bottom_type();
700 const TypePtr* at = NULL; 700 const TypePtr* at = NULL;
701 if (t == Type::MEMORY) at = flatten_phi_adr_type(x->adr_type()); 701 if (t == Type::MEMORY) at = flatten_phi_adr_type(x->adr_type());
702 return new (Compile::current(), r->req()) PhiNode(r, t, at); 702 return new (Compile::current()) PhiNode(r, t, at);
703 } 703 }
704 704
705 705
706 //------------------------slice_memory----------------------------------------- 706 //------------------------slice_memory-----------------------------------------
707 // create a new phi with narrowed memory type 707 // create a new phi with narrowed memory type
1203 } else if( b->_test._test == BoolTest::eq ) { 1203 } else if( b->_test._test == BoolTest::eq ) {
1204 flipped = 1-flipped; 1204 flipped = 1-flipped;
1205 } else return NULL; 1205 } else return NULL;
1206 1206
1207 // Build int->bool conversion 1207 // Build int->bool conversion
1208 Node *n = new (phase->C, 2) Conv2BNode( cmp->in(1) ); 1208 Node *n = new (phase->C) Conv2BNode( cmp->in(1) );
1209 if( flipped ) 1209 if( flipped )
1210 n = new (phase->C, 3) XorINode( phase->transform(n), phase->intcon(1) ); 1210 n = new (phase->C) XorINode( phase->transform(n), phase->intcon(1) );
1211 1211
1212 return n; 1212 return n;
1213 } 1213 }
1214 1214
1215 //------------------------------is_cond_add------------------------------------ 1215 //------------------------------is_cond_add------------------------------------
1264 1264
1265 // Not so profitable if compare and add are constants 1265 // Not so profitable if compare and add are constants
1266 if( q->is_Con() && phase->type(q) != TypeInt::ZERO && y->is_Con() ) 1266 if( q->is_Con() && phase->type(q) != TypeInt::ZERO && y->is_Con() )
1267 return NULL; 1267 return NULL;
1268 1268
1269 Node *cmplt = phase->transform( new (phase->C, 3) CmpLTMaskNode(p,q) ); 1269 Node *cmplt = phase->transform( new (phase->C) CmpLTMaskNode(p,q) );
1270 Node *j_and = phase->transform( new (phase->C, 3) AndINode(cmplt,y) ); 1270 Node *j_and = phase->transform( new (phase->C) AndINode(cmplt,y) );
1271 return new (phase->C, 3) AddINode(j_and,x); 1271 return new (phase->C) AddINode(j_and,x);
1272 } 1272 }
1273 1273
1274 //------------------------------is_absolute------------------------------------ 1274 //------------------------------is_absolute------------------------------------
1275 // Check for absolute value. 1275 // Check for absolute value.
1276 static Node* is_absolute( PhaseGVN *phase, PhiNode *phi_root, int true_path) { 1276 static Node* is_absolute( PhaseGVN *phase, PhiNode *phi_root, int true_path) {
1328 // Allow only Sub(0,X) and fail out for all others; Neg is not OK 1328 // Allow only Sub(0,X) and fail out for all others; Neg is not OK
1329 if( tzero == TypeF::ZERO ) { 1329 if( tzero == TypeF::ZERO ) {
1330 if( sub->Opcode() != Op_SubF || 1330 if( sub->Opcode() != Op_SubF ||
1331 sub->in(2) != x || 1331 sub->in(2) != x ||
1332 phase->type(sub->in(1)) != tzero ) return NULL; 1332 phase->type(sub->in(1)) != tzero ) return NULL;
1333 x = new (phase->C, 2) AbsFNode(x); 1333 x = new (phase->C) AbsFNode(x);
1334 if (flip) { 1334 if (flip) {
1335 x = new (phase->C, 3) SubFNode(sub->in(1), phase->transform(x)); 1335 x = new (phase->C) SubFNode(sub->in(1), phase->transform(x));
1336 } 1336 }
1337 } else { 1337 } else {
1338 if( sub->Opcode() != Op_SubD || 1338 if( sub->Opcode() != Op_SubD ||
1339 sub->in(2) != x || 1339 sub->in(2) != x ||
1340 phase->type(sub->in(1)) != tzero ) return NULL; 1340 phase->type(sub->in(1)) != tzero ) return NULL;
1341 x = new (phase->C, 2) AbsDNode(x); 1341 x = new (phase->C) AbsDNode(x);
1342 if (flip) { 1342 if (flip) {
1343 x = new (phase->C, 3) SubDNode(sub->in(1), phase->transform(x)); 1343 x = new (phase->C) SubDNode(sub->in(1), phase->transform(x));
1344 } 1344 }
1345 } 1345 }
1346 1346
1347 return x; 1347 return x;
1348 } 1348 }
1413 return NULL; 1413 return NULL;
1414 1414
1415 // Now start splitting out the flow paths that merge the same value. 1415 // Now start splitting out the flow paths that merge the same value.
1416 // Split first the RegionNode. 1416 // Split first the RegionNode.
1417 PhaseIterGVN *igvn = phase->is_IterGVN(); 1417 PhaseIterGVN *igvn = phase->is_IterGVN();
1418 RegionNode *newr = new (phase->C, hit+1) RegionNode(hit+1); 1418 RegionNode *newr = new (phase->C) RegionNode(hit+1);
1419 split_once(igvn, phi, val, r, newr); 1419 split_once(igvn, phi, val, r, newr);
1420 1420
1421 // Now split all other Phis than this one 1421 // Now split all other Phis than this one
1422 for (DUIterator_Fast kmax, k = r->fast_outs(kmax); k < kmax; k++) { 1422 for (DUIterator_Fast kmax, k = r->fast_outs(kmax); k < kmax; k++) {
1423 Node* phi2 = r->fast_out(k); 1423 Node* phi2 = r->fast_out(k);
1721 } 1721 }
1722 } 1722 }
1723 } 1723 }
1724 if (doit) { 1724 if (doit) {
1725 if (base == NULL) { 1725 if (base == NULL) {
1726 base = new (phase->C, in(0)->req()) PhiNode(in(0), type, NULL); 1726 base = new (phase->C) PhiNode(in(0), type, NULL);
1727 for (uint i = 1; i < req(); i++) { 1727 for (uint i = 1; i < req(); i++) {
1728 base->init_req(i, in(i)->in(AddPNode::Base)); 1728 base->init_req(i, in(i)->in(AddPNode::Base));
1729 } 1729 }
1730 phase->is_IterGVN()->register_new_node_with_optimizer(base); 1730 phase->is_IterGVN()->register_new_node_with_optimizer(base);
1731 } 1731 }
1732 return new (phase->C, 4) AddPNode(base, base, y); 1732 return new (phase->C) AddPNode(base, base, y);
1733 } 1733 }
1734 } 1734 }
1735 } 1735 }
1736 1736
1737 // Split phis through memory merges, so that the memory merges will go away. 1737 // Split phis through memory merges, so that the memory merges will go away.
1804 return top; // all inputs reference back to this phi - dead loop 1804 return top; // all inputs reference back to this phi - dead loop
1805 1805
1806 // Phi(...MergeMem(m0, m1:AT1, m2:AT2)...) into 1806 // Phi(...MergeMem(m0, m1:AT1, m2:AT2)...) into
1807 // MergeMem(Phi(...m0...), Phi:AT1(...m1...), Phi:AT2(...m2...)) 1807 // MergeMem(Phi(...m0...), Phi:AT1(...m1...), Phi:AT2(...m2...))
1808 PhaseIterGVN *igvn = phase->is_IterGVN(); 1808 PhaseIterGVN *igvn = phase->is_IterGVN();
1809 Node* hook = new (phase->C, 1) Node(1); 1809 Node* hook = new (phase->C) Node(1);
1810 PhiNode* new_base = (PhiNode*) clone(); 1810 PhiNode* new_base = (PhiNode*) clone();
1811 // Must eagerly register phis, since they participate in loops. 1811 // Must eagerly register phis, since they participate in loops.
1812 if (igvn) { 1812 if (igvn) {
1813 igvn->register_new_node_with_optimizer(new_base); 1813 igvn->register_new_node_with_optimizer(new_base);
1814 hook->add_req(new_base); 1814 hook->add_req(new_base);
1894 1894
1895 if (has_decodeN && may_push) { 1895 if (has_decodeN && may_push) {
1896 PhaseIterGVN *igvn = phase->is_IterGVN(); 1896 PhaseIterGVN *igvn = phase->is_IterGVN();
1897 // Make narrow type for new phi. 1897 // Make narrow type for new phi.
1898 const Type* narrow_t = TypeNarrowOop::make(this->bottom_type()->is_ptr()); 1898 const Type* narrow_t = TypeNarrowOop::make(this->bottom_type()->is_ptr());
1899 PhiNode* new_phi = new (phase->C, r->req()) PhiNode(r, narrow_t); 1899 PhiNode* new_phi = new (phase->C) PhiNode(r, narrow_t);
1900 uint orig_cnt = req(); 1900 uint orig_cnt = req();
1901 for (uint i=1; i<req(); ++i) {// For all paths in 1901 for (uint i=1; i<req(); ++i) {// For all paths in
1902 Node *ii = in(i); 1902 Node *ii = in(i);
1903 Node* new_ii = NULL; 1903 Node* new_ii = NULL;
1904 if (ii->is_DecodeN()) { 1904 if (ii->is_DecodeN()) {
1907 } else { 1907 } else {
1908 assert(ii->is_Phi(), "sanity"); 1908 assert(ii->is_Phi(), "sanity");
1909 if (ii->as_Phi() == this) { 1909 if (ii->as_Phi() == this) {
1910 new_ii = new_phi; 1910 new_ii = new_phi;
1911 } else { 1911 } else {
1912 new_ii = new (phase->C, 2) EncodePNode(ii, narrow_t); 1912 new_ii = new (phase->C) EncodePNode(ii, narrow_t);
1913 igvn->register_new_node_with_optimizer(new_ii); 1913 igvn->register_new_node_with_optimizer(new_ii);
1914 } 1914 }
1915 } 1915 }
1916 new_phi->set_req(i, new_ii); 1916 new_phi->set_req(i, new_ii);
1917 } 1917 }
1918 igvn->register_new_node_with_optimizer(new_phi, this); 1918 igvn->register_new_node_with_optimizer(new_phi, this);
1919 progress = new (phase->C, 2) DecodeNNode(new_phi, bottom_type()); 1919 progress = new (phase->C) DecodeNNode(new_phi, bottom_type());
1920 } 1920 }
1921 } 1921 }
1922 #endif 1922 #endif
1923 1923
1924 return progress; // Return any progress 1924 return progress; // Return any progress