< prev index next >

src/hotspot/share/c1/c1_Compiler.cpp

Print this page
@@ -29,10 +29,11 @@
  #include "c1/c1_GraphBuilder.hpp"
  #include "c1/c1_LinearScan.hpp"
  #include "c1/c1_MacroAssembler.hpp"
  #include "c1/c1_Runtime1.hpp"
  #include "c1/c1_ValueType.hpp"
+ #include "code/SCCache.hpp"
  #include "compiler/compileBroker.hpp"
  #include "compiler/compilerDirectives.hpp"
  #include "interpreter/linkResolver.hpp"
  #include "jfr/support/jfrIntrinsics.hpp"
  #include "memory/allocation.hpp"

@@ -49,10 +50,11 @@
  }
  
  void Compiler::init_c1_runtime() {
    BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
    Runtime1::initialize(buffer_blob);
+   SCCache::init_c1_table();
    FrameMap::initialize();
    // initialize data structures
    ValueType::initialize();
    GraphBuilder::initialize();
    // note: to use more than one instance of LinearScan at a time this function call has to

@@ -250,10 +252,27 @@
  
    return true;
  }
  
  void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci, bool install_code, DirectiveSet* directive) {
+   CompileTask* task = env->task();
+   if (install_code && task->is_scc()) {
+     assert(!task->preload(), "Pre-loading cached code is not implemeted for C1 code");
+     bool success = SCCache::load_nmethod(env, method, entry_bci, this, CompLevel(task->comp_level()));
+     if (success) {
+       assert(task->is_success(), "sanity");
+       return;
+     }
+     SCCache::invalidate(task->scc_entry()); // mark scc_entry as not entrant
+     if (SCCache::is_code_load_thread_on() && !StoreCachedCode) {
+       // Bail out if failed to load cached code in SC thread
+       // unless the code is updating.
+       env->record_failure("Failed to load cached code");
+       return;
+     }
+     task->clear_scc();
+   }
    BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
    assert(buffer_blob != nullptr, "Must exist");
    // invoke compilation
    {
      // We are nested here because we need for the destructor
< prev index next >