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 }
1279 debug_info->describe_scope(pc_offset, null_mh, method, jvms->bci(), jvms->should_reexecute());
1280 }
1281
1282 // Mark the end of the scope set.
1283 debug_info->end_non_safepoint(pc_offset);
1284 }
1285
1286 //------------------------------init_buffer------------------------------------
1287 void PhaseOutput::estimate_buffer_size(int& const_req) {
1288
1289 // Set the initially allocated size
1290 const_req = initial_const_capacity;
1291
1292 // The extra spacing after the code is necessary on some platforms.
1293 // Sometimes we need to patch in a jump after the last instruction,
1294 // if the nmethod has been deoptimized. (See 4932387, 4894843.)
1295
1296 // Compute the byte offset where we can store the deopt pc.
1297 if (C->fixed_slots() != 0) {
1298 _orig_pc_slot_offset_in_bytes = C->regalloc()->reg2offset(OptoReg::stack2reg(_orig_pc_slot));
1299 }
1300
1301 // Compute prolog code size
1302 _frame_slots = OptoReg::reg2stack(C->matcher()->_old_SP) + C->regalloc()->_framesize;
1303 assert(_frame_slots >= 0 && _frame_slots < 1000000, "sanity check");
1304
1305 if (C->has_mach_constant_base_node()) {
1306 uint add_size = 0;
1307 // Fill the constant table.
1308 // Note: This must happen before shorten_branches.
1309 for (uint i = 0; i < C->cfg()->number_of_blocks(); i++) {
1310 Block* b = C->cfg()->get_block(i);
1311
1312 for (uint j = 0; j < b->number_of_nodes(); j++) {
1313 Node* n = b->get_node(j);
1314
1315 // If the node is a MachConstantNode evaluate the constant
1316 // value section.
1317 if (n->is_MachConstant()) {
1318 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 }
1283 debug_info->describe_scope(pc_offset, null_mh, method, jvms->bci(), jvms->should_reexecute());
1284 }
1285
1286 // Mark the end of the scope set.
1287 debug_info->end_non_safepoint(pc_offset);
1288 }
1289
1290 //------------------------------init_buffer------------------------------------
1291 void PhaseOutput::estimate_buffer_size(int& const_req) {
1292
1293 // Set the initially allocated size
1294 const_req = initial_const_capacity;
1295
1296 // The extra spacing after the code is necessary on some platforms.
1297 // Sometimes we need to patch in a jump after the last instruction,
1298 // if the nmethod has been deoptimized. (See 4932387, 4894843.)
1299
1300 // Compute the byte offset where we can store the deopt pc.
1301 if (C->fixed_slots() != 0) {
1302 _orig_pc_slot_offset_in_bytes = C->regalloc()->reg2offset(OptoReg::stack2reg(_orig_pc_slot));
1303 _gc_barrier_save_slots_offset_in_bytes = C->regalloc()->reg2offset(OptoReg::stack2reg(_gc_barrier_save_slots));
1304 }
1305
1306 // Compute prolog code size
1307 _frame_slots = OptoReg::reg2stack(C->matcher()->_old_SP) + C->regalloc()->_framesize;
1308 assert(_frame_slots >= 0 && _frame_slots < 1000000, "sanity check");
1309
1310 if (C->has_mach_constant_base_node()) {
1311 uint add_size = 0;
1312 // Fill the constant table.
1313 // Note: This must happen before shorten_branches.
1314 for (uint i = 0; i < C->cfg()->number_of_blocks(); i++) {
1315 Block* b = C->cfg()->get_block(i);
1316
1317 for (uint j = 0; j < b->number_of_nodes(); j++) {
1318 Node* n = b->get_node(j);
1319
1320 // If the node is a MachConstantNode evaluate the constant
1321 // value section.
1322 if (n->is_MachConstant()) {
1323 MachConstantNode* machcon = n->as_MachConstant();
|