aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/c1
diff options
context:
space:
mode:
authoranoll <none@none>2013-10-10 15:44:12 +0200
committeranoll <none@none>2013-10-10 15:44:12 +0200
commitc237160bc97e8d6f1cdd63e81be5e519b002a127 (patch)
treec67fee9fd9e4dc51bf66646371f0626b1b8889c5 /src/share/vm/c1
parent7b1b703324ec4a8cd9efc61cb6bf6d2226c5ea5a (diff)
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
Summary: Ensure ensure correct initialization of compiler runtime Reviewed-by: kvn, twisti
Diffstat (limited to 'src/share/vm/c1')
-rw-r--r--src/share/vm/c1/c1_Compiler.cpp56
-rw-r--r--src/share/vm/c1/c1_Compiler.hpp13
2 files changed, 22 insertions, 47 deletions
diff --git a/src/share/vm/c1/c1_Compiler.cpp b/src/share/vm/c1/c1_Compiler.cpp
index ecace4dad..0fb723c8a 100644
--- a/src/share/vm/c1/c1_Compiler.cpp
+++ b/src/share/vm/c1/c1_Compiler.cpp
@@ -42,26 +42,16 @@
#include "runtime/interfaceSupport.hpp"
#include "runtime/sharedRuntime.hpp"
-volatile int Compiler::_runtimes = uninitialized;
-Compiler::Compiler() {
-}
-
-
-Compiler::~Compiler() {
- Unimplemented();
-}
+Compiler::Compiler () {}
-
-void Compiler::initialize_all() {
+void Compiler::init_c1_runtime() {
BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
Arena* arena = new (mtCompiler) Arena();
Runtime1::initialize(buffer_blob);
FrameMap::initialize();
// initialize data structures
ValueType::initialize(arena);
- // Instruction::initialize();
- // BlockBegin::initialize();
GraphBuilder::initialize();
// note: to use more than one instance of LinearScan at a time this function call has to
// be moved somewhere outside of this constructor:
@@ -70,32 +60,33 @@ void Compiler::initialize_all() {
void Compiler::initialize() {
- if (_runtimes != initialized) {
- initialize_runtimes( initialize_all, &_runtimes);
+ // Buffer blob must be allocated per C1 compiler thread at startup
+ BufferBlob* buffer_blob = init_buffer_blob();
+
+ if (should_perform_init()) {
+ if (buffer_blob == NULL) {
+ // When we come here we are in state 'initializing'; entire C1 compilation
+ // can be shut down.
+ set_state(failed);
+ } else {
+ init_c1_runtime();
+ set_state(initialized);
+ }
}
- mark_initialized();
}
-
-BufferBlob* Compiler::get_buffer_blob(ciEnv* env) {
+BufferBlob* Compiler::init_buffer_blob() {
// Allocate buffer blob once at startup since allocation for each
// compilation seems to be too expensive (at least on Intel win32).
- BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
- if (buffer_blob != NULL) {
- return buffer_blob;
- }
+ assert (CompilerThread::current()->get_buffer_blob() == NULL, "Should initialize only once");
// setup CodeBuffer. Preallocate a BufferBlob of size
// NMethodSizeLimit plus some extra space for constants.
int code_buffer_size = Compilation::desired_max_code_buffer_size() +
Compilation::desired_max_constant_size();
- buffer_blob = BufferBlob::create("Compiler1 temporary CodeBuffer",
- code_buffer_size);
- if (buffer_blob == NULL) {
- CompileBroker::handle_full_code_cache();
- env->record_failure("CodeCache is full");
- } else {
+ BufferBlob* buffer_blob = BufferBlob::create("C1 temporary CodeBuffer", code_buffer_size);
+ if (buffer_blob != NULL) {
CompilerThread::current()->set_buffer_blob(buffer_blob);
}
@@ -104,15 +95,8 @@ BufferBlob* Compiler::get_buffer_blob(ciEnv* env) {
void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {
- BufferBlob* buffer_blob = Compiler::get_buffer_blob(env);
- if (buffer_blob == NULL) {
- return;
- }
-
- if (!is_initialized()) {
- initialize();
- }
-
+ BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
+ assert(buffer_blob != NULL, "Must exist");
// invoke compilation
{
// We are nested here because we need for the destructor
diff --git a/src/share/vm/c1/c1_Compiler.hpp b/src/share/vm/c1/c1_Compiler.hpp
index 6e209d003..fe95c8cd7 100644
--- a/src/share/vm/c1/c1_Compiler.hpp
+++ b/src/share/vm/c1/c1_Compiler.hpp
@@ -30,11 +30,9 @@
// There is one instance of the Compiler per CompilerThread.
class Compiler: public AbstractCompiler {
-
private:
-
- // Tracks whether runtime has been initialized
- static volatile int _runtimes;
+ static void init_c1_runtime();
+ BufferBlob* init_buffer_blob();
public:
// Creation
@@ -46,19 +44,12 @@ class Compiler: public AbstractCompiler {
virtual bool is_c1() { return true; };
- BufferBlob* get_buffer_blob(ciEnv* env);
-
// Missing feature tests
virtual bool supports_native() { return true; }
virtual bool supports_osr () { return true; }
- // Customization
- virtual bool needs_adapters () { return false; }
- virtual bool needs_stubs () { return false; }
-
// Initialization
virtual void initialize();
- static void initialize_all();
// Compilation entry point for methods
virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci);