Skip to content

Commit

Permalink
Showing 16 changed files with 97 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public String getLabel() {
private boolean explicitCallProtocolSupported(IRScope scope) {
return scope instanceof IRMethod
// SSS: Turning this off till this is fully debugged
// || (scope instanceof IRClosure && !(scope instanceof IREvalScript))
|| (scope instanceof IRClosure && !(scope instanceof IREvalScript))
|| (scope instanceof IRModuleBody && !(scope instanceof IRMetaClassBody));
}

Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ public InterpreterContext ensureInstrsReady() {

if (interpreterContext == null) {
interpreterContext = closure.getInterpreterContext();
hasCallProtocolIR = closure.getFlags().contains(IRFlags.HAS_EXPLICIT_CALL_PROTOCOL);
hasCallProtocolIR = false;
}
return interpreterContext;
}
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ public InterpreterContext ensureInstrsReady() {

if (interpreterContext == null) {
interpreterContext = closure.getInterpreterContext();
hasCallProtocolIR = closure.getFlags().contains(IRFlags.HAS_EXPLICIT_CALL_PROTOCOL);
hasCallProtocolIR = false;
}
return interpreterContext;
}
17 changes: 17 additions & 0 deletions lib/ruby/truffle/jruby+truffle/README.md
Original file line number Diff line number Diff line change
@@ -92,6 +92,23 @@ activesupport's configuration file follows:
- shims
```
## Using the tool in CI
Assuming there are similar stored commands for a given gem:
```yaml
:stored_commands:
:ci:
- :setup
- :test
:setup:
- "git clone git@github.com:lucasocon/openweather.git"
- "jruby+truffle --dir openweather setup"
:test: "jruby+truffle --dir openweather run --require-pattern 'test/*_test.rb' -I test -- -e nil"
```
then `jruby+truffle --config openweather stored ci` can be used to run tests of the given gem in CI.

## Example step-by-step

```sh
Original file line number Diff line number Diff line change
@@ -81,8 +81,11 @@
- pathname
:stored_commands:
:ci:
- "jruby+truffle setup"
- :setup
- :test
:test: "jruby+truffle run --exclude-pattern 'jdom_engine' --require-pattern 'test/**/**/*_test.rb' -r exclude_tests -- -I test -e 'nil'"
:setup:
- "git clone -b 4-2-stable git@github.com:rails/rails.git"
- "jruby+truffle --dir rails/activesupport setup"
:test: "jruby+truffle --dir rails/activesupport run --exclude-pattern 'jdom_engine' --require-pattern 'test/**/**/*_test.rb' -r exclude_tests -- -I test -e 'nil'"


12 changes: 12 additions & 0 deletions lib/ruby/truffle/jruby+truffle/gem_configurations/openweather.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:setup:
:file:
"bundler/gem_tasks.rb": nil
:stored_commands:
:ci:
- :setup
- :test
:setup:
- "git clone git@github.com:lucasocon/openweather.git"
- "jruby+truffle --dir openweather setup"
:test: "jruby+truffle --dir openweather run --require-pattern 'test/*_test.rb' -I test -- -e nil"

41 changes: 24 additions & 17 deletions lib/ruby/truffle/jruby+truffle/runner.rb
Original file line number Diff line number Diff line change
@@ -57,9 +57,11 @@ class JRubyTruffleRunner
mock_load_path: ['--mock-load-path PATH',
'Path of mocks & monkey-patches (prepended in $:, relative to --truffle_bundle_path)',
assign_new_value, 'mocks'],
use_fs_core: ['--[no-]use-fs-core', 'use core from the filesystem rather than the JAR',
use_fs_core: ['--[no-]use-fs-core', 'Use core from the filesystem rather than the JAR',
assign_new_value, true],
bundle_cmd: ['--bundle-cmd CMD', 'command to run for bundle', assign_new_value, 'bundle']
bundle_cmd: ['--bundle-cmd CMD', 'Command to run for bundle', assign_new_value, 'bundle'],
configuration: ['--config GEM_NAME', 'Load configuration for specified gem', assign_new_value, nil],
dir: ['--dir DIRECTORY', 'Set working directory', assign_new_value, Dir.pwd],
},
setup: {
help: ['-h', '--help', 'Show this message', assign_new_value, false],
@@ -170,27 +172,32 @@ class JRubyTruffleRunner

def initialize(argv = ARGV)
construct_default_options
load_gem_configuration
load_local_configuration
build_option_parsers

subcommand, *argv_after_global = @option_parsers[:global].order argv

if subcommand.nil?
print_options
help :global
end
help :global if @options[:global][:help]
Dir.chdir @options[:global][:dir] do
puts "pwd: #{Dir.pwd}" if verbose?

subcommand = subcommand.to_sym
load_gem_configuration
load_local_configuration

if subcommand.nil?
print_options
help :global
end
help :global if @options[:global][:help]

subcommand_option_parser = @option_parsers[subcommand] || raise("unknown subcommand: #{subcommand}")
argv_after_subcommand = subcommand_option_parser.order argv_after_global
subcommand = subcommand.to_sym

print_options
help subcommand if @options[subcommand][:help] && subcommand != :readme
subcommand_option_parser = @option_parsers[subcommand] || raise("unknown subcommand: #{subcommand}")
argv_after_subcommand = subcommand_option_parser.order argv_after_global

send "subcommand_#{subcommand}", argv_after_subcommand
print_options
help subcommand if @options[subcommand][:help] && subcommand != :readme

send "subcommand_#{subcommand}", argv_after_subcommand
end
end

def print_options
@@ -224,12 +231,11 @@ def build_option_parsers
end

def load_gem_configuration
candidates = Dir['*.gemspec'] # TODO pwd?
candidates = @options[:global][:configuration] ? [@options[:global][:configuration]] : Dir['*.gemspec']

if candidates.size == 1
gem_name, _ = candidates.first.split('.')
yaml_path = File.dirname(__FILE__) + "/gem_configurations/#{gem_name}.yaml"
File.exist? yaml_path
end

apply_yaml_to_configuration(yaml_path)
@@ -325,6 +331,7 @@ def subcommand_setup(rest)

@options[:setup][:file].each do |name, content|
puts "creating file: #{mock_path}/#{name}" if verbose?
FileUtils.mkpath File.dirname("#{mock_path}/#{name}")
File.write "#{mock_path}/#{name}", content
end

1 change: 1 addition & 0 deletions test/mri/excludes_truffle/TestFloat.rb
Original file line number Diff line number Diff line change
@@ -14,3 +14,4 @@
exclude :test_strtod, "needs investigation"
exclude :test_to_s, "needs investigation"
exclude :test_truncate, "needs investigation"
exclude :test_hash_0, "-0.0.hash is not == 0.0.hash currently"
2 changes: 2 additions & 0 deletions test/mri/excludes_truffle/TestMethod.rb
Original file line number Diff line number Diff line change
@@ -41,3 +41,5 @@
exclude :test_unlinked_method_entry_in_method_object_bug, "needs investigation"
exclude :test_visibility, "needs investigation"
exclude :test_caller_top_level, "needs investigation"
exclude :test_insecure_method, "needs investigation"
exclude :test_to_proc_binding, "needs investigation"
1 change: 1 addition & 0 deletions test/mri/excludes_truffle/TestRange.rb
Original file line number Diff line number Diff line change
@@ -15,3 +15,4 @@
exclude :test_range_bsearch_for_floats, "needs investigation"
exclude :test_range_numeric_string, "needs investigation"
exclude :test_size, "needs investigation"
exclude :test_eqq_time, "needs investigation"
2 changes: 2 additions & 0 deletions test/mri/excludes_truffle/TestSymbol.rb
Original file line number Diff line number Diff line change
@@ -4,3 +4,5 @@
exclude :test_symbol_encoding, "needs investigation"
exclude :test_symbol_gc_1, "needs investigation"
exclude :test_to_proc, "needs investigation"
exclude :test_hash_redefinition, "hangs"
exclude :test_symbol_fstr_leak, "hangs"
6 changes: 6 additions & 0 deletions test/mri/excludes_truffle/TestSyntax.rb
Original file line number Diff line number Diff line change
@@ -51,3 +51,9 @@
exclude :test_brace_block_after_blockcall_colon_with_arg, "needs investigation"
exclude :test_newline_in_block_parameters, "needs investigation"
exclude :test_warn_unreachable, "needs investigation"
exclude :test_bad_kwarg, "needs investigation"
exclude :test_do_block_in_lambda, "needs investigation"
exclude :test_keyword_self_reference, "needs investigation"
exclude :test_keyword_empty_splat, "needs investigation"
exclude :test_null_range_cmdarg, "needs investigation"
exclude :test_too_big_nth_ref, "needs investigation"
9 changes: 9 additions & 0 deletions test/mri/excludes_truffle/TestTimeExtension.rb
Original file line number Diff line number Diff line change
@@ -24,3 +24,12 @@
exclude :test_xmlschema_fraction, "needs investigation"
exclude :test_xmlschema_leap_second, "needs investigation"
exclude :test_zone_0000, "needs investigation"
exclude :test_iso8601, "needs investigation"
exclude :test_iso8601_alias, "needs investigation"
exclude :test_iso8601_encode, "needs investigation"
exclude :test_iso8601_nsec, "needs investigation"
exclude :test_strptime_s_N, "needs investigation"
exclude :test_xmlschema_alias, "needs investigation"
exclude :test_xmlschema_encode, "needs investigation"
exclude :test_xmlschema_nsec, "needs investigation"
exclude :test_iso8601_leap_second, "needs investigation"
9 changes: 9 additions & 0 deletions tool/jruby_eclipse
Original file line number Diff line number Diff line change
@@ -4,9 +4,12 @@

TRUFFLEJAR = "#{Dir.home}/.m2/repository/com/oracle/truffle/0.7/truffle-0.7.jar"
SNAKEYAMLJAR = "#{Dir.home}/.m2/repository/org/yaml/snakeyaml/1.14/snakeyaml-1.14.jar"
ANTLR4JAR = "#{Dir.home}/.m2/repository/org/antlr/antlr4-runtime/4.5/antlr4-runtime-4.5.jar"

JRUBY = File.expand_path('../..', __FILE__)

VERIFY_JRUBY = false

java = ENV["JAVACMD"] || "java"

java_flags = []
@@ -33,10 +36,16 @@ classpath << "#{JRUBY}/lib/jruby-stdlib-9.0.0.0-SNAPSHOT.jar"
if rest.include?('-X+T')
bootclasspath << TRUFFLEJAR
classpath << SNAKEYAMLJAR
classpath << ANTLR4JAR
classpath << "#{JRUBY}/truffle/build.eclipse"
java_flags << "-Djruby.truffle.core.load_path=#{JRUBY}/truffle/src/main/ruby"
end

unless VERIFY_JRUBY
bootclasspath += classpath
classpath.clear
end

args = [java]
args << "-Djffi.boot.library.path=#{JRUBY}/lib/jni"
args << "-Xbootclasspath/a:" + bootclasspath.join(':')
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ DynamicObjectFactory createThreadShape(DynamicObject logicalClass,

DynamicObject createThread(DynamicObjectFactory factory,
DynamicObject threadLocals,
InterruptMode interruptMode,
@Volatile InterruptMode interruptMode, // needs to be volatile for fibers implemented by threads
@Volatile RubyThread.Status status,
List<Lock> ownedLocks,
@Nullable FiberManager fiberManager,
Original file line number Diff line number Diff line change
@@ -83,10 +83,13 @@ private void poll(Node currentNode, boolean fromBlockingCall) {
@TruffleBoundary
private void assumptionInvalidated(Node currentNode, boolean fromBlockingCall) {
final DynamicObject thread = context.getThreadManager().getCurrentThread();
final boolean interruptible = (Layouts.THREAD.getInterruptMode(thread) == InterruptMode.IMMEDIATE) ||
(fromBlockingCall && Layouts.THREAD.getInterruptMode(thread) == InterruptMode.ON_BLOCKING);
final InterruptMode interruptMode = Layouts.THREAD.getInterruptMode(thread);

final boolean interruptible = (interruptMode == InterruptMode.IMMEDIATE) ||
(fromBlockingCall && interruptMode == InterruptMode.ON_BLOCKING);

if (!interruptible) {
Thread.currentThread().interrupt(); // keep the interrupt flag
return; // interrupt me later
}

0 comments on commit 4c8121f

Please sign in to comment.