1189 // emitted before MachConstantBaseNode.
1190 Compile::ConstantTable& constant_table = C->constant_table();
1191 constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
1192 }
1193 }
1194
1195 uint MachPrologNode::size(PhaseRegAlloc *ra_) const {
1196 return MachNode::size(ra_);
1197 }
1198
1199 int MachPrologNode::reloc() const {
1200 return 10; // a large enough number
1201 }
1202
1203 //=============================================================================
1204 #ifndef PRODUCT
1205 void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
1206 Compile* C = ra_->C;
1207
1208 if(do_polling() && ra_->C->is_method_compilation()) {
1209 st->print("SETHI #PollAddr,L0\t! Load Polling address\n\t");
1210 st->print("LDX [L0],G0\t!Poll for Safepointing\n\t");
1211 }
1212
1213 if(do_polling()) {
1214 if (UseCBCond && !ra_->C->is_method_compilation()) {
1215 st->print("NOP\n\t");
1216 }
1217 st->print("RET\n\t");
1218 }
1219
1220 st->print("RESTORE");
1221 }
1222 #endif
1223
1224 void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
1225 MacroAssembler _masm(&cbuf);
1226 Compile* C = ra_->C;
1227
1228 __ verify_thread();
1229
1230 if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
1231 __ reserved_stack_check();
1232 }
1233
1234 // If this does safepoint polling, then do it here
1235 if(do_polling() && ra_->C->is_method_compilation()) {
1236 AddressLiteral polling_page(os::get_polling_page());
1237 __ sethi(polling_page, L0);
1238 __ relocate(relocInfo::poll_return_type);
1239 __ ld_ptr(L0, 0, G0);
1240 }
1241
1242 // If this is a return, then stuff the restore in the delay slot
1243 if(do_polling()) {
1244 if (UseCBCond && !ra_->C->is_method_compilation()) {
1245 // Insert extra padding for the case when the epilogue is preceded by
1246 // a cbcond jump, which can't be followed by a CTI instruction
1247 __ nop();
1248 }
1249 __ ret();
1250 __ delayed()->restore();
1251 } else {
1252 __ restore();
1253 }
1254 }
1255
1256 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
1257 return MachNode::size(ra_);
1258 }
1259
1260 int MachEpilogNode::reloc() const {
1261 return 16; // a large enough number
1262 }
1263
1264 const Pipeline * MachEpilogNode::pipeline() const {
1265 return MachNode::pipeline_class();
1266 }
1267
1268 int MachEpilogNode::safepoint_offset() const {
1269 assert( do_polling(), "no return for this epilog node");
1270 return MacroAssembler::insts_for_sethi(os::get_polling_page()) * BytesPerInstWord;
1271 }
1272
1273 //=============================================================================
1274
1275 // Figure out which register class each belongs in: rc_int, rc_float, rc_stack
1276 enum RC { rc_bad, rc_int, rc_float, rc_stack };
1277 static enum RC rc_class( OptoReg::Name reg ) {
1278 if (!OptoReg::is_valid(reg)) return rc_bad;
1279 if (OptoReg::is_stack(reg)) return rc_stack;
1280 VMReg r = OptoReg::as_VMReg(reg);
1281 if (r->is_Register()) return rc_int;
1282 assert(r->is_FloatRegister(), "must be");
1283 return rc_float;
1284 }
1285
1286 #ifndef PRODUCT
1287 ATTRIBUTE_PRINTF(2, 3)
1288 static void print_helper(outputStream* st, const char* format, ...) {
|
1189 // emitted before MachConstantBaseNode.
1190 Compile::ConstantTable& constant_table = C->constant_table();
1191 constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
1192 }
1193 }
1194
1195 uint MachPrologNode::size(PhaseRegAlloc *ra_) const {
1196 return MachNode::size(ra_);
1197 }
1198
1199 int MachPrologNode::reloc() const {
1200 return 10; // a large enough number
1201 }
1202
1203 //=============================================================================
1204 #ifndef PRODUCT
1205 void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
1206 Compile* C = ra_->C;
1207
1208 if(do_polling() && ra_->C->is_method_compilation()) {
1209 if (SafepointMechanism::uses_global_page_poll()) {
1210 st->print("SETHI #PollAddr,L0\t! Load Polling address\n\t");
1211 } else {
1212 st->print("LDX [R_G2 + #poll_offset],L0\t! Load local polling address\n\t");
1213 }
1214 st->print("LDX [L0],G0\t!Poll for Safepointing\n\t");
1215 }
1216
1217 if(do_polling()) {
1218 if (UseCBCond && !ra_->C->is_method_compilation()) {
1219 st->print("NOP\n\t");
1220 }
1221 st->print("RET\n\t");
1222 }
1223
1224 st->print("RESTORE");
1225 }
1226 #endif
1227
1228 void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
1229 MacroAssembler _masm(&cbuf);
1230 Compile* C = ra_->C;
1231
1232 __ verify_thread();
1233
1234 if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
1235 __ reserved_stack_check();
1236 }
1237
1238 // If this does safepoint polling, then do it here
1239 if(do_polling() && ra_->C->is_method_compilation()) {
1240 if (SafepointMechanism::uses_thread_local_poll()) {
1241 __ ld_ptr(Address(G2_thread, Thread::polling_page_offset()), L0);
1242 } else {
1243 AddressLiteral polling_page(os::get_polling_page());
1244 __ sethi(polling_page, L0);
1245 }
1246 __ relocate(relocInfo::poll_return_type);
1247 __ ld_ptr(L0, 0, G0);
1248 }
1249
1250 // If this is a return, then stuff the restore in the delay slot
1251 if(do_polling()) {
1252 if (UseCBCond && !ra_->C->is_method_compilation()) {
1253 // Insert extra padding for the case when the epilogue is preceded by
1254 // a cbcond jump, which can't be followed by a CTI instruction
1255 __ nop();
1256 }
1257 __ ret();
1258 __ delayed()->restore();
1259 } else {
1260 __ restore();
1261 }
1262 }
1263
1264 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
1265 return MachNode::size(ra_);
1266 }
1267
1268 int MachEpilogNode::reloc() const {
1269 return 16; // a large enough number
1270 }
1271
1272 const Pipeline * MachEpilogNode::pipeline() const {
1273 return MachNode::pipeline_class();
1274 }
1275
1276 int MachEpilogNode::safepoint_offset() const {
1277 assert(SafepointMechanism::uses_global_page_poll(), "sanity");
1278 assert( do_polling(), "no return for this epilog node");
1279 return MacroAssembler::insts_for_sethi(os::get_polling_page()) * BytesPerInstWord;
1280 }
1281
1282 //=============================================================================
1283
1284 // Figure out which register class each belongs in: rc_int, rc_float, rc_stack
1285 enum RC { rc_bad, rc_int, rc_float, rc_stack };
1286 static enum RC rc_class( OptoReg::Name reg ) {
1287 if (!OptoReg::is_valid(reg)) return rc_bad;
1288 if (OptoReg::is_stack(reg)) return rc_stack;
1289 VMReg r = OptoReg::as_VMReg(reg);
1290 if (r->is_Register()) return rc_int;
1291 assert(r->is_FloatRegister(), "must be");
1292 return rc_float;
1293 }
1294
1295 #ifndef PRODUCT
1296 ATTRIBUTE_PRINTF(2, 3)
1297 static void print_helper(outputStream* st, const char* format, ...) {
|