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: 0c12f0fb001d
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 79eee3f69dab
Choose a head ref
  • 4 commits
  • 44 files changed
  • 1 contributor

Commits on May 19, 2015

  1. Copy the full SHA
    f262415 View commit details
  2. Copy the full SHA
    1714c0b View commit details
  3. Copy the full SHA
    7b90b2f View commit details
  4. More zsuper specs.

    chrisseaton committed May 19, 2015
    Copy the full SHA
    79eee3f View commit details
Showing with 186 additions and 69 deletions.
  1. +46 −0 spec/ruby/language/fixtures/super.rb
  2. +21 −5 spec/ruby/language/super_spec.rb
  3. +4 −3 spec/truffle/tags/language/super_tags.txt
  4. +3 −0 spec/truffle/tags/library/set/sortedset/classify_tags.txt
  5. +1 −0 spec/truffle/tags/library/set/sortedset/collect_tags.txt
  6. +1 −0 spec/truffle/tags/library/set/sortedset/constructor_tags.txt
  7. +3 −0 spec/truffle/tags/library/set/sortedset/delete_if_tags.txt
  8. +1 −0 spec/truffle/tags/library/set/sortedset/delete_tags.txt
  9. +2 −0 spec/truffle/tags/library/set/sortedset/divide_tags.txt
  10. +2 −0 spec/truffle/tags/library/set/sortedset/each_tags.txt
  11. +1 −0 spec/truffle/tags/library/set/sortedset/empty_tags.txt
  12. +1 −0 spec/truffle/tags/library/set/sortedset/eql_tags.txt
  13. +1 −0 spec/truffle/tags/library/set/sortedset/equal_value_tags.txt
  14. +1 −0 spec/truffle/tags/library/set/sortedset/exclusion_tags.txt
  15. +1 −0 spec/truffle/tags/library/set/sortedset/flatten_tags.txt
  16. +1 −0 spec/truffle/tags/library/set/sortedset/hash_tags.txt
  17. +1 −0 spec/truffle/tags/library/set/sortedset/include_tags.txt
  18. +2 −0 spec/truffle/tags/library/set/sortedset/initialize_tags.txt
  19. +3 −0 spec/truffle/tags/library/set/sortedset/keep_if_tags.txt
  20. +1 −0 spec/truffle/tags/library/set/sortedset/length_tags.txt
  21. +1 −0 spec/truffle/tags/library/set/sortedset/map_tags.txt
  22. +1 −0 spec/truffle/tags/library/set/sortedset/member_tags.txt
  23. +1 −0 spec/truffle/tags/library/set/sortedset/merge_tags.txt
  24. +1 −0 spec/truffle/tags/library/set/sortedset/plus_tags.txt
  25. +1 −0 spec/truffle/tags/library/set/sortedset/pretty_print_cycle_tags.txt
  26. +1 −0 spec/truffle/tags/library/set/sortedset/proper_subset_tags.txt
  27. +1 −0 spec/truffle/tags/library/set/sortedset/proper_superset_tags.txt
  28. +4 −0 spec/truffle/tags/library/set/sortedset/reject_tags.txt
  29. +1 −0 spec/truffle/tags/library/set/sortedset/replace_tags.txt
  30. +4 −0 spec/truffle/tags/library/set/sortedset/select_tags.txt
  31. +1 −0 spec/truffle/tags/library/set/sortedset/size_tags.txt
  32. +1 −0 spec/truffle/tags/library/set/sortedset/subset_tags.txt
  33. +1 −0 spec/truffle/tags/library/set/sortedset/superset_tags.txt
  34. +1 −0 spec/truffle/tags/library/set/sortedset/to_a_tags.txt
  35. +2 −0 spec/truffle/tags/library/set/sortedset/union_tags.txt
  36. +1 −0 spec/truffle/tags/library/thread/sizedqueue/deq_tags.txt
  37. +1 −0 spec/truffle/tags/library/thread/sizedqueue/pop_tags.txt
  38. +1 −0 spec/truffle/tags/library/thread/sizedqueue/shift_tags.txt
  39. +0 −39 truffle/src/main/java/org/jruby/truffle/nodes/arguments/WritePreArgumentNode.java
  40. +11 −0 truffle/src/main/java/org/jruby/truffle/nodes/control/SequenceNode.java
  41. +11 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  42. +22 −14 truffle/src/main/java/org/jruby/truffle/nodes/supercall/GeneralSuperReCallNode.java
  43. +4 −1 truffle/src/main/java/org/jruby/truffle/translator/MethodTranslator.java
  44. +16 −4 truffle/src/main/java/org/jruby/truffle/translator/ReloadArgumentsTranslator.java
