src/share/vm/opto/idealKit.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8034812 Sdiff src/share/vm/opto

src/share/vm/opto/idealKit.cpp

Print this page




  69 //          /  \
  70 //   iffalse    iftrue
  71 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
  72 void IdealKit::if_then(Node* left, BoolTest::mask relop,
  73                        Node* right, float prob, float cnt, bool push_new_state) {
  74   assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If");
  75   Node* bol;
  76   if (left->bottom_type()->isa_ptr() == NULL) {
  77     if (left->bottom_type()->isa_int() != NULL) {
  78       bol = Bool(CmpI(left, right), relop);
  79     } else {
  80       assert(left->bottom_type()->isa_long() != NULL, "what else?");
  81       bol = Bool(CmpL(left, right), relop);
  82     }
  83 
  84   } else {
  85     bol = Bool(CmpP(left, right), relop);
  86   }
  87   // Delay gvn.tranform on if-nodes until construction is finished
  88   // to prevent a constant bool input from discarding a control output.
  89   IfNode* iff = delay_transform(new (C) IfNode(ctrl(), bol, prob, cnt))->as_If();
  90   Node* then  = IfTrue(iff);
  91   Node* elsen = IfFalse(iff);
  92   Node* else_cvstate = copy_cvstate();
  93   else_cvstate->set_req(TypeFunc::Control, elsen);
  94   _pending_cvstates->push(else_cvstate);
  95   DEBUG_ONLY(if (push_new_state) _state->push(IfThenS));
  96   set_ctrl(then);
  97 }
  98 
  99 //-------------------------------else_-------------------------------------
 100 // Pop the else cvstate off the stack, and push the (current) then cvstate.
 101 // The else cvstate becomes the current cvstate.
 102 void IdealKit::else_() {
 103   assert(state() == IfThenS, "bad state for new Else");
 104   Node* else_cvstate = _pending_cvstates->pop();
 105   DEBUG_ONLY(_state->pop());
 106   // save current (then) cvstate for later use at endif
 107   _pending_cvstates->push(_cvstate);
 108   DEBUG_ONLY(_state->push(ElseS));
 109   _cvstate = else_cvstate;


 188 // Expects the else (loop exit) cvstate to be on top of the
 189 // stack, and the loop top cvstate to be 2nd.
 190 void IdealKit::end_loop() {
 191   assert((state() == LoopS), "bad state for new end_loop");
 192   Node* exit = _pending_cvstates->pop();
 193   Node* head = _pending_cvstates->pop();
 194   goto_(head);
 195   clear(head);
 196   DEBUG_ONLY(_state->pop());
 197   _cvstate = exit;
 198 }
 199 
 200 //-------------------------------make_label-------------------------------------
 201 // Creates a label.  The number of goto's
 202 // must be specified (which should be 1 less than
 203 // the number of precedessors.)
 204 Node* IdealKit::make_label(int goto_ct) {
 205   assert(_cvstate != NULL, "must declare variables before labels");
 206   Node* lab = new_cvstate();
 207   int sz = 1 + goto_ct + 1 /* fall thru */;
 208   Node* reg = delay_transform(new (C) RegionNode(sz));
 209   lab->init_req(TypeFunc::Control, reg);
 210   return lab;
 211 }
 212 
 213 //-------------------------------bind-------------------------------------
 214 // Bind a label at the current cvstate by simulating
 215 // a goto to the label.
 216 void IdealKit::bind(Node* lab) {
 217   goto_(lab, true /* bind */);
 218   _cvstate = lab;
 219 }
 220 
 221 //-------------------------------goto_-------------------------------------
 222 // Make the current cvstate a predecessor of the label,
 223 // creating phi's to merge values.  If bind is true and
 224 // this is not the last control edge, then ensure that
 225 // all live values have phis created. Used to create phis
 226 // at loop-top regions.
 227 void IdealKit::goto_(Node* lab, bool bind) {
 228   Node* reg = lab->in(TypeFunc::Control);


 295   if (_delay_all_transforms) {
 296     return delay_transform(n);
 297   } else {
 298     n = gvn().transform(n);
 299     C->record_for_igvn(n);
 300     return n;
 301   }
 302 }
 303 
 304 //-----------------------------delay_transform-----------------------------------
 305 Node* IdealKit::delay_transform(Node* n) {
 306   // Delay transform until IterativeGVN
 307   gvn().set_type(n, n->bottom_type());
 308   C->record_for_igvn(n);
 309   return n;
 310 }
 311 
 312 //-----------------------------new_cvstate-----------------------------------
 313 Node* IdealKit::new_cvstate() {
 314   uint sz = _var_ct + first_var;
 315   return new (C) Node(sz);
 316 }
 317 
 318 //-----------------------------copy_cvstate-----------------------------------
 319 Node* IdealKit::copy_cvstate() {
 320   Node* ns = new_cvstate();
 321   for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i));
 322   // We must clone memory since it will be updated as we do stores.
 323   ns->set_req(TypeFunc::Memory, MergeMemNode::make(C, ns->in(TypeFunc::Memory)));
 324   return ns;
 325 }
 326 
 327 //-----------------------------clear-----------------------------------
 328 void IdealKit::clear(Node* m) {
 329   for (uint i = 0; i < m->req(); i++) m->set_req(i, NULL);
 330 }
 331 
 332 //-----------------------------IdealVariable----------------------------
 333 IdealVariable::IdealVariable(IdealKit &k) {
 334   k.declare(this);
 335 }


 380     st = StoreNode::make(_gvn, ctl, mem, adr, adr_type, val, bt, mo);
 381   }
 382   st = transform(st);
 383   set_memory(st, adr_idx);
 384 
 385   return st;
 386 }
 387 
 388 // Card mark store. Must be ordered so that it will come after the store of
 389 // the oop.
 390 Node* IdealKit::storeCM(Node* ctl, Node* adr, Node *val, Node* oop_store, int oop_adr_idx,
 391                         BasicType bt,
 392                         int adr_idx) {
 393   assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
 394   const TypePtr* adr_type = NULL;
 395   debug_only(adr_type = C->get_adr_type(adr_idx));
 396   Node *mem = memory(adr_idx);
 397 
 398   // Add required edge to oop_store, optimizer does not support precedence edges.
 399   // Convert required edge to precedence edge before allocation.
 400   Node* st = new (C) StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx);
 401 
 402   st = transform(st);
 403   set_memory(st, adr_idx);
 404 
 405   return st;
 406 }
 407 
 408 //---------------------------- do_memory_merge --------------------------------
 409 // The memory from one merging cvstate needs to be merged with the memory for another
 410 // join cvstate. If the join cvstate doesn't have a merged memory yet then we
 411 // can just copy the state from the merging cvstate
 412 
 413 // Merge one slow path into the rest of memory.
 414 void IdealKit::do_memory_merge(Node* merging, Node* join) {
 415 
 416   // Get the region for the join state
 417   Node* join_region = join->in(TypeFunc::Control);
 418   assert(join_region != NULL, "join region must exist");
 419   if (join->in(TypeFunc::I_O) == NULL ) {
 420     join->set_req(TypeFunc::I_O,  merging->in(TypeFunc::I_O));


 480     phi->set_req(slot, merging_io);
 481   }
 482 }
 483 
 484 
 485 //----------------------------- make_call  ----------------------------
 486 // Trivial runtime call
 487 void IdealKit::make_leaf_call(const TypeFunc *slow_call_type,
 488                               address slow_call,
 489                               const char *leaf_name,
 490                               Node* parm0,
 491                               Node* parm1,
 492                               Node* parm2,
 493                               Node* parm3) {
 494 
 495   // We only handle taking in RawMem and modifying RawMem
 496   const TypePtr* adr_type = TypeRawPtr::BOTTOM;
 497   uint adr_idx = C->get_alias_index(adr_type);
 498 
 499   // Slow-path leaf call
 500   CallNode *call =  (CallNode*)new (C) CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type);
 501 
 502   // Set fixed predefined input arguments
 503   call->init_req( TypeFunc::Control, ctrl() );
 504   call->init_req( TypeFunc::I_O    , top() )     ;   // does no i/o
 505   // Narrow memory as only memory input
 506   call->init_req( TypeFunc::Memory , memory(adr_idx));
 507   call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ );
 508   call->init_req( TypeFunc::ReturnAdr, top() );
 509 
 510   if (parm0 != NULL)  call->init_req(TypeFunc::Parms+0, parm0);
 511   if (parm1 != NULL)  call->init_req(TypeFunc::Parms+1, parm1);
 512   if (parm2 != NULL)  call->init_req(TypeFunc::Parms+2, parm2);
 513   if (parm3 != NULL)  call->init_req(TypeFunc::Parms+3, parm3);
 514 
 515   // Node *c = _gvn.transform(call);
 516   call = (CallNode *) _gvn.transform(call);
 517   Node *c = call; // dbx gets confused with call call->dump()
 518 
 519   // Slow leaf call has no side-effects, sets few values
 520 
 521   set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) ));
 522 
 523   // Make memory for the call
 524   Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) );
 525 
 526   // Set the RawPtr memory state only.
 527   set_memory(mem, adr_idx);
 528 
 529   assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
 530          "call node must be constructed correctly");
 531 }
 532 
 533 
 534 void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type,
 535                               address slow_call,
 536                               const char *leaf_name,
 537                               const TypePtr* adr_type,
 538                               Node* parm0,
 539                               Node* parm1,
 540                               Node* parm2,
 541                               Node* parm3) {
 542 
 543   // We only handle taking in RawMem and modifying RawMem
 544   uint adr_idx = C->get_alias_index(adr_type);
 545 
 546   // Slow-path leaf call
 547   CallNode *call =  (CallNode*)new (C) CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type);
 548 
 549   // Set fixed predefined input arguments
 550   call->init_req( TypeFunc::Control, ctrl() );
 551   call->init_req( TypeFunc::I_O    , top() )     ;   // does no i/o
 552   // Narrow memory as only memory input
 553   call->init_req( TypeFunc::Memory , memory(adr_idx));
 554   call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ );
 555   call->init_req( TypeFunc::ReturnAdr, top() );
 556 
 557   if (parm0 != NULL)  call->init_req(TypeFunc::Parms+0, parm0);
 558   if (parm1 != NULL)  call->init_req(TypeFunc::Parms+1, parm1);
 559   if (parm2 != NULL)  call->init_req(TypeFunc::Parms+2, parm2);
 560   if (parm3 != NULL)  call->init_req(TypeFunc::Parms+3, parm3);
 561 
 562   // Node *c = _gvn.transform(call);
 563   call = (CallNode *) _gvn.transform(call);
 564   Node *c = call; // dbx gets confused with call call->dump()
 565 
 566   // Slow leaf call has no side-effects, sets few values
 567 
 568   set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) ));
 569 
 570   // Make memory for the call
 571   Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) );
 572 
 573   // Set the RawPtr memory state only.
 574   set_memory(mem, adr_idx);
 575 
 576   assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
 577          "call node must be constructed correctly");
 578 }


  69 //          /  \
  70 //   iffalse    iftrue
  71 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
  72 void IdealKit::if_then(Node* left, BoolTest::mask relop,
  73                        Node* right, float prob, float cnt, bool push_new_state) {
  74   assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If");
  75   Node* bol;
  76   if (left->bottom_type()->isa_ptr() == NULL) {
  77     if (left->bottom_type()->isa_int() != NULL) {
  78       bol = Bool(CmpI(left, right), relop);
  79     } else {
  80       assert(left->bottom_type()->isa_long() != NULL, "what else?");
  81       bol = Bool(CmpL(left, right), relop);
  82     }
  83 
  84   } else {
  85     bol = Bool(CmpP(left, right), relop);
  86   }
  87   // Delay gvn.tranform on if-nodes until construction is finished
  88   // to prevent a constant bool input from discarding a control output.
  89   IfNode* iff = delay_transform(new IfNode(ctrl(), bol, prob, cnt))->as_If();
  90   Node* then  = IfTrue(iff);
  91   Node* elsen = IfFalse(iff);
  92   Node* else_cvstate = copy_cvstate();
  93   else_cvstate->set_req(TypeFunc::Control, elsen);
  94   _pending_cvstates->push(else_cvstate);
  95   DEBUG_ONLY(if (push_new_state) _state->push(IfThenS));
  96   set_ctrl(then);
  97 }
  98 
  99 //-------------------------------else_-------------------------------------
 100 // Pop the else cvstate off the stack, and push the (current) then cvstate.
 101 // The else cvstate becomes the current cvstate.
 102 void IdealKit::else_() {
 103   assert(state() == IfThenS, "bad state for new Else");
 104   Node* else_cvstate = _pending_cvstates->pop();
 105   DEBUG_ONLY(_state->pop());
 106   // save current (then) cvstate for later use at endif
 107   _pending_cvstates->push(_cvstate);
 108   DEBUG_ONLY(_state->push(ElseS));
 109   _cvstate = else_cvstate;


 188 // Expects the else (loop exit) cvstate to be on top of the
 189 // stack, and the loop top cvstate to be 2nd.
 190 void IdealKit::end_loop() {
 191   assert((state() == LoopS), "bad state for new end_loop");
 192   Node* exit = _pending_cvstates->pop();
 193   Node* head = _pending_cvstates->pop();
 194   goto_(head);
 195   clear(head);
 196   DEBUG_ONLY(_state->pop());
 197   _cvstate = exit;
 198 }
 199 
 200 //-------------------------------make_label-------------------------------------
 201 // Creates a label.  The number of goto's
 202 // must be specified (which should be 1 less than
 203 // the number of precedessors.)
 204 Node* IdealKit::make_label(int goto_ct) {
 205   assert(_cvstate != NULL, "must declare variables before labels");
 206   Node* lab = new_cvstate();
 207   int sz = 1 + goto_ct + 1 /* fall thru */;
 208   Node* reg = delay_transform(new RegionNode(sz));
 209   lab->init_req(TypeFunc::Control, reg);
 210   return lab;
 211 }
 212 
 213 //-------------------------------bind-------------------------------------
 214 // Bind a label at the current cvstate by simulating
 215 // a goto to the label.
 216 void IdealKit::bind(Node* lab) {
 217   goto_(lab, true /* bind */);
 218   _cvstate = lab;
 219 }
 220 
 221 //-------------------------------goto_-------------------------------------
 222 // Make the current cvstate a predecessor of the label,
 223 // creating phi's to merge values.  If bind is true and
 224 // this is not the last control edge, then ensure that
 225 // all live values have phis created. Used to create phis
 226 // at loop-top regions.
 227 void IdealKit::goto_(Node* lab, bool bind) {
 228   Node* reg = lab->in(TypeFunc::Control);


 295   if (_delay_all_transforms) {
 296     return delay_transform(n);
 297   } else {
 298     n = gvn().transform(n);
 299     C->record_for_igvn(n);
 300     return n;
 301   }
 302 }
 303 
 304 //-----------------------------delay_transform-----------------------------------
 305 Node* IdealKit::delay_transform(Node* n) {
 306   // Delay transform until IterativeGVN
 307   gvn().set_type(n, n->bottom_type());
 308   C->record_for_igvn(n);
 309   return n;
 310 }
 311 
 312 //-----------------------------new_cvstate-----------------------------------
 313 Node* IdealKit::new_cvstate() {
 314   uint sz = _var_ct + first_var;
 315   return new Node(sz);
 316 }
 317 
 318 //-----------------------------copy_cvstate-----------------------------------
 319 Node* IdealKit::copy_cvstate() {
 320   Node* ns = new_cvstate();
 321   for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i));
 322   // We must clone memory since it will be updated as we do stores.
 323   ns->set_req(TypeFunc::Memory, MergeMemNode::make(C, ns->in(TypeFunc::Memory)));
 324   return ns;
 325 }
 326 
 327 //-----------------------------clear-----------------------------------
 328 void IdealKit::clear(Node* m) {
 329   for (uint i = 0; i < m->req(); i++) m->set_req(i, NULL);
 330 }
 331 
 332 //-----------------------------IdealVariable----------------------------
 333 IdealVariable::IdealVariable(IdealKit &k) {
 334   k.declare(this);
 335 }


 380     st = StoreNode::make(_gvn, ctl, mem, adr, adr_type, val, bt, mo);
 381   }
 382   st = transform(st);
 383   set_memory(st, adr_idx);
 384 
 385   return st;
 386 }
 387 
 388 // Card mark store. Must be ordered so that it will come after the store of
 389 // the oop.
 390 Node* IdealKit::storeCM(Node* ctl, Node* adr, Node *val, Node* oop_store, int oop_adr_idx,
 391                         BasicType bt,
 392                         int adr_idx) {
 393   assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
 394   const TypePtr* adr_type = NULL;
 395   debug_only(adr_type = C->get_adr_type(adr_idx));
 396   Node *mem = memory(adr_idx);
 397 
 398   // Add required edge to oop_store, optimizer does not support precedence edges.
 399   // Convert required edge to precedence edge before allocation.
 400   Node* st = new StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx);
 401 
 402   st = transform(st);
 403   set_memory(st, adr_idx);
 404 
 405   return st;
 406 }
 407 
 408 //---------------------------- do_memory_merge --------------------------------
 409 // The memory from one merging cvstate needs to be merged with the memory for another
 410 // join cvstate. If the join cvstate doesn't have a merged memory yet then we
 411 // can just copy the state from the merging cvstate
 412 
 413 // Merge one slow path into the rest of memory.
 414 void IdealKit::do_memory_merge(Node* merging, Node* join) {
 415 
 416   // Get the region for the join state
 417   Node* join_region = join->in(TypeFunc::Control);
 418   assert(join_region != NULL, "join region must exist");
 419   if (join->in(TypeFunc::I_O) == NULL ) {
 420     join->set_req(TypeFunc::I_O,  merging->in(TypeFunc::I_O));


 480     phi->set_req(slot, merging_io);
 481   }
 482 }
 483 
 484 
 485 //----------------------------- make_call  ----------------------------
 486 // Trivial runtime call
 487 void IdealKit::make_leaf_call(const TypeFunc *slow_call_type,
 488                               address slow_call,
 489                               const char *leaf_name,
 490                               Node* parm0,
 491                               Node* parm1,
 492                               Node* parm2,
 493                               Node* parm3) {
 494 
 495   // We only handle taking in RawMem and modifying RawMem
 496   const TypePtr* adr_type = TypeRawPtr::BOTTOM;
 497   uint adr_idx = C->get_alias_index(adr_type);
 498 
 499   // Slow-path leaf call
 500   CallNode *call =  (CallNode*)new CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type);
 501 
 502   // Set fixed predefined input arguments
 503   call->init_req( TypeFunc::Control, ctrl() );
 504   call->init_req( TypeFunc::I_O    , top() )     ;   // does no i/o
 505   // Narrow memory as only memory input
 506   call->init_req( TypeFunc::Memory , memory(adr_idx));
 507   call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ );
 508   call->init_req( TypeFunc::ReturnAdr, top() );
 509 
 510   if (parm0 != NULL)  call->init_req(TypeFunc::Parms+0, parm0);
 511   if (parm1 != NULL)  call->init_req(TypeFunc::Parms+1, parm1);
 512   if (parm2 != NULL)  call->init_req(TypeFunc::Parms+2, parm2);
 513   if (parm3 != NULL)  call->init_req(TypeFunc::Parms+3, parm3);
 514 
 515   // Node *c = _gvn.transform(call);
 516   call = (CallNode *) _gvn.transform(call);
 517   Node *c = call; // dbx gets confused with call call->dump()
 518 
 519   // Slow leaf call has no side-effects, sets few values
 520 
 521   set_ctrl(transform( new ProjNode(call,TypeFunc::Control) ));
 522 
 523   // Make memory for the call
 524   Node* mem = _gvn.transform( new ProjNode(call, TypeFunc::Memory) );
 525 
 526   // Set the RawPtr memory state only.
 527   set_memory(mem, adr_idx);
 528 
 529   assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
 530          "call node must be constructed correctly");
 531 }
 532 
 533 
 534 void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type,
 535                               address slow_call,
 536                               const char *leaf_name,
 537                               const TypePtr* adr_type,
 538                               Node* parm0,
 539                               Node* parm1,
 540                               Node* parm2,
 541                               Node* parm3) {
 542 
 543   // We only handle taking in RawMem and modifying RawMem
 544   uint adr_idx = C->get_alias_index(adr_type);
 545 
 546   // Slow-path leaf call
 547   CallNode *call =  (CallNode*)new CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type);
 548 
 549   // Set fixed predefined input arguments
 550   call->init_req( TypeFunc::Control, ctrl() );
 551   call->init_req( TypeFunc::I_O    , top() )     ;   // does no i/o
 552   // Narrow memory as only memory input
 553   call->init_req( TypeFunc::Memory , memory(adr_idx));
 554   call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ );
 555   call->init_req( TypeFunc::ReturnAdr, top() );
 556 
 557   if (parm0 != NULL)  call->init_req(TypeFunc::Parms+0, parm0);
 558   if (parm1 != NULL)  call->init_req(TypeFunc::Parms+1, parm1);
 559   if (parm2 != NULL)  call->init_req(TypeFunc::Parms+2, parm2);
 560   if (parm3 != NULL)  call->init_req(TypeFunc::Parms+3, parm3);
 561 
 562   // Node *c = _gvn.transform(call);
 563   call = (CallNode *) _gvn.transform(call);
 564   Node *c = call; // dbx gets confused with call call->dump()
 565 
 566   // Slow leaf call has no side-effects, sets few values
 567 
 568   set_ctrl(transform( new ProjNode(call,TypeFunc::Control) ));
 569 
 570   // Make memory for the call
 571   Node* mem = _gvn.transform( new ProjNode(call, TypeFunc::Memory) );
 572 
 573   // Set the RawPtr memory state only.
 574   set_memory(mem, adr_idx);
 575 
 576   assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
 577          "call node must be constructed correctly");
 578 }
src/share/vm/opto/idealKit.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File