Skip to content

Commit

Permalink
Fixed handling JIT being off.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Oct 19, 2014
1 parent 31c1d67 commit d4e17e5
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 22 deletions.
2 changes: 1 addition & 1 deletion kernel/delta/rubinius.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def self.received_signal(sig)
def self.version
extra = ""

if jit = Rubinius::JIT.properties
if Rubinius::JIT.enabled? and jit = Rubinius::JIT.properties
extra << "J"

if jit.include? :inline_generic
Expand Down
8 changes: 3 additions & 5 deletions vm/builtin/block_environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "builtin/constant_scope.hpp"
#include "builtin/exception.hpp"
#include "builtin/fixnum.hpp"
#include "builtin/jit.hpp"
#include "builtin/location.hpp"
#include "builtin/native_method.hpp"
#include "builtin/object.hpp"
Expand Down Expand Up @@ -395,13 +396,10 @@ namespace rubinius {
#ifdef ENABLE_LLVM
if(mcode->call_count >= 0) {
if(mcode->call_count >= state->shared().config.jit_call_til_compile) {
LLVMState* ls = state->shared().llvm_state;

GCTokenImpl gct;
OnStack<1> os(state, env);
ls->compile_soon(state, gct, env->compiled_code(), previous,
invocation.self->direct_class(state), env, true);

G(jit)->compile_soon(state, env->compiled_code(), previous,
invocation.self->direct_class(state), env, true);
} else {
mcode->call_count++;
}
Expand Down
46 changes: 46 additions & 0 deletions vm/builtin/jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,58 @@ namespace rubinius {
}

Object* JIT::enable(STATE) {
if(!CBOOL(enabled())) return cFalse;

state->shared().llvm_state->enable(state);
enabled(state, cTrue);

return cTrue;
}

Object* JIT::compile_soon(STATE, CompiledCode* code, CallFrame* call_frame,
Class* receiver_class, BlockEnvironment* block_env, bool is_block)
{
if(!CBOOL(enabled())) return cFalse;

GCTokenImpl gct;

LLVMState* ls = state->shared().llvm_state;
ls->compile_soon(state, gct, code, call_frame, receiver_class, block_env, is_block);

return cTrue;
}

Object* JIT::compile_callframe(STATE, CompiledCode* code, CallFrame* call_frame,
int primitive)
{
if(!CBOOL(enabled())) return cFalse;

GCTokenImpl gct;

LLVMState* ls = state->shared().llvm_state;
ls->compile_callframe(state, gct, code, call_frame, primitive);

return cTrue;
}

Object* JIT::start_method_update(STATE) {
if(!CBOOL(enabled())) return cFalse;

LLVMState* ls = state->shared().llvm_state;
ls->start_method_update();

return cTrue;
}

Object* JIT::end_method_update(STATE) {
if(!CBOOL(enabled())) return cFalse;

LLVMState* ls = state->shared().llvm_state;
ls->end_method_update();

return cTrue;
}

JITCompileRequest* JITCompileRequest::create(STATE, CompiledCode* code,
Class* receiver_class, int hits, BlockEnvironment* block_env, bool is_block)
{
Expand Down
7 changes: 7 additions & 0 deletions vm/builtin/jit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ namespace rubinius {

Object* enable(STATE);

Object* compile_soon(STATE, CompiledCode* code, CallFrame* call_frame,
Class* receiver_class, BlockEnvironment* block_env=NULL, bool is_block=false);
Object* compile_callframe(STATE, CompiledCode* code, CallFrame* call_frame,
int primitive=-1);
Object* start_method_update(STATE);
Object* end_method_update(STATE);

class Info : public Module::Info {
public:
BASIC_TYPEINFO(Module::Info)
Expand Down
6 changes: 5 additions & 1 deletion vm/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ namespace rubinius {
void Environment::start_jit(STATE) {
utilities::thread::SpinLock::LockGuard lg(state->shared().llvm_state_lock());

if(state->shared().config.jit_disabled) return;

if(!state->shared().llvm_state) {
state->shared().llvm_state = new LLVMState(state);
}
Expand All @@ -145,8 +147,10 @@ namespace rubinius {
void Environment::stop_jit(STATE) {
utilities::thread::SpinLock::LockGuard lg(state->shared().llvm_state_lock());

if(state->shared().config.jit_disabled) return;

if(state->shared().llvm_state) {
state->shared().llvm_state->shutdown(state);
state->shared().llvm_state->stop(state);
}
}

Expand Down
8 changes: 0 additions & 8 deletions vm/llvm/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,6 @@ namespace rubinius {
start_thread(state);
}

void LLVMState::before_fork(STATE) {
stop_thread(state);
}

void LLVMState::after_fork_parent(STATE) {
start_thread(state);
}

void LLVMState::after_fork_child(STATE) {
reset_compile_state(state);
start_thread(state);
Expand Down
2 changes: 0 additions & 2 deletions vm/llvm/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ namespace rubinius {

void before_exec(STATE);
void after_exec(STATE);
void before_fork(STATE);
void after_fork_parent(STATE);
void after_fork_child(STATE);

void gc_scan(GarbageCollector* gc);
Expand Down
10 changes: 5 additions & 5 deletions vm/machine_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "builtin/exception.hpp"
#include "builtin/fixnum.hpp"
#include "builtin/iseq.hpp"
#include "builtin/jit.hpp"
#include "builtin/symbol.hpp"
#include "builtin/tuple.hpp"
#include "builtin/class.hpp"
Expand Down Expand Up @@ -749,9 +750,9 @@ namespace rubinius {
// for this method.
if(mcode->call_count >= 0) {
if(mcode->call_count >= state->shared().config.jit_call_til_compile) {
LLVMState* ls = state->shared().llvm_state;
OnStack<3> os(state, exec, mod, code);
ls->compile_callframe(state, gct, code, frame);

G(jit)->compile_callframe(state, code, frame);
} else {
mcode->call_count++;
}
Expand Down Expand Up @@ -851,8 +852,7 @@ namespace rubinius {
bool disable)
{
#ifdef ENABLE_LLVM
LLVMState* ls = state->shared().llvm_state;
ls->start_method_update();
G(jit)->start_method_update(state);

bool still_others = false;

Expand Down Expand Up @@ -903,7 +903,7 @@ namespace rubinius {
if(!found) rubinius::bug("no specializations!");
}

ls->end_method_update();
G(jit)->end_method_update(state);
#endif
}

Expand Down

0 comments on commit d4e17e5

Please sign in to comment.