1.1 --- a/src/share/vm/c1/c1_Compiler.cpp Wed May 22 18:25:43 2013 -0700 1.2 +++ b/src/share/vm/c1/c1_Compiler.cpp Thu May 23 14:11:09 2013 +0200 1.3 @@ -77,30 +77,42 @@ 1.4 } 1.5 1.6 1.7 -BufferBlob* Compiler::build_buffer_blob() { 1.8 +BufferBlob* Compiler::get_buffer_blob(ciEnv* env) { 1.9 + // Allocate buffer blob once at startup since allocation for each 1.10 + // compilation seems to be too expensive (at least on Intel win32). 1.11 + BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); 1.12 + if (buffer_blob != NULL) { 1.13 + return buffer_blob; 1.14 + } 1.15 + 1.16 // setup CodeBuffer. Preallocate a BufferBlob of size 1.17 // NMethodSizeLimit plus some extra space for constants. 1.18 int code_buffer_size = Compilation::desired_max_code_buffer_size() + 1.19 Compilation::desired_max_constant_size(); 1.20 - BufferBlob* blob = BufferBlob::create("Compiler1 temporary CodeBuffer", 1.21 - code_buffer_size); 1.22 - guarantee(blob != NULL, "must create initial code buffer"); 1.23 - return blob; 1.24 + 1.25 + buffer_blob = BufferBlob::create("Compiler1 temporary CodeBuffer", 1.26 + code_buffer_size); 1.27 + if (buffer_blob == NULL) { 1.28 + CompileBroker::handle_full_code_cache(); 1.29 + env->record_failure("CodeCache is full"); 1.30 + } else { 1.31 + CompilerThread::current()->set_buffer_blob(buffer_blob); 1.32 + } 1.33 + 1.34 + return buffer_blob; 1.35 } 1.36 1.37 1.38 void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) { 1.39 - // Allocate buffer blob once at startup since allocation for each 1.40 - // compilation seems to be too expensive (at least on Intel win32). 1.41 - BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); 1.42 + BufferBlob* buffer_blob = Compiler::get_buffer_blob(env); 1.43 if (buffer_blob == NULL) { 1.44 - buffer_blob = build_buffer_blob(); 1.45 - CompilerThread::current()->set_buffer_blob(buffer_blob); 1.46 + return; 1.47 } 1.48 1.49 if (!is_initialized()) { 1.50 initialize(); 1.51 } 1.52 + 1.53 // invoke compilation 1.54 { 1.55 // We are nested here because we need for the destructor