Exemplo n.º 1
0
  /*
   * Turns a CompiledCode's InstructionSequence into a C array of opcodes.
   */
  MachineCode::MachineCode(STATE, CompiledCode* meth)
    : parent_(NULL)
    , type(NULL)
    , uncommon_count(0)
    , number_of_caches_(0)
    , caches(0)
    , execute_status_(eInterpret)
    , name_(meth->name())
    , method_id_(state->shared().inc_method_count(state))
    , debugging(false)
    , flags(0)
  {
    if(state->shared().tool_broker()->tooling_interpreter_p()) {
      run = MachineCode::tooling_interpreter;
    } else {
      run = MachineCode::interpreter;
    }

    total = meth->iseq()->opcodes()->num_fields();

    opcodes = new opcode[total];
    addresses = new void*[total];

    fill_opcodes(state, meth);
    stack_size = meth->stack_size()->to_native();
    number_of_locals = meth->number_of_locals();

    total_args = meth->total_args()->to_native();
    required_args = meth->required_args()->to_native();
    post_args = meth->post_args()->to_native();

    if(Fixnum* pos = try_as<Fixnum>(meth->splat())) {
      splat_position = pos->to_native();
    } else {
      splat_position = -1;
    }

    // Disable JIT for large methods
    if(meth->primitive()->nil_p() &&
        !state->shared().config.jit_disabled &&
        total < (size_t)state->shared().config.jit_max_method_size) {
      call_count = 0;
    } else {
      call_count = -1;
    }

    unspecialized = 0;
    fallback = 0;

    for(int i = 0; i < cMaxSpecializations; i++) {
      specializations[i].class_id = 0;
      specializations[i].execute = 0;
      specializations[i].jit_data = 0;
    }

    state->shared().om->add_code_resource(this);
  }
Exemplo n.º 2
0
  /*
   * Turns a CompiledMethod's InstructionSequence into a C array of opcodes.
   */
  VMMethod::VMMethod(STATE, CompiledMethod* meth)
    : parent_(NULL)
    , run(standard_interpreter)
    , type(NULL)
    , number_of_caches_(0)
    , caches(0)
#ifdef ENABLE_LLVM
    , llvm_function_(NULL)
    , jitted_impl_(NULL)
#endif
    , name_(meth->name())
  {
    meth->set_executor(&VMMethod::execute);

    total = meth->iseq()->opcodes()->num_fields();

    opcodes = new opcode[total];
    addresses = new void*[total];

    fill_opcodes(state, meth);
    stack_size =    meth->stack_size()->to_native();
    number_of_locals = meth->number_of_locals();

    total_args =    meth->total_args()->to_native();
    required_args = meth->required_args()->to_native();
    if(meth->splat()->nil_p()) {
      splat_position = -1;
    } else {
      splat_position = as<Integer>(meth->splat())->to_native();
    }

    setup_argument_handler(meth);

    // Disable JIT for large methods
    if(meth->primitive()->nil_p() &&
        !state->shared.config.jit_disabled &&
        total < (size_t)state->shared.config.jit_max_method_size) {
      call_count = 0;
    } else {
      call_count = -1;
    }

    state->shared.om->add_code_resource(this);
  }