当前位置: 首页>>代码示例>>C++>>正文


C++ CompiledCode::machine_code方法代码示例

本文整理汇总了C++中CompiledCode::machine_code方法的典型用法代码示例。如果您正苦于以下问题:C++ CompiledCode::machine_code方法的具体用法?C++ CompiledCode::machine_code怎么用?C++ CompiledCode::machine_code使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CompiledCode的用法示例。


在下文中一共展示了CompiledCode::machine_code方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

  void CompiledCode::Info::mark(Object* obj, memory::ObjectMark& mark) {
    auto_mark(obj, mark);

    mark_inliners(obj, mark);

    CompiledCode* code = as<CompiledCode>(obj);
    if(!code->machine_code()) return;

    MachineCode* mcode = code->machine_code();
    mcode->set_mark();

    for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
      // TODO: JIT
    }

    for(size_t i = 0; i < mcode->references_count(); i++) {
      if(size_t ip = mcode->references()[i]) {
        Object* ref = reinterpret_cast<Object*>(mcode->opcodes[ip]);
        if(Object* updated_ref = mark.call(ref)) {
          mcode->opcodes[ip] = reinterpret_cast<intptr_t>(updated_ref);
          mark.just_set(code, updated_ref);
        }
      }
    }
  }
开发者ID:clockmaker002,项目名称:rubinius,代码行数:25,代码来源:compiled_code.cpp

示例2: update_profile

  void VM::update_profile(STATE) {
    timer::StopWatch<timer::nanoseconds> timer(metrics().machine.profile_ns);

    metrics().machine.profiles++;
    profile_sample_count_++;

    CompiledCode* code = state->vm()->call_frame()->compiled_code;
    code->machine_code()->sample_count++;

    Tuple* profile = profile_.get();

    if(profile->nil_p()) {
      profile = Tuple::create(state, max_profile_entries_);
      profile_.set(profile);
    }

    ::qsort(reinterpret_cast<void*>(profile->field), profile->num_fields(),
        sizeof(intptr_t), profile_compare);

    for(native_int i = 0; i < profile->num_fields(); i++) {
      if(code == profile->at(i)) return;
    }

    CompiledCode* pcode = try_as<CompiledCode>(profile->at(0));
    if(!pcode || (pcode &&
          code->machine_code()->call_count > pcode->machine_code()->call_count))
    {
      profile->put(state, 0, code);
      min_profile_call_count_ = code->machine_code()->call_count;
    }
  }
开发者ID:clockmaker002,项目名称:rubinius,代码行数:31,代码来源:vm.cpp

示例3: constant_caches

  Tuple* CompiledCode::constant_caches(STATE) {
    CompiledCode* self = this;
    OnStack<1> os(state, self);

    if(self->machine_code() == NULL) {
      if(!self->internalize(state)) return force_as<Tuple>(Primitives::failure());
    }
    MachineCode* mcode = self->machine_code();
    return mcode->constant_caches(state);
  }
开发者ID:clockmaker002,项目名称:rubinius,代码行数:10,代码来源:compiled_code.cpp

示例4: primitive_failed

  Object* CompiledCode::primitive_failed(STATE,
              Executable* exec, Module* mod, Arguments& args)
  {
    CompiledCode* code = as<CompiledCode>(exec);

    Class* cls = args.recv()->direct_class(state);
    uint64_t class_data = cls->data_raw();

    MachineCode* v = code->machine_code();

    executor target = v->unspecialized;

    for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
      uint64_t c_id = v->specializations[i].class_data.raw;
      executor x = v->specializations[i].execute;

      if(c_id == class_data && x != 0) {
        target = x;
        break;
      }
    }

    if(target) {
      return target(state, exec, mod, args);
    } else {
      return MachineCode::execute(state, exec, mod, args);
    }
  }
开发者ID:clockmaker002,项目名称:rubinius,代码行数:28,代码来源:compiled_code.cpp

