diff --git a/machine/machine.cpp b/machine/machine.cpp index 5800eb3210..c43ff5c801 100644 --- a/machine/machine.cpp +++ b/machine/machine.cpp @@ -233,9 +233,10 @@ namespace rubinius { // TODO: Machine // _console_->start(_environment_->state); - // state->shared().start_compiler(state); // state->diagnostics().start_diagnostics(state); + start_compiler(state); + MachineException::guard(state, false, [&]{ if(const char* var = getenv("RBX_OPTIONS")) { environment()->load_string(var); @@ -351,17 +352,15 @@ namespace rubinius { _console_->after_fork_child(state); } - /* TODO jit::MachineCompiler* Machine::start_compiler(STATE) { - if(!compiler_) { + if(!_compiler_) { if(state->configuration()->jit_enabled.value) { - compiler_ = new jit::MachineCompiler(state); + _compiler_ = new jit::MachineCompiler(state); } } - return compiler_; + return _compiler_; } - */ void Machine::halt_console(STATE) { if(_console_) { diff --git a/machine/machine.hpp b/machine/machine.hpp index 4bf417e4e9..ad1e154521 100644 --- a/machine/machine.hpp +++ b/machine/machine.hpp @@ -255,6 +255,8 @@ namespace rubinius { Diagnostics* start_diagnostics(STATE); void report_diagnostics(diagnostics::Diagnostic* diagnostic); + jit::MachineCompiler* start_compiler(STATE); + uint32_t new_thread_id(); // --- diff --git a/machine/machine_compiler.cpp b/machine/machine_compiler.cpp index c88c2d5c86..5f916389bc 100644 --- a/machine/machine_compiler.cpp +++ b/machine/machine_compiler.cpp @@ -6,46 +6,7 @@ namespace rubinius { namespace jit { MachineCompiler::MachineCompiler(STATE) - : MachineThread(state, "rbx.jit", MachineThread::eXLarge) - , list_() - , list_mutex_() - , list_condition_() { } - - void MachineCompiler::initialize(STATE) { - MachineThread::initialize(state); - } - - void MachineCompiler::wakeup(STATE) { - MachineThread::wakeup(state); - - list_condition_.notify_one(); - } - - void MachineCompiler::after_fork_child(STATE) { - MachineThread::after_fork_child(state); - - list_.clear(); - } - - void MachineCompiler::run(STATE) { - state->unmanaged_phase(); - - while(!thread_exit_) { - CompileRequest* request = 0; - - { - std::unique_lock lk(list_mutex_); - list_condition_.wait(lk, - [this]{ return thread_exit_ || !list_.empty(); }); - - if(!list_.empty()) { - request = list_.back(); - list_.pop_back(); - } - } - } - } } } diff --git a/machine/machine_compiler.hpp b/machine/machine_compiler.hpp index e0de03cf10..267f1671aa 100644 --- a/machine/machine_compiler.hpp +++ b/machine/machine_compiler.hpp @@ -32,17 +32,18 @@ namespace rubinius { namespace jit { - - class CompileRequest; - - typedef std::list CompileList; - #if LLVM_VERSION_MAJOR == 9 - using namespace llvm; using namespace llvm::orc; +#endif + + class MachineCompiler { + public: + MachineCompiler(STATE); + + virtual ~MachineCompiler() { } - class Compiler { +#if LLVM_VERSION_MAJOR == 9 ExecutionSession ES; RTDyldObjectLinkingLayer ObjectLayer; IRCompileLayer CompileLayer; @@ -113,25 +114,8 @@ namespace rubinius { return TSM; } - }; #endif - - class MachineCompiler : public MachineThread { - CompileList list_; - - std::mutex list_mutex_; - std::condition_variable list_condition_; - - public: - MachineCompiler(STATE); - - virtual ~MachineCompiler() { } - - void initialize(STATE); - void after_fork_child(STATE); - void wakeup(STATE); - void run(STATE); - }; + }; } }