Skip to content

Commit

Permalink
Showing 300 changed files with 3,283 additions and 3,661 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ release.properties
share
spaces test
target
test/pom.xml
test/prawn
test/rails
test/testapp/testapp
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -2271,7 +2271,7 @@ public Operand buildEnsureInternal(Node ensureBodyNode, Node ensurerNode) {

// Emit code to conditionally restore $!
Variable ret = createTemporaryVariable();
addInstr(new RuntimeHelperCall(ret, RESTORE_PERLY_EXC, new Operand[]{exc, savedGlobalException} ));
addInstr(new RuntimeHelperCall(ret, RESTORE_EXCEPTION_VAR, new Operand[]{exc, savedGlobalException} ));

// Now emit the ensure body's stashed instructions
if (ensurerNode != null) {
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ public enum Methods {
HANDLE_PROPAGATE_BREAK, HANDLE_NONLOCAL_RETURN, HANDLE_BREAK_AND_RETURNS_IN_LAMBDA,
IS_DEFINED_BACKREF, IS_DEFINED_NTH_REF, IS_DEFINED_GLOBAL, IS_DEFINED_INSTANCE_VAR,
IS_DEFINED_CLASS_VAR, IS_DEFINED_SUPER, IS_DEFINED_METHOD, IS_DEFINED_CALL,
IS_DEFINED_CONSTANT_OR_METHOD, MERGE_KWARGS, RESTORE_PERLY_EXC;
IS_DEFINED_CONSTANT_OR_METHOD, MERGE_KWARGS, RESTORE_EXCEPTION_VAR;

public static Methods fromOrdinal(int value) {
return value < 0 || value >= values().length ? null : values()[value];
@@ -128,7 +128,7 @@ public IRubyObject callHelper(ThreadContext context, StaticScope currScope, Dyna
case MERGE_KWARGS:
return IRRuntimeHelpers.mergeKeywordArguments(context, (IRubyObject) arg1,
(IRubyObject) getArgs()[1].retrieve(context, self, currScope, currDynScope, temp));
case RESTORE_PERLY_EXC:
case RESTORE_EXCEPTION_VAR:
Object exc = getArgs()[0].retrieve(context, self, currScope, currDynScope, temp);
// SSS FIXME: These are non-local control-flow exit scenarios that just
// happen to use exceptions for exiting scopes and we should
Original file line number Diff line number Diff line change
@@ -727,7 +727,7 @@ public static IRubyObject mergeKeywordArguments(ThreadContext context, IRubyObje
}

@JIT
public static IRubyObject restorePerlyExc(ThreadContext context, IRubyObject exc, IRubyObject savedExc) {
public static IRubyObject restoreExceptionVar(ThreadContext context, IRubyObject exc, IRubyObject savedExc) {
if (exc instanceof IRReturnJump || exc instanceof IRBreakJump) {
context.runtime.getGlobalVariables().set("$!", savedExc);
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -1700,11 +1700,11 @@ public void RuntimeHelperCall(RuntimeHelperCall runtimehelpercall) {
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "mergeKeywordArguments", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class));
jvmStoreLocal(runtimehelpercall.getResult());
break;
case RESTORE_PERLY_EXC:
case RESTORE_EXCEPTION_VAR:
jvmMethod().loadContext();
visit(runtimehelpercall.getArgs()[0]);
visit(runtimehelpercall.getArgs()[1]);
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "restorePerlyExc", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class));
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "restoreExceptionVar", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class));
jvmStoreLocal(runtimehelpercall.getResult());
break;
default:
9 changes: 2 additions & 7 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -136,11 +136,12 @@ public class Options {
public static final Option<String> TRUFFLE_TRANSLATOR_PRINT_AST = string(TRUFFLE, "truffle.translator.print_asts", "", "Comma delimited list of method names to print the AST of after translation.");
public static final Option<String> TRUFFLE_TRANSLATOR_PRINT_FULL_AST = string(TRUFFLE, "truffle.translator.print_full_asts", "", "Comma delimited list of method names to print the full AST of after translation.");
public static final Option<String> TRUFFLE_TRANSLATOR_PRINT_PARSE_TREE = string(TRUFFLE, "truffle.translator.print_parse_trees", "", "Comma delimited list of method names to print the JRuby parse tree of before translation.");
public static final Option<Boolean> TRUFFLE_PANIC_ON_JAVA_ASSERT = bool(TRUFFLE, "truffle.debug.panic_on_java_assert", false, "Panic as soon as a Java assertion failure is found.");
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_java", false, "Print Java exceptions at the point of translating them to Ruby exceptions.");
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_UNCAUGHT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_uncaught_java", false, "Print uncaught Java exceptions at the point of translating them to Ruby exceptions.");
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_BACKTRACES_HIDE_CORE_FILES = bool(TRUFFLE, "truffle.backtraces.hide_core_files", true, "Hide core source files in backtraces, like MRI does.");

public static final Option<Boolean> TRUFFLE_INLINER_ALWAYS_CLONE_YIELD = bool(TRUFFLE, "truffle.inliner.always_clone_yield", true, "Always clone yield call targets.");
public static final Option<Boolean> TRUFFLE_INLINER_ALWAYS_INLINE_YIELD = bool(TRUFFLE, "truffle.inliner.always_inline_yield", true, "Always inline yield call targets.");
public static final Option<Boolean> TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_UNCACHED = bool(TRUFFLE, "truffle.dispatch.metaprogramming_always_uncached", false, "Always use uncached dispatch for the metaprogramming methods #__send__, #send and #respond_to?, and for any call site that has to use #method_missing or #const_missing.");
@@ -151,12 +152,6 @@ public class Options {
public static final Option<Boolean> TRUFFLE_RANDOMIZE_STORAGE_ARRAY = bool(TRUFFLE, "truffle.randomize_storage.array", false, "Randomize Array storage strategy.");
public static final Option<Integer> TRUFFLE_RANDOMIZE_SEED = integer(TRUFFLE, "truffle.randomize.seed", 0, "Seed for any randomization.");

public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_DISPLAY_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.display_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.MRI, "How to format backtraces displayed to the user.");
public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_DEBUG_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.debug_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.DEBUG, "How to format backtraces displayed using TruffleDebug.dump_call_stack.");
public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_EXCEPTION_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.exception_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.MRI, "How to format backtraces in Exception objects.");
public static final Option<Integer> TRUFFLE_BACKTRACE_MAX_VALUE_LENGTH = integer(TRUFFLE, "truffle.backtrace.max_value_length", 20, "Max length for values when displayed in a backtrace.");
public static final Option<Boolean> TRUFFLE_BACKTRACE_GENERATE = bool(TRUFFLE, "truffle.backtrace.generate", true, "Generate backtraces on exceptions.");

public static final Option<Boolean> NATIVE_ENABLED = bool(NATIVE, "native.enabled", true, "Enable/disable native code, including POSIX features and C exts.");
public static final Option<Boolean> NATIVE_VERBOSE = bool(NATIVE, "native.verbose", false, "Enable verbose logging of native extension loading.");
public static final Option<Boolean> FFI_COMPILE_DUMP = bool(NATIVE, "ffi.compile.dump", false, "Dump bytecode-generated FFI stubs to console.");
2 changes: 1 addition & 1 deletion lib/pom.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def version
ImportedGem.new( 'minitest', 'minitest.version', true ),
ImportedGem.new( 'test-unit', 'test-unit.version', true ),
ImportedGem.new( 'power_assert', 'power_assert.version', true ),
ImportedGem.new( 'psych', '2.0.14.pre1', true ),
ImportedGem.new( 'psych', '2.0.14', true ),
ImportedGem.new( 'json', 'json.version', true ),
ImportedGem.new( 'jar-dependencies', '0.1.15', true )
]
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>rubygems</groupId>
<artifactId>psych</artifactId>
<version>2.0.14.pre1</version>
<version>2.0.14</version>
<type>gem</type>
<scope>provided</scope>
<exclusions>
8 changes: 4 additions & 4 deletions pom.rb
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@

properties( 'its.j2ee' => 'j2ee*/pom.xml',
'its.osgi' => 'osgi*/pom.xml',
'rspec-core.version' => '2.14.2',
'rspec-core.version' => '3.3.2',
'jruby.basedir' => '${project.basedir}',
'minitest.version' => '5.4.1',
'ant.version' => '1.9.2',
@@ -61,15 +61,15 @@
'project.build.sourceEncoding' => 'utf-8',
'jruby-launcher.version' => '1.1.1',
'asm.version' => '5.0.3',
'rspec-expectations.version' => '2.14.0',
'rspec-expectations.version' => '3.3.1',
'base.javac.version' => '1.7',
'krypt.version' => '0.0.2.rc1',
'rdoc.version' => '4.1.0',
'polyglot.dump.pom' => 'pom.xml',
'rspec.version' => '2.14.1',
'rspec.version' => '3.3.0',
'base.java.version' => '1.7',
'polyglot.dump.readonly' => 'true',
'rspec-mocks.version' => '2.14.1',
'rspec-mocks.version' => '3.3.2',
'jruby.plugins.version' => '1.0.10',
'invoker.skip' => 'true',
'json.version' => '1.8.0',
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ DO NOT MODIFIY - GENERATED CODE
</site>
</distributionManagement>
<properties>
<rspec-core.version>2.14.2</rspec-core.version>
<rspec-core.version>3.3.2</rspec-core.version>
<polyglot.dump.readonly>true</polyglot.dump.readonly>
<its.j2ee>j2ee*/pom.xml</its.j2ee>
<jruby.basedir>${project.basedir}</jruby.basedir>
@@ -116,16 +116,16 @@ DO NOT MODIFIY - GENERATED CODE
<rake.version>10.1.0</rake.version>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<jruby-launcher.version>1.1.1</jruby-launcher.version>
<rspec-expectations.version>2.14.0</rspec-expectations.version>
<rspec-expectations.version>3.3.1</rspec-expectations.version>
<asm.version>5.0.3</asm.version>
<its.osgi>osgi*/pom.xml</its.osgi>
<base.javac.version>1.7</base.javac.version>
<krypt.version>0.0.2.rc1</krypt.version>
<test-unit.version>3.0.3</test-unit.version>
<rdoc.version>4.1.0</rdoc.version>
<rspec.version>2.14.1</rspec.version>
<rspec.version>3.3.0</rspec.version>
<base.java.version>1.7</base.java.version>
<rspec-mocks.version>2.14.1</rspec-mocks.version>
<rspec-mocks.version>3.3.2</rspec-mocks.version>
<jruby.plugins.version>1.0.10</jruby.plugins.version>
<json.version>1.8.0</json.version>
<invoker.skip>true</invoker.skip>
13 changes: 7 additions & 6 deletions spec/compiler/general_spec.rb
Original file line number Diff line number Diff line change
@@ -573,8 +573,8 @@ def blank?
end.new
') do |obj|
$~ = nil
obj.blank?.should == false
$~.should be_nil
expect(obj).not_to be_blank
expect($~).to be_nil
end
end

@@ -699,8 +699,8 @@ def self.remove; remove_method :gh1239; end
run("def foo; x = {1 => 2}; x.inject({}) do |hash, (key, value)|; hash[key.to_s] = value; hash; end; end; foo") {|result| expect(result).to eq({"1" => 2}) }
end

it "compiles very long code bodies", pending: "JIT support" do
# JRUBY-2246
it "compiles very long code bodies" do
skip "JRUBY-2246"
long_src = "a = 1\n"
5000.times { long_src << "a += 1\n" }
run(long_src) {|result| expect(result).to eq 5001 }
@@ -756,8 +756,9 @@ class AFromLocal < a
EOS
end

it "can compile large literal arrays and hashes", pending: "JIT support" do
# JRUBY-4757 and JRUBY-2621: can't compile large array/hash
it "can compile large literal arrays and hashes" do
skip "JRUBY-4757 and JRUBY-2621: can't compile large array/hash"

large_array = (1..10000).to_a.inspect
large_hash = large_array.clone
large_hash.gsub!('[', '{')
2 changes: 1 addition & 1 deletion spec/compiler/rubyscript_spec.rb
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
script1.add_import('my.java.import')

script2 = JRuby::Compiler::RubyScript.new("script2")
script2.imports.should_not include('my.java.import')
expect(script2.imports).not_to include('my.java.import')
end

end
12 changes: 7 additions & 5 deletions spec/compiler/skinnymethodadapter_spec.rb
Original file line number Diff line number Diff line change
@@ -55,13 +55,15 @@ def method_missing(name, *args)

insn_opcodes.each do |opcode|
opcode = opcode.downcase
instance_methods.should include(opcode)
expect(instance_methods).to include(opcode)
end

instance_methods.should include("go_to")
instance_methods.should include("voidreturn")
instance_methods.should include("instance_of")
instance_methods.should include("newobj")
expect(instance_methods).to include(
"go_to",
"voidreturn",
"instance_of",
"newobj"
)
end
end

30 changes: 15 additions & 15 deletions spec/java_integration/addons/io_spec.rb
Original file line number Diff line number Diff line change
@@ -5,69 +5,69 @@
let(:input_number){"1234567890"}
it "gets an IO from a java.io.InputStream" do
io = java.io.ByteArrayInputStream.new(input_number.to_java_bytes).to_io
io.class.should == IO
io.read(5).should == "12345"
expect(io.class).to eq(IO)
expect(io.read(5)).to eq("12345")
end

it "gets an IO from a java.io.OutputStream" do
output = java.io.ByteArrayOutputStream.new
io = output.to_io
io.class.should == IO
expect(io.class).to eq(IO)
io.write("12345")
io.flush
String.from_java_bytes(output.to_byte_array).should == "12345"
expect(String.from_java_bytes(output.to_byte_array)).to eq("12345")
end

it "is coercible to java.io.InputStream with IO#to_inputstream" do
file = File.open(__FILE__)
first_ten = file.read(10)
file.seek(0)
stream = file.to_inputstream
java.io.InputStream.should === stream
expect(java.io.InputStream).to be === stream

bytes = "0000000000".to_java_bytes
stream.read(bytes).should == 10
String.from_java_bytes(bytes).should == first_ten
expect(stream.read(bytes)).to eq(10)
expect(String.from_java_bytes(bytes)).to eq(first_ten)
end

it "is coercible to java.io.OutputStream with IO#to_outputstream" do
file = Tempfile.new("io_spec")
stream = file.to_outputstream
java.io.OutputStream.should === stream
expect(java.io.OutputStream).to be === stream

bytes = input_number.to_java_bytes
stream.write(bytes)
stream.flush
file.seek(0)
str = file.read(10)
str.should == String.from_java_bytes(bytes)
expect(str).to eq(String.from_java_bytes(bytes))
end

it "gets an IO from a java.nio.channels.Channel" do
input = java.io.ByteArrayInputStream.new(input_number.to_java_bytes)
channel = java.nio.channels.Channels.newChannel(input)
io = channel.to_io
io.class.should == IO
io.read(5).should == "12345"
expect(io.class).to eq(IO)
expect(io.read(5)).to eq("12345")

output = java.io.ByteArrayOutputStream.new
channel = java.nio.channels.Channels.newChannel(output)
io = channel.to_io
io.class.should == IO
expect(io.class).to eq(IO)
io.write("12345")
io.flush
String.from_java_bytes(output.to_byte_array).should == "12345"
expect(String.from_java_bytes(output.to_byte_array)).to eq("12345")
end

it "is coercible to java.nio.channels.Channel with IO#to_channel" do
file = Tempfile.new("io_spec")
channel = file.to_channel
java.nio.channels.Channel.should === channel
expect(java.nio.channels.Channel).to be === channel

bytes = java.nio.ByteBuffer.wrap(input_number.to_java_bytes)
channel.write(bytes)
file.seek(0)
str = file.read(10)
str.should == String.from_java_bytes(bytes.array)
expect(str).to eq(String.from_java_bytes(bytes.array))
end
end
7 changes: 5 additions & 2 deletions spec/java_integration/addons/object_spec.rb
Original file line number Diff line number Diff line change
@@ -38,10 +38,13 @@ module Foo
class Foo
def initialize
java_import java.util.Properties
Properties.should == java.util.Properties
end

def props
Properties
end
end
Foo.new
expect(Foo.new.props).to eq(java.util.Properties)
end
end

18 changes: 9 additions & 9 deletions spec/java_integration/addons/stringio_addons.rb
Original file line number Diff line number Diff line change
@@ -6,38 +6,38 @@
it "should be coercible to java.io.InputStream with StringIO#to_inputstream" do
file = StringIO.new("\xC3\x80abcdefghij")
stream = file.to_inputstream
java.io.InputStream.should === stream
expect(java.io.InputStream).to be === stream

stream.read.should == 0xc3
stream.read.should == 0x80
expect(stream.read).to eq(0xc3)
expect(stream.read).to eq(0x80)

bytes = "0000000000".to_java_bytes
stream.read(bytes).should == 10
String.from_java_bytes(bytes).should == 'abcdefghij'
expect(stream.read(bytes)).to eq(10)
expect(String.from_java_bytes(bytes)).to eq('abcdefghij')
end

it "should be coercible to java.io.OutputStream with StringIO#to_outputstream" do
file = StringIO.new
stream = file.to_outputstream
java.io.OutputStream.should === stream
expect(java.io.OutputStream).to be === stream

bytes = "1234567890".to_java_bytes
stream.write(bytes)
stream.flush
file.seek(0)
str = file.read(10)
str.should == String.from_java_bytes(bytes)
expect(str).to eq(String.from_java_bytes(bytes))
end

it "should be coercible to java.nio.channels.Channel with StringIO#to_channel" do
file = StringIO.new
channel = file.to_channel
java.nio.channels.Channel.should === channel
expect(java.nio.channels.Channel).to be === channel

bytes = java.nio.ByteBuffer.wrap("1234567890".to_java_bytes)
channel.write(bytes)
file.seek(0)
str = file.read(10)
str.should == String.from_java_bytes(bytes.array)
expect(str).to eq(String.from_java_bytes(bytes.array))
end
end
2 changes: 1 addition & 1 deletion spec/java_integration/addons/synchronized_class_spec.rb
Original file line number Diff line number Diff line change
@@ -63,6 +63,6 @@ def expect_unsynchronized

it "should be includable only in classes" do
mod = Module.new
lambda { mod.class_eval { include JRuby::Synchronized } }.should raise_error(TypeError)
expect { mod.class_eval { include JRuby::Synchronized } }.to raise_error(TypeError)
end
end
2 changes: 1 addition & 1 deletion spec/java_integration/addons/throwable_spec.rb
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
it "implements backtrace" do
ex = java.lang.Exception.new
trace = nil
lambda {trace = ex.backtrace}.should_not raise_error
expect {trace = ex.backtrace}.not_to raise_error
expect(trace).to eq(ex.stack_trace.map(&:to_s))
end

Loading

0 comments on commit 9953aea

Please sign in to comment.