本文整理汇总了C++中CompiledCode类的典型用法代码示例。如果您正苦于以下问题:C++ CompiledCode类的具体用法?C++ CompiledCode怎么用?C++ CompiledCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CompiledCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: auto_mark
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);
}
}
}
}
示例2: 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);
}
}
示例3: test_specialize_transforms_ivars_to_slots
void test_specialize_transforms_ivars_to_slots() {
CompiledCode* code = CompiledCode::create(state);
Tuple* tup = Tuple::from(state, 1, state->symbol("@blah"));
code->literals(state, tup);
InstructionSequence* iseq = InstructionSequence::create(state, 3);
iseq->opcodes()->put(state, 0, Fixnum::from(InstructionSequence::insn_push_ivar));
iseq->opcodes()->put(state, 1, Fixnum::from(0));
iseq->opcodes()->put(state, 2, Fixnum::from(InstructionSequence::insn_push_nil));
code->iseq(state, iseq);
MachineCode* mcode = new MachineCode(state, code);
Object::Info ti(ObjectType);
ti.slots[state->symbol("@blah")->index()] = 5;
ti.slot_locations.resize(6);
ti.slot_locations[5] = 33;
mcode->specialize(state, code, &ti);
TS_ASSERT_EQUALS(mcode->total, 3U);
TS_ASSERT_EQUALS(mcode->opcodes[0], static_cast<unsigned int>(InstructionSequence::insn_push_my_offset));
TS_ASSERT_EQUALS(mcode->opcodes[1], 33U);
TS_ASSERT_EQUALS(mcode->opcodes[2], static_cast<unsigned int>(InstructionSequence::insn_push_nil));
}
示例4: lg
Object* CompiledCode::default_executor(STATE, CallFrame* call_frame,
Executable* exec, Module* mod, Arguments& args)
{
LockableScopedLock lg(state, &state->shared(), __FILE__, __LINE__);
CompiledCode* code = as<CompiledCode>(exec);
if(code->execute == default_executor) {
const char* reason = 0;
int ip = -1;
OnStack<5> os(state, code, exec, mod, args.recv_location(), args.block_location());
VariableRootBuffer vrb(state->vm()->current_root_buffers(),
&args.arguments_location(), args.total());
GCTokenImpl gct;
if(!code->internalize(state, gct, call_frame, &reason, &ip)) {
Exception::bytecode_error(state, call_frame, code, ip, reason);
return 0;
}
}
lg.unlock();
return code->execute(state, call_frame, exec, mod, args);
}
示例5: compile_method
void Compiler::compile_method(LLVMState* ls, BackgroundCompileRequest* req) {
CompiledCode* cm = req->method();
if(ls->config().jit_inline_debug) {
struct timeval tv;
gettimeofday(&tv, NULL);
ls->log() << "JIT: compiling "
<< ls->enclosure_name(cm)
<< "#"
<< ls->symbol_debug_str(cm->name())
<< " (" << tv.tv_sec << "." << tv.tv_usec << ")\n";
}
JITMethodInfo info(ctx_, cm, cm->backend_method());
info.is_block = false;
if(Class* cls = req->receiver_class()) {
info.set_self_class(cls);
}
ctx_.set_root(&info);
jit::MethodBuilder work(ls, info);
work.setup();
compile_builder(ctx_, ls, info, work);
ctx_.set_root(NULL);
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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);
}
示例9: i
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;
}
示例10: i
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;
}
示例11: 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);
}
示例12: G
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;
}
示例13: dup
CompiledCode* CompiledCode::dup(STATE) {
CompiledCode* code = CompiledCode::create(state);
code->copy_object(state, this);
code->set_executor(CompiledCode::default_executor);
code->jit_data_ = NULL;
code->machine_code_ = NULL;
return code;
}
示例14: dup
CompiledCode* CompiledCode::dup(STATE) {
CompiledCode* code = state->new_object_dirty<CompiledCode>(G(compiled_code));
code->copy_object(state, this);
code->set_executor(CompiledCode::default_executor);
code->jit_data_ = NULL;
code->machine_code_ = NULL;
return code;
}
示例15: constant_caches
Tuple* CompiledCode::constant_caches(STATE, CallFrame* calling_environment) {
GCTokenImpl gct;
CompiledCode* self = this;
OnStack<1> os(state, self);
if(self->machine_code_ == NULL) {
if(!self->internalize(state, gct, calling_environment)) return force_as<Tuple>(Primitives::failure());
}
MachineCode* mcode = self->machine_code_;
return mcode->constant_caches(state);
}