示例5: specialized_executor

  Object* CompiledCode::specialized_executor(STATE, CallFrame* call_frame,
                          Executable* exec, Module* mod, Arguments& args)
  {
    CompiledCode* code = as<CompiledCode>(exec);

    Class* cls = args.recv()->class_object(state);
    int id = cls->class_id();

    MachineCode* v = code->machine_code();

    executor target = v->unspecialized;

    for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
      int c_id = v->specializations[i].class_id;
      executor x = v->specializations[i].execute;

      if(c_id == id && x != 0) {
        target = x;
        break;
      }
    }

    // This is a bug. We should not have this setup if there are no
    // specializations. FIX THIS BUG!
    if(!target) target = v->fallback;

    return target(state, call_frame, exec, mod, args);
  }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例6: compile_method

  void Compiler::compile_method(BackgroundCompileRequest* req) {
    CompiledCode* code = req->method();

    if(ctx_->llvm_state()->config().jit_inline_debug) {
      struct timeval tv;
      gettimeofday(&tv, NULL);

      ctx_->llvm_state()->log() << "JIT: compiling "
        << ctx_->llvm_state()->enclosure_name(code)
        << "#"
        << ctx_->llvm_state()->symbol_debug_str(code->name())
        << " (" << tv.tv_sec << "." << tv.tv_usec << ")\n";
    }

    JITMethodInfo info(ctx_, code, code->machine_code());
    info.is_block = false;

    if(Class* cls = req->receiver_class()) {
      info.set_self_class(cls);
    }

    ctx_->set_root(&info);

    jit::MethodBuilder work(ctx_, info);
    work.setup();

    compile_builder(info, work);
    ctx_->set_root(NULL);
  }
开发者ID:,项目名称:,代码行数:29,代码来源:

示例7: primitive_failed

  Object* CompiledCode::primitive_failed(STATE, CallFrame* call_frame,
              Executable* exec, Module* mod, Arguments& args)
  {
    CompiledCode* code = as<CompiledCode>(exec);

    Class* cls = args.recv()->lookup_begin(state);
    uint32_t id = cls->class_id();

    MachineCode* v = code->machine_code();

    executor target = v->unspecialized;

    for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
      uint32_t c_id = v->specializations[i].class_id;
      executor x = v->specializations[i].execute;

      if(c_id == id && x != 0) {
        target = x;
        break;
      }
    }

    if(target) {
      return target(state, call_frame, exec, mod, args);
    } else {
      return MachineCode::execute(state, call_frame, exec, mod, args);
    }
  }
开发者ID:mbj,项目名称:rubinius,代码行数:28,代码来源:compiledcode.cpp

示例8: method_id

  r_mint Env::method_id(rmethod meth) {
    CompiledCode* code = i(meth);

    if(MachineCode* mcode = code->machine_code()) {
      return (mcode->method_id() << 1) | 1;
    }

    return 0;
  }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9: method_id

  r_mint Env::method_id(rcompiled_code code) {
    CompiledCode* ccode = i(code);

    if(MachineCode* mcode = ccode->machine_code()) {
      return (mcode->method_id() << 1) | 1;
    }

    return 0;
  }
开发者ID:Energy0124,项目名称:rubinius,代码行数:9,代码来源:rbxti.cpp

示例10: dup

  CompiledCode* CompiledCode::dup(STATE) {
    CompiledCode* code =
      state->memory()->new_object<CompiledCode>(state, G(compiled_code));

    code->copy_object(state, this);
    code->set_executor(CompiledCode::default_executor);
    code->machine_code(NULL);

    return code;
  }
开发者ID:clockmaker002,项目名称:rubinius,代码行数:10,代码来源:compiled_code.cpp

示例11: set_breakpoint

  Object* CompiledCode::set_breakpoint(STATE, Fixnum* ip, Object* bp) {
    CompiledCode* self = this;
    OnStack<3> os(state, self, ip, bp);

    int i = ip->to_native();
    if(self->machine_code() == NULL) {
      if(!self->internalize(state)) return Primitives::failure();
    }

    if(!self->machine_code()->validate_ip(state, i)) return Primitives::failure();

    if(self->breakpoints()->nil_p()) {
      self->breakpoints(state, LookupTable::create(state));
    }

    self->breakpoints()->store(state, ip, bp);
    self->machine_code()->debugging = 1;
    self->machine_code()->run = MachineCode::debugger_interpreter;

    return ip;
  }
