Skip to content

Commit

Permalink
Begin support for LLVM 3.6+.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Mar 26, 2016
1 parent 93228c4 commit 3ac5902
Show file tree
Hide file tree
Showing 58 changed files with 202 additions and 710 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -11,12 +11,13 @@ before_install:
- echo $LANG
- echo $LC_ALL
- if [ $TRAVIS_OS_NAME == linux ]; then ./scripts/llvm.sh; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install llvm35 && brew link --force llvm35; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install llvm; fi
- gem update --system
- gem --version
before_script:
- travis_retry bundle
- ./configure
if [ $TRAVIS_OS_NAME == linux ]; then travis_retry ./configure --llvm-config=llvm-config-3.6; fi
if [ $TRAVIS_OS_NAME == osx ]; then travis_retry ./configure; fi
script: rake ci
after_success:
- if [ $TRAVIS_BRANCH == $TRAVIS_TAG ]; then ./scripts/deploy.sh release github website triggers; fi
Expand Down
42 changes: 12 additions & 30 deletions configure
Expand Up @@ -58,7 +58,6 @@ class Configure
@gem = nil

# LLVM settings
@llvm_enabled = true
@llvm_path = nil
@llvm_system_name = get_system_name
@llvm_configure = nil
Expand Down Expand Up @@ -336,10 +335,6 @@ class Configure

o.doc "\n LLVM settings"

o.on "--disable-llvm", "Don't build with LLVM" do
@llvm_enabled = false
end

o.on "--system-name", "NAME", "Name of OS (eg fedora-8, ubuntu-10.04)" do |name|
@llvm_system_name = name
end
Expand Down Expand Up @@ -565,11 +560,6 @@ class Configure
end

def setup_llvm
unless @llvm_enabled
@log.write "WARNING: LLVM disabled."
return false
end

@log.print " Checking for 'llvm-config': "

config = @llvm_configure
Expand All @@ -583,8 +573,8 @@ class Configure
if macports?
config = macports_llvm_config
else
out = Bundler.with_clean_env { `brew --prefix llvm35` }.chomp
config = "#{out}/bin/llvm-config-3.5" if $?.success?
out = Bundler.with_clean_env { `brew --prefix llvm` }.chomp
config = "#{out}/bin/llvm-config" if $?.success?
end
end
end
Expand All @@ -604,8 +594,8 @@ class Configure
unless failed
parts = version.sub(/svn$/, "").split(".").map { |i| i.to_i }
api_version = ("%d%02d" % parts[0..1]).to_i
if api_version < 300 or api_version > 305
@log.write "only LLVM 3.0-3.5 is supported"
if api_version < 306
@log.write "only LLVM 3.6+ is supported"
else
@log.write "found! (version #{version} - api: #{api_version})"
@llvm = :config
Expand Down Expand Up @@ -666,19 +656,16 @@ int main() { LLVMContext &Context = getGlobalContext(); }
def check_llvm_flags
flags = '--ldflags'

if @llvm_api_version >= 305
# Starting with LLVM 3.5 the --system-libs option is required in order to
# link against libraries such as zlib. Prior to 3.5 this was handled by
# --ldflags.
flags << ' --system-libs'
end
@llvm_cxxflags << " -std=c++11"

# Starting with LLVM 3.5 the --system-libs option is required in order to
# link against libraries such as zlib. Prior to 3.5 this was handled by
# --ldflags.
flags << ' --system-libs'

# Generate the actual flags. For whatever reason llvm-config also includes
# newlines in the output, so lets get rid of those while we're at it.
@llvm_ldflags = `#{@llvm_configure} #{flags}`.strip.gsub("\n", ' ')

# We use some C++11 features in the VM source, so we need to enable support.
@llvm_cxxflags << " -std=c++11"
end

def env(which)
Expand Down Expand Up @@ -717,7 +704,7 @@ int main() { LLVMContext &Context = getGlobalContext(); }
check_tool_version @cc, '-dumpversion', [4, 1]
check_tool_version @cxx, '-dumpversion', [4, 1]

