1.1 --- a/src/share/vm/opto/idealKit.cpp Fri Apr 01 21:45:33 2011 -0700 1.2 +++ b/src/share/vm/opto/idealKit.cpp Sat Apr 02 09:49:27 2011 -0700 1.3 @@ -38,15 +38,16 @@ 1.4 const uint IdealKit::first_var = TypeFunc::Parms + 1; 1.5 1.6 //----------------------------IdealKit----------------------------------------- 1.7 -IdealKit::IdealKit(PhaseGVN &gvn, Node* control, Node* mem, bool delay_all_transforms, bool has_declarations) : 1.8 - _gvn(gvn), C(gvn.C) { 1.9 - _initial_ctrl = control; 1.10 - _initial_memory = mem; 1.11 +IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarations) : 1.12 + _gvn(gkit->gvn()), C(gkit->C) { 1.13 + _initial_ctrl = gkit->control(); 1.14 + _initial_memory = gkit->merged_memory(); 1.15 + _initial_i_o = gkit->i_o(); 1.16 _delay_all_transforms = delay_all_transforms; 1.17 _var_ct = 0; 1.18 _cvstate = NULL; 1.19 // We can go memory state free or else we need the entire memory state 1.20 - assert(mem == NULL || mem->Opcode() == Op_MergeMem, "memory must be pre-split"); 1.21 + assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split"); 1.22 int init_size = 5; 1.23 _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0); 1.24 _delay_transform = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0); 1.25 @@ -56,6 +57,13 @@ 1.26 } 1.27 } 1.28 1.29 +//----------------------------sync_kit----------------------------------------- 1.30 +void IdealKit::sync_kit(GraphKit* gkit) { 1.31 + set_all_memory(gkit->merged_memory()); 1.32 + set_i_o(gkit->i_o()); 1.33 + set_ctrl(gkit->control()); 1.34 +} 1.35 + 1.36 //-------------------------------if_then------------------------------------- 1.37 // Create: if(left relop right) 1.38 // / \ 1.39 @@ -156,16 +164,14 @@ 1.40 // onto the stack. 1.41 void IdealKit::loop(GraphKit* gkit, int nargs, IdealVariable& iv, Node* init, BoolTest::mask relop, Node* limit, float prob, float cnt) { 1.42 assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new loop"); 1.43 - 1.44 - // Sync IdealKit and graphKit. 1.45 - gkit->set_all_memory(this->merged_memory()); 1.46 - gkit->set_control(this->ctrl()); 1.47 - // Add loop predicate. 1.48 - gkit->add_predicate(nargs); 1.49 - // Update IdealKit memory. 1.50 - this->set_all_memory(gkit->merged_memory()); 1.51 - this->set_ctrl(gkit->control()); 1.52 - 1.53 + if (UseLoopPredicate) { 1.54 + // Sync IdealKit and graphKit. 1.55 + gkit->sync_kit(*this); 1.56 + // Add loop predicate. 1.57 + gkit->add_predicate(nargs); 1.58 + // Update IdealKit memory. 1.59 + sync_kit(gkit); 1.60 + } 1.61 set(iv, init); 1.62 Node* head = make_label(1); 1.63 bind(head); 1.64 @@ -280,6 +286,7 @@ 1.65 _cvstate = new_cvstate(); // initialize current cvstate 1.66 set_ctrl(_initial_ctrl); // initialize control in current cvstate 1.67 set_all_memory(_initial_memory);// initialize memory in current cvstate 1.68 + set_i_o(_initial_i_o); // initialize i_o in current cvstate 1.69 DEBUG_ONLY(_state->push(BlockS)); 1.70 } 1.71 1.72 @@ -421,6 +428,9 @@ 1.73 // Get the region for the join state 1.74 Node* join_region = join->in(TypeFunc::Control); 1.75 assert(join_region != NULL, "join region must exist"); 1.76 + if (join->in(TypeFunc::I_O) == NULL ) { 1.77 + join->set_req(TypeFunc::I_O, merging->in(TypeFunc::I_O)); 1.78 + } 1.79 if (join->in(TypeFunc::Memory) == NULL ) { 1.80 join->set_req(TypeFunc::Memory, merging->in(TypeFunc::Memory)); 1.81 return; 1.82 @@ -467,6 +477,20 @@ 1.83 mms.set_memory(phi); 1.84 } 1.85 } 1.86 + 1.87 + Node* join_io = join->in(TypeFunc::I_O); 1.88 + Node* merging_io = merging->in(TypeFunc::I_O); 1.89 + if (join_io != merging_io) { 1.90 + PhiNode* phi; 1.91 + if (join_io->is_Phi() && join_io->as_Phi()->region() == join_region) { 1.92 + phi = join_io->as_Phi(); 1.93 + } else { 1.94 + phi = PhiNode::make(join_region, join_io, Type::ABIO); 1.95 + phi = (PhiNode*) delay_transform(phi); 1.96 + join->set_req(TypeFunc::I_O, phi); 1.97 + } 1.98 + phi->set_req(slot, merging_io); 1.99 + } 1.100 } 1.101 1.102 1.103 @@ -477,7 +501,8 @@ 1.104 const char *leaf_name, 1.105 Node* parm0, 1.106 Node* parm1, 1.107 - Node* parm2) { 1.108 + Node* parm2, 1.109 + Node* parm3) { 1.110 1.111 // We only handle taking in RawMem and modifying RawMem 1.112 const TypePtr* adr_type = TypeRawPtr::BOTTOM; 1.113 @@ -498,6 +523,7 @@ 1.114 if (parm0 != NULL) call->init_req(TypeFunc::Parms+0, parm0); 1.115 if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1); 1.116 if (parm2 != NULL) call->init_req(TypeFunc::Parms+2, parm2); 1.117 + if (parm3 != NULL) call->init_req(TypeFunc::Parms+3, parm3); 1.118 1.119 // Node *c = _gvn.transform(call); 1.120 call = (CallNode *) _gvn.transform(call); 1.121 @@ -516,3 +542,51 @@ 1.122 assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type), 1.123 "call node must be constructed correctly"); 1.124 } 1.125 + 1.126 + 1.127 +void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type, 1.128 + address slow_call, 1.129 + const char *leaf_name, 1.130 + const TypePtr* adr_type, 1.131 + Node* parm0, 1.132 + Node* parm1, 1.133 + Node* parm2, 1.134 + Node* parm3) { 1.135 + 1.136 + // We only handle taking in RawMem and modifying RawMem 1.137 + uint adr_idx = C->get_alias_index(adr_type); 1.138 + 1.139 + // Slow-path leaf call 1.140 + int size = slow_call_type->domain()->cnt(); 1.141 + CallNode *call = (CallNode*)new (C, size) CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type); 1.142 + 1.143 + // Set fixed predefined input arguments 1.144 + call->init_req( TypeFunc::Control, ctrl() ); 1.145 + call->init_req( TypeFunc::I_O , top() ) ; // does no i/o 1.146 + // Narrow memory as only memory input 1.147 + call->init_req( TypeFunc::Memory , memory(adr_idx)); 1.148 + call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ ); 1.149 + call->init_req( TypeFunc::ReturnAdr, top() ); 1.150 + 1.151 + if (parm0 != NULL) call->init_req(TypeFunc::Parms+0, parm0); 1.152 + if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1); 1.153 + if (parm2 != NULL) call->init_req(TypeFunc::Parms+2, parm2); 1.154 + if (parm3 != NULL) call->init_req(TypeFunc::Parms+3, parm3); 1.155 + 1.156 + // Node *c = _gvn.transform(call); 1.157 + call = (CallNode *) _gvn.transform(call); 1.158 + Node *c = call; // dbx gets confused with call call->dump() 1.159 + 1.160 + // Slow leaf call has no side-effects, sets few values 1.161 + 1.162 + set_ctrl(transform( new (C, 1) ProjNode(call,TypeFunc::Control) )); 1.163 + 1.164 + // Make memory for the call 1.165 + Node* mem = _gvn.transform( new (C, 1) ProjNode(call, TypeFunc::Memory) ); 1.166 + 1.167 + // Set the RawPtr memory state only. 1.168 + set_memory(mem, adr_idx); 1.169 + 1.170 + assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type), 1.171 + "call node must be constructed correctly"); 1.172 +}