Skip to content

Commit

Permalink
Showing 129 changed files with 1,938 additions and 2,895 deletions.
38 changes: 0 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -28,24 +28,6 @@ env:
- JAVA_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xmn48M -Xmx512M"
- MALLOC_ARENA_MAX=2
matrix:
- PHASE='-Ptest'
- PHASE='-Prake -Dtask=test:jruby'
- PHASE='-Prake -Dtask=test:jruby:fullint'
- PHASE='-Prake -Dtask=test:jruby:jit'
- PHASE='-Prake -Dtask=test:mri'
- PHASE='-Prake -Dtask=test:mri:fullint'
- PHASE='-Prake -Dtask=test:mri:jit'
- PHASE='-Prake -Dtask=test:slow_suites'
- PHASE='-Prake -Dtask=test:tracing'
- PHASE='-Prake -Dtask=spec:ji'
- PHASE='-Prake -Dtask=spec:compiler'
- PHASE='-Prake -Dtask=spec:compiler' JRUBY_OPTS=-Xcompile.invokedynamic
- PHASE='-Prake -Dtask=spec:ffi'
- PHASE='-Prake -Dtask=spec:regression'
- PHASE='-Prake -Dtask=spec:ruby:fast'
- PHASE='-Prake -Dtask=spec:jruby'
- PHASE='-Prake -Dtask=spec:jrubyc'
- PHASE='-Prake -Dtask=spec:profiler'
- JT='test specs :command_line'
- JT='test specs :language'
- JT='test specs :core'
@@ -56,26 +38,6 @@ env:

matrix:
include:
# these profile do no need to run for all JDKs
- env: PHASE='-Pdist --projects !truffle'
jdk: oraclejdk8
- env: PHASE='-Pjruby-jars --projects !truffle'
jdk: openjdk7
- env: PHASE='-Pmain --projects !truffle'
jdk: oraclejdk8
- env: PHASE='-Pcomplete --projects !truffle'
jdk: oraclejdk8
- env: PHASE='-Posgi --projects !truffle'
jdk: openjdk7
- env: PHASE='-Pj2ee --projects !truffle'
jdk: oraclejdk7
# These next two started crashing on JDK7 in March 2015, possibly due to JVM issues on Travis's Docker-based env
- env: PHASE='-Pjruby-jars,test -Dinvoker.test=extended --projects !truffle'
jdk: oraclejdk8
- env: PHASE='-Pmain,test -Dinvoker.test=extended --projects !truffle'
jdk: oraclejdk8
- env: PHASE='-Pjruby_complete_jar_extended -Dinvoker.skip=true --projects !truffle'
jdk: oraclejdk8
- env: COMMAND=test/check_versions.sh
jdk: oraclejdk8
#- env: JT=check_ambiguous_arguments
58 changes: 58 additions & 0 deletions bin/jruby-cext-c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env jruby

# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
# This code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# A compiler for JRuby+Truffle C extensions

require 'yaml'

MX_DIR = ENV['MX_DIR']

unless MX_DIR
abort 'You need to set MX_DIR to a checkout of the mx repository'
end

SULONG_DIR = ENV['SULONG_DIR']

unless SULONG_DIR
abort 'You need to set SULONG_DIR to the location of a built checkout of the Sulong repository'
end

def mx(command, *args)
command = "#{MX_DIR}/mx.py -p #{SULONG_DIR} --vm server #{command} #{args.join(' ')}"
puts "$ #{command}"
`#{command}`
end

CEXT_DIR = ARGV[0]

unless CEXT_DIR
abort 'You need to pass the directory of a C extension so I can build it'
end

CONFIG_FILE = File.join(CEXT_DIR, '.jruby-cext-build.yml')

unless File.exist?(CONFIG_FILE)
abort "There is no .jruby-cext-build.yml in this C extension at the moment - I don't know how to build it"
end

CONFIG = YAML.load_file(CONFIG_FILE)

SRC = Dir[File.join(CEXT_DIR, CONFIG['src'])]
OUT = File.join(CEXT_DIR, CONFIG['out'])

LL = []

SRC.each do |src|
ll = File.join(File.dirname(src), File.basename(src, '.*') + '.ll')
mx 'su-clang', "-I#{SULONG_DIR}/include", '-Ilib/ruby/truffle/cext', '-S', '-emit-llvm', src, '-o', ll
LL.push ll
end

mx 'su-link', '-o', OUT, *LL
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
import java.util.Locale;
import java.util.regex.Pattern;

