< prev index next >

src/hotspot/share/opto/idealKit.cpp

Print this page




  31 
  32 // Static initialization
  33 
  34 // This declares the position where vars are kept in the cvstate
  35 // For some degree of consistency we use the TypeFunc enum to
  36 // soak up spots in the inputs even though we only use early Control
  37 // and Memory slots. (So far.)
  38 const uint IdealKit::first_var = TypeFunc::Parms + 1;
  39 
  40 //----------------------------IdealKit-----------------------------------------
  41 IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarations) :
  42   C(gkit->C), _gvn(gkit->gvn()) {
  43   _initial_ctrl = gkit->control();
  44   _initial_memory = gkit->merged_memory();
  45   _initial_i_o = gkit->i_o();
  46   _delay_all_transforms = delay_all_transforms;
  47   _var_ct = 0;
  48   _cvstate = NULL;
  49   // We can go memory state free or else we need the entire memory state
  50   assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split");
  51   assert(!_gvn.is_IterGVN(), "IdealKit can't be used during Optimize phase");
  52   int init_size = 5;
  53   _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
  54   DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
  55   if (!has_declarations) {
  56      declarations_done();
  57   }
  58 }
  59 
  60 //----------------------------sync_kit-----------------------------------------
  61 void IdealKit::sync_kit(GraphKit* gkit) {
  62   set_all_memory(gkit->merged_memory());
  63   set_i_o(gkit->i_o());
  64   set_ctrl(gkit->control());
  65 }
  66 
  67 //-------------------------------if_then-------------------------------------
  68 // Create:  if(left relop right)
  69 //          /  \
  70 //   iffalse    iftrue
  71 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.


 279   const BasicType bt = n->bottom_type()->basic_type();
 280   const Type* ct = Type::get_const_basic_type(bt);
 281   return delay_transform(PhiNode::make(reg, n, ct));
 282 }
 283 
 284 //-----------------------------declarations_done-------------------------------
 285 void IdealKit::declarations_done() {
 286   _cvstate = new_cvstate();   // initialize current cvstate
 287   set_ctrl(_initial_ctrl);    // initialize control in current cvstate
 288   set_all_memory(_initial_memory);// initialize memory in current cvstate
 289   set_i_o(_initial_i_o);      // initialize i_o in current cvstate
 290   DEBUG_ONLY(_state->push(BlockS));
 291 }
 292 
 293 //-----------------------------transform-----------------------------------
 294 Node* IdealKit::transform(Node* n) {
 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(ns->in(TypeFunc::Memory)));
 324   return ns;
 325 }
 326 
 327 //-----------------------------clear-----------------------------------
 328 void IdealKit::clear(Node* m) {


 516   if (parm2 != NULL)  call->init_req(TypeFunc::Parms+2, parm2);
 517   if (parm3 != NULL)  call->init_req(TypeFunc::Parms+3, parm3);
 518 
 519   // Node *c = _gvn.transform(call);
 520   call = (CallNode *) _gvn.transform(call);
 521   Node *c = call; // dbx gets confused with call call->dump()
 522 
 523   // Slow leaf call has no side-effects, sets few values
 524 
 525   set_ctrl(transform( new ProjNode(call,TypeFunc::Control) ));
 526 
 527   // Make memory for the call
 528   Node* mem = _gvn.transform( new ProjNode(call, TypeFunc::Memory) );
 529 
 530   // Set the RawPtr memory state only.
 531   set_memory(mem, adr_idx);
 532 
 533   assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
 534          "call node must be constructed correctly");
 535   Node* res = NULL;
 536   if (slow_call_type->range()->cnt() > TypeFunc::Parms) {
 537     assert(slow_call_type->range()->cnt() == TypeFunc::Parms+1, "only one return value");
 538     res = transform(new ProjNode(call, TypeFunc::Parms));
 539   }
 540   return res;
 541 }
 542 
 543 void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type,
 544                               address slow_call,
 545                               const char *leaf_name,
 546                               const TypePtr* adr_type,
 547                               Node* parm0,
 548                               Node* parm1,
 549                               Node* parm2,
 550                               Node* parm3) {
 551 
 552   // We only handle taking in RawMem and modifying RawMem
 553   uint adr_idx = C->get_alias_index(adr_type);
 554 
 555   // Slow-path leaf call
 556   CallNode *call =  (CallNode*)new CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type);
 557 




  31 
  32 // Static initialization
  33 
  34 // This declares the position where vars are kept in the cvstate
  35 // For some degree of consistency we use the TypeFunc enum to
  36 // soak up spots in the inputs even though we only use early Control
  37 // and Memory slots. (So far.)
  38 const uint IdealKit::first_var = TypeFunc::Parms + 1;
  39 
  40 //----------------------------IdealKit-----------------------------------------
  41 IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarations) :
  42   C(gkit->C), _gvn(gkit->gvn()) {
  43   _initial_ctrl = gkit->control();
  44   _initial_memory = gkit->merged_memory();
  45   _initial_i_o = gkit->i_o();
  46   _delay_all_transforms = delay_all_transforms;
  47   _var_ct = 0;
  48   _cvstate = NULL;
  49   // We can go memory state free or else we need the entire memory state
  50   assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split");

  51   int init_size = 5;
  52   _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
  53   DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
  54   if (!has_declarations) {
  55      declarations_done();
  56   }
  57 }
  58 
  59 //----------------------------sync_kit-----------------------------------------
  60 void IdealKit::sync_kit(GraphKit* gkit) {
  61   set_all_memory(gkit->merged_memory());
  62   set_i_o(gkit->i_o());
  63   set_ctrl(gkit->control());
  64 }
  65 
  66 //-------------------------------if_then-------------------------------------
  67 // Create:  if(left relop right)
  68 //          /  \
  69 //   iffalse    iftrue
  70 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.


 278   const BasicType bt = n->bottom_type()->basic_type();
 279   const Type* ct = Type::get_const_basic_type(bt);
 280   return delay_transform(PhiNode::make(reg, n, ct));
 281 }
 282 
 283 //-----------------------------declarations_done-------------------------------
 284 void IdealKit::declarations_done() {
 285   _cvstate = new_cvstate();   // initialize current cvstate
 286   set_ctrl(_initial_ctrl);    // initialize control in current cvstate
 287   set_all_memory(_initial_memory);// initialize memory in current cvstate
 288   set_i_o(_initial_i_o);      // initialize i_o in current cvstate
 289   DEBUG_ONLY(_state->push(BlockS));
 290 }
 291 
 292 //-----------------------------transform-----------------------------------
 293 Node* IdealKit::transform(Node* n) {
 294   if (_delay_all_transforms) {
 295     return delay_transform(n);
 296   } else {
 297     n = gvn().transform(n);
 298     gvn().record_for_igvn(n);
 299     return n;
 300   }
 301 }
 302 
 303 //-----------------------------delay_transform-----------------------------------
 304 Node* IdealKit::delay_transform(Node* n) {
 305   // Delay transform until IterativeGVN
 306   gvn().set_type(n, n->bottom_type());
 307   gvn().record_for_igvn(n);
 308   return n;
 309 }
 310 
 311 //-----------------------------new_cvstate-----------------------------------
 312 Node* IdealKit::new_cvstate() {
 313   uint sz = _var_ct + first_var;
 314   return new Node(sz);
 315 }
 316 
 317 //-----------------------------copy_cvstate-----------------------------------
 318 Node* IdealKit::copy_cvstate() {
 319   Node* ns = new_cvstate();
 320   for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i));
 321   // We must clone memory since it will be updated as we do stores.
 322   ns->set_req(TypeFunc::Memory, MergeMemNode::make(ns->in(TypeFunc::Memory)));
 323   return ns;
 324 }
 325 
 326 //-----------------------------clear-----------------------------------
 327 void IdealKit::clear(Node* m) {


 515   if (parm2 != NULL)  call->init_req(TypeFunc::Parms+2, parm2);
 516   if (parm3 != NULL)  call->init_req(TypeFunc::Parms+3, parm3);
 517 
 518   // Node *c = _gvn.transform(call);
 519   call = (CallNode *) _gvn.transform(call);
 520   Node *c = call; // dbx gets confused with call call->dump()
 521 
 522   // Slow leaf call has no side-effects, sets few values
 523 
 524   set_ctrl(transform( new ProjNode(call,TypeFunc::Control) ));
 525 
 526   // Make memory for the call
 527   Node* mem = _gvn.transform( new ProjNode(call, TypeFunc::Memory) );
 528 
 529   // Set the RawPtr memory state only.
 530   set_memory(mem, adr_idx);
 531 
 532   assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
 533          "call node must be constructed correctly");
 534   Node* res = NULL;
 535   if (slow_call_type->range_sig()->cnt() > TypeFunc::Parms) {
 536     assert(slow_call_type->range_sig()->cnt() == TypeFunc::Parms+1, "only one return value");
 537     res = transform(new ProjNode(call, TypeFunc::Parms));
 538   }
 539   return res;
 540 }
 541 
 542 void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type,
 543                               address slow_call,
 544                               const char *leaf_name,
 545                               const TypePtr* adr_type,
 546                               Node* parm0,
 547                               Node* parm1,
 548                               Node* parm2,
 549                               Node* parm3) {
 550 
 551   // We only handle taking in RawMem and modifying RawMem
 552   uint adr_idx = C->get_alias_index(adr_type);
 553 
 554   // Slow-path leaf call
 555   CallNode *call =  (CallNode*)new CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type);
 556 


< prev index next >