184 const TypeTuple *range = C->tf()->range();
185 if( range->cnt() > TypeFunc::Parms ) { // If not a void function
186 // Get ideal-register return type
187 int ireg = range->field_at(TypeFunc::Parms)->ideal_reg();
188 // Get machine return register
189 uint sop = C->start()->Opcode();
190 OptoRegPair regs = return_value(ireg, false);
191
192 // And mask for same
193 _return_value_mask = RegMask(regs.first());
194 if( OptoReg::is_valid(regs.second()) )
195 _return_value_mask.Insert(regs.second());
196 }
197
198 // ---------------
199 // Frame Layout
200
201 // Need the method signature to determine the incoming argument types,
202 // because the types determine which registers the incoming arguments are
203 // in, and this affects the matched code.
204 const TypeTuple *domain = C->tf()->domain();
205 uint argcnt = domain->cnt() - TypeFunc::Parms;
206 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
207 VMRegPair *vm_parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
208 _parm_regs = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
209 _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
210 uint i;
211 for( i = 0; i<argcnt; i++ ) {
212 sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
213 }
214
215 // Pass array of ideal registers and length to USER code (from the AD file)
216 // that will convert this to an array of register numbers.
217 const StartNode *start = C->start();
218 start->calling_convention( sig_bt, vm_parm_regs, argcnt );
219 #ifdef ASSERT
220 // Sanity check users' calling convention. Real handy while trying to
221 // get the initial port correct.
222 { for (uint i = 0; i<argcnt; i++) {
223 if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {
224 assert(domain->field_at(i+TypeFunc::Parms)==Type::HALF, "only allowed on halve" );
699 }
700
701 // Input RegMask array shared by all Halts
702 uint halt_edge_cnt = TypeFunc::Parms;
703 RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
704
705 // Capture the return input masks into each exit flavor
706 for( i=1; i < root->req(); i++ ) {
707 MachReturnNode *exit = root->in(i)->as_MachReturn();
708 switch( exit->ideal_Opcode() ) {
709 case Op_Return : exit->_in_rms = ret_rms; break;
710 case Op_Rethrow : exit->_in_rms = reth_rms; break;
711 case Op_TailCall : exit->_in_rms = tail_call_rms; break;
712 case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
713 case Op_Halt : exit->_in_rms = halt_rms; break;
714 default : ShouldNotReachHere();
715 }
716 }
717
718 // Next unused projection number from Start.
719 int proj_cnt = C->tf()->domain()->cnt();
720
721 // Do all the save-on-entry registers. Make projections from Start for
722 // them, and give them a use at the exit points. To the allocator, they
723 // look like incoming register arguments.
724 for( i = 0; i < _last_Mach_Reg; i++ ) {
725 if( is_save_on_entry(i) ) {
726
727 // Add the save-on-entry to the mask array
728 ret_rms [ ret_edge_cnt] = mreg2regmask[i];
729 reth_rms [ reth_edge_cnt] = mreg2regmask[i];
730 tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
731 tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
732 // Halts need the SOE registers, but only in the stack as debug info.
733 // A just-prior uncommon-trap or deoptimization will use the SOE regs.
734 halt_rms [ halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
735
736 Node *mproj;
737
738 // Is this a RegF low half of a RegD? Double up 2 adjacent RegF's
739 // into a single RegD.
1160 }
1161 return OptoReg::as_OptoReg(reg);
1162 }
1163
1164
1165 //------------------------------match_sfpt-------------------------------------
1166 // Helper function to match call instructions. Calls match special.
1167 // They match alone with no children. Their children, the incoming
1168 // arguments, match normally.
1169 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1170 MachSafePointNode *msfpt = NULL;
1171 MachCallNode *mcall = NULL;
1172 uint cnt;
1173 // Split out case for SafePoint vs Call
1174 CallNode *call;
1175 const TypeTuple *domain;
1176 ciMethod* method = NULL;
1177 bool is_method_handle_invoke = false; // for special kill effects
1178 if( sfpt->is_Call() ) {
1179 call = sfpt->as_Call();
1180 domain = call->tf()->domain();
1181 cnt = domain->cnt();
1182
1183 // Match just the call, nothing else
1184 MachNode *m = match_tree(call);
1185 if (C->failing()) return NULL;
1186 if( m == NULL ) { Matcher::soft_match_failure(); return NULL; }
1187
1188 // Copy data from the Ideal SafePoint to the machine version
1189 mcall = m->as_MachCall();
1190
1191 mcall->set_tf( call->tf());
1192 mcall->set_entry_point(call->entry_point());
1193 mcall->set_cnt( call->cnt());
1194
1195 if( mcall->is_MachCallJava() ) {
1196 MachCallJavaNode *mcall_java = mcall->as_MachCallJava();
1197 const CallJavaNode *call_java = call->as_CallJava();
1198 method = call_java->method();
1199 mcall_java->_method = method;
1200 mcall_java->_bci = call_java->_bci;
1288 assert( reg3 != reg4, "calling conv. must produce distinct regs");
1289 }
1290 }
1291 }
1292 }
1293 #endif
1294
1295 // Visit each argument. Compute its outgoing register mask.
1296 // Return results now can have 2 bits returned.
1297 // Compute max over all outgoing arguments both per call-site
1298 // and over the entire method.
1299 for( i = 0; i < argcnt; i++ ) {
1300 // Address of incoming argument mask to fill in
1301 RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms];
1302 if( !parm_regs[i].first()->is_valid() &&
1303 !parm_regs[i].second()->is_valid() ) {
1304 continue; // Avoid Halves
1305 }
1306 // Grab first register, adjust stack slots and insert in mask.
1307 OptoReg::Name reg1 = warp_outgoing_stk_arg(parm_regs[i].first(), begin_out_arg_area, out_arg_limit_per_call );
1308 if (OptoReg::is_valid(reg1))
1309 rm->Insert( reg1 );
1310 // Grab second register (if any), adjust stack slots and insert in mask.
1311 OptoReg::Name reg2 = warp_outgoing_stk_arg(parm_regs[i].second(), begin_out_arg_area, out_arg_limit_per_call );
1312 if (OptoReg::is_valid(reg2))
1313 rm->Insert( reg2 );
1314 } // End of for all arguments
1315
1316 // Compute number of stack slots needed to restore stack in case of
1317 // Pascal-style argument popping.
1318 mcall->_argsize = out_arg_limit_per_call - begin_out_arg_area;
1319 }
1320
1321 // Compute the max stack slot killed by any call. These will not be
1322 // available for debug info, and will be used to adjust FIRST_STACK_mask
1323 // after all call sites have been visited.
1324 if( _out_arg_limit < out_arg_limit_per_call)
1325 _out_arg_limit = out_arg_limit_per_call;
1326
1327 if (mcall) {
1328 // Kill the outgoing argument area, including any non-argument holes and
1329 // any legacy C-killed slots. Use Fat-Projections to do the killing.
1330 // Since the max-per-method covers the max-per-call-site and debug info
1331 // is excluded on the max-per-method basis, debug info cannot land in
1332 // this killed area.
1333 uint r_cnt = mcall->tf()->range()->cnt();
1334 MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1335 if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
1336 C->record_method_not_compilable_all_tiers("unsupported outgoing calling sequence");
1337 } else {
1338 for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
1339 proj->_rout.Insert(OptoReg::Name(i));
1340 }
1341 if (proj->_rout.is_NotEmpty()) {
1342 push_projection(proj);
1343 }
1344 }
1345 // Transfer the safepoint information from the call to the mcall
1346 // Move the JVMState list
1347 msfpt->set_jvms(sfpt->jvms());
1348 for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1349 jvms->set_map(sfpt);
1350 }
1351
1352 // Debug inputs begin just after the last incoming parameter
1353 assert((mcall == NULL) || (mcall->jvms() == NULL) ||
1354 (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain()->cnt()), "");
1355
1356 // Move the OopMap
1357 msfpt->_oop_map = sfpt->_oop_map;
1358
1359 // Add additional edges.
1360 if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1361 // For these calls we can not add MachConstantBase in expand(), as the
1362 // ins are not complete then.
1363 msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1364 if (msfpt->jvms() &&
1365 msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1366 // We added an edge before jvms, so we must adapt the position of the ins.
1367 msfpt->jvms()->adapt_position(+1);
1368 }
1369 }
1370
1371 // Registers killed by the call are set in the local scheduling pass
1372 // of Global Code Motion.
1373 return msfpt;
1374 }
|
184 const TypeTuple *range = C->tf()->range();
185 if( range->cnt() > TypeFunc::Parms ) { // If not a void function
186 // Get ideal-register return type
187 int ireg = range->field_at(TypeFunc::Parms)->ideal_reg();
188 // Get machine return register
189 uint sop = C->start()->Opcode();
190 OptoRegPair regs = return_value(ireg, false);
191
192 // And mask for same
193 _return_value_mask = RegMask(regs.first());
194 if( OptoReg::is_valid(regs.second()) )
195 _return_value_mask.Insert(regs.second());
196 }
197
198 // ---------------
199 // Frame Layout
200
201 // Need the method signature to determine the incoming argument types,
202 // because the types determine which registers the incoming arguments are
203 // in, and this affects the matched code.
204 const TypeTuple *domain = C->tf()->domain_cc();
205 uint argcnt = domain->cnt() - TypeFunc::Parms;
206 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
207 VMRegPair *vm_parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
208 _parm_regs = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
209 _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
210 uint i;
211 for( i = 0; i<argcnt; i++ ) {
212 sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
213 }
214
215 // Pass array of ideal registers and length to USER code (from the AD file)
216 // that will convert this to an array of register numbers.
217 const StartNode *start = C->start();
218 start->calling_convention( sig_bt, vm_parm_regs, argcnt );
219 #ifdef ASSERT
220 // Sanity check users' calling convention. Real handy while trying to
221 // get the initial port correct.
222 { for (uint i = 0; i<argcnt; i++) {
223 if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {
224 assert(domain->field_at(i+TypeFunc::Parms)==Type::HALF, "only allowed on halve" );
699 }
700
701 // Input RegMask array shared by all Halts
702 uint halt_edge_cnt = TypeFunc::Parms;
703 RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
704
705 // Capture the return input masks into each exit flavor
706 for( i=1; i < root->req(); i++ ) {
707 MachReturnNode *exit = root->in(i)->as_MachReturn();
708 switch( exit->ideal_Opcode() ) {
709 case Op_Return : exit->_in_rms = ret_rms; break;
710 case Op_Rethrow : exit->_in_rms = reth_rms; break;
711 case Op_TailCall : exit->_in_rms = tail_call_rms; break;
712 case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
713 case Op_Halt : exit->_in_rms = halt_rms; break;
714 default : ShouldNotReachHere();
715 }
716 }
717
718 // Next unused projection number from Start.
719 int proj_cnt = C->tf()->domain_cc()->cnt();
720
721 // Do all the save-on-entry registers. Make projections from Start for
722 // them, and give them a use at the exit points. To the allocator, they
723 // look like incoming register arguments.
724 for( i = 0; i < _last_Mach_Reg; i++ ) {
725 if( is_save_on_entry(i) ) {
726
727 // Add the save-on-entry to the mask array
728 ret_rms [ ret_edge_cnt] = mreg2regmask[i];
729 reth_rms [ reth_edge_cnt] = mreg2regmask[i];
730 tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
731 tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
732 // Halts need the SOE registers, but only in the stack as debug info.
733 // A just-prior uncommon-trap or deoptimization will use the SOE regs.
734 halt_rms [ halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
735
736 Node *mproj;
737
738 // Is this a RegF low half of a RegD? Double up 2 adjacent RegF's
739 // into a single RegD.
1160 }
1161 return OptoReg::as_OptoReg(reg);
1162 }
1163
1164
1165 //------------------------------match_sfpt-------------------------------------
1166 // Helper function to match call instructions. Calls match special.
1167 // They match alone with no children. Their children, the incoming
1168 // arguments, match normally.
1169 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1170 MachSafePointNode *msfpt = NULL;
1171 MachCallNode *mcall = NULL;
1172 uint cnt;
1173 // Split out case for SafePoint vs Call
1174 CallNode *call;
1175 const TypeTuple *domain;
1176 ciMethod* method = NULL;
1177 bool is_method_handle_invoke = false; // for special kill effects
1178 if( sfpt->is_Call() ) {
1179 call = sfpt->as_Call();
1180 domain = call->tf()->domain_cc();
1181 cnt = domain->cnt();
1182
1183 // Match just the call, nothing else
1184 MachNode *m = match_tree(call);
1185 if (C->failing()) return NULL;
1186 if( m == NULL ) { Matcher::soft_match_failure(); return NULL; }
1187
1188 // Copy data from the Ideal SafePoint to the machine version
1189 mcall = m->as_MachCall();
1190
1191 mcall->set_tf( call->tf());
1192 mcall->set_entry_point(call->entry_point());
1193 mcall->set_cnt( call->cnt());
1194
1195 if( mcall->is_MachCallJava() ) {
1196 MachCallJavaNode *mcall_java = mcall->as_MachCallJava();
1197 const CallJavaNode *call_java = call->as_CallJava();
1198 method = call_java->method();
1199 mcall_java->_method = method;
1200 mcall_java->_bci = call_java->_bci;
1288 assert( reg3 != reg4, "calling conv. must produce distinct regs");
1289 }
1290 }
1291 }
1292 }
1293 #endif
1294
1295 // Visit each argument. Compute its outgoing register mask.
1296 // Return results now can have 2 bits returned.
1297 // Compute max over all outgoing arguments both per call-site
1298 // and over the entire method.
1299 for( i = 0; i < argcnt; i++ ) {
1300 // Address of incoming argument mask to fill in
1301 RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms];
1302 if( !parm_regs[i].first()->is_valid() &&
1303 !parm_regs[i].second()->is_valid() ) {
1304 continue; // Avoid Halves
1305 }
1306 // Grab first register, adjust stack slots and insert in mask.
1307 OptoReg::Name reg1 = warp_outgoing_stk_arg(parm_regs[i].first(), begin_out_arg_area, out_arg_limit_per_call );
1308 if (OptoReg::is_valid(reg1)) {
1309 rm->Insert( reg1 );
1310 }
1311 // Grab second register (if any), adjust stack slots and insert in mask.
1312 OptoReg::Name reg2 = warp_outgoing_stk_arg(parm_regs[i].second(), begin_out_arg_area, out_arg_limit_per_call );
1313 if (OptoReg::is_valid(reg2)) {
1314 rm->Insert( reg2 );
1315 }
1316 } // End of for all arguments
1317
1318 // Compute number of stack slots needed to restore stack in case of
1319 // Pascal-style argument popping.
1320 mcall->_argsize = out_arg_limit_per_call - begin_out_arg_area;
1321 }
1322
1323 // Compute the max stack slot killed by any call. These will not be
1324 // available for debug info, and will be used to adjust FIRST_STACK_mask
1325 // after all call sites have been visited.
1326 if( _out_arg_limit < out_arg_limit_per_call)
1327 _out_arg_limit = out_arg_limit_per_call;
1328
1329 if (mcall) {
1330 // Kill the outgoing argument area, including any non-argument holes and
1331 // any legacy C-killed slots. Use Fat-Projections to do the killing.
1332 // Since the max-per-method covers the max-per-call-site and debug info
1333 // is excluded on the max-per-method basis, debug info cannot land in
1334 // this killed area.
1335 uint r_cnt = mcall->tf()->range()->cnt();
1336 MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1337 if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
1338 C->record_method_not_compilable_all_tiers("unsupported outgoing calling sequence");
1339 } else {
1340 for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
1341 proj->_rout.Insert(OptoReg::Name(i));
1342 }
1343 if (proj->_rout.is_NotEmpty()) {
1344 push_projection(proj);
1345 }
1346 }
1347 // Transfer the safepoint information from the call to the mcall
1348 // Move the JVMState list
1349 msfpt->set_jvms(sfpt->jvms());
1350 for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1351 jvms->set_map(sfpt);
1352 }
1353
1354 // Debug inputs begin just after the last incoming parameter
1355 assert((mcall == NULL) || (mcall->jvms() == NULL) ||
1356 (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain_cc()->cnt()), "");
1357
1358 // Move the OopMap
1359 msfpt->_oop_map = sfpt->_oop_map;
1360
1361 // Add additional edges.
1362 if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1363 // For these calls we can not add MachConstantBase in expand(), as the
1364 // ins are not complete then.
1365 msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1366 if (msfpt->jvms() &&
1367 msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1368 // We added an edge before jvms, so we must adapt the position of the ins.
1369 msfpt->jvms()->adapt_position(+1);
1370 }
1371 }
1372
1373 // Registers killed by the call are set in the local scheduling pass
1374 // of Global Code Motion.
1375 return msfpt;
1376 }
|