46 changes: 46 additions & 0 deletions spec/ruby/language/fixtures/super.rb
Original file line number Diff line number Diff line change
@@ -391,4 +391,50 @@ def m(x, y, z = 14)
end
end

module ZSuperWithRest
class A
def m(*args)
args
end

def m_modified(*args)
args
end
end

class B < A
def m(*args)
super
end

def m_modified(*args)
args[1] = 14
super
end
end
end

module ZSuperWithRestAndOthers
class A
def m(a, b, *args)
args
end

def m_modified(a, b, *args)
args
end
end

class B < A
def m(a, b, *args)
super
end

def m_modified(a, b, *args)
args[1] = 14
super
end
end
end

end
26 changes: 21 additions & 5 deletions spec/ruby/language/super_spec.rb
Original file line number Diff line number Diff line change
@@ -162,24 +162,40 @@ def a(arg)
Super::AnonymousModuleIncludedTwice.new.a([]).should == ["anon", "anon", "non-anon"]
end

it "can accept a block but still pass the original arguments" do
it "without explicit arguments can accept a block but still pass the original arguments" do
Super::ZSuperWithBlock::B.new.a.should == 14
end

it "passes optional arguments that have a default value" do
it "without explicit arguments passes optional arguments that have a default value" do
Super::ZSuperWithOptional::B.new.m(1, 2).should == 14
end

it "passes optional arguments that have a non-default value" do
it "without explicit arguments passes optional arguments that have a non-default value" do
Super::ZSuperWithOptional::B.new.m(1, 2, 3).should == 3
end

it "passes optional arguments that have a default value but were modified" do
it "without explicit arguments passes optional arguments that have a default value but were modified" do
Super::ZSuperWithOptional::C.new.m(1, 2).should == 100
end

it "passes optional arguments that have a non-default value but were modified" do
it "without explicit arguments passes optional arguments that have a non-default value but were modified" do
Super::ZSuperWithOptional::C.new.m(1, 2, 3).should == 100
end

it "without explicit arguments passes rest arguments" do
Super::ZSuperWithRest::B.new.m(1, 2, 3).should == [1, 2, 3]
end

it "without explicit arguments passes rest arguments including any modifications" do
Super::ZSuperWithRest::B.new.m_modified(1, 2, 3).should == [1, 14, 3]
end

it "without explicit arguments passes arguments and rest arguments" do
Super::ZSuperWithRestAndOthers::B.new.m(1, 2, 3, 4, 5).should == [3, 4, 5]
end

it "without explicit arguments passes arguments and rest arguments including any modifications" do
Super::ZSuperWithRestAndOthers::B.new.m_modified(1, 2, 3, 4, 5).should == [3, 14, 5]
end

