--- old/src/share/vm/c1/c1_Compilation.cpp 2010-06-03 11:27:00.015434000 -0700 +++ new/src/share/vm/c1/c1_Compilation.cpp 2010-06-03 11:26:59.842712000 -0700 @@ -66,9 +66,6 @@ } }; -Arena* Compilation::_arena = NULL; -Compilation* Compilation::_compilation = NULL; - // Implementation of Compilation @@ -238,9 +235,23 @@ } +void Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { + // Preinitialize the consts section to some large size: + int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo)); + char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); + code->insts()->initialize_shared_locs((relocInfo*)locs_buffer, + locs_buffer_size / sizeof(relocInfo)); + code->initialize_consts_size(Compilation::desired_max_constant_size()); + // Call stubs + deopt/exception handler + code->initialize_stubs_size((call_stub_estimate * LIR_Assembler::call_stub_size) + + LIR_Assembler::exception_handler_size + + LIR_Assembler::deopt_handler_size); +} + + int Compilation::emit_code_body() { // emit code - Runtime1::setup_code_buffer(code(), allocator()->num_calls()); + setup_code_buffer(code(), allocator()->num_calls()); code()->initialize_oop_recorder(env()->oop_recorder()); _masm = new C1_MacroAssembler(code()); @@ -422,7 +433,8 @@ } -Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, int osr_bci) +Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, + int osr_bci, BufferBlob* buffer_blob) : _compiler(compiler) , _env(env) , _method(method) @@ -437,8 +449,10 @@ , _bailout_msg(NULL) , _exception_info_list(NULL) , _allocator(NULL) -, _code(Runtime1::get_buffer_blob()->instructions_begin(), - Runtime1::get_buffer_blob()->instructions_size()) +, _next_id(0) +, _next_block_id(0) +, _code(buffer_blob->instructions_begin(), + buffer_blob->instructions_size()) , _current_instruction(NULL) #ifndef PRODUCT , _last_instruction_printed(NULL) @@ -446,17 +460,15 @@ { PhaseTraceTime timeit(_t_compile); - assert(_arena == NULL, "shouldn't only one instance of Compilation in existence at a time"); _arena = Thread::current()->resource_area(); - _compilation = this; + _env->set_compiler_data(this); _exception_info_list = new ExceptionInfoList(); _implicit_exception_table.set_size(0); compile_method(); } Compilation::~Compilation() { - _arena = NULL; - _compilation = NULL; + _env->set_compiler_data(NULL); }