Skip to content

Commit

Permalink
Showing 8 changed files with 77 additions and 222 deletions.
11 changes: 6 additions & 5 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1914,21 +1914,21 @@ protected void receiveNonBlockArgs(final ArgsNode argsNode) {
// Now for opt args
if (opt > 0) {
int optIndex = argsNode.getOptArgIndex();
Variable temp = createTemporaryVariable();
for (int j = 0; j < opt; j++, argIndex++) {
// Jump to 'l' if this arg is not null. If null, fall through and build the default value!
Label l = getNewLabel();
OptArgNode n = (OptArgNode)args[optIndex + j];
String argName = n.getName();
Variable av = getNewLocalVariable(argName, 0);
if (scope instanceof IRMethod) addArgumentDescription(ArgumentType.opt, argName);
Variable temp = createTemporaryVariable();
// You need at least required+j+1 incoming args for this opt arg to get an arg at all
addInstr(new ReceiveOptArgInstr(temp, signature.required(), signature.pre(), j));
addInstr(BNEInstr.create(l, temp, UndefinedValue.UNDEFINED)); // if 'av' is not undefined, go to default
addInstr(new ReceiveOptArgInstr(av, signature.required(), signature.pre(), j));
addInstr(BNEInstr.create(l, av, UndefinedValue.UNDEFINED)); // if 'av' is not undefined, go to default
addInstr(new CopyInstr(av, buildNil())); // wipe out undefined value with nil
Operand defaultResult = build(n.getValue());
addInstr(new CopyInstr(temp, defaultResult));
addInstr(new CopyInstr(av, defaultResult));
addInstr(new LabelInstr(l));
addInstr(new CopyInstr(av, temp));
}
}

@@ -2024,6 +2024,7 @@ public void receiveArgs(final ArgsNode argsNode) {

// Required kwargs have no value and check_arity will throw if they are not provided.
if (!isRequiredKeywordArgumentValue(kasgn)) {
addInstr(new CopyInstr(av, buildNil())); // wipe out undefined value with nil
build(kasgn);
} else {
addInstr(new RaiseRequiredKeywordArgumentError(argName));
192 changes: 0 additions & 192 deletions core/src/main/java/org/jruby/ir/passes/OptimizeTempVarsPass.java

This file was deleted.

23 changes: 0 additions & 23 deletions maven/jruby-dist/pom.rb
Original file line number Diff line number Diff line change
@@ -9,29 +9,6 @@
inherit "org.jruby:jruby-artifacts:#{version}"
packaging 'pom'

properties( 'main.basedir' => '${project.parent.parent.basedir}',
'ruby.maven.version' => '3.3.3',
'ruby.maven.libs.version' => '3.3.3' )

# pre-installed gems - not default gems !
gem 'ruby-maven', '${ruby.maven.version}', :scope => 'provided'

# HACK: add torquebox repo only when building from filesystem
# not when using the pom as "dependency" in some other projects
profile 'gem proxy' do

activation do
file( :exists => '../jruby' )
end

repository( :url => 'https://otto.takari.io/content/repositories/rubygems/maven/releases',
:id => 'rubygems-releases' )
end

jruby_plugin :gem do
execute_goal :initialize
end

phase 'prepare-package' do

plugin :dependency do
24 changes: 24 additions & 0 deletions spec/compiler/general_spec.rb
Original file line number Diff line number Diff line change
@@ -1080,6 +1080,30 @@ def a; __callee__; end
run('def foo; yield; end; foo {|a = a, b = b, c = c|; [a.inspect, b.inspect, c.inspect]}') do |x|
expect(x).to eq(["nil", "nil", "nil"])
end

run('def foo(a: a, b: b, c: c); [a.inspect, b.inspect, c.inspect]; end; foo') do |x|
expect(x).to eq(["nil", "nil", "nil"])
end
run('def foo; yield; end; foo {|a: a, b: b, c: c|; [a.inspect, b.inspect, c.inspect]}') do |x|
expect(x).to eq(["nil", "nil", "nil"])
end
ensure
$VERBOSE = verbose
end
end

it "combines optional args and zsuper properly" do
begin
verbose = $VERBOSE
$VERBOSE = nil

run('class OptZSuperA; def foo(a, b); [a, b]; end; end; class OptZSuperB < OptZSuperA; def foo(a = "", b = nil); super; end; end; OptZSuperB.new.foo') do |x|
expect(x).to eq(["", nil])
end

run('class OptZSuperA; def foo(a:, b:); [a, b]; end; end; class OptZSuperB < OptZSuperA; def foo(a: "", b: nil); super; end; end; OptZSuperB.new.foo') do |x|
expect(x).to eq(["", nil])
end
ensure
$VERBOSE = verbose
end
3 changes: 3 additions & 0 deletions test/truffle/compiler/osr.sh
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/osr/osr.rb
28 changes: 28 additions & 0 deletions test/truffle/compiler/osr/osr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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

timeout = Time.now + 30

begin
while Time.now < timeout
Truffle::Primitive.assert_not_compiled
end

puts "while loop optimisation timed out"
exit 1
rescue RubyTruffleError => e
if e.message.include? 'Truffle::Primitive.assert_not_compiled'
puts "while loop optimising"
exit 0
else
puts "some other error"
exit 1
end
end

exit 1
Original file line number Diff line number Diff line change
@@ -142,8 +142,8 @@ public Backtrace getBacktrace(Node currentNode,
final ArrayList<Activation> activations = new ArrayList<>();

if (omit == 0 && currentNode != null && Truffle.getRuntime().getCurrentFrame() != null) {
final InternalMethod method = RubyArguments.getMethod(Truffle.getRuntime().getCurrentFrame()
.getFrame(FrameInstance.FrameAccess.READ_ONLY, true));
final InternalMethod method = RubyArguments.tryGetMethod(Truffle.getRuntime().getCurrentFrame()
.getFrame(FrameInstance.FrameAccess.READ_ONLY, true).getArguments());

activations.add(new Activation(currentNode, method));
}
Original file line number Diff line number Diff line change
@@ -215,6 +215,20 @@ public static DynamicObject tryGetBlock(Object[] arguments) {
}
}

public static InternalMethod tryGetMethod(Object[] arguments) {
if (ArgumentIndicies.METHOD.ordinal() >= arguments.length) {
return null;
}

final Object method = arguments[ArgumentIndicies.METHOD.ordinal()];

if (method instanceof InternalMethod) {
return (InternalMethod) method;
}

return null;
}

// Setters

public static void setDeclarationFrame(Object[] arguments, MaterializedFrame declarationFrame) {

0 comments on commit 1ef6d7c

Please sign in to comment.