Skip to content

Commit

Permalink
[Truffle] Start to remove notDesignedForCompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed May 1, 2015
1 parent adc95e0 commit 58c6722
Show file tree
Hide file tree
Showing 47 changed files with 41 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void executeVoid(VirtualFrame frame) {

@Override
public Object isDefined(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final RubyContext context = getContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public RubyNode[] expandedArgumentNodes(InternalMethod method, RubyNode[] argume

@Override
public Object isDefined(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

if (receiver.isDefined(frame) == nil()) {
return nil();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public WriteConstantNode(RubyContext context, SourceSection sourceSection, Strin

@Override
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

// Evaluate RHS first.
final Object rhsValue = rhs.execute(frame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ public Object cast(RubyNilClass nil) {

@Specialization(guards = {"!isRubyNilClass(object)", "!isRubyArray(object)"})
public Object cast(VirtualFrame frame, RubyBasicObject object) {
notDesignedForCompilation();

final Object result = toArrayNode.call(frame, object, "to_ary", null, new Object[]{});

if (result == DispatchNode.MISSING) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public RubyNilClass cast(RubyNilClass nil) {

@Specialization(guards = {"!isRubyNilClass(object)", "!isRubyHash(object)"})
public Object cast(VirtualFrame frame, RubyBasicObject object) {
notDesignedForCompilation();

final Object result = toHashNode.call(frame, object, "to_hash", null, new Object[]{});

if (result == DispatchNode.MISSING) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public LambdaNode(RubyContext context, SourceSection sourceSection, RubyNode def

@Override
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

final InternalMethod method = (InternalMethod) definition.execute(frame);

// TODO(CS): not sure we're closing over the correct state here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public RubyProc doRubyProc(RubyProc proc) {

@Specialization
public RubyProc doObject(VirtualFrame frame, RubyBasicObject object) {
notDesignedForCompilation();

return (RubyProc) toProc.call(frame, object, "to_proc", null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.cast;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
Expand Down Expand Up @@ -36,11 +37,10 @@ protected RubyNilClass castNil(Object[] args) {
protected Object castSingle(Object[] args) {
return args[0];
}


@CompilerDirectives.TruffleBoundary
@Specialization(guards = { "!noArguments(args)", "!singleArgument(args)" })
protected RubyArray castMany(Object[] args) {
notDesignedForCompilation();

return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.cast;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
Expand Down Expand Up @@ -84,8 +85,6 @@ public RubyArray splat(VirtualFrame frame, RubyArray array) {

@Specialization(guards = {"!isRubyNilClass(object)", "!isRubyArray(object)"})
public RubyArray splat(VirtualFrame frame, Object object) {
notDesignedForCompilation();

final String method;

if (useToAry) {
Expand All @@ -102,6 +101,7 @@ public RubyArray splat(VirtualFrame frame, Object object) {
if (array instanceof RubyArray) {
return (RubyArray) array;
} else if (array instanceof RubyNilClass || array == DispatchNode.MISSING) {
CompilerDirectives.transferToInterpreter();
return RubyArray.fromObject(getContext().getCoreLibrary().getArrayClass(), object);
} else {
throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertTo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ public StringToSymbolNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CompilerDirectives.TruffleBoundary
@Specialization
public RubySymbol doString(RubyString string) {
notDesignedForCompilation();

return getContext().getSymbol(string.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public String coerceRubyString(RubyString string) {

@Specialization(guards = { "!isRubySymbol(object)", "!isRubyString(object)" })
public String coerceObject(VirtualFrame frame, Object object) {
notDesignedForCompilation();

final Object coerced;

try {
Expand All @@ -63,7 +61,7 @@ public String coerceObject(VirtualFrame frame, Object object) {
}

if (coerced instanceof RubyString) {
return ((RubyString) coerced).toString();
return coerced.toString();
} else {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorBadCoercion(object, "String", "to_str", coerced, this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public RubyArray coerceRubyArray(RubyArray rubyArray) {

@Specialization(guards = "!isRubyArray(object)")
public RubyArray coerceObject(VirtualFrame frame, Object object) {
notDesignedForCompilation();

if (toAryNode == null) {
CompilerDirectives.transferToInterpreter();
toAryNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public RubyString coerceRubyString(RubyString string) {

@Specialization(guards = "!isRubyString(object)")
public RubyString coerceObject(VirtualFrame frame, Object object) {
notDesignedForCompilation();

final Object coerced;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
Expand All @@ -35,8 +36,6 @@ public FlipFlopNode(RubyContext context, SourceSection sourceSection, RubyNode b

@Override
public boolean executeBoolean(VirtualFrame frame) {
notDesignedForCompilation();

if (exclusive) {
if (stateNode.getState(frame)) {
if (end.executeBoolean(frame)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.AssumedValue;
Expand All @@ -29,8 +30,6 @@ public OnceNode(RubyContext context, SourceSection sourceSection, RubyNode child

@Override
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

Object value = valueMemo.get();

if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.source.SourceSection;
Expand All @@ -30,10 +31,9 @@ public RescueClassesNode(RubyContext context, SourceSection sourceSection, RubyN
this.handlingClassNodes = handlingClassNodes;
}

@ExplodeLoop
@Override
public boolean canHandle(VirtualFrame frame, RubyException exception) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final RubyClass exceptionRubyClass = exception.getLogicalClass();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.source.SourceSection;
Expand All @@ -33,10 +34,9 @@ public RescueSplatNode(RubyContext context, SourceSection sourceSection, RubyNod
this.handlingClassesArray = handlingClassesArray;
}

@ExplodeLoop
@Override
public boolean canHandle(VirtualFrame frame, RubyException exception) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final RubyArray handlingClasses = (RubyArray) handlingClassesArray.execute(frame);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ControlFlowException;
import com.oracle.truffle.api.nodes.ExplodeLoop;
Expand Down Expand Up @@ -80,11 +81,8 @@ public Object execute(VirtualFrame frame) {
}
}

@ExplodeLoop
private Object handleException(VirtualFrame frame, RaiseException exception) {
CompilerAsserts.neverPartOfCompilation();

notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final RubyBasicObject threadLocals = getContext().getThreadManager().getCurrentThread().getThreadLocals();
threadLocals.getOperations().setInstanceVariable(threadLocals, "$!", exception.getRubyException());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
Expand All @@ -33,7 +34,7 @@ public WhenSplatNode(RubyContext context, SourceSection sourceSection, RubyNode

@Override
public boolean executeBoolean(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final Object caseExpression = readCaseExpression.execute(frame);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public CheckMatchVariableTypeNode(RubyContext context, SourceSection sourceSecti
}

public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

final Object childValue = child.execute(frame);

if (!(childValue instanceof RubyMatchData || childValue instanceof RubyNilClass || childValue instanceof RubyNilClass)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public CheckOutputSeparatorVariableTypeNode(RubyContext context, SourceSection s
}

public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

final Object childValue = child.execute(frame);

if (!(childValue instanceof RubyString) && childValue != nil()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public CheckProgramNameVariableTypeNode(RubyContext context, SourceSection sourc
}

public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

final Object childValue = child.execute(frame);

if (!(childValue instanceof RubyString)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public CheckRecordSeparatorVariableTypeNode(RubyContext context, SourceSection s
}

public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

final Object childValue = child.execute(frame);

if (!(childValue instanceof RubyString) && childValue != nil()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.globals;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
Expand All @@ -26,7 +27,7 @@ public CheckStdoutVariableTypeNode(RubyContext context, SourceSection sourceSect
}

public Object execute(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final Object childValue = child.execute(frame);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.globals;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
Expand All @@ -31,7 +32,7 @@ public ReadMatchReferenceNode(RubyContext context, SourceSection sourceSection,

@Override
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final Object match = getContext().getThreadManager().getCurrentThread().getThreadLocals().getInstanceVariable("$~");

Expand Down Expand Up @@ -71,8 +72,6 @@ public Object execute(VirtualFrame frame) {

@Override
public Object isDefined(VirtualFrame frame) {
notDesignedForCompilation();

if (execute(frame) != nil()) {
return getContext().makeString("global-variable");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.globals;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.runtime.builtin.IRubyObject;
Expand All @@ -25,7 +26,7 @@ public UpdateVerbosityNode(RubyContext context, SourceSection sourceSection, Rub
}

public Object execute(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final Object childValue = child.execute(frame);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.literal;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
Expand All @@ -32,7 +33,7 @@ public ConcatHashLiteralNode(RubyContext context, SourceSection sourceSection, R

@Override
public RubyHash executeRubyHash(VirtualFrame frame) {
notDesignedForCompilation();
CompilerDirectives.transferToInterpreter();

final List<KeyValue> keyValues = new ArrayList<>();

Expand Down