public final class RubyFiletypeDetector extends FileTypeDetector {
public final class RubyFileTypeDetector extends FileTypeDetector {

private static final String[] KNOWN_RUBY_FILES = new String[]{ "Gemfile", "Rakefile", "Mavenfile" };
private static final String[] KNOWN_RUBY_SUFFIXES = new String[]{ ".rb", ".rake", ".gemspec" };
@@ -43,6 +43,8 @@ public String probeContentType(Path path) throws IOException {
if (firstLine != null && SHEBANG_REGEXP.matcher(firstLine).matches()) {
return RUBY_MIME;
}
} catch (IOException e) {
// Reading random files as UTF-8 could cause all sorts of errors
}

return null;
2 changes: 0 additions & 2 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -235,7 +235,6 @@ public class Options {
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_PUTS = bool(TRUFFLE, "truffle.platform.safe_puts", true, "Treat Truffle::Primitive.safe_puts as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_USE_JAVA = bool(TRUFFLE, "truffle.platform.use_java", false, "Use a pure-Java platform, so no native POSIX.");

public static final Option<Boolean> TRUFFLE_COVERAGE = bool(TRUFFLE, "truffle.coverage", false, "Enable coverage (will be enabled by default in the future - currently has some bugs).");
public static final Option<Boolean> TRUFFLE_COVERAGE_GLOBAL = bool(TRUFFLE, "truffle.coverage.global", false, "Run coverage for all code and print results on exit.");

public static final Option<String> TRUFFLE_CORE_LOAD_PATH = string(TRUFFLE, "truffle.core.load_path", "truffle:/jruby-truffle", "Location to load the Truffle core library from.");
@@ -293,7 +292,6 @@ public class Options {
public static final Option<Boolean> TRUFFLE_BACKTRACES_INTERLEAVE_JAVA = bool(TRUFFLE, "truffle.backtraces.interleave_java", false, "Interleave Java stacktraces into the Ruby backtrace.");
public static final Option<Integer> TRUFFLE_BACKTRACES_LIMIT = integer(TRUFFLE, "truffle.backtraces.limit", 9999, "Limit the size of Ruby backtraces.");
public static final Option<Boolean> TRUFFLE_BACKTRACES_OMIT_UNUSED = bool(TRUFFLE, "truffle.backtraces.omit_unused", true, "Omit backtraces that should be unused as they have pure rescue expressions.");
public static final Option<Boolean> TRUFFLE_INCLUDE_CORE_FILE_CALLERS_IN_SET_TRACE_FUNC = bool(TRUFFLE, "truffle.set_trace_func.include_core_file_callers", false, "Include internal core library calls in set_trace_func output.");

public static final Option<Boolean> TRUFFLE_METRICS_TIME = bool(TRUFFLE, "truffle.metrics.time", false, "Print the time at various stages of VM operation.");
public static final Option<Boolean> TRUFFLE_METRICS_MEMORY_USED_ON_EXIT = bool(TRUFFLE, "truffle.metrics.memory_used_on_exit", false, "Print the size of heap memory in use on exit.");
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.jruby.util.RubyFiletypeDetector
org.jruby.util.RubyFileTypeDetector
32 changes: 21 additions & 11 deletions lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -26,15 +26,25 @@ extern "C" {
typedef void *ID;
typedef void *VALUE;

extern VALUE Qfalse;
extern VALUE Qtrue;
extern VALUE Qnil;
VALUE get_Qfalse();
VALUE get_Qtrue();
VALUE get_Qnil();

extern VALUE rb_cObject;
extern VALUE rb_cArray;
extern VALUE rb_cHash;
#define Qfalse get_Qfalse()
#define Qtrue get_Qtrue()
#define Qnil get_Qnil()

extern VALUE rb_eRuntimeError;
VALUE get_rb_cObject();
VALUE get_rb_cArray();
VALUE get_rb_cHash();

#define rb_cObject get_rb_cObject()
#define rb_cArray get_rb_cArray()
#define rb_cHash get_rb_cHash()

VALUE get_rb_eRuntimeError();

#define rb_eRuntimeError get_rb_eRuntimeError();

int NUM2INT(VALUE value);
unsigned int NUM2UINT(VALUE value);
@@ -53,14 +63,14 @@ VALUE LONG2FIX(long value);

int FIXNUM_P(VALUE value);

char* RSTRING_PTR(VALUE string);
char *RSTRING_PTR(VALUE string);
int RSTRING_LEN(VALUE string);
ID rb_intern(const char *string);
VALUE rb_intern_str(VALUE string);
void rb_str_cat(VALUE string, char *to_concat, long length);

int RARRAY_LEN(VALUE array);
VALUE* RARRAY_PTR(VALUE array);
VALUE *RARRAY_PTR(VALUE array);
VALUE rb_ary_new_capa(long capacity);
VALUE rb_ary_new2();
VALUE rb_ary_new();
@@ -71,9 +81,9 @@ VALUE rb_ary_entry(VALUE array, long index);
VALUE rb_hash_aref(VALUE hash, VALUE key);
void rb_hash_aset(VALUE hash, VALUE key, VALUE value);

void rb_scan_args(int, VALUE*, char *, ...);
void rb_scan_args(int argc, VALUE *argv, char *format, ...);

VALUE rb_funcall(VALUE object, ID, int, ...);
VALUE rb_funcall(VALUE object, ID name, int argc, ...);

VALUE rb_iv_get(VALUE object, const char *name);
VALUE rb_iv_set(VALUE object, const char *name, VALUE value);
19 changes: 0 additions & 19 deletions spec/truffle/specs/truffle/primitive/coverage_result_spec.rb

This file was deleted.

19 changes: 0 additions & 19 deletions spec/truffle/specs/truffle/primitive/coverage_start_spec.rb

This file was deleted.

2 changes: 2 additions & 0 deletions spec/truffle/tags/truffle/attachments/attach_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Truffle::Attachments.attach only runs the block once each time the line is executed
fails:Truffle::Attachments.attach allows multiple blocks to be installed on the same line and runs both of them
2 changes: 1 addition & 1 deletion spec/truffle/truffle.mspec
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ class MSpecScript
set :target, File.expand_path("../../../bin/jruby#{windows? ? '.bat' : ''}", __FILE__)

if ARGV[-2..-1] != %w[-t ruby] # No flags for MRI
set :flags, %w[-X+T -J-ea -J-esa -J-Xmx2G -Xtruffle.coverage=true]
set :flags, %w[-X+T -J-ea -J-esa -J-Xmx2G]
end

set :command_line, [
2 changes: 2 additions & 0 deletions test/truffle/cexts/minimum/.jruby-cext-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src: ext/minimum/*.c
out: lib/minimum/minimum.su
3 changes: 3 additions & 0 deletions test/truffle/cexts/minimum/bin/minimum
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby

require 'minimum'
5 changes: 5 additions & 0 deletions test/truffle/cexts/minimum/ext/minimum/minimum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>

void Init_minimum() {
printf("Hello!\n");
}
1 change: 1 addition & 0 deletions test/truffle/cexts/minimum/lib/minimum.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'minimum/minimum'
Empty file.
Original file line number Diff line number Diff line change
@@ -18,19 +18,19 @@ def foo
begin
loop do
x = foo
raise "value not correct" unless x == 200
raise 'value not correct' unless x == 200
Truffle::Primitive.assert_constant x
Truffle::Primitive.assert_not_compiled
end
rescue RubyTruffleError => e
if e.message.include? 'Truffle::Primitive.assert_not_compiled'
puts "attachments optimising"
puts 'attachments optimising'
exit 0
elsif e.message.include? 'Truffle::Primitive.assert_constant'
puts "attachments not optimising"
puts 'attachments not optimising'
exit 1
else
puts "some other error"
puts 'some other error'
exit 1
end
end
3 changes: 3 additions & 0 deletions test/truffle/compiler/stf-optimises.sh_excluded
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruby -X+T -J-G:+TruffleCompilationExceptionsAreFatal test/truffle/compiler/stf-optimises/stf-optimises.rb
40 changes: 40 additions & 0 deletions test/truffle/compiler/stf-optimises/stf-optimises.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

def foo
foo = 14
foo * 2
end

set_trace_func proc { |event, file, line, id, binding, classname|
if event == 'line' && file == __FILE__ && line == 11
binding.local_variable_set(:foo, 100)
end
}

begin
loop do
x = foo
raise 'value not correct' unless x == 200
Truffle::Primitive.assert_constant x
Truffle::Primitive.assert_not_compiled
end
rescue RubyTruffleError => e
if e.message.include? 'Truffle::Primitive.assert_not_compiled'
puts 'STF optimising'
exit 0
elsif e.message.include? 'Truffle::Primitive.assert_constant'
puts 'STF not optimising'
exit 1
else
puts 'some other error'
exit 1
end
end

exit 1
3 changes: 3 additions & 0 deletions test/truffle/compiler/tp-optimises.sh_excluded
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruby -X+T -J-G:+TruffleCompilationExceptionsAreFatal test/truffle/compiler/tp-optimises/tp-optimises.rb
40 changes: 40 additions & 0 deletions test/truffle/compiler/tp-optimises/tp-optimises.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

def foo
foo = 14
foo * 2
end

tp = TracePoint.new(:line) do |tp|
tp.binding.local_variable_set(:foo, 100)
end

tp.enable

begin
loop do
x = foo
raise 'value not correct' unless x == 200
Truffle::Primitive.assert_constant x
Truffle::Primitive.assert_not_compiled
end
rescue RubyTruffleError => e
if e.message.include? 'Truffle::Primitive.assert_not_compiled'
puts 'TP optimising'
exit 0
elsif e.message.include? 'Truffle::Primitive.assert_constant'
puts 'TP not optimising'
exit 1
else
puts 'some other error'
exit 1
end
end

exit 1
3 changes: 0 additions & 3 deletions test/truffle/integration/coverage.sh

This file was deleted.

3 changes: 3 additions & 0 deletions test/truffle/integration/coverage.sh_excluded
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruby -X+T test/truffle/integration/coverage/test.rb
Loading

0 comments on commit adde194

Please sign in to comment.