Skip to content

Commit

Permalink
[Truffle] Replace the last usages for notDesigned with transfer.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed May 7, 2015
1 parent 740b5e5 commit 76ac629
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 216 deletions.
8 changes: 0 additions & 8 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,6 @@ public RubyContext getContext() {
return context;
}

// notDesignedForCompilation() helper

// TODO CS 30-Apr-15 inline this when we think it's working well

public static void notDesignedForCompilation() {
CompilerDirectives.transferToInterpreter();
}

// ruby() helper

protected Object ruby(VirtualFrame frame, String expression, Object... arguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Expand All @@ -32,14 +33,14 @@ public ArrayDropTailNode(RubyContext context, SourceSection sourceSection, int i

@Specialization(guards = "isNull(array)")
public RubyArray getHeadNull(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

return new RubyArray(getContext().getCoreLibrary().getArrayClass());
}

@Specialization(guards = "isIntegerFixnum(array)")
public RubyArray getHeadIntegerFixnum(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (index >= array.getSize()) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
Expand All @@ -50,7 +51,7 @@ public RubyArray getHeadIntegerFixnum(RubyArray array) {

@Specialization(guards = "isLongFixnum(array)")
public RubyArray geHeadLongFixnum(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (index >= array.getSize()) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
Expand All @@ -62,7 +63,7 @@ public RubyArray geHeadLongFixnum(RubyArray array) {

@Specialization(guards = "isFloat(array)")
public RubyArray getHeadFloat(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (index >= array.getSize()) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
Expand All @@ -74,7 +75,7 @@ public RubyArray getHeadFloat(RubyArray array) {

@Specialization(guards = "isObject(array)")
public RubyArray getHeadObject(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (index >= array.getSize()) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Expand All @@ -32,14 +33,14 @@ public ArrayGetTailNode(RubyContext context, SourceSection sourceSection, int in

@Specialization(guards = "isNull(array)")
public RubyArray getTailNull(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

return new RubyArray(getContext().getCoreLibrary().getArrayClass());
}

@Specialization(guards = "isIntegerFixnum(array)")
public RubyArray getTailIntegerFixnum(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (index >= array.getSize()) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
Expand All @@ -50,7 +51,7 @@ public RubyArray getTailIntegerFixnum(RubyArray array) {

@Specialization(guards = "isLongFixnum(array)")
public RubyArray getTailLongFixnum(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (index >= array.getSize()) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
Expand All @@ -61,7 +62,7 @@ public RubyArray getTailLongFixnum(RubyArray array) {

@Specialization(guards = "isFloat(array)")
public RubyArray getTailFloat(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (index >= array.getSize()) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
Expand All @@ -72,7 +73,7 @@ public RubyArray getTailFloat(RubyArray array) {

@Specialization(guards = "isObject(array)")
public RubyArray getTailObject(RubyArray array) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (index >= array.getSize()) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
Expand Down
57 changes: 28 additions & 29 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.nodes.CoreSourceSection;
Expand Down Expand Up @@ -270,13 +269,13 @@ public RubyArray mulObject(RubyArray array, int count) {

@Specialization(guards = "isRubyString(string)")
public Object mulObject(VirtualFrame frame, RubyArray array, RubyString string) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();
return ruby(frame, "join(sep)", "sep", string);
}

@Specialization(guards = {"!isRubyString(object)"})
public Object mulObjectCount(VirtualFrame frame, RubyArray array, Object object) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();
if (respondToToStrNode == null) {
CompilerDirectives.transferToInterpreter();
respondToToStrNode = insert(KernelNodesFactory.RespondToNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{null, null, null}));
Expand Down Expand Up @@ -466,7 +465,7 @@ public Object setObject(VirtualFrame frame, RubyArray array, Object startObject,

@Specialization(guards = { "!isRubyArray(value)", "!isUndefinedPlaceholder(value)" })
public Object setObject(VirtualFrame frame, RubyArray array, int start, int length, Object value) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (length < 0) {
CompilerDirectives.transferToInterpreter();
Expand Down Expand Up @@ -557,7 +556,7 @@ public Object setOtherArray(VirtualFrame frame, RubyArray array, Object startObj

@Specialization
public Object setOtherArray(VirtualFrame frame, RubyArray array, int start, int length, RubyArray value) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (length < 0) {
CompilerDirectives.transferToInterpreter();
Expand Down Expand Up @@ -862,7 +861,7 @@ public RubyArray concatNull(RubyArray array, RubyArray other) {

@Specialization(guards = "areBothIntegerFixnum(array, other)")
public RubyArray concatIntegerFixnum(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final int newSize = array.getSize() + other.getSize();
int[] store = (int[]) array.getStore();
Expand All @@ -878,7 +877,7 @@ public RubyArray concatIntegerFixnum(RubyArray array, RubyArray other) {

@Specialization(guards = "areBothLongFixnum(array, other)")
public RubyArray concatLongFixnum(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final int newSize = array.getSize() + other.getSize();
long[] store = (long[]) array.getStore();
Expand All @@ -894,7 +893,7 @@ public RubyArray concatLongFixnum(RubyArray array, RubyArray other) {

@Specialization(guards = "areBothFloat(array, other)")
public RubyArray concatDouble(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final int newSize = array.getSize() + other.getSize();
double[] store = (double[]) array.getStore();
Expand All @@ -910,7 +909,7 @@ public RubyArray concatDouble(RubyArray array, RubyArray other) {

@Specialization(guards = "areBothObject(array, other)")
public RubyArray concatObject(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final int size = array.getSize();
final int newSize = size + other.getSize();
Expand All @@ -927,7 +926,7 @@ public RubyArray concatObject(RubyArray array, RubyArray other) {

@Specialization
public RubyArray concat(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final int newSize = array.getSize() + other.getSize();

Expand Down Expand Up @@ -1081,7 +1080,7 @@ public int deleteAtIntegerFixnumInBounds(RubyArray array, int index) throws Unex

@Specialization(contains = "deleteAtIntegerFixnumInBounds", guards = "isIntegerFixnum(array)")
public Object deleteAtIntegerFixnum(RubyArray array, int index) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

int normalizedIndex = index;

Expand Down Expand Up @@ -1123,7 +1122,7 @@ public long deleteAtLongFixnumInBounds(RubyArray array, int index) throws Unexpe

@Specialization(contains = "deleteAtLongFixnumInBounds", guards = "isLongFixnum(array)")
public Object deleteAtLongFixnum(RubyArray array, int index) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

int normalizedIndex = index;

Expand Down Expand Up @@ -1165,7 +1164,7 @@ public double deleteAtFloatInBounds(RubyArray array, int index) throws Unexpecte

@Specialization(contains = "deleteAtFloatInBounds", guards = "isFloat(array)")
public Object deleteAtFloat(RubyArray array, int index) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

int normalizedIndex = index;

Expand Down Expand Up @@ -1207,7 +1206,7 @@ public Object deleteAtObjectInBounds(RubyArray array, int index) throws Unexpect

@Specialization(contains = "deleteAtObjectInBounds", guards = "isObject(array)")
public Object deleteAtObject(RubyArray array, int index) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

int normalizedIndex = index;

Expand Down Expand Up @@ -1849,14 +1848,14 @@ public Object initializeNegative(VirtualFrame frame, RubyArray array, int size,

@Specialization
public RubyArray initialize(RubyArray array, RubyArray copy, UndefinedPlaceholder defaultValue, UndefinedPlaceholder block) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();
array.setStore(copy.slowToArray(), copy.getSize());
return array;
}

@Specialization
public RubyArray initialize(RubyArray array, RubyArray copy, UndefinedPlaceholder defaultValue, RubyProc block) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();
array.setStore(copy.slowToArray(), copy.getSize());
return array;
}
Expand Down Expand Up @@ -2046,7 +2045,7 @@ public Object injectNull(VirtualFrame frame, RubyArray array, Object initial, Ru

@Specialization
public Object inject(VirtualFrame frame, RubyArray array, RubySymbol symbol, UndefinedPlaceholder unused) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final Object[] store = array.slowToArray();

Expand Down Expand Up @@ -2081,7 +2080,7 @@ public InsertNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = {"isNull(array)", "isIntIndexAndOtherSingleObjectArg(array, values)"})
public Object insertNull(RubyArray array, Object[] values) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();
final int index = (int) values[0];
if (index < 0) {
CompilerDirectives.transferToInterpreter();
Expand All @@ -2108,7 +2107,7 @@ public Object insert(RubyArray array, Object[] values) {

@Specialization(contains = {"insert", "insertNull"})
public Object insertBoxed(VirtualFrame frame, RubyArray array, Object[] values) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();
if (values.length == 1) {
return array;
}
Expand Down Expand Up @@ -3451,7 +3450,7 @@ public Object selectObject(VirtualFrame frame, RubyArray array, RubyProc block)

final Object value = store[n];

notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (! yieldIsTruthy(frame, block, new Object[]{value})) {
selectedStore = arrayBuilder.append(selectedStore, selectedSize, value);
Expand Down Expand Up @@ -3484,7 +3483,7 @@ public Object selectFixnumInteger(VirtualFrame frame, RubyArray array, RubyProc

final Object value = store[n];

notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (! yieldIsTruthy(frame, block, value)) {
selectedStore = arrayBuilder.append(selectedStore, selectedSize, value);
Expand Down Expand Up @@ -3759,39 +3758,39 @@ public ReplaceNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isOtherNull(array, other)")
public RubyArray replace(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

array.setStore(null, 0);
return array;
}

@Specialization(guards = "isOtherIntegerFixnum(array, other)")
public RubyArray replaceIntegerFixnum(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

array.setStore(Arrays.copyOf((int[]) other.getStore(), other.getSize()), other.getSize());
return array;
}

@Specialization(guards = "isOtherLongFixnum(array, other)")
public RubyArray replaceLongFixnum(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

array.setStore(Arrays.copyOf((long[]) other.getStore(), other.getSize()), other.getSize());
return array;
}

@Specialization(guards = "isOtherFloat(array, other)")
public RubyArray replaceFloat(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

array.setStore(Arrays.copyOf((double[]) other.getStore(), other.getSize()), other.getSize());
return array;
}

@Specialization(guards = "isOtherObject(array, other)")
public RubyArray replaceObject(RubyArray array, RubyArray other) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

array.setStore(Arrays.copyOf((Object[]) other.getStore(), other.getSize()), other.getSize());
return array;
Expand Down Expand Up @@ -3832,7 +3831,7 @@ public Object selectObject(VirtualFrame frame, RubyArray array, RubyProc block)

final Object value = store[n];

notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (yieldIsTruthy(frame, block, new Object[]{value})) {
selectedStore = arrayBuilder.append(selectedStore, selectedSize, value);
Expand Down Expand Up @@ -3865,7 +3864,7 @@ public Object selectFixnumInteger(VirtualFrame frame, RubyArray array, RubyProc

final Object value = store[n];

notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (yieldIsTruthy(frame, block, value)) {
selectedStore = arrayBuilder.append(selectedStore, selectedSize, value);
Expand Down Expand Up @@ -4488,7 +4487,7 @@ public UnshiftNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public RubyArray unshift(RubyArray array, Object... args) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

array.slowUnshift(args);
return array;
Expand Down
Loading

0 comments on commit 76ac629

Please sign in to comment.