Exemplo n.º 1
0
  void LLVMState::compile_soon(STATE, GCToken gct, CompiledCode* code, CallFrame* call_frame,
                               Object* placement, bool is_block)
  {
    bool wait = config().jit_sync;

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

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

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

    BackgroundCompileRequest* req =
      new BackgroundCompileRequest(state, code, placement, hits, is_block);

    queued_methods_++;

    if(wait) {
      wait_mutex.lock();

      req->set_waiter(&wait_cond);

      background_thread_->add(req);

      state->set_call_frame(call_frame);
      gc_independent();

      wait_cond.wait(wait_mutex);

      wait_mutex.unlock();
      gc_dependent();
      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) ")
          << queued_methods() << "/"
          << jitted_methods() << " ]]]\n";
      }
    } else {
      background_thread_->add(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) ")
          << queued_methods() << "/"
          << jitted_methods() << " ]]]\n";
      }
    }
  }
Exemplo n.º 2
0
Arquivo: jit.cpp Projeto: rdp/rubinius
  void LLVMState::compile_soon(STATE, CompiledMethod* cm, BlockEnvironment* block) {
    Object* placement;
    bool is_block = false;
    bool wait = config().jit_sync;

    // Ignore it!
    if(cm->backend_method()->call_count < 0) {
      if(config().jit_inline_debug) {
        log() << "JIT: ignoring candidate! "
          << symbol_cstr(cm->name()) << "\n";
      }
      return;
    }

    if(config().jit_inline_debug) {
      log() << "JIT: queueing method: "
        << symbol_cstr(cm->name()) << "\n";
    }

    cm->backend_method()->call_count = -1;

    if(block) {
      is_block = true;
      placement = block;
    } else {
      placement = Qnil;
    }

    BackgroundCompileRequest* req =
      new BackgroundCompileRequest(state, cm, placement, is_block);

    queued_methods_++;

    if(wait) {
      thread::Condition cond;
      req->set_waiter(&cond);

      thread::Mutex mux;
      mux.lock();

      background_thread_->add(req);
      cond.wait(mux);

      mux.unlock();

      if(config().jit_inline_debug) {
        log() << "JIT: compiled method: "
              << symbol_cstr(cm->name()) << "\n";
      }
    } else {
      background_thread_->add(req);

      if(state->shared.config.jit_show_compiling) {
        llvm::outs() << "[[[ JIT Queued"
          << (block ? " block " : " method ")
          << queued_methods() << "/"
          << jitted_methods() << " ]]]\n";
      }
    }
  }
Exemplo n.º 3
0
  void LLVMState::compile_soon(STATE, VMMethod* vmm, BlockEnvironment* block) {
    Object* placement;
    bool is_block = false;

    // Ignore it!
    if(vmm->call_count < 0) {
      if(config().jit_inline_debug) {
        llvm::errs() << "JIT: ignoring candidate! "
          << symbol_cstr(vmm->original->scope()->module()->name())
          << "#"
          << symbol_cstr(vmm->original->name()) << "\n";
      }
      return;
    }

    if(config().jit_inline_debug) {
      llvm::errs() << "JIT: queueing method: "
        << symbol_cstr(vmm->original->scope()->module()->name())
        << "#"
        << symbol_cstr(vmm->original->name()) << "\n";
    }
    vmm->call_count = -1;

    if(block) {
      is_block = true;
      placement = block;
    } else {
      placement = state->new_struct<MachineMethod>(G(machine_method));
    }

    state->stats.jitted_methods++;

    BackgroundCompileRequest* req =
      new BackgroundCompileRequest(state, vmm, placement, is_block);

    queued_methods_++;

    background_thread_->add(req);

    if(state->shared.config.jit_show_compiling) {
      llvm::outs() << "[[[ JIT Queued"
                << (block ? " block " : " method ")
                << queued_methods() << "/"
                << jitted_methods() << " ]]]\n";
    }
  }