Skip to content

Commit

Permalink
Revert "[Truffle] Use declarative guards for checking classes in the …
Browse files Browse the repository at this point in the history
…IC."

This reverts commit f2b1582.
  • Loading branch information
chrisseaton committed Jan 9, 2015
1 parent 7e01a86 commit bb62232
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 36 deletions.
Expand Up @@ -103,13 +103,24 @@ public CachedBoxedDispatchNode(CachedBoxedDispatchNode prev) {
indirectCallNode = prev.indirectCallNode;
}

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

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

// Check the class has not been modified

try {
Expand Down Expand Up @@ -159,14 +170,6 @@ public Object dispatch(
}
}

protected final boolean guardClass(
RubyBasicObject receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return receiverObject.getMetaClass() == expectedClass;
}

@Fallback
public Object dispatch(
VirtualFrame frame,
Expand Down
Expand Up @@ -83,13 +83,24 @@ public CachedBoxedMethodMissingDispatchNode(CachedBoxedMethodMissingDispatchNode
indirectCallNode = prev.indirectCallNode;
}

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

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

// Check the class has not been modified

try {
Expand Down Expand Up @@ -166,14 +177,6 @@ public Object dispatch(
}
}

protected final boolean guardClass(
RubyBasicObject receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return receiverObject.getMetaClass() == expectedClass;
}

@Fallback
public Object dispatch(
VirtualFrame frame,
Expand Down
Expand Up @@ -45,13 +45,24 @@ public CachedBoxedReturnMissingDispatchNode(CachedBoxedReturnMissingDispatchNode
unmodifiedAssumption = prev.unmodifiedAssumption;
}

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

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

// Check the class has not been modified

try {
Expand All @@ -78,14 +89,6 @@ public Object dispatch(
}
}

protected final boolean guardClass(
RubyBasicObject receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return receiverObject.getMetaClass() == expectedClass;
}

@Fallback
public Object dispatch(
VirtualFrame frame,
Expand Down
Expand Up @@ -69,13 +69,24 @@ public CachedUnboxedDispatchNode(CachedUnboxedDispatchNode prev) {
indirectCallNode = prev.indirectCallNode;
}

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

if (receiverObject.getClass() != expectedClass) {
return next.executeDispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

// Check the class has not been modified

try {
Expand Down Expand Up @@ -123,14 +134,6 @@ public Object dispatch(
}
}

protected final boolean guardClass(
Object receiverObject,
Object methodName,
Object blockObject,
Object argumentsObjects) {
return receiverObject.getClass() == expectedClass;
}

@Fallback
public Object fallback(
VirtualFrame frame,
Expand Down

0 comments on commit bb62232

Please sign in to comment.