Permalink
Browse files

Conditionalize using LLVM

  • Loading branch information...
1 parent f7cb6ca commit 0356ed375b62dff74dddaba03540d2e27d510809 Evan Phoenix committed May 15, 2009
Showing with 27 additions and 529 deletions.
  1. +2 −3 rakelib/vm.rake
  2. +0 −16 vm/builtin/compiledmethod.cpp
  3. +10 −0 vm/builtin/machine_method.cpp
  4. +7 −1 vm/codegen/instruction_macros.rb
  5. +0 −468 vm/llvm.cpp
  6. +0 −32 vm/llvm.hpp
  7. +4 −0 vm/llvm/jit.cpp
  8. +4 −0 vm/llvm/jit_util.cpp
  9. +0 −4 vm/shared_state.cpp
  10. +0 −5 vm/vm.cpp
View
@@ -27,8 +27,7 @@ else
LLVM_STYLE = "Release"
end
-LLVM_ENABLE = true
-
+LLVM_ENABLE = false
ENV.delete 'CDPATH' # confuses llvm_config
LLVM_CONFIG = "vm/external_libs/llvm/#{LLVM_STYLE}/bin/llvm-config"
@@ -185,7 +184,7 @@ if RUBY_PLATFORM =~ /darwin/i && `sw_vers` =~ /10\.4/
end
if LLVM_ENABLE
- # FLAGS << "-DENABLE_LLVM"
+ FLAGS << "-DENABLE_LLVM"
llvm_flags = `#{LLVM_CONFIG} --cflags`.split(/\s+/)
llvm_flags.delete_if { |e| e.index("-O") == 0 }
FLAGS.concat llvm_flags
@@ -13,7 +13,6 @@
#include "ffi.hpp"
#include "marshal.hpp"
#include "primitives.hpp"
-#include "llvm.hpp"
#include "objectmemory.hpp"
#include "arguments.hpp"
#include "dispatch.hpp"
@@ -70,22 +69,7 @@ namespace rubinius {
VMMethod* CompiledMethod::formalize(STATE, bool ondemand) {
if(!backend_method_) {
VMMethod* vmm = NULL;
-#ifdef ENABLE_LLVM
- /* Controls whether we use LLVM out of the gate or not. */
- if(state->config.compile_up_front) {
- if(ondemand) {
- set_executor(VMLLVMMethod::uncompiled_execute);
- } else {
- VMLLVMMethod* llvm = new VMLLVMMethod(state, this);
- llvm->compile(state);
- vmm = llvm;
- }
- } else {
- vmm = new VMMethod(state, this);
- }
-#else
vmm = new VMMethod(state, this);
-#endif
backend_method_ = vmm;
resolve_primitive(state);
@@ -9,8 +9,10 @@
#include "detection.hpp"
+#ifdef ENABLE_LLVM
#include "llvm/jit.hpp"
#include <llvm/Support/CommandLine.h>
+#endif
// #define MM_DEBUG
@@ -20,8 +22,10 @@ namespace rubinius {
GO(machine_method).set(state->new_class_under("MachineMethod", G(rubinius)));
GO(machine_method)->name(state, state->symbol("Rubinius::MachineMethod"));
+#ifdef ENABLE_LLVM
//setenv("RBX_JIT", "--debug-only=jit", 1);
llvm::cl::ParseEnvironmentOptions("rbx", "RBX_JIT", "blah", false);
+#endif
}
@@ -80,6 +84,7 @@ namespace rubinius {
}
MachineMethod* MachineMethod::create(STATE, VMMethod* vmm) {
+#ifdef ENABLE_LLVM
LLVMCompiler* jit = new LLVMCompiler();
jit->compile(state, vmm);
@@ -94,6 +99,9 @@ namespace rubinius {
mm->jit_data_ = reinterpret_cast<void*>(jit);
return mm;
+#else
+ return (MachineMethod*)Qnil;
+#endif
}
void* MachineMethod::resolve_virtual_ip(int ip) {
@@ -103,6 +111,7 @@ namespace rubinius {
}
Object* MachineMethod::show(STATE) {
+#ifdef ENABLE_LLVM
if(code_size_ == 0) {
std::cout << "== llvm assembly ==\n";
reinterpret_cast<LLVMCompiler*>(jit_data_)->show_assembly(state);
@@ -117,6 +126,7 @@ namespace rubinius {
std::cout << "\n== x86 assembly ==\n";
assembler_x86::AssemblerX86::show_buffer(function(), code_size_, false, comments_);
}
+#endif
return Qnil;
}
@@ -1,6 +1,12 @@
require "#{File.dirname(__FILE__)}/../../kernel/compiler/iseq"
-File.open "#{File.dirname(__FILE__)}/../gen/inst_list.hpp", "w" do |f|
+dir = "#{File.dirname(__FILE__)}/../gen/"
+
+unless File.directory? dir
+ Dir.mkdir dir
+end
+
+File.open "#{dir}/inst_list.hpp", "w" do |f|
Rubinius::InstructionSet::OpCodes.each do |ins|
case ins.arg_count
when 2
Oops, something went wrong. Retry.

0 comments on commit 0356ed3

Please sign in to comment.