8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)

Thu, 23 May 2013 14:11:09 +0200

author
anoll
date
Thu, 23 May 2013 14:11:09 +0200
changeset 5157
01e51113b4f5
parent 5156
3f281b313240
child 5158
59e18b573605

8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
Summary: Disable client compiler and switch to interpreter if there is not enough free space in the code cache.
Reviewed-by: kvn, twisti

src/share/vm/c1/c1_Compiler.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_Compiler.hpp file | annotate | diff | comparison | revisions
     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
     2.1 --- a/src/share/vm/c1/c1_Compiler.hpp	Wed May 22 18:25:43 2013 -0700
     2.2 +++ b/src/share/vm/c1/c1_Compiler.hpp	Thu May 23 14:11:09 2013 +0200
     2.3 @@ -46,7 +46,7 @@
     2.4  
     2.5    virtual bool is_c1()                           { return true; };
     2.6  
     2.7 -  BufferBlob* build_buffer_blob();
     2.8 +  BufferBlob* get_buffer_blob(ciEnv* env);
     2.9  
    2.10    // Missing feature tests
    2.11    virtual bool supports_native()                 { return true; }

mercurial