コード例 #1
0
ファイル: state.cpp プロジェクト: d4rky-pl/rubinius
  void LLVMState::compile_soon(STATE, GCToken gct, CompiledCode* code, CallFrame* call_frame,
                               Class* receiver_class, BlockEnvironment* block_env, bool is_block)
  {
    bool wait = config().jit_sync;

    if(!enabled_) return;

    // TODO: Fix compile policy checks
    if(!code->keywords()->nil_p()) {
      metrics().m.jit_metrics.methods_failed++;

      return;
    }

    if(code->machine_code()->call_count <= 1) {
      return;
    }

    if(code->machine_code()->compiling_p()) {
      return;
    }

    int hits = code->machine_code()->method_call_count();
    code->machine_code()->set_compiling();

    JITCompileRequest* req = JITCompileRequest::create(state, code, receiver_class,
        hits, block_env, is_block);

    if(wait) {
      wait_mutex.lock();

      req->set_waiter(&wait_cond);

      add(state, req);
      bool req_block = req->is_block();

      state->set_call_frame(call_frame);

      wait_cond.wait(wait_mutex);

      wait_mutex.unlock();
      state->set_call_frame(0);

      if(state->shared().config.jit_show_compiling) {
        llvm::outs() << "[[[ JIT compiled "
          << enclosure_name(code) << "#" << symbol_debug_str(code->name())
          << (req_block ? " (block) " : " (method) ")
          << " (" << hits << ") " << " ]]]\n";
      }
    } else {
      add(state, req);

      if(state->shared().config.jit_show_compiling) {
        llvm::outs() << "[[[ JIT queued "
          << enclosure_name(code) << "#" << symbol_debug_str(code->name())
          << (req->is_block() ? " (block) " : " (method) ")
          << " (" << hits << ") " << " ]]]\n";
      }
    }
  }
コード例 #2
0
ファイル: state.cpp プロジェクト: d4rky-pl/rubinius
  void LLVMState::compile(STATE, GCToken gct, CompiledCode* code, CallFrame* call_frame,
      Class* receiver_class, BlockEnvironment* block_env, bool is_block)
  {
    if(!enabled_) return;

    // TODO: Fix compile policy checks
    if(!code->keywords()->nil_p()) {
      metrics().m.jit_metrics.methods_failed++;

      return;
    }

    // In case the method hasn't been internalized yet
    if(!code->machine_code()) {
      code->internalize(state, gct, call_frame);
    }

    JITCompileRequest* req = JITCompileRequest::create(state, code, receiver_class,
        0, block_env, is_block);

    wait_mutex.lock();
    req->set_waiter(&wait_cond);

    add(state, req);

    state->set_call_frame(call_frame);

    {
      GCIndependent guard(state, 0);

      wait_cond.wait(wait_mutex);
    }

    wait_mutex.unlock();
    state->set_call_frame(0);

    if(state->shared().config.jit_show_compiling) {
      llvm::outs() << "[[[ JIT compiled "
        << enclosure_name(code) << "#" << symbol_debug_str(code->name())
        << (req->is_block() ? " (block) " : " (method) ") << " ]]]\n";
    }
  }
コード例 #3
0
ファイル: jit.cpp プロジェクト: clockmaker002/rubinius
  JITCompileRequest* JITCompileRequest::create(STATE, CompiledCode* code,
      Class* receiver_class, int hits, BlockEnvironment* block_env, bool is_block)
  {
    JITCompileRequest* request =
      state->memory()->new_object<JITCompileRequest>(state, G(jit)->compile_class());

    request->method(state, code);
    request->receiver_class(state, receiver_class);
    request->block_env(state, block_env);
    request->hits(hits);
    request->is_block(is_block);
    request->waiter(NULL);

    return request;
  }