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

Commits on Apr 13, 2016

  1. Verified

    This commit was signed with the committer’s verified signature.
    makenowjust Hiroya Fujinami
    Copy the full SHA
    53d73ca View commit details
  2. Copy the full SHA
    c448aa7 View commit details
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public DynamicObject getHeadNull(DynamicObject array) {
return createArray(getContext(), null, 0);
}

@Specialization(guards = "strategy.matches(array)")
@Specialization(guards = "strategy.matches(array)", limit = "ARRAY_STRATEGIES")
public DynamicObject dropTail(DynamicObject array,
@Cached("of(array)") ArrayStrategy strategy,
@Cached("createBinaryProfile()") ConditionProfile indexLargerThanSize) {
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.core.array;

import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
@@ -42,40 +43,12 @@ public DynamicObject dupNull(DynamicObject from) {
return allocateNode.allocateArray(coreLibrary().getArrayClass(), null, 0);
}

@Specialization(guards = "isIntArray(from)")
public DynamicObject dupIntegerFixnum(DynamicObject from) {
final int[] store = (int[]) Layouts.ARRAY.getStore(from);
return allocateNode.allocateArray(
coreLibrary().getArrayClass(),
store.clone(),
Layouts.ARRAY.getSize(from));
}

@Specialization(guards = "isLongArray(from)")
public DynamicObject dupLongFixnum(DynamicObject from) {
final long[] store = (long[]) Layouts.ARRAY.getStore(from);
return allocateNode.allocateArray(
coreLibrary().getArrayClass(),
store.clone(),
Layouts.ARRAY.getSize(from));
}

@Specialization(guards = "isDoubleArray(from)")
public DynamicObject dupFloat(DynamicObject from) {
final double[] store = (double[]) Layouts.ARRAY.getStore(from);
return allocateNode.allocateArray(
coreLibrary().getArrayClass(),
store.clone(),
Layouts.ARRAY.getSize(from));
}

@Specialization(guards = "isObjectArray(from)")
public DynamicObject dupObject(DynamicObject from) {
final Object[] store = (Object[]) Layouts.ARRAY.getStore(from);
return allocateNode.allocateArray(
coreLibrary().getArrayClass(),
ArrayUtils.copy(store),
Layouts.ARRAY.getSize(from));
@Specialization(guards = "strategy.matches(from)", limit = "ARRAY_STRATEGIES")
public DynamicObject dupOther(DynamicObject from,
@Cached("of(from)") ArrayStrategy strategy) {
final int size = Layouts.ARRAY.getSize(from);
Object store = strategy.newMirror(from).copyArrayAndMirror().getArray();
return allocateNode.allocateArray(coreLibrary().getArrayClass(), store, size);
}

}