Skip to content

Commit

Permalink
JIT: "I'm back fam" 😻
Browse files Browse the repository at this point in the history
Narrator: "Kinda, sorta"
  • Loading branch information
brixen committed Apr 21, 2020
1 parent 78a7cb8 commit 20e3b6c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 70 deletions.
11 changes: 5 additions & 6 deletions machine/machine.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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_) {
Expand Down
2 changes: 2 additions & 0 deletions machine/machine.hpp
Expand Up @@ -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();
// ---

Expand Down
39 changes: 0 additions & 39 deletions machine/machine_compiler.cpp
Expand Up @@ -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<std::mutex> lk(list_mutex_);
list_condition_.wait(lk,
[this]{ return thread_exit_ || !list_.empty(); });

if(!list_.empty()) {
request = list_.back();
list_.pop_back();
}
}
}
}
}
}
34 changes: 9 additions & 25 deletions machine/machine_compiler.hpp
Expand Up @@ -32,17 +32,18 @@

namespace rubinius {
namespace jit {

class CompileRequest;

typedef std::list<CompileRequest*> 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;
Expand Down Expand Up @@ -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);
};
};
}
}

Expand Down

0 comments on commit 20e3b6c

Please sign in to comment.