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

Commits on Jun 9, 2015

  1. Copy the full SHA
    5b0d8f8 View commit details
  2. Copy the full SHA
    8af4e38 View commit details
  3. 4
    Copy the full SHA
    2cb7716 View commit details
  4. Copy the full SHA
    3528613 View commit details
2 changes: 1 addition & 1 deletion spec/ruby/core/symbol/all_symbols_spec.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
it "increases size of the return array when new symbol comes" do
symbols = Symbol.all_symbols
sym = [eval(":aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")]
Symbol.all_symbols.size.should == symbols.size + 1
Symbol.all_symbols.size.should > symbols.size
sym.clear
end
end
1 change: 0 additions & 1 deletion spec/truffle/tags/core/symbol/all_symbols_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:Symbol.all_symbols increases size of the return array when new symbol comes
slow:Symbol.all_symbols returns an array containing all the Symbols in the symbol table
slow:Symbol.all_symbols increases size of the return array when new symbol comes
17 changes: 0 additions & 17 deletions spec/truffle/tags/core/symbol/element_reference_tags.txt

This file was deleted.

17 changes: 0 additions & 17 deletions spec/truffle/tags/core/symbol/slice_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/symbol/to_proc_tags.txt

This file was deleted.

4 changes: 4 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -275,6 +275,10 @@ protected RubyBasicObject createEmptyArray() {
return ArrayNodes.createEmptyArray(getContext().getCoreLibrary().getArrayClass());
}

protected RubyBasicObject createArray(Object... store) {
return createArray(store, store.length);
}

