src/share/vm/c1/c1_Compiler.cpp
Print this page
@@ -40,81 +40,66 @@
#include "prims/nativeLookup.hpp"
#include "runtime/arguments.hpp"
#include "runtime/interfaceSupport.hpp"
#include "runtime/sharedRuntime.hpp"
-volatile int Compiler::_runtimes = uninitialized;
-
-Compiler::Compiler() {
-}
-
-
-Compiler::~Compiler() {
- Unimplemented();
-}
+Compiler::Compiler () {}
+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:
Interval::initialize(arena);
}
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);
}
return buffer_blob;
}
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
// of Compilation to occur before we release the any
// competing compiler thread