207 };
208
209 PhaseOutput::PhaseOutput()
210 : Phase(Phase::Output),
211 _code_buffer("Compile::Fill_buffer"),
212 _first_block_size(0),
213 _handler_table(),
214 _inc_table(),
215 _stub_list(),
216 _oop_map_set(nullptr),
217 _scratch_buffer_blob(nullptr),
218 _scratch_locs_memory(nullptr),
219 _scratch_const_size(-1),
220 _in_scratch_emit_size(false),
221 _frame_slots(0),
222 _code_offsets(),
223 _node_bundling_limit(0),
224 _node_bundling_base(nullptr),
225 _orig_pc_slot(0),
226 _orig_pc_slot_offset_in_bytes(0),
227 _buf_sizes(),
228 _block(nullptr),
229 _index(0) {
230 C->set_output(this);
231 if (C->stub_name() == nullptr) {
232 _orig_pc_slot = C->fixed_slots() - (sizeof(address) / VMRegImpl::stack_slot_size);
233 }
234 }
235
236 PhaseOutput::~PhaseOutput() {
237 C->set_output(nullptr);
238 if (_scratch_buffer_blob != nullptr) {
239 BufferBlob::free(_scratch_buffer_blob);
240 }
241 }
242
243 void PhaseOutput::perform_mach_node_analysis() {
244 // Late barrier analysis must be done after schedule and bundle
245 // Otherwise liveness based spilling will fail
246 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
247 bs->late_barrier_analysis();
248
249 pd_perform_mach_node_analysis();
250
251 C->print_method(CompilerPhaseType::PHASE_MACH_ANALYSIS, 3);
252 }
1270 debug_info->describe_scope(pc_offset, null_mh, method, jvms->bci(), jvms->should_reexecute());
1271 }
1272
1273 // Mark the end of the scope set.
1274 debug_info->end_non_safepoint(pc_offset);
1275 }
1276
1277 //------------------------------init_buffer------------------------------------
1278 void PhaseOutput::estimate_buffer_size(int& const_req) {
1279
1280 // Set the initially allocated size
1281 const_req = initial_const_capacity;
1282
1283 // The extra spacing after the code is necessary on some platforms.
1284 // Sometimes we need to patch in a jump after the last instruction,
1285 // if the nmethod has been deoptimized. (See 4932387, 4894843.)
1286
1287 // Compute the byte offset where we can store the deopt pc.
1288 if (C->fixed_slots() != 0) {
1289 _orig_pc_slot_offset_in_bytes = C->regalloc()->reg2offset(OptoReg::stack2reg(_orig_pc_slot));
1290 }
1291
1292 // Compute prolog code size
1293 _frame_slots = OptoReg::reg2stack(C->matcher()->_old_SP) + C->regalloc()->_framesize;
1294 assert(_frame_slots >= 0 && _frame_slots < 1000000, "sanity check");
1295
1296 if (C->has_mach_constant_base_node()) {
1297 uint add_size = 0;
1298 // Fill the constant table.
1299 // Note: This must happen before shorten_branches.
1300 for (uint i = 0; i < C->cfg()->number_of_blocks(); i++) {
1301 Block* b = C->cfg()->get_block(i);
1302
1303 for (uint j = 0; j < b->number_of_nodes(); j++) {
1304 Node* n = b->get_node(j);
1305
1306 // If the node is a MachConstantNode evaluate the constant
1307 // value section.
1308 if (n->is_MachConstant()) {
1309 MachConstantNode* machcon = n->as_MachConstant();
|
207 };
208
209 PhaseOutput::PhaseOutput()
210 : Phase(Phase::Output),
211 _code_buffer("Compile::Fill_buffer"),
212 _first_block_size(0),
213 _handler_table(),
214 _inc_table(),
215 _stub_list(),
216 _oop_map_set(nullptr),
217 _scratch_buffer_blob(nullptr),
218 _scratch_locs_memory(nullptr),
219 _scratch_const_size(-1),
220 _in_scratch_emit_size(false),
221 _frame_slots(0),
222 _code_offsets(),
223 _node_bundling_limit(0),
224 _node_bundling_base(nullptr),
225 _orig_pc_slot(0),
226 _orig_pc_slot_offset_in_bytes(0),
227 _gc_barrier_save_slots(0),
228 _gc_barrier_save_slots_offset_in_bytes(-1),
229 _buf_sizes(),
230 _block(nullptr),
231 _index(0) {
232 C->set_output(this);
233 if (C->stub_name() == nullptr) {
234 int reserved_gc_slots = BarrierSet::barrier_set()->barrier_set_c2()->reserved_slots();
235 _gc_barrier_save_slots = C->fixed_slots() - (reserved_gc_slots + 1) * sizeof(address) / VMRegImpl::stack_slot_size;
236 _orig_pc_slot = C->fixed_slots() - 1 * sizeof(address) / VMRegImpl::stack_slot_size;
237 }
238 }
239
240 PhaseOutput::~PhaseOutput() {
241 C->set_output(nullptr);
242 if (_scratch_buffer_blob != nullptr) {
243 BufferBlob::free(_scratch_buffer_blob);
244 }
245 }
246
247 void PhaseOutput::perform_mach_node_analysis() {
248 // Late barrier analysis must be done after schedule and bundle
249 // Otherwise liveness based spilling will fail
250 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
251 bs->late_barrier_analysis();
252
253 pd_perform_mach_node_analysis();
254
255 C->print_method(CompilerPhaseType::PHASE_MACH_ANALYSIS, 3);
256 }
1274 debug_info->describe_scope(pc_offset, null_mh, method, jvms->bci(), jvms->should_reexecute());
1275 }
1276
1277 // Mark the end of the scope set.
1278 debug_info->end_non_safepoint(pc_offset);
1279 }
1280
1281 //------------------------------init_buffer------------------------------------
1282 void PhaseOutput::estimate_buffer_size(int& const_req) {
1283
1284 // Set the initially allocated size
1285 const_req = initial_const_capacity;
1286
1287 // The extra spacing after the code is necessary on some platforms.
1288 // Sometimes we need to patch in a jump after the last instruction,
1289 // if the nmethod has been deoptimized. (See 4932387, 4894843.)
1290
1291 // Compute the byte offset where we can store the deopt pc.
1292 if (C->fixed_slots() != 0) {
1293 _orig_pc_slot_offset_in_bytes = C->regalloc()->reg2offset(OptoReg::stack2reg(_orig_pc_slot));
1294 _gc_barrier_save_slots_offset_in_bytes = C->regalloc()->reg2offset(OptoReg::stack2reg(_gc_barrier_save_slots));
1295 }
1296
1297 // Compute prolog code size
1298 _frame_slots = OptoReg::reg2stack(C->matcher()->_old_SP) + C->regalloc()->_framesize;
1299 assert(_frame_slots >= 0 && _frame_slots < 1000000, "sanity check");
1300
1301 if (C->has_mach_constant_base_node()) {
1302 uint add_size = 0;
1303 // Fill the constant table.
1304 // Note: This must happen before shorten_branches.
1305 for (uint i = 0; i < C->cfg()->number_of_blocks(); i++) {
1306 Block* b = C->cfg()->get_block(i);
1307
1308 for (uint j = 0; j < b->number_of_nodes(); j++) {
1309 Node* n = b->get_node(j);
1310
1311 // If the node is a MachConstantNode evaluate the constant
1312 // value section.
1313 if (n->is_MachConstant()) {
1314 MachConstantNode* machcon = n->as_MachConstant();
|