Skip to content

Commit

Permalink
Showing 7 changed files with 41 additions and 122 deletions.
Original file line number Diff line number Diff line change
@@ -104,14 +104,23 @@ public CachedBooleanDispatchNode(CachedBooleanDispatchNode prev) {
indirectCallNode = prev.indirectCallNode;
}

@Specialization(guards = "guardName")
@Specialization
public Object dispatch(
VirtualFrame frame,
boolean receiverObject,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
if (receiverObject) {
if (!guardName(methodName) || !(receiverObject instanceof Boolean)) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

if ((boolean) receiverObject) {
trueProfile.enter();

try {
@@ -211,19 +220,4 @@ public Object dispatch(
}
}

@Fallback
public Object dispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

}
Original file line number Diff line number Diff line change
@@ -103,21 +103,19 @@ public CachedBoxedDispatchNode(CachedBoxedDispatchNode prev) {
indirectCallNode = prev.indirectCallNode;
}

@Specialization(guards = "guardName")
@Specialization
public Object dispatch(
VirtualFrame frame,
RubyBasicObject receiverObject,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
// Check the lookup node is what we expect

if (receiverObject.getMetaClass() != expectedClass) {
if (!guardName(methodName) || !(receiverObject instanceof RubyBasicObject) || ((RubyBasicObject) receiverObject).getMetaClass() != expectedClass) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
CompilerDirectives.unsafeCast(blockObject, RubyProc.class, true, false),
blockObject,
argumentsObjects);
}

@@ -170,21 +168,6 @@ public Object dispatch(
}
}

@Fallback
public Object dispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

@Override
public String toString() {
return String.format("CachedBoxedDispatchNode(:%s, %s@%x, %s, %s)",
Original file line number Diff line number Diff line change
@@ -83,21 +83,19 @@ public CachedBoxedMethodMissingDispatchNode(CachedBoxedMethodMissingDispatchNode
indirectCallNode = prev.indirectCallNode;
}

@Specialization(guards = "guardName")
@Specialization
public Object dispatch(
VirtualFrame frame,
RubyBasicObject receiverObject,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
// Check the lookup node is what we expect

if (receiverObject.getMetaClass() != expectedClass) {
if (!guardName(methodName) || !(receiverObject instanceof RubyBasicObject) || ((RubyBasicObject) receiverObject).getMetaClass() != expectedClass) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
CompilerDirectives.unsafeCast(blockObject, RubyProc.class, true, false),
blockObject,
argumentsObjects);
}

@@ -177,19 +175,4 @@ public Object dispatch(
}
}

@Fallback
public Object dispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

}
Original file line number Diff line number Diff line change
@@ -45,21 +45,19 @@ public CachedBoxedReturnMissingDispatchNode(CachedBoxedReturnMissingDispatchNode
unmodifiedAssumption = prev.unmodifiedAssumption;
}

@Specialization(guards = "guardName")
@Specialization
public Object dispatch(
VirtualFrame frame,
RubyBasicObject receiverObject,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
// Check the lookup node is what we expect

if (receiverObject.getMetaClass() != expectedClass) {
if (!guardName(methodName) || !(receiverObject instanceof RubyBasicObject) || ((RubyBasicObject) receiverObject).getMetaClass() != expectedClass) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
CompilerDirectives.unsafeCast(blockObject, RubyProc.class, true, false),
blockObject,
argumentsObjects);
}

@@ -89,19 +87,4 @@ public Object dispatch(
}
}

@Fallback
public Object dispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

}
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.methods.RubyMethod;
@@ -71,13 +72,22 @@ public CachedBoxedSymbolDispatchNode(CachedBoxedSymbolDispatchNode prev) {
indirectCallNode = prev.indirectCallNode;
}

@Specialization(guards = "guardName")
@Specialization
public Object dispatch(
VirtualFrame frame,
RubySymbol receiverObject,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
if (!guardName(methodName) || !(receiverObject instanceof RubySymbol)) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

// Check the class has not been modified

try {
@@ -127,19 +137,4 @@ public Object dispatch(
}
}

@Fallback
public Object dispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

}
Original file line number Diff line number Diff line change
@@ -58,11 +58,7 @@ public CachedDispatchNode(CachedDispatchNode prev) {
indirect = prev.indirect;
}

protected final boolean guardName(
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
protected final boolean guardName(Object methodName) {
if (cachedName == methodName) {
return true;
}
@@ -72,6 +68,7 @@ protected final boolean guardName(
if (cachedName instanceof String) {
return cachedName.equals(methodName);
} else if (cachedName instanceof RubySymbol) {
// TODO(CS, 11-Jan-15) this just repeats the above guard...
return cachedName == methodName;
} else if (cachedName instanceof RubyString) {
return (methodName instanceof RubyString) && ((RubyString) cachedName).getBytes().equals(((RubyString) methodName).getBytes());
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;

@@ -69,16 +70,14 @@ public CachedUnboxedDispatchNode(CachedUnboxedDispatchNode prev) {
indirectCallNode = prev.indirectCallNode;
}

@Specialization(guards = {"!isRubyBasicObject", "guardName"})
@Specialization
public Object dispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
// Check the class is what we expect

if (receiverObject.getClass() != expectedClass) {
if (!guardName(methodName) || receiverObject instanceof RubyBasicObject || receiverObject.getClass() != expectedClass) {
return next.executeDispatch(
frame,
receiverObject,
@@ -134,19 +133,4 @@ public Object dispatch(
}
}

@Fallback
public Object fallback(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

}

0 comments on commit ad066eb

Please sign in to comment.