Skip to content

Commit bb62232

Browse files
committed
Revert "[Truffle] Use declarative guards for checking classes in the IC."
This reverts commit f2b1582.
1 parent 7e01a86 commit bb62232

File tree

4 files changed

+48
-36
lines changed

4 files changed

+48
-36
lines changed

core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedDispatchNode.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,24 @@ public CachedBoxedDispatchNode(CachedBoxedDispatchNode prev) {
103103
indirectCallNode = prev.indirectCallNode;
104104
}
105105

106-
@Specialization(guards = {"guardClass", "guardName"})
106+
@Specialization(guards = "guardName")
107107
public Object dispatch(
108108
VirtualFrame frame,
109109
RubyBasicObject receiverObject,
110110
Object methodName,
111111
Object blockObject,
112112
Object argumentsObjects) {
113+
// Check the lookup node is what we expect
114+
115+
if (receiverObject.getMetaClass() != expectedClass) {
116+
return next.executeDispatch(
117+
frame,
118+
receiverObject,
119+
methodName,
120+
CompilerDirectives.unsafeCast(blockObject, RubyProc.class, true, false),
121+
argumentsObjects);
122+
}
123+
113124
// Check the class has not been modified
114125

115126
try {
@@ -159,14 +170,6 @@ public Object dispatch(
159170
}
160171
}
161172

162-
protected final boolean guardClass(
163-
RubyBasicObject receiverObject,
164-
Object methodName,
165-
Object blockObject,
166-
Object argumentsObjects) {
167-
return receiverObject.getMetaClass() == expectedClass;
168-
}
169-
170173
@Fallback
171174
public Object dispatch(
172175
VirtualFrame frame,

core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedMethodMissingDispatchNode.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,24 @@ public CachedBoxedMethodMissingDispatchNode(CachedBoxedMethodMissingDispatchNode
8383
indirectCallNode = prev.indirectCallNode;
8484
}
8585

86-
@Specialization(guards = {"guardClass", "guardName"})
86+
@Specialization(guards = "guardName")
8787
public Object dispatch(
8888
VirtualFrame frame,
8989
RubyBasicObject receiverObject,
9090
Object methodName,
9191
Object blockObject,
9292
Object argumentsObjects) {
93+
// Check the lookup node is what we expect
94+
95+
if (receiverObject.getMetaClass() != expectedClass) {
96+
return next.executeDispatch(
97+
frame,
98+
receiverObject,
99+
methodName,
100+
CompilerDirectives.unsafeCast(blockObject, RubyProc.class, true, false),
101+
argumentsObjects);
102+
}
103+
93104
// Check the class has not been modified
94105

95106
try {
@@ -166,14 +177,6 @@ public Object dispatch(
166177
}
167178
}
168179

169-
protected final boolean guardClass(
170-
RubyBasicObject receiverObject,
171-
Object methodName,
172-
Object blockObject,
173-
Object argumentsObjects) {
174-
return receiverObject.getMetaClass() == expectedClass;
175-
}
176-
177180
@Fallback
178181
public Object dispatch(
179182
VirtualFrame frame,

core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedReturnMissingDispatchNode.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,24 @@ public CachedBoxedReturnMissingDispatchNode(CachedBoxedReturnMissingDispatchNode
4545
unmodifiedAssumption = prev.unmodifiedAssumption;
4646
}
4747

48-
@Specialization(guards = {"guardClass", "guardName"})
48+
@Specialization(guards = "guardName")
4949
public Object dispatch(
5050
VirtualFrame frame,
5151
RubyBasicObject receiverObject,
5252
Object methodName,
5353
Object blockObject,
5454
Object argumentsObjects) {
55+
// Check the lookup node is what we expect
56+
57+
if (receiverObject.getMetaClass() != expectedClass) {
58+
return next.executeDispatch(
59+
frame,
60+
receiverObject,
61+
methodName,
62+
CompilerDirectives.unsafeCast(blockObject, RubyProc.class, true, false),
63+
argumentsObjects);
64+
}
65+
5566
// Check the class has not been modified
5667

5768
try {
@@ -78,14 +89,6 @@ public Object dispatch(
7889
}
7990
}
8091

81-
protected final boolean guardClass(
82-
RubyBasicObject receiverObject,
83-
Object methodName,
84-
Object blockObject,
85-
Object argumentsObjects) {
86-
return receiverObject.getMetaClass() == expectedClass;
87-
}
88-
8992
@Fallback
9093
public Object dispatch(
9194
VirtualFrame frame,

core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedUnboxedDispatchNode.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,24 @@ public CachedUnboxedDispatchNode(CachedUnboxedDispatchNode prev) {
6969
indirectCallNode = prev.indirectCallNode;
7070
}
7171

72-
@Specialization(guards = {"!isRubyBasicObject", "guardClass", "guardName"})
72+
@Specialization(guards = {"!isRubyBasicObject", "guardName"})
7373
public Object dispatch(
7474
VirtualFrame frame,
7575
Object receiverObject,
7676
Object methodName,
7777
Object blockObject,
7878
Object argumentsObjects) {
79+
// Check the class is what we expect
80+
81+
if (receiverObject.getClass() != expectedClass) {
82+
return next.executeDispatch(
83+
frame,
84+
receiverObject,
85+
methodName,
86+
blockObject,
87+
argumentsObjects);
88+
}
89+
7990
// Check the class has not been modified
8091

8192
try {
@@ -123,14 +134,6 @@ public Object dispatch(
123134
}
124135
}
125136

126-
protected final boolean guardClass(
127-
Object receiverObject,
128-
Object methodName,
129-
Object blockObject,
130-
Object argumentsObjects) {
131-
return receiverObject.getClass() == expectedClass;
132-
}
133-
134137
@Fallback
135138
public Object fallback(
136139
VirtualFrame frame,

0 commit comments

Comments
 (0)