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

Commits on Apr 7, 2016

  1. Copy the full SHA
    8efa9dd View commit details
  2. Copy the full SHA
    ae6d9b3 View commit details
  3. Copy the full SHA
    c1fbbdf View commit details
  4. [Truffle] No need to check if RHS is an Array in Array#+ since the ca…

    …st will already do it.
    eregon committed Apr 7, 2016
    Copy the full SHA
    973de09 View commit details
  5. fix

    eregon committed Apr 7, 2016
    Copy the full SHA
    cce2b27 View commit details
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ public interface ArrayMirror {

Object getArray();

Object copyArrayAndMirror();
ArrayMirror copyArrayAndMirror();

Object[] getBoxedCopy();

18 changes: 10 additions & 8 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@
import org.jruby.truffle.core.CoreSourceSection;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.YieldingCoreMethodNode;
import org.jruby.truffle.core.array.ArrayNodesFactory.MaxBlockNodeFactory;
import org.jruby.truffle.core.array.ArrayNodesFactory.MinBlockNodeFactory;
import org.jruby.truffle.core.array.ArrayNodesFactory.ReplaceNodeFactory;
import org.jruby.truffle.core.coerce.ToAryNodeGen;
import org.jruby.truffle.core.coerce.ToIntNode;
@@ -125,8 +127,8 @@ public AddNode(RubyContext context, SourceSection sourceSection) {
return ToAryNodeGen.create(getContext(), getSourceSection(), other);
}

@Specialization(guards = {"isNullArray(a)", "isNullArray(b)"})
public DynamicObject addNull(DynamicObject a, DynamicObject b) {
@Specialization(guards = { "isNullArray(a)", "isNullArray(b)" })
public DynamicObject addNullNull(DynamicObject a, DynamicObject b) {
return createArray(getContext(), null, 0);
}

@@ -189,7 +191,7 @@ public DynamicObject addNullObject(DynamicObject a, DynamicObject b) {
return createArray(getContext(), Arrays.copyOf((Object[]) getStore(b), size), size);
}

@Specialization(guards = {"!isObjectArray(a)", "isRubyArray(b)", "isObjectArray(b)"})
@Specialization(guards = { "!isObjectArray(a)", "isObjectArray(b)" })
public DynamicObject addOtherObject(DynamicObject a, DynamicObject b) {
final int combinedSize = getSize(a) + getSize(b);
final Object[] combined = new Object[combinedSize];
@@ -198,7 +200,7 @@ public DynamicObject addOtherObject(DynamicObject a, DynamicObject b) {
return createArray(getContext(), combined, combinedSize);
}

@Specialization(guards = {"isObjectArray(a)", "isRubyArray(b)", "!isObjectArray(b)"})
@Specialization(guards = { "isObjectArray(a)", "!isObjectArray(b)" })
public DynamicObject addObject(DynamicObject a, DynamicObject b) {
final int combinedSize = getSize(a) + getSize(b);
final Object[] combined = new Object[combinedSize];
@@ -207,13 +209,13 @@ public DynamicObject addObject(DynamicObject a, DynamicObject b) {
return createArray(getContext(), combined, combinedSize);
}

@Specialization(guards = {"isEmptyArray(a)", "isRubyArray(b)"})
@Specialization(guards = "isEmptyArray(a)")
public DynamicObject addEmpty(DynamicObject a, DynamicObject b) {
final int size = getSize(b);
return createArray(getContext(), ArrayUtils.box(getStore(b)), size);
}

@Specialization(guards = {"isEmptyArray(b)", "isRubyArray(b)"})
@Specialization(guards = "isEmptyArray(b)")
public DynamicObject addOtherEmpty(DynamicObject a, DynamicObject b) {
final int size = getSize(a);
return createArray(getContext(), ArrayUtils.box(getStore(a)), size);
@@ -2269,7 +2271,7 @@ public MaxBlock(RubyContext context) {

sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.NO_ARGUMENTS, "max", false, null, false, false, false);

callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, sourceSection, null, sharedMethodInfo, ArrayNodesFactory.MaxBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, sourceSection, null, sharedMethodInfo, MaxBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
new ReadDeclarationVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, 1, frameSlot),
new ReadPreArgumentNode(context, sourceSection, 0, MissingArgumentBehavior.RUNTIME_ERROR)
}), false));
@@ -2387,7 +2389,7 @@ public MinBlock(RubyContext context) {

sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.NO_ARGUMENTS, "min", false, null, false, false, false);

callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, sourceSection, null, sharedMethodInfo, ArrayNodesFactory.MinBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, sourceSection, null, sharedMethodInfo, MinBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
new ReadDeclarationVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, 1, frameSlot),
new ReadPreArgumentNode(context, sourceSection, 0, MissingArgumentBehavior.RUNTIME_ERROR)
}), false));
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
public abstract class BasicArrayMirror implements ArrayMirror {

@Override
public Object copyArrayAndMirror() {
public ArrayMirror copyArrayAndMirror() {
return copyArrayAndMirror(getLength());
}

Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public void set(int index, Object value) {

@Override
public ArrayMirror copyArrayAndMirror(int newLength) {
return new ObjectArrayMirror(ArrayUtils.grow(array, newLength));
return new ObjectArrayMirror(ArrayUtils.copyOf(array, newLength));
}

@Override