Skip to content

Commit

Permalink
Fixed JIT loading CompiledCode from method_id.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Feb 4, 2016
1 parent 7f77821 commit 7e8d52c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions vm/builtin/code_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ namespace rubinius {
return load(state, m_id->c_str(state));
}

CompiledCode* CodeDB::load(STATE, Object* id_or_code) {
if(String* m_id = try_as<String>(id_or_code)) {
return CodeDB::load(state, m_id);
}

return as<CompiledCode>(id_or_code);
}

Object* CodeDB::store(STATE, CompiledCode* code) {
return cNil;
}
Expand Down
2 changes: 2 additions & 0 deletions vm/builtin/code_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace rubinius {
static CompiledCode* load(STATE, String* m_id);
static CompiledCode* load(STATE, const char* m_id);

static CompiledCode* load(STATE, Object* id_or_code);

// Rubinius.primitive :code_db_store
Object* store(STATE, CompiledCode* code);

Expand Down
8 changes: 7 additions & 1 deletion vm/llvm/jit_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "call_frame.hpp"
#include "on_stack.hpp"

#include "builtin/code_db.hpp"
#include "builtin/object.hpp"
#include "builtin/symbol.hpp"
#include "builtin/system.hpp"
Expand Down Expand Up @@ -249,7 +250,12 @@ extern "C" {
CPP_TRY

Object* _lit = call_frame->compiled_code->literals()->at(state, index);
CompiledCode* code = as<CompiledCode>(_lit);
CompiledCode* code = 0;

if(!(code = try_as<CompiledCode>(_lit))) {
code = CodeDB::load(state, as<String>(_lit));
call_frame->compiled_code->literals()->put(state, index, code);
}

MachineCode* mcode = call_frame->compiled_code->machine_code();
GCTokenImpl gct;
Expand Down
3 changes: 2 additions & 1 deletion vm/llvm/jit_visit.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "instructions_util.hpp"

#include "builtin/code_db.hpp"
#include "builtin/symbol.hpp"
#include "builtin/tuple.hpp"
#include "builtin/constant_cache.hpp"
Expand Down Expand Up @@ -1809,7 +1810,7 @@ namespace rubinius {
b().CreateBr(block_continue);
set_block(block_continue);

CompiledCode* block_code = as<CompiledCode>(literal(which));
CompiledCode* block_code = CodeDB::load(ctx_->llvm_state()->state(), literal(which));
MachineCode* code = block_code->machine_code();

current_block_ = new JITInlineBlock(ctx_, block_code, code, &info(), which, stack_ptr());
Expand Down

0 comments on commit 7e8d52c

Please sign in to comment.