src/share/vm/c1/c1_Compiler.cpp

changeset 1939
b812ff5abc73
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
     1.1 --- a/src/share/vm/c1/c1_Compiler.cpp	Thu Jun 03 14:20:27 2010 -0700
     1.2 +++ b/src/share/vm/c1/c1_Compiler.cpp	Fri Jun 04 11:18:04 2010 -0700
     1.3 @@ -27,9 +27,6 @@
     1.4  
     1.5  volatile int Compiler::_runtimes = uninitialized;
     1.6  
     1.7 -volatile bool Compiler::_compiling = false;
     1.8 -
     1.9 -
    1.10  Compiler::Compiler() {
    1.11  }
    1.12  
    1.13 @@ -39,47 +36,62 @@
    1.14  }
    1.15  
    1.16  
    1.17 +void Compiler::initialize_all() {
    1.18 +  BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
    1.19 +  Arena* arena = new Arena();
    1.20 +  Runtime1::initialize(buffer_blob);
    1.21 +  FrameMap::initialize();
    1.22 +  // initialize data structures
    1.23 +  ValueType::initialize(arena);
    1.24 +  // Instruction::initialize();
    1.25 +  // BlockBegin::initialize();
    1.26 +  GraphBuilder::initialize();
    1.27 +  // note: to use more than one instance of LinearScan at a time this function call has to
    1.28 +  //       be moved somewhere outside of this constructor:
    1.29 +  Interval::initialize(arena);
    1.30 +}
    1.31 +
    1.32 +
    1.33  void Compiler::initialize() {
    1.34    if (_runtimes != initialized) {
    1.35 -    initialize_runtimes( Runtime1::initialize, &_runtimes);
    1.36 +    initialize_runtimes( initialize_all, &_runtimes);
    1.37    }
    1.38    mark_initialized();
    1.39  }
    1.40  
    1.41  
    1.42 +BufferBlob* Compiler::build_buffer_blob() {
    1.43 +  // setup CodeBuffer.  Preallocate a BufferBlob of size
    1.44 +  // NMethodSizeLimit plus some extra space for constants.
    1.45 +  int code_buffer_size = Compilation::desired_max_code_buffer_size() +
    1.46 +    Compilation::desired_max_constant_size();
    1.47 +  BufferBlob* blob = BufferBlob::create("Compiler1 temporary CodeBuffer",
    1.48 +                                        code_buffer_size);
    1.49 +  guarantee(blob != NULL, "must create initial code buffer");
    1.50 +  return blob;
    1.51 +}
    1.52 +
    1.53 +
    1.54  void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {
    1.55 +  // Allocate buffer blob once at startup since allocation for each
    1.56 +  // compilation seems to be too expensive (at least on Intel win32).
    1.57 +  BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
    1.58 +  if (buffer_blob == NULL) {
    1.59 +    buffer_blob = build_buffer_blob();
    1.60 +    CompilerThread::current()->set_buffer_blob(buffer_blob);
    1.61 +  }
    1.62  
    1.63    if (!is_initialized()) {
    1.64      initialize();
    1.65    }
    1.66    // invoke compilation
    1.67 -#ifdef TIERED
    1.68 -  // We are thread in native here...
    1.69 -  CompilerThread* thread = CompilerThread::current();
    1.70 -  {
    1.71 -    ThreadInVMfromNative tv(thread);
    1.72 -    MutexLocker only_one (C1_lock, thread);
    1.73 -    while ( _compiling) {
    1.74 -      C1_lock->wait();
    1.75 -    }
    1.76 -    _compiling = true;
    1.77 -  }
    1.78 -#endif // TIERED
    1.79    {
    1.80      // We are nested here because we need for the destructor
    1.81      // of Compilation to occur before we release the any
    1.82      // competing compiler thread
    1.83      ResourceMark rm;
    1.84 -    Compilation c(this, env, method, entry_bci);
    1.85 +    Compilation c(this, env, method, entry_bci, buffer_blob);
    1.86    }
    1.87 -#ifdef TIERED
    1.88 -  {
    1.89 -    ThreadInVMfromNative tv(thread);
    1.90 -    MutexLocker only_one (C1_lock, thread);
    1.91 -    _compiling = false;
    1.92 -    C1_lock->notify();
    1.93 -  }
    1.94 -#endif // TIERED
    1.95  }
    1.96  
    1.97  

mercurial