243 // done |
243 // done |
244 masm()->flush(); |
244 masm()->flush(); |
245 } |
245 } |
246 |
246 |
247 |
247 |
248 void Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { |
248 bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { |
249 // Preinitialize the consts section to some large size: |
249 // Preinitialize the consts section to some large size: |
250 int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo)); |
250 int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo)); |
251 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); |
251 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); |
252 code->insts()->initialize_shared_locs((relocInfo*)locs_buffer, |
252 code->insts()->initialize_shared_locs((relocInfo*)locs_buffer, |
253 locs_buffer_size / sizeof(relocInfo)); |
253 locs_buffer_size / sizeof(relocInfo)); |
254 code->initialize_consts_size(Compilation::desired_max_constant_size()); |
254 code->initialize_consts_size(Compilation::desired_max_constant_size()); |
255 // Call stubs + two deopt handlers (regular and MH) + exception handler |
255 // Call stubs + two deopt handlers (regular and MH) + exception handler |
256 code->initialize_stubs_size((call_stub_estimate * LIR_Assembler::call_stub_size) + |
256 int stub_size = (call_stub_estimate * LIR_Assembler::call_stub_size) + |
257 LIR_Assembler::exception_handler_size + |
257 LIR_Assembler::exception_handler_size + |
258 2 * LIR_Assembler::deopt_handler_size); |
258 (2 * LIR_Assembler::deopt_handler_size); |
|
259 if (stub_size >= code->insts_capacity()) return false; |
|
260 code->initialize_stubs_size(stub_size); |
|
261 return true; |
259 } |
262 } |
260 |
263 |
261 |
264 |
262 int Compilation::emit_code_body() { |
265 int Compilation::emit_code_body() { |
263 // emit code |
266 // emit code |
264 setup_code_buffer(code(), allocator()->num_calls()); |
267 if (!setup_code_buffer(code(), allocator()->num_calls())) { |
|
268 BAILOUT_("size requested greater than avail code buffer size", 0); |
|
269 } |
265 code()->initialize_oop_recorder(env()->oop_recorder()); |
270 code()->initialize_oop_recorder(env()->oop_recorder()); |
266 |
271 |
267 _masm = new C1_MacroAssembler(code()); |
272 _masm = new C1_MacroAssembler(code()); |
268 _masm->set_oop_recorder(env()->oop_recorder()); |
273 _masm->set_oop_recorder(env()->oop_recorder()); |
269 |
274 |