Skip to content

Commit

Permalink
[Truffle] Fixed improper guards that could lead primitives down the s…
Browse files Browse the repository at this point in the history
…low path in ToIntNode.
  • Loading branch information
nirvdrum committed Apr 17, 2015
1 parent 097abf9 commit 6a985a3
Showing 1 changed file with 11 additions and 2 deletions.
Expand Up @@ -23,6 +23,7 @@
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyBignum;

@NodeChild(value = "child", type = RubyNode.class)
Expand Down Expand Up @@ -63,10 +64,18 @@ public Object coerceDouble(VirtualFrame frame, double value) {
return floatToIntNode.executeToI(frame, value);
}

@Specialization
public Object coerceBoolean(VirtualFrame frame, boolean value) {
return coerceObject(frame, value);
}

@Specialization(guards = "!isRubyBignum")
public Object coerceObject(VirtualFrame frame, Object object) {
notDesignedForCompilation();
public Object coerceBasicObject(VirtualFrame frame, RubyBasicObject object) {
return coerceObject(frame, object);
}

@CompilerDirectives.TruffleBoundary
private Object coerceObject(VirtualFrame frame, Object object) {
if (toIntNode == null) {
CompilerDirectives.transferToInterpreter();
toIntNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
Expand Down

0 comments on commit 6a985a3

Please sign in to comment.