end
7 changes: 4 additions & 3 deletions spec/truffle/tags/language/super_tags.txt
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ fails:The super keyword passes along modified rest args when they weren't origin
fails:The super keyword passes along modified rest args when they were originally empty
fails:The super keyword raises a RuntimeError when called with implicit arguments from a method defined with define_method
fails:The super keyword calls method_missing when a superclass method is not found
fails:The super keyword passes optional arguments that have a default value
fails:The super keyword passes optional arguments that have a default value but were modified
fails:The super keyword passes optional arguments that have a non-default value but were modified
fails:The super keyword without explicit arguments passes rest arguments
fails:The super keyword without explicit arguments passes rest arguments including any modifications
fails:The super keyword without explicit arguments passes arguments and rest arguments
fails:The super keyword without explicit arguments passes arguments and rest arguments including any modifications
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/set/sortedset/classify_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:SortedSet#classify yields each Object in self in sorted order
fails:SortedSet#classify returns an Enumerator when passed no block
fails:SortedSet#classify classifies the Objects in self based on the block's return value
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/collect_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#collect! yields each Object in self in sorted order
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet[] returns a new SortedSet populated with the passed Objects
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/set/sortedset/delete_if_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:SortedSet#delete_if yields each Object in self in sorted order
fails:SortedSet#delete_if deletes every element from self for which the passed block returns true
fails:SortedSet#delete_if returns an Enumerator when passed no block
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/delete_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#delete? returns self when the passed Object is in self
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/set/sortedset/divide_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
fails:SortedSet#divide when passed a block with an arity of 2 divides self into a set of subsets based on the blocks return values
fails:SortedSet#divide when passed a block with an arity of 2 yields each two Objects to the block
fails:SortedSet#divide divides self into a set of subsets based on the blocks return values
fails:SortedSet#divide yields each Object in self in sorted order
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/set/sortedset/each_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:SortedSet#each yields each Object in self in sorted order
fails:SortedSet#each returns an Enumerator when not passed a block
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/empty_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#empty? returns true if self is empty
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/eql_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#eql? returns true when the passed argument is a SortedSet and contains the same elements
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#== returns true when the passed Object is a SortedSet and self and the Object contain the same elements
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/exclusion_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#^ returns a new SortedSet containing elements that are not in both self and the passed Enumberable
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/flatten_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#flatten! returns self when self was modified
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/hash_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#hash is static
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/include_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#include? returns true when self contains the passed Object
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/set/sortedset/initialize_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:SortedSet#initialize adds all elements of the passed Enumerable to self
fails:SortedSet#initialize preprocesses all elements by a passed block before adding to self
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/set/sortedset/keep_if_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:SortedSet#keep_if yields each Object in self in sorted order
fails:SortedSet#keep_if keeps every element from self for which the passed block returns true
fails:SortedSet#keep_if returns an Enumerator when passed no block
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/length_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#length returns the number of elements in the set
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/map_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#map! yields each Object in self in sorted order
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/member_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#member? returns true when self contains the passed Object
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/merge_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#merge adds the elements of the passed Enumerable to self
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/plus_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#+ returns a new SortedSet containing all elements of self and the passed Enumerable
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#pretty_print_cycle passes the 'pretty print' representation of a self-referencing SortedSet to the pretty print writer
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#proper_subset? returns true if passed a SortedSet that self is a proper subset of
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#proper_superset? returns true if passed a SortedSet that self is a proper superset of
4 changes: 4 additions & 0 deletions spec/truffle/tags/library/set/sortedset/reject_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fails:SortedSet#reject! yields each Object in self in sorted order
fails:SortedSet#reject! deletes every element from self for which the passed block returns true
fails:SortedSet#reject! returns self when self was modified
fails:SortedSet#reject! returns an Enumerator when passed no block
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/replace_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#replace accepts any enumerable as other
4 changes: 4 additions & 0 deletions spec/truffle/tags/library/set/sortedset/select_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fails:SortedSet#select! yields each Object in self in sorted order
fails:SortedSet#select! keeps every element from self for which the passed block returns true
fails:SortedSet#select! returns self when self was modified
fails:SortedSet#select! returns an Enumerator when passed no block
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/size_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#size returns the number of elements in the set
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/subset_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#subset? returns true if passed a SortedSet that is equal to self or self is a subset of
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/superset_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#superset? returns true if passed a SortedSet that equals self or self is a proper superset of
1 change: 1 addition & 0 deletions spec/truffle/tags/library/set/sortedset/to_a_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:SortedSet#to_a returns an array containing elements of self
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/set/sortedset/union_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:SortedSet#union returns a new SortedSet containing all elements of self and the passed Enumerable
fails:SortedSet#| returns a new SortedSet containing all elements of self and the passed Enumerable
1 change: 1 addition & 0 deletions spec/truffle/tags/library/thread/sizedqueue/deq_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Thread::SizedQueue#deq raises a ThreadError if Queue is empty
1 change: 1 addition & 0 deletions spec/truffle/tags/library/thread/sizedqueue/pop_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Thread::SizedQueue#pop raises a ThreadError if Queue is empty
1 change: 1 addition & 0 deletions spec/truffle/tags/library/thread/sizedqueue/shift_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Thread::SizedQueue#shift raises a ThreadError if Queue is empty

This file was deleted.