protected RubyBasicObject createArray(int[] store, int size) {
return ArrayNodes.createArray(getContext().getCoreLibrary().getArrayClass(), store, size);
}
37 changes: 21 additions & 16 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
Original file line number Diff line number Diff line change
@@ -597,8 +597,8 @@ public GetIndexNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object getIndex(VirtualFrame frame, RubyString string, int index, NotProvided length) {
@Specialization(guards = "wasNotProvided(length) || isRubiniusUndefined(length)")
public Object getIndex(VirtualFrame frame, RubyString string, int index, Object length) {
int normalizedIndex = normalizeIndex(string, index);
final ByteList bytes = getByteList(string);

@@ -610,24 +610,24 @@ public Object getIndex(VirtualFrame frame, RubyString string, int index, NotProv
}
}

@Specialization(guards = { "!isRubyRange(index)", "!isRubyRegexp(index)", "!isRubyString(index)" })
public Object getIndex(VirtualFrame frame, RubyString string, Object index, NotProvided length) {
@Specialization(guards = { "!isRubyRange(index)", "!isRubyRegexp(index)", "!isRubyString(index)", "wasNotProvided(length) || isRubiniusUndefined(length)" })
public Object getIndex(VirtualFrame frame, RubyString string, Object index, Object length) {
return getIndex(frame, string, getToIntNode().doInt(frame, index), length);
}

@Specialization
public Object sliceIntegerRange(VirtualFrame frame, RubyString string, RubyRange.IntegerFixnumRange range, NotProvided length) {
@Specialization(guards = "wasNotProvided(length) || isRubiniusUndefined(length)")
public Object sliceIntegerRange(VirtualFrame frame, RubyString string, RubyRange.IntegerFixnumRange range, Object length) {
return sliceRange(frame, string, range.getBegin(), range.getEnd(), range.doesExcludeEnd());
}

@Specialization
public Object sliceLongRange(VirtualFrame frame, RubyString string, RubyRange.LongFixnumRange range, NotProvided length) {
@Specialization(guards = "wasNotProvided(length) || isRubiniusUndefined(length)")
public Object sliceLongRange(VirtualFrame frame, RubyString string, RubyRange.LongFixnumRange range, Object length) {
// TODO (nirvdrum 31-Mar-15) The begin and end values should be properly lowered, only if possible.
return sliceRange(frame, string, (int) range.getBegin(), (int) range.getEnd(), range.doesExcludeEnd());
}

@Specialization
public Object sliceObjectRange(VirtualFrame frame, RubyString string, RubyRange.ObjectRange range, NotProvided length) {
@Specialization(guards = "wasNotProvided(length) || isRubiniusUndefined(length)")
public Object sliceObjectRange(VirtualFrame frame, RubyString string, RubyRange.ObjectRange range, Object length) {
// TODO (nirvdrum 31-Mar-15) The begin and end values may return Fixnums beyond int boundaries and we should handle that -- Bignums are always errors.
final int coercedBegin = getToIntNode().doInt(frame, range.getBegin());
final int coercedEnd = getToIntNode().doInt(frame, range.getEnd());
@@ -687,19 +687,19 @@ public Object slice(VirtualFrame frame, RubyString string, Object start, Object
return slice(frame, string, getToIntNode().doInt(frame, start), getToIntNode().doInt(frame, length));
}

@Specialization
public Object slice(VirtualFrame frame, RubyString string, RubyRegexp regexp, NotProvided capture) {
return slice(frame, string, regexp, 0);
@Specialization(guards = "wasNotProvided(capture) || isRubiniusUndefined(capture)")
public Object slice(VirtualFrame frame, RubyString string, RubyRegexp regexp, Object capture) {
return sliceCapture(frame, string, regexp, 0);
}

@Specialization(guards = "wasProvided(capture)")
public Object slice(VirtualFrame frame, RubyString string, RubyRegexp regexp, Object capture) {
public Object sliceCapture(VirtualFrame frame, RubyString string, RubyRegexp regexp, Object capture) {
// Extracted from Rubinius's definition of String#[].
return ruby(frame, "match, str = subpattern(index, other); Regexp.last_match = match; str", "index", regexp, "other", capture);
}

@Specialization
public Object slice(VirtualFrame frame, RubyString string, RubyString matchStr, NotProvided length) {
@Specialization(guards = "wasNotProvided(length) || isRubiniusUndefined(length)")
public Object slice(VirtualFrame frame, RubyString string, RubyString matchStr, Object length) {
if (includeNode == null) {
CompilerDirectives.transferToInterpreter();
includeNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
@@ -738,6 +738,11 @@ private StringPrimitiveNodes.StringSubstringPrimitiveNode getSubstringNode() {

return substringNode;
}

protected boolean isRubiniusUndefined(Object object) {
return object == getContext().getCoreLibrary().getRubiniusUndefined();
}

}

@CoreMethod(names = "=~", required = 1)
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.arguments.CheckArityNode;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.methods.SymbolProcNode;
import org.jruby.truffle.runtime.RubyContext;
@@ -31,6 +33,7 @@
import org.jruby.truffle.runtime.object.BasicObjectType;
import org.jruby.util.ByteList;

import java.util.Collection;
import java.util.EnumSet;

@CoreClass(name = "Symbol")
@@ -149,12 +152,7 @@ public AllSymbolsNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public RubyBasicObject allSymbols() {
final RubyBasicObject array = createEmptyArray();

for (RubyBasicObject s : getContext().getSymbolTable().allSymbols()) {
ArrayNodes.slowPush(array, s);
}
return array;
return createArray(getContext().getSymbolTable().allSymbols().toArray());
}

}
@@ -219,7 +217,9 @@ sourceSection, null, Arity.NO_ARGUMENTS, getString(symbol),
getContext(), sourceSection,
new FrameDescriptor(),
sharedMethodInfo,
new SymbolProcNode(getContext(), sourceSection, getString(symbol)));
SequenceNode.sequence(getContext(), sourceSection,
new CheckArityNode(getContext(), sourceSection, Arity.AT_LEAST_ONE),
new SymbolProcNode(getContext(), sourceSection, getString(symbol))));

final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);

Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ public class Arity {

public static final Arity NO_ARGUMENTS = new Arity(0, 0, false, false, false, 0);
public static final Arity ONE_REQUIRED = new Arity(1, 0, false, false, false, 0);
public static final Arity AT_LEAST_ONE = new Arity(1, 0, true, false, false, 0);

private final int required;
private final int optional;