开发者ID:clockmaker002,项目名称:rubinius,代码行数:21,代码来源:compiled_code.cpp

示例12:

  void CompiledCode::Info::show(STATE, Object* self, int level) {
    CompiledCode* code = as<CompiledCode>(self);

    class_header(state, self);
    indent_attribute(++level, "file"); code->file()->show(state, level);
    indent_attribute(level, "iseq"); code->iseq()->show(state, level);
    indent_attribute(level, "lines"); code->lines()->show_simple(state, level);
    indent_attribute(level, "literals"); code->literals()->show_simple(state, level);
    indent_attribute(level, "local_count"); code->local_count()->show(state, level);
    indent_attribute(level, "local_names"); code->local_names()->show_simple(state, level);
    indent_attribute(level, "name"); code->name()->show(state, level);
    indent_attribute(level, "required_args"); code->required_args()->show(state, level);
    indent_attribute(level, "scope"); code->scope()->show(state, level);
    indent_attribute(level, "splat"); code->splat()->show(state, level);
    indent_attribute(level, "stack_size"); code->stack_size()->show(state, level);
    indent_attribute(level, "total_args"); code->total_args()->show(state, level);

    indent_attribute(level, "internalized");
    if(!code->machine_code_) {
      std::cout << "no\n";
    } else {
      std::cout << "yes\n";

#ifdef ENABLE_LLVM
      MachineCode* v = code->machine_code();

      for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
        if(!v->specializations[i].jit_data) continue;

        llvm::Function* func = v->specializations[i].jit_data->llvm_function();

        llvm::outs() << "<LLVM>\n"
                     << *func
                     << "</LLVM>\n<MachineCode>\n";

        LLVMState::show_machine_code(
            v->specializations[i].jit_data->native_func(),
            v->specializations[i].jit_data->native_size());
        llvm::outs() << "</MachineCode>\n";
      }
#endif
    }

    close_body(level);
  }
开发者ID:,项目名称:,代码行数:45,代码来源:

