Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 793d175bf266
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ef346375b8cf
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 15, 2015

  1. Copy the full SHA
    8e481f6 View commit details
  2. Copy the full SHA
    ef34637 View commit details
Showing with 31 additions and 15 deletions.
  1. +12 −11 tool/truffle/jruby_truffle_runner/lib/jruby+truffle_runner.rb
  2. +19 −4 truffle/src/main/ruby/core/thread.rb
23 changes: 12 additions & 11 deletions tool/truffle/jruby_truffle_runner/lib/jruby+truffle_runner.rb
Original file line number Diff line number Diff line change
@@ -25,6 +25,13 @@ class JRubyTruffleRunner
assign_new_value = -> (new, old) { new }
add_to_array = -> (new, old) { old << new }
merge_hash = -> ((k, v), old) { old.merge k => v }
apply_pattern = -> (pattern, old) do
Dir.glob(pattern) do |file|
next if @options[:run][:exclude_pattern].any? { |p| /#{p}/ =~ file }
@options[:run][:require] << File.expand_path(file)
end
old
end

# Format:
# subcommand_name: {
@@ -60,8 +67,8 @@ class JRubyTruffleRunner
rebuild: ['--rebuild', 'Run `jt rebuild` in JRuby', assign_new_value, false],
debug: ['-d', '--debug', 'JVM remote debugging', assign_new_value, false],
require: ['-r', '--require FILE', 'Files to require, same as Ruby\'s -r', add_to_array, []],
require_pattern: ['--require-pattern DIR_GLOB_PATTERN', 'Files matching the pattern will be required', add_to_array, []],
exclude_pattern: ['--exclude-pattern REGEXP', 'Files matching the regexp will not be required by --require-pattern', add_to_array, []],
require_pattern: ['--require-pattern DIR_GLOB_PATTERN', 'Files matching the pattern will be required', apply_pattern, nil],
exclude_pattern: ['--exclude-pattern REGEXP', 'Files matching the regexp will not be required by --require-pattern (applies to subsequent --require-pattern options)', add_to_array, []],
load_path: ['-I', '--load-path LOAD_PATH', 'Paths to add to load path, same as Ruby\'s -I', add_to_array, []],
executable: ['-S', '--executable NAME', 'finds and runs an executable of a gem', assign_new_value, nil],
jexception: ['--jexception', 'print Java exceptions', assign_new_value, false]
@@ -129,7 +136,7 @@ def initialize(argv = ARGV)
build_option_parsers

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

if subcommand.nil?
print_options
@@ -169,7 +176,7 @@ def build_option_parsers

option_parser.on(*args, description + " (default: #{default.inspect})") do |new_value|
old_value = @options[group][option]
@options[group][option] = block.call new_value, old_value
@options[group][option] = instance_exec new_value, old_value, &block
end
end
end
@@ -179,7 +186,7 @@ def build_option_parsers
end

def collect_vm_options(argv)
vm_options = []
vm_options = []
other_options = argv.reject do |arg|
vm = arg.start_with? '-J'
vm_options.push arg if vm
@@ -315,12 +322,6 @@ def subcommand_run(vm_options, rest)
end

core_load_path = "#{jruby_path}/truffle/src/main/ruby"
@options[:run][:require_pattern].each do |pattern|
Dir.glob(pattern) do |file|
next if @options[:run][:exclude_pattern].any? { |p| /#{p}/ =~ file }
@options[:run][:require] << File.expand_path(file)
end
end

cmd_options = [
*(['-X+T', *vm_options, "-Xtruffle.core.load_path=#{core_load_path}"] unless @options[:run][:test]),
23 changes: 19 additions & 4 deletions truffle/src/main/ruby/core/thread.rb
Original file line number Diff line number Diff line change
@@ -9,22 +9,32 @@
class Thread

def [](symbol)
__thread_local_variables[symbol]
__thread_local_variables[symbol.to_sym]
end

def []=(symbol, value)
__thread_local_variables[symbol] = value
__thread_local_variables[symbol.to_sym] = value
end

def thread_variable?(symbol)
__thread_local_variables.has_key? symbol
__thread_local_variables.has_key? symbol.to_sym
end

alias_method :thread_variable_get, :[]
alias_method :thread_variable_set, :[]=

LOCK = Mutex.new

def __thread_local_variables
@__thread_local_variables ||= {}
if defined?(@__thread_local_variables)
@__thread_local_variables
else
LOCK.synchronize { @__thread_local_variables ||= {} }
end
end

def thread_variables
__thread_local_variables.keys
end

def self.start(&block)
@@ -49,6 +59,11 @@ def self.handle_interrupt(config, &block)
end
end

def freeze
__thread_local_variables.freeze
super
end

end

class ThreadGroup