Original file line number Diff line number Diff line change
@@ -31,6 +31,14 @@ public final class SequenceNode extends RubyNode {

@Children private final RubyNode[] body;

public static RubyNode sequenceNoFlatten(RubyContext context, SourceSection sourceSection, RubyNode... sequence) {
return new SequenceNode(context, sourceSection, sequence);
}

public static RubyNode sequenceNoFlatten(RubyContext context, SourceSection sourceSection, List<RubyNode> sequence) {
return sequenceNoFlatten(context, sourceSection, sequence.toArray(new RubyNode[sequence.size()]));
}

public static RubyNode sequence(RubyContext context, SourceSection sourceSection, RubyNode... sequence) {
return sequence(context, sourceSection, Arrays.asList(sequence));
}
@@ -93,4 +101,7 @@ public void executeVoid(VirtualFrame frame) {
}
}

public RubyNode[] getSequence() {
return body;
}
}
Original file line number Diff line number Diff line change
@@ -960,16 +960,19 @@ public RubyProc proc(RubyProc block) {
}
}

@CoreMethod(names = "load", isModuleFunction = true, required = 1)
@CoreMethod(names = "load", isModuleFunction = true, required = 1, optional = 1)
public abstract static class LoadNode extends CoreMethodArrayArgumentsNode {

public LoadNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public boolean load(RubyString file) {
CompilerDirectives.transferToInterpreter();
public boolean load(RubyString file, boolean wrap) {
if (wrap) {
throw new UnsupportedOperationException();
}

try {
getContext().loadFile(file.toString(), this);
@@ -986,6 +989,11 @@ public boolean load(RubyString file) {

return true;
}

@Specialization
public boolean load(RubyString file, UndefinedPlaceholder wrap) {
return load(file, false);
}
}

@CoreMethod(names = "local_variables", needsSelf = false)
Original file line number Diff line number Diff line change
@@ -11,30 +11,29 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;

import java.util.Arrays;
import org.jruby.truffle.runtime.core.RubyProc;

public class GeneralSuperReCallNode extends AbstractGeneralSuperCallNode {

private final boolean inBlock;
@Child private RubyNode reload;
@Children private final RubyNode[] reloadNodes;
@Child private RubyNode block;

public GeneralSuperReCallNode(RubyContext context, SourceSection sourceSection, boolean inBlock, RubyNode reload, RubyNode block) {
public GeneralSuperReCallNode(RubyContext context, SourceSection sourceSection, boolean inBlock, RubyNode[] reloadNodes, RubyNode block) {
super(context, sourceSection);
this.inBlock = inBlock;
this.reload = reload;
this.reloadNodes = reloadNodes;
this.block = block;
}

@ExplodeLoop
@Override
public final Object execute(VirtualFrame frame) {
reload.execute(frame);

final Object self = RubyArguments.getSelf(frame.getArguments());

if (!guard(frame, self)) {
@@ -50,21 +49,30 @@ public final Object execute(VirtualFrame frame) {
originalArguments = frame.getArguments();
}

final Object[] superArguments = Arrays.copyOf(originalArguments, originalArguments.length);
final Object[] superArguments = new Object[reloadNodes.length];

for (int n = 0; n < superArguments.length; n++) {
superArguments[n] = reloadNodes[n].execute(frame);
}

Object blockObject;

if (block != null) {
Object blockObject = block.execute(frame);
blockObject = block.execute(frame);

if (blockObject == nil()) {
blockObject = null;
}

superArguments[RubyArguments.BLOCK_INDEX] = blockObject;
} else {
blockObject = RubyArguments.getBlock(originalArguments);
}

superArguments[RubyArguments.METHOD_INDEX] = superMethod;

return callNode.call(frame, superArguments);
return callNode.call(frame, RubyArguments.pack(
superMethod,
RubyArguments.getDeclarationFrame(originalArguments),
RubyArguments.getSelf(originalArguments),
(RubyProc) blockObject,
superArguments));
}

}
Original file line number Diff line number Diff line change
@@ -284,8 +284,11 @@ public RubyNode visitZSuperNode(org.jruby.ast.ZSuperNode node) {
blockNode = null;
}

final SequenceNode reloadSequence = (SequenceNode) new ReloadArgumentsTranslator(
currentNode, context, source, this).visitArgsNode(argsNode);

return new GeneralSuperReCallNode(context, sourceSection, environment.isBlock(),
new ReloadArgumentsTranslator(currentNode, context, source, this).visitArgsNode(argsNode),
reloadSequence.getSequence(),
blockNode);
}

Loading