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: 4dceff3801ae
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6727b2c93d6b
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Mar 17, 2015

  1. Copy the full SHA
    bd39f25 View commit details
  2. Merge pull request #2719 from bjfish/truffle_array_element_set_fix_fa…

    …nnkuch_again
    
    [Truffle] Adding back a Specialization used by fannkuch benchmark.
    chrisseaton committed Mar 17, 2015
    Copy the full SHA
    6727b2c View commit details
Showing with 26 additions and 1 deletion.
  1. +5 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayGuards.java
  2. +21 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.core;

import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyRange;

public class ArrayGuards {

@@ -69,6 +70,10 @@ public static boolean areBothIntegerFixnum(RubyArray a, RubyArray b) {
return a.getStore() instanceof int[] && b.getStore() instanceof int[];
}

public static boolean areBothIntegerFixnum(RubyArray array, RubyRange.IntegerFixnumRange range, RubyArray other) {
return array.getStore() instanceof int[] && other.getStore() instanceof int[];
}

public static boolean areBothLongFixnum(RubyArray a, RubyArray b) {
return a.getStore() instanceof long[] && b.getStore() instanceof long[];
}
Original file line number Diff line number Diff line change
@@ -492,14 +492,34 @@ public Object setRange(VirtualFrame frame, RubyArray array, RubyRange.IntegerFix
return setObject(frame, array, normalizedStart, length, other);
}

@Specialization
@Specialization(guards = "!areBothIntegerFixnum")
public Object setRangeArray(VirtualFrame frame, RubyArray array, RubyRange.IntegerFixnumRange range, RubyArray other, UndefinedPlaceholder unused) {
final int normalizedStart = array.normalizeIndex(range.getBegin());
final int normalizedEnd = range.doesExcludeEnd() ? array.normalizeIndex(range.getEnd()) - 1 : array.normalizeIndex(range.getEnd());
final int length = normalizedEnd - normalizedStart + 1;
return setOtherArray(frame, array, normalizedStart, length, other);
}

@Specialization(guards = "areBothIntegerFixnum" )
public Object setIntegerFixnumRange(VirtualFrame frame, RubyArray array, RubyRange.IntegerFixnumRange range, RubyArray other, UndefinedPlaceholder unused) {
if (range.doesExcludeEnd()) {
CompilerDirectives.transferToInterpreter();
return setRangeArray(frame, array, range, other, unused);
} else {
int normalizedBegin = array.normalizeIndex(range.getBegin());
int normalizedEnd = array.normalizeIndex(range.getEnd());

if (normalizedBegin == 0 && normalizedEnd == array.getSize() - 1) {
array.setStore(Arrays.copyOf((int[]) other.getStore(), other.getSize()), other.getSize());
} else {
CompilerDirectives.transferToInterpreter();
return setRangeArray(frame, array, range, other, unused);
}
}

return other;
}

}

@CoreMethod(names = "at", required = 1)