Skip to content

Commit

Permalink
Showing 191 changed files with 1,456 additions and 1,193 deletions.
Original file line number Diff line number Diff line change
@@ -275,6 +275,7 @@ public Instr decodeInstr() {
case RESCUE_EQQ: return RescueEQQInstr.decode(this);
case RESTORE_ERROR_INFO: return RestoreErrorInfoInstr.decode(this);
case RETURN: return ReturnInstr.decode(this);
case RETURN_OR_RETHROW_SAVED_EXC: return ReturnOrRethrowSavedExcInstr.decode(this);
case RUNTIME_HELPER: return RuntimeHelperCall.decode(this);
case SEARCH_CONST: return SearchConstInstr.decode(this);
case SET_CAPTURED_VAR: return SetCapturedVarInstr.decode(this);
18 changes: 8 additions & 10 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -200,7 +200,7 @@ public static IRubyObject handleBreakAndReturnsInLambdas(ThreadContext context,
return ((IRWrappedLambdaReturnValue)exc).returnValue;
} else if ((exc instanceof IRBreakJump) && inNonMethodBodyLambda(scope, blockType)) {
// We just unwound all the way up because of a non-local break
context.setSavedExceptionInLambda(IRException.BREAK_LocalJumpError.getException(context.getRuntime()));
context.setSavedExceptionInLambda(IRException.BREAK_LocalJumpError.getException(context.runtime));
return null;
} else if (exc instanceof IRReturnJump && (blockType == null || inLambda(blockType))) {
try {
@@ -247,7 +247,7 @@ public static IRubyObject handlePropagatedBreak(ThreadContext context, DynamicSc
IRScopeType scopeType = scope.getScopeType();
if (!scopeType.isClosureType()) {
// Error -- breaks can only be initiated in closures
throw IRException.BREAK_LocalJumpError.getException(context.getRuntime());
throw IRException.BREAK_LocalJumpError.getException(context.runtime);
} else {
bj.breakInEval = false;
throw bj;
@@ -311,7 +311,7 @@ public static IRubyObject undefMethod(ThreadContext context, Object nameArg, Dyn

module.undef(context, name);

return context.runtime.getNil();
return context.nil;
}

public static double unboxFloat(IRubyObject val) {
@@ -702,7 +702,7 @@ protected static void checkSuperDisabledOrOutOfMethod(ThreadContext context, Rub
if (methodName == null || !methodName.equals("")) {
throw context.runtime.newNameError("superclass method '" + methodName + "' disabled", methodName);
} else {
throw context.runtime.newNoMethodError("super called outside of method", null, context.runtime.getNil());
throw context.runtime.newNoMethodError("super called outside of method", null, context.nil);
}
}
}
@@ -904,7 +904,7 @@ public static IRubyObject receiveKeywordArg(ThreadContext context, IRubyObject[]

if (keywordArguments == null) return UndefinedValue.UNDEFINED;

RubySymbol keywordName = context.getRuntime().newSymbol(argName);
RubySymbol keywordName = context.runtime.newSymbol(argName);

if (keywordArguments.fastARef(keywordName) == null) return UndefinedValue.UNDEFINED;

@@ -916,7 +916,7 @@ public static IRubyObject receiveKeywordArg(ThreadContext context, IRubyObject[]
public static IRubyObject receiveKeywordRestArg(ThreadContext context, IRubyObject[] args, int required, boolean keywordArgumentSupplied) {
RubyHash keywordArguments = extractKwargsHash(args, required, keywordArgumentSupplied);

return keywordArguments == null ? RubyHash.newSmallHash(context.getRuntime()) : keywordArguments;
return keywordArguments == null ? RubyHash.newSmallHash(context.runtime) : keywordArguments;
}

public static IRubyObject setCapturedVar(ThreadContext context, IRubyObject matchRes, String varName) {
@@ -1114,8 +1114,7 @@ public static RubyHash dupKwargsHashAndPopulateFromArray(ThreadContext context,

@JIT
public static IRubyObject searchConst(ThreadContext context, StaticScope staticScope, String constName, boolean noPrivateConsts) {
Ruby runtime = context.getRuntime();
RubyModule object = runtime.getObject();
RubyModule object = context.runtime.getObject();
IRubyObject constant = (staticScope == null) ? object.getConstant(constName) : staticScope.getConstantInner(constName);

// Inheritance lookup
@@ -1136,12 +1135,11 @@ public static IRubyObject searchConst(ThreadContext context, StaticScope staticS

@JIT
public static IRubyObject inheritedSearchConst(ThreadContext context, IRubyObject cmVal, String constName, boolean noPrivateConsts) {
Ruby runtime = context.runtime;
RubyModule module;
if (cmVal instanceof RubyModule) {
module = (RubyModule) cmVal;
} else {
throw runtime.newTypeError(cmVal + " is not a type/class");
throw context.runtime.newTypeError(cmVal + " is not a type/class");
}

IRubyObject constant = noPrivateConsts ? module.getConstantFromNoConstMissing(constName, false) : module.getConstantNoConstMissing(constName);
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -246,6 +246,7 @@ public class Options {
public static final Option<Integer> TRUFFLE_PACK_CACHE = integer(TRUFFLE, "truffle.pack.cache", TRUFFLE_DEFAULT_CACHE.load(), "Array#pack cache size");
public static final Option<Integer> TRUFFLE_UNPACK_CACHE = integer(TRUFFLE, "truffle.unpack.cache", TRUFFLE_DEFAULT_CACHE.load(), "String#unpack cache size");
public static final Option<Integer> TRUFFLE_EVAL_CACHE = integer(TRUFFLE, "truffle.eval.cache", TRUFFLE_DEFAULT_CACHE.load(), "eval lookup cache size");
public static final Option<Integer> TRUFFLE_CLASS_CACHE = integer(TRUFFLE, "truffle.class.cache", TRUFFLE_DEFAULT_CACHE.load(), ".class and .metaclass cache size");
public static final Option<Integer> TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE = integer(TRUFFLE, "truffle.encoding_compatible_query.cache", TRUFFLE_DEFAULT_CACHE.load(), "Encoding.compatible? cache size");

public static final Option<Boolean> TRUFFLE_CLONE_DEFAULT = bool(TRUFFLE, "truffle.clone.default", true, "Default option for cloning.");
2 changes: 1 addition & 1 deletion test/truffle/integration/backtraces/backtraces.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ def check(file)
expected = nil

File.open('test/truffle/integration/backtraces/' + file) do |f|
expected = f.lines.map(&:strip)
expected = f.each_line.map(&:strip)
end

begin
4 changes: 2 additions & 2 deletions test/truffle/integration/backtraces/eval.rb
Original file line number Diff line number Diff line change
@@ -6,10 +6,10 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

require_relative 'backtraces'

# TODO CS 3-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'backtraces'

def m1
eval 'm2'
end
4 changes: 2 additions & 2 deletions test/truffle/integration/backtraces/send.rb
Original file line number Diff line number Diff line change
@@ -6,10 +6,10 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

require_relative 'backtraces'

# TODO CS 3-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'backtraces'

def m1
send :m2
end
9 changes: 9 additions & 0 deletions test/truffle/integration/tracing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

for f in test/truffle/integration/tracing/*.rb
do
echo $f
ruby -X+T $f
done
34 changes: 34 additions & 0 deletions test/truffle/integration/tracing/binding.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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

# TODO CS 19-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'tracing'

def add(a)
a + yield
end

outside_trace = 1
captured_in_scope = 2
modified = 3

set_trace_func $trace_proc

inside_trace = 4
modified = 5

result = add(14) {
captured_in_scope
}

result

set_trace_func nil

check('binding.trace')
11 changes: 11 additions & 0 deletions test/truffle/integration/tracing/binding.trace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
["line", "/binding.rb", 23, nil, {:captured_in_scope=>2, :inside_trace=>nil, :modified=>3, :outside_trace=>1, :result=>nil}, nil]
["line", "/binding.rb", 24, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>3, :outside_trace=>1, :result=>nil}, nil]
["line", "/binding.rb", 26, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>nil}, nil]
["call", "/binding.rb", 26, :add, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>nil}, Object]
["line", "/binding.rb", 14, nil, {:a=>14}, nil]
["call", "/binding.rb", 14, :"<main>", {:a=>14}, Object]
["line", "/binding.rb", 27, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>16}, nil]
["call", "/binding.rb", 14, :+, {:a=>14}, Fixnum]
["line", "/binding.rb", 30, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>16}, nil]
["line", "/binding.rb", 32, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>16}, nil]
["call", "/binding.rb", 32, :set_trace_func, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>16}, Object]
27 changes: 27 additions & 0 deletions test/truffle/integration/tracing/modules.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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

# TODO CS 19-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'tracing'

def add(a, b)
a + b
end

set_trace_func $trace_proc

module Foo
end

class Bar
end

set_trace_func nil

check('modules.trace')
9 changes: 9 additions & 0 deletions test/truffle/integration/tracing/modules.trace
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
["class", "/modules.rb", 19, nil, {}, nil]
["line", "/modules.rb", 19, nil, {}, nil]
["call", "/modules.rb", 19, :Foo, {}, Module]
["class", "/modules.rb", 22, nil, {}, nil]
["line", "/modules.rb", 22, nil, {}, nil]
["call", "/modules.rb", 22, :inherited, {}, Class]
["call", "/modules.rb", 22, :Bar, {}, Class]
["line", "/modules.rb", 25, nil, {}, nil]
["call", "/modules.rb", 25, :set_trace_func, {}, Object]
23 changes: 23 additions & 0 deletions test/truffle/integration/tracing/simple.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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

# TODO CS 19-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'tracing'

def add(a, b)
a + b
end

set_trace_func $trace_proc

add(14, 2)

set_trace_func nil

check('simple.trace')
6 changes: 6 additions & 0 deletions test/truffle/integration/tracing/simple.trace
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
["line", "/simple.rb", 19, nil, {}, nil]
["call", "/simple.rb", 19, :add, {}, Object]
["line", "/simple.rb", 14, nil, {:a=>14, :b=>2}, nil]
["call", "/simple.rb", 14, :+, {:a=>14, :b=>2}, Fixnum]
["line", "/simple.rb", 21, nil, {}, nil]
["call", "/simple.rb", 21, :set_trace_func, {}, Object]
82 changes: 82 additions & 0 deletions test/truffle/integration/tracing/tracing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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

$trace = []

$trace_proc = proc { |*args|
args[4] = args[4].dup
$trace << args
}

class MockBinding

def local_variables
[]
end

end

def check(file)
expected = nil

File.open('test/truffle/integration/tracing/' + file) do |f|
expected = f.each_line.map { |line| eval(line) }
end

actual = $trace

empty_binding = MockBinding.new

while actual.size < expected.size
actual.push ['missing', 'missing', :missing, :missing, empty_binding, :missing]
end

while expected.size < actual.size
expected.push ['missing', 'missing', :missing, :missing, empty_binding, :missing]
end

success = true

expected.zip(actual).each do |e, a|
unless a[0] == e[0]
puts "Expected #{e[0].inspect}, actually #{a[0].inspect}"
success = false
end

unless a[1].end_with?(e[1])
puts "Expected #{e[1].inspect}, actually #{a[1].inspect}"
success = false
end

unless a[2] == e[2]
puts "Expected #{e[2].inspect}, actually #{a[2].inspect}"
success = false
end

unless a[3] == e[3]
puts "Expected #{e[3].inspect}, actually #{a[3].inspect}"
success = false
end

ab = Hash[a[4].local_variables.sort.map { |v| [v, a[4].local_variable_get(v)] }]

unless ab == e[4]
puts "Expected Binding, actually #{ab.inspect}"
success = false
end

unless a[5] == e[5]
puts "Expected #{e[5].inspect}, actually #{a[5].inspect}"
success = false
end
end

unless success
exit 1
end
end
6 changes: 5 additions & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -161,7 +161,11 @@ def raw_sh(*args)
false
else
$stderr.puts "FAILED (#{$?}): #{printable_cmd(args)}"
exit $?.exitstatus
if $?
exit $?.exitstatus
else
exit 1
end
end
end
end
Loading

0 comments on commit 461172d

Please sign in to comment.