Ejemplo n.º 1
0
  void LLVMState::compile_callframe(STATE, VMMethod* start, CallFrame* call_frame,
                                    int primitive) {
    if(config().jit_inline_debug) {
      if(start) {
        llvm::errs() << "JIT: target search from "
          << symbol_cstr(start->original->scope()->module()->name())
          << "#"
          << symbol_cstr(start->original->name()) << "\n";
      } else {
        llvm::errs() << "JIT: target search from primitive\n";
      }
    }

    VMMethod* candidate = find_candidate(start, call_frame);
    if(!candidate) {
      if(config().jit_inline_debug) {
        llvm::errs() << "JIT: unable to find candidate\n";
      }
      return;
    }

    assert(!candidate->parent());

    if(candidate->call_count < 0) {
      if(!start) return;
      // Ignore it. compile this one.
      candidate = start;
    }

    compile_soon(state, candidate);
  }
Ejemplo n.º 2
0
Archivo: jit.cpp Proyecto: 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";
      }
    }
  }
Ejemplo n.º 3
0
  void LLVMState::compile_callframe(STATE, CompiledMethod* start, CallFrame* call_frame,
                                    int primitive) {
    if(config().jit_inline_debug) {
      if(start) {
        log() << "JIT: target search from "
          << symbol_cstr(start->name()) << "\n";
      } else {
        log() << "JIT: target search from primitive\n";
      }
    }

    CallFrame* candidate = find_candidate(start, call_frame);
    if(!candidate || candidate->jitted_p() || candidate->inline_method_p()) {
      if(config().jit_inline_debug) {
        log() << "JIT: unable to find candidate\n";
      }
      return;
    }

    if(candidate->cm->backend_method()->call_count <= 1) {
      if(!start || start->backend_method()->jitted()) return;
      // Ignore it. compile this one.
      candidate = call_frame;
    }

    if(candidate->block_p()) {
      compile_soon(state, candidate->cm, candidate->block_env());
    } else {
      compile_soon(state, candidate->cm);
    }
  }
Ejemplo n.º 4
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";
    }
  }
Ejemplo n.º 5
0
  const char* LLVMState::enclosure_name(CompiledMethod* cm) {
    StaticScope* ss = cm->scope();
    if(!kind_of<StaticScope>(ss) || !kind_of<Module>(ss->module())) {
      return "ANONYMOUS";
    }

    return symbol_cstr(ss->module()->name());
  }