unless @cc == "clang" and @cxx == "clang++"
unless @cc =~ /clang/ and @cxx =~ /clang\+\+/
@log.deprecated <<-EOM
Support for compilers other than clang/clang++ is deprecated and will be
removed soon. If your platform does not have support for clang/clang++,
Expand Down Expand Up @@ -1532,10 +1519,6 @@ int main() { return tgetnum(""); }
def write_configure_files
@log.write "\nWriting configuration files..."

unless @llvm_enabled
@llvm_configure = ""
end

@bin_links.delete @program_name

config_settings = {
Expand All @@ -1544,7 +1527,6 @@ int main() { return tgetnum(""); }
:build_make => @make,
:build_rake => @rake,
:build_perl => @perl,
:llvm_enabled => @llvm_enabled,
:llvm_path => @llvm_path,
:llvm_system_name => @llvm_system_name,
:llvm_configure => @llvm_configure,
Expand Down Expand Up @@ -2073,7 +2055,7 @@ Available commands are:
# Query MacPorts for the path to the latest installed version of
# llvm-config that is within the range of supported LLVM versions.
def macports_llvm_config
supported_versions = (3.0 .. 3.5)
supported_versions = (3.6..3.9)
installed_ports = `port installed | egrep -o 'llvm-[^ ]+'`.split
latest_usable_port = installed_ports.sort.select do |fname|
version = fname.match(/-\K.*/)[0].to_f
Expand Down
6 changes: 0 additions & 6 deletions machine/builtin/block_environment.cpp
Expand Up @@ -21,9 +21,7 @@
#include "builtin/tuple.hpp"
#include "builtin/variable_scope.hpp"

#ifdef ENABLE_LLVM
#include "jit/llvm/state.hpp"
#endif

#include <iostream>

Expand Down Expand Up @@ -75,11 +73,9 @@ namespace rubinius {

state->vm()->metrics().machine.blocks_invoked++;

#ifdef ENABLE_LLVM
if(executor ptr = mcode->unspecialized) {
return (*((BlockExecutor)ptr))(state, env, args, invocation);
}
#endif

return execute_interpreter(state, env, args, invocation);
}
Expand Down Expand Up @@ -390,7 +386,6 @@ namespace rubinius {
return 0;
}

#ifdef ENABLE_LLVM
if(mcode->call_count >= 0) {
if(mcode->call_count >= state->shared().config.jit_threshold_compile) {
OnStack<1> os(state, env);
Expand All @@ -401,7 +396,6 @@ namespace rubinius {
mcode->call_count++;
}
}
#endif

StackVariables* scope = ALLOCA_STACKVARIABLES(mcode->number_of_locals);

Expand Down
8 changes: 0 additions & 8 deletions machine/builtin/compiled_code.cpp
Expand Up @@ -25,11 +25,9 @@

#include <ostream>

#ifdef ENABLE_LLVM
#include "jit/llvm/state.hpp"
#include "jit/llvm/compiler.hpp"
#include "jit/llvm/runtime.hpp"
#endif

namespace rubinius {

Expand Down Expand Up @@ -258,9 +256,7 @@ namespace rubinius {

machine_code_->set_execute_status(MachineCode::eJIT);

#ifdef ENABLE_LLVM
jit_data_ = rd;
#endif
machine_code_->unspecialized = exec;

// See if we can also just make this the normal execute
Expand Down Expand Up @@ -469,7 +465,6 @@ namespace rubinius {
MachineCode* mcode = code->machine_code_;
mcode->set_mark();

#ifdef ENABLE_LLVM
if(code->jit_data()) {
code->jit_data()->set_mark();
code->jit_data()->mark_all(code, mark);
Expand All @@ -482,7 +477,6 @@ namespace rubinius {
mcode->specializations[i].jit_data->mark_all(code, mark);
}
}
#endif

for(size_t i = 0; i < mcode->call_site_count(); i++) {
size_t index = mcode->call_site_offsets()[i];
Expand Down Expand Up @@ -526,7 +520,6 @@ namespace rubinius {
} else {
std::cout << "yes\n";

#ifdef ENABLE_LLVM
MachineCode* v = code->machine_code();

for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
Expand All @@ -538,7 +531,6 @@ namespace rubinius {
v->specializations[i].jit_data->native_size());
llvm::outs() << "</MachineCode>\n";
}
#endif
}

close_body(level);
Expand Down
7 changes: 0 additions & 7 deletions machine/builtin/compiled_code.hpp
Expand Up @@ -46,9 +46,7 @@ namespace rubinius {

MachineCode* machine_code_;

#ifdef ENABLE_LLVM
jit::RuntimeDataHolder* jit_data_;
#endif

public:
// Access directly from assembly, so has to be public.
Expand All @@ -59,15 +57,13 @@ namespace rubinius {
return machine_code_;
}

#ifdef ENABLE_LLVM
jit::RuntimeDataHolder* jit_data() {
return jit_data_;
}

void set_jit_data(jit::RuntimeDataHolder* rds) {
jit_data_ = rds;
}
#endif

bool can_specialize_p();
void set_unspecialized(executor exec, jit::RuntimeDataHolder* rd);
Expand Down Expand Up @@ -115,10 +111,7 @@ namespace rubinius {
obj-> arity_ = nil<Fixnum>();
obj-> breakpoints_ = nil<LookupTable>();
obj-> machine_code_ = NULL;

#ifdef ENABLE_LLVM
obj->jit_data_ = NULL;
#endif

obj->literals_ = nil<Tuple>();
}
Expand Down
16 changes: 0 additions & 16 deletions machine/builtin/jit.cpp
Expand Up @@ -5,9 +5,7 @@
#include "builtin/jit.hpp"
#include "builtin/list.hpp"

#ifdef ENABLE_LLVM
#include "jit/llvm/state.hpp"
#endif

namespace rubinius {
void JIT::bootstrap(STATE) {
Expand All @@ -27,9 +25,6 @@ namespace rubinius {
Object* JIT::compile(STATE, Object* object, CompiledCode* code,
Object* block_environment)
{
#ifndef ENABLE_LLVM
return cFalse;
#else
if(!CBOOL(enabled())) return cFalse;

BlockEnvironment* block_env = try_as<BlockEnvironment>(block_environment);
Expand All @@ -40,7 +35,6 @@ namespace rubinius {
block_env, !block_env->nil_p());

return cTrue;
#endif
}

Object* JIT::compile_threshold(STATE) {
Expand All @@ -59,10 +53,8 @@ namespace rubinius {
Object* JIT::enable(STATE) {
if(!CBOOL(enabled())) return cFalse;

#ifdef ENABLE_LLVM
state->shared().llvm_state->enable(state);
enabled(state, cTrue);
#endif

return cTrue;
}
Expand All @@ -72,10 +64,8 @@ namespace rubinius {
{
if(!CBOOL(enabled())) return cFalse;

#ifdef ENABLE_LLVM
LLVMState* ls = state->shared().llvm_state;
ls->compile_soon(state, code, receiver_class, block_env, is_block);
#endif

return cTrue;
}
Expand All @@ -85,32 +75,26 @@ namespace rubinius {
{
if(!CBOOL(enabled())) return cFalse;

#ifdef ENABLE_LLVM
LLVMState* ls = state->shared().llvm_state;
ls->compile_callframe(state, code, primitive);
#endif

return cTrue;
}

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

#ifdef ENABLE_LLVM
LLVMState* ls = state->shared().llvm_state;
ls->start_method_update();
#endif

return cTrue;
}

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

#ifdef ENABLE_LLVM
LLVMState* ls = state->shared().llvm_state;
ls->end_method_update();
#endif

return cTrue;
}
Expand Down
2 changes: 0 additions & 2 deletions machine/builtin/system.cpp
Expand Up @@ -63,11 +63,9 @@
#include <dlfcn.h>
#endif

#ifdef ENABLE_LLVM
#include "jit/llvm/state.hpp"
#include "jit/llvm/context.hpp"
#include "jit/llvm/compiler.hpp"
#endif

#include "missing/setproctitle.h"

Expand Down

0 comments on commit 3ac5902

Please sign in to comment.