示例13: find_candidate

  CallFrame* LLVMState::find_candidate(STATE, CompiledCode* start, CallFrame* call_frame) {
    if(!config_.jit_inline_generic) {
      return call_frame;
    }

    int depth = config().jit_limit_search;

    if(!start) {
      throw CompileError("find_candidate: null start");
    }

    if(!call_frame) {
      throw CompileError("find_candidate: null call frame");
    }

    // if(!start) {
      // start = call_frame->compiled_code;
      // call_frame = call_frame->previous;
      // depth--;
    // }

    if(debug_search) {
      std::cout << "> call_count: " << call_frame->compiled_code->machine_code()->call_count
            << " size: " << call_frame->compiled_code->machine_code()->total
            << " sends: " << call_frame->compiled_code->machine_code()->call_site_count()
            << std::endl;

      call_frame->print_backtrace(state, 1);
    }

    if(start->machine_code()->total > (size_t)config_.jit_limit_inline_method) {
      if(debug_search) {
        std::cout << "JIT: STOP. reason: trigger method isn't small: "
              << start->machine_code()->total << " > "
              << config_.jit_limit_inline_method
              << std::endl;
      }

      return call_frame;
    }

    MachineCode* mcode = start->machine_code();

    if(mcode->required_args != mcode->total_args) {
      if(debug_search) {
        std::cout << "JIT: STOP. reason: trigger method req_args != total_args" << std::endl;
      }

      return call_frame;
    }

    if(mcode->no_inline_p()) {
      if(debug_search) {
        std::cout << "JIT: STOP. reason: trigger method no_inline_p() = true" << std::endl;
      }

      return call_frame;
    }

    CallFrame* callee = call_frame;
    call_frame = call_frame->previous;

    if(!call_frame) return callee;

    // Now start looking at callers.

    while(depth-- > 0) {
      CompiledCode* cur = call_frame->compiled_code;

      if(!cur) {
        if(debug_search) {
          std::cout << "JIT: STOP. reason: synthetic CallFrame hit" << std::endl;
        }
        return callee;
      }

      MachineCode* mcode = cur->machine_code();

      if(debug_search) {
        std::cout << "> call_count: " << mcode->call_count
              << " size: " << mcode->total
              << " sends: " << mcode->call_site_count()
              << std::endl;

        call_frame->print_backtrace(state, 1);
      }


      /*
      if(call_frame->block_p()
          || mcode->required_args != mcode->total_args // has a splat
          || mcode->call_count < 200 // not called much
          || mcode->jitted() // already jitted
          || mcode->parent() // is a block
        ) return callee;
      */

      if(mcode->required_args != mcode->total_args) {
        if(debug_search) {
          std::cout << "JIT: STOP. reason: req_args != total_args" << std::endl;
//.........这里部分代码省略.........
开发者ID:d4rky-pl,项目名称:rubinius,代码行数:101,代码来源:state.cpp

示例14: machine_code

 MachineCode* machine_code() {
     return method_->machine_code();
 }
开发者ID:,项目名称:,代码行数:3,代码来源:

示例15: compile_method

  void Compiler::compile_method(BackgroundCompileRequest* req) {
    CompiledCode* code = req->method();

    if(ctx_->llvm_state()->config().jit_inline_debug) {
      struct timeval tv;
      gettimeofday(&tv, NULL);

      ctx_->llvm_state()->log() << "JIT: compiling "
        << ctx_->llvm_state()->enclosure_name(code)
        << "#"
        << ctx_->llvm_state()->symbol_debug_str(code->name())
        << " (" << tv.tv_sec << "." << tv.tv_usec << ")\n";
    }

#ifdef HAVE_DTRACE
    if(RUBINIUS_JIT_FUNCTION_BEGIN_ENABLED()) {
      RBX_DTRACE_CONST char* class_name =
          const_cast<RBX_DTRACE_CONST char*>(
              ctx_->llvm_state()->enclosure_name(code).c_str());
      RBX_DTRACE_CONST char* method_name =
          const_cast<RBX_DTRACE_CONST char*>(
              ctx_->llvm_state()->symbol_debug_str(code->name()).c_str());
      RBX_DTRACE_CONST char* file_name =
          const_cast<RBX_DTRACE_CONST char*>(
              ctx_->llvm_state()->symbol_debug_str(code->file()).c_str());
      int line = code->start_line();
      RUBINIUS_JIT_FUNCTION_BEGIN(class_name, method_name, file_name, line);
    }
#endif

    JITMethodInfo info(ctx_, code, code->machine_code());
    info.is_block = false;
    info.hits = req->hits();

    if(Class* cls = req->receiver_class()) {
      info.set_self_class(cls);
    }

    ctx_->set_root(&info);

    jit::MethodBuilder work(ctx_, info);
    work.setup();

    compile_builder(info, work);
    ctx_->set_root(NULL);

#ifdef HAVE_DTRACE
    if(RUBINIUS_JIT_FUNCTION_END_ENABLED()) {
      RBX_DTRACE_CONST char* class_name =
          const_cast<RBX_DTRACE_CONST char*>(
              ctx_->llvm_state()->enclosure_name(code).c_str());
      RBX_DTRACE_CONST char* method_name =
          const_cast<RBX_DTRACE_CONST char*>(
              ctx_->llvm_state()->symbol_debug_str(code->name()).c_str());
      RBX_DTRACE_CONST char* file_name =
          const_cast<RBX_DTRACE_CONST char*>(
              ctx_->llvm_state()->symbol_debug_str(code->file()).c_str());
      int line = code->start_line();
      RUBINIUS_JIT_FUNCTION_END(class_name, method_name, file_name, line);
    }
#endif
  }
开发者ID:khamutov,项目名称:rubinius,代码行数:62,代码来源:jit_compiler.cpp


注:本文中的CompiledCode::machine_code方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。