src/share/vm/c1/c1_Compilation.cpp

changeset 2421
2f9d59b0fa5c
parent 2349
5ddfcf4b079e
child 2559
72d6c57d0658
     1.1 --- a/src/share/vm/c1/c1_Compilation.cpp	Mon Jan 03 14:09:11 2011 -0500
     1.2 +++ b/src/share/vm/c1/c1_Compilation.cpp	Fri Jan 07 12:44:54 2011 -0500
     1.3 @@ -245,7 +245,7 @@
     1.4  }
     1.5  
     1.6  
     1.7 -void Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) {
     1.8 +bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) {
     1.9    // Preinitialize the consts section to some large size:
    1.10    int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo));
    1.11    char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
    1.12 @@ -253,15 +253,20 @@
    1.13                                          locs_buffer_size / sizeof(relocInfo));
    1.14    code->initialize_consts_size(Compilation::desired_max_constant_size());
    1.15    // Call stubs + two deopt handlers (regular and MH) + exception handler
    1.16 -  code->initialize_stubs_size((call_stub_estimate * LIR_Assembler::call_stub_size) +
    1.17 -                              LIR_Assembler::exception_handler_size +
    1.18 -                              2 * LIR_Assembler::deopt_handler_size);
    1.19 +  int stub_size = (call_stub_estimate * LIR_Assembler::call_stub_size) +
    1.20 +                   LIR_Assembler::exception_handler_size +
    1.21 +                   (2 * LIR_Assembler::deopt_handler_size);
    1.22 +  if (stub_size >= code->insts_capacity()) return false;
    1.23 +  code->initialize_stubs_size(stub_size);
    1.24 +  return true;
    1.25  }
    1.26  
    1.27  
    1.28  int Compilation::emit_code_body() {
    1.29    // emit code
    1.30 -  setup_code_buffer(code(), allocator()->num_calls());
    1.31 +  if (!setup_code_buffer(code(), allocator()->num_calls())) {
    1.32 +    BAILOUT_("size requested greater than avail code buffer size", 0);
    1.33 +  }
    1.34    code()->initialize_oop_recorder(env()->oop_recorder());
    1.35  
    1.36    _masm = new C1_MacroAssembler(code());

mercurial