src/share/vm/c1/c1_Compilation.cpp

changeset 1939
b812ff5abc73
parent 1907
c18cbe5936b8
child 1972
9887b5e57f9e
     1.1 --- a/src/share/vm/c1/c1_Compilation.cpp	Thu Jun 03 14:20:27 2010 -0700
     1.2 +++ b/src/share/vm/c1/c1_Compilation.cpp	Fri Jun 04 11:18:04 2010 -0700
     1.3 @@ -66,9 +66,6 @@
     1.4    }
     1.5  };
     1.6  
     1.7 -Arena* Compilation::_arena = NULL;
     1.8 -Compilation* Compilation::_compilation = NULL;
     1.9 -
    1.10  // Implementation of Compilation
    1.11  
    1.12  
    1.13 @@ -238,9 +235,23 @@
    1.14  }
    1.15  
    1.16  
    1.17 +void Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) {
    1.18 +  // Preinitialize the consts section to some large size:
    1.19 +  int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo));
    1.20 +  char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
    1.21 +  code->insts()->initialize_shared_locs((relocInfo*)locs_buffer,
    1.22 +                                        locs_buffer_size / sizeof(relocInfo));
    1.23 +  code->initialize_consts_size(Compilation::desired_max_constant_size());
    1.24 +  // Call stubs + deopt/exception handler
    1.25 +  code->initialize_stubs_size((call_stub_estimate * LIR_Assembler::call_stub_size) +
    1.26 +                              LIR_Assembler::exception_handler_size +
    1.27 +                              LIR_Assembler::deopt_handler_size);
    1.28 +}
    1.29 +
    1.30 +
    1.31  int Compilation::emit_code_body() {
    1.32    // emit code
    1.33 -  Runtime1::setup_code_buffer(code(), allocator()->num_calls());
    1.34 +  setup_code_buffer(code(), allocator()->num_calls());
    1.35    code()->initialize_oop_recorder(env()->oop_recorder());
    1.36  
    1.37    _masm = new C1_MacroAssembler(code());
    1.38 @@ -422,7 +433,8 @@
    1.39  }
    1.40  
    1.41  
    1.42 -Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, int osr_bci)
    1.43 +Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method,
    1.44 +                         int osr_bci, BufferBlob* buffer_blob)
    1.45  : _compiler(compiler)
    1.46  , _env(env)
    1.47  , _method(method)
    1.48 @@ -437,8 +449,10 @@
    1.49  , _bailout_msg(NULL)
    1.50  , _exception_info_list(NULL)
    1.51  , _allocator(NULL)
    1.52 -, _code(Runtime1::get_buffer_blob()->instructions_begin(),
    1.53 -        Runtime1::get_buffer_blob()->instructions_size())
    1.54 +, _next_id(0)
    1.55 +, _next_block_id(0)
    1.56 +, _code(buffer_blob->instructions_begin(),
    1.57 +        buffer_blob->instructions_size())
    1.58  , _current_instruction(NULL)
    1.59  #ifndef PRODUCT
    1.60  , _last_instruction_printed(NULL)
    1.61 @@ -446,17 +460,15 @@
    1.62  {
    1.63    PhaseTraceTime timeit(_t_compile);
    1.64  
    1.65 -  assert(_arena == NULL, "shouldn't only one instance of Compilation in existence at a time");
    1.66    _arena = Thread::current()->resource_area();
    1.67 -  _compilation = this;
    1.68 +  _env->set_compiler_data(this);
    1.69    _exception_info_list = new ExceptionInfoList();
    1.70    _implicit_exception_table.set_size(0);
    1.71    compile_method();
    1.72  }
    1.73  
    1.74  Compilation::~Compilation() {
    1.75 -  _arena = NULL;
    1.76 -  _compilation = NULL;
    1.77 +  _env->set_compiler_data(NULL);
    1.78  }
    1.79  
    1.80  

mercurial