Skip to content

Commit c36f08c

Browse files
committed
Adjust library limit for LookupAndCallUnaryNodes
1 parent f8e087b commit c36f08c

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallBinaryNode.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
import com.oracle.graal.python.util.Supplier;
5454
import com.oracle.truffle.api.CompilerDirectives;
5555
import com.oracle.truffle.api.dsl.Cached;
56+
import com.oracle.truffle.api.dsl.ImportStatic;
57+
import com.oracle.truffle.api.dsl.ReportPolymorphism;
5658
import com.oracle.truffle.api.dsl.Specialization;
5759
import com.oracle.truffle.api.frame.VirtualFrame;
5860
import com.oracle.truffle.api.library.CachedLibrary;
@@ -70,6 +72,7 @@
7072
// The (int, double) and (double, int) specializations are needed to avoid int->long conversion.
7173
// Although it would produce correct results, the special handling of long to double comparison
7274
// is slower than converting int->double, which is always correct.
75+
@ReportPolymorphism
7376
public abstract class LookupAndCallBinaryNode extends Node {
7477

7578
public abstract static class NotImplementedHandler extends PNodeWithContext {
@@ -355,10 +358,11 @@ boolean callBoolean(VirtualFrame frame, double left, double right,
355358

356359
@Specialization(guards = {"!isReversible()"}, limit = "2")
357360
Object callObject(VirtualFrame frame, Object left, Object right,
358-
@CachedLibrary("left") PythonObjectLibrary libLeft,
361+
@CachedLibrary("left") PythonObjectLibrary libLeft,
359362
@Cached("create(name, ignoreDescriptorException)") LookupSpecialMethodNode getattr) {
363+
Object leftClass = libLeft.getLazyPythonClass(left);
360364
Object leftValue = libLeft.getDelegatedValue(left);
361-
Object leftCallable = getattr.execute(frame, libLeft.getLazyPythonClass(leftValue), leftValue);
365+
Object leftCallable = getattr.execute(frame, leftClass, leftValue);
362366
if (leftCallable == PNone.NO_VALUE) {
363367
if (handlerFactory != null) {
364368
return runErrorHandler(leftValue, right);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallUnaryNode.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@
5151
import com.oracle.truffle.api.CompilerDirectives;
5252
import com.oracle.truffle.api.dsl.Cached;
5353
import com.oracle.truffle.api.dsl.GenerateUncached;
54+
import com.oracle.truffle.api.dsl.ImportStatic;
55+
import com.oracle.truffle.api.dsl.ReportPolymorphism;
5456
import com.oracle.truffle.api.dsl.Specialization;
5557
import com.oracle.truffle.api.frame.VirtualFrame;
5658
import com.oracle.truffle.api.library.CachedLibrary;
5759
import com.oracle.truffle.api.nodes.Node;
5860
import com.oracle.truffle.api.nodes.UnexpectedResultException;
5961
import com.oracle.truffle.api.profiles.ConditionProfile;
6062

63+
@ReportPolymorphism
6164
public abstract class LookupAndCallUnaryNode extends Node {
6265

6366
public abstract static class NoAttributeHandler extends PNodeWithContext {
@@ -130,88 +133,88 @@ protected PythonUnaryBuiltinNode getBuiltin(Object receiver) {
130133
// int
131134

132135
@Specialization(guards = "function != null", rewriteOn = UnexpectedResultException.class)
133-
int callInt(VirtualFrame frame, int receiver,
136+
static int callInt(VirtualFrame frame, int receiver,
134137
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) throws UnexpectedResultException {
135138
return function.executeInt(frame, receiver);
136139
}
137140

138141
@Specialization(guards = "function != null", rewriteOn = UnexpectedResultException.class)
139-
boolean callBool(VirtualFrame frame, int receiver,
142+
static boolean callBool(VirtualFrame frame, int receiver,
140143
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) throws UnexpectedResultException {
141144
return function.executeBool(frame, receiver);
142145
}
143146

144147
@Specialization(guards = "function != null")
145-
Object callObject(VirtualFrame frame, int receiver,
148+
static Object callObject(VirtualFrame frame, int receiver,
146149
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) {
147150
return function.execute(frame, receiver);
148151
}
149152

150153
// long
151154

152155
@Specialization(guards = "function != null", rewriteOn = UnexpectedResultException.class)
153-
long callInt(VirtualFrame frame, long receiver,
156+
static long callInt(VirtualFrame frame, long receiver,
154157
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) throws UnexpectedResultException {
155158
return function.executeLong(frame, receiver);
156159
}
157160

158161
@Specialization(guards = "function != null", rewriteOn = UnexpectedResultException.class)
159-
boolean callBool(VirtualFrame frame, long receiver,
162+
static boolean callBool(VirtualFrame frame, long receiver,
160163
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) throws UnexpectedResultException {
161164
return function.executeBool(frame, receiver);
162165
}
163166

164167
@Specialization(guards = "function != null")
165-
Object callObject(VirtualFrame frame, long receiver,
168+
static Object callObject(VirtualFrame frame, long receiver,
166169
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) {
167170
return function.execute(frame, receiver);
168171
}
169172

170173
// double
171174

172175
@Specialization(guards = "function != null", rewriteOn = UnexpectedResultException.class)
173-
double callInt(VirtualFrame frame, double receiver,
176+
static double callInt(VirtualFrame frame, double receiver,
174177
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) throws UnexpectedResultException {
175178
return function.executeDouble(frame, receiver);
176179
}
177180

178181
@Specialization(guards = "function != null", rewriteOn = UnexpectedResultException.class)
179-
boolean callBool(VirtualFrame frame, double receiver,
182+
static boolean callBool(VirtualFrame frame, double receiver,
180183
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) throws UnexpectedResultException {
181184
return function.executeBool(frame, receiver);
182185
}
183186

184187
@Specialization(guards = "function != null")
185-
Object callObject(VirtualFrame frame, double receiver,
188+
static Object callObject(VirtualFrame frame, double receiver,
186189
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) {
187190
return function.execute(frame, receiver);
188191
}
189192

190193
// bool
191194

192195
@Specialization(guards = "function != null", rewriteOn = UnexpectedResultException.class)
193-
boolean callBool(VirtualFrame frame, boolean receiver,
196+
static boolean callBool(VirtualFrame frame, boolean receiver,
194197
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) throws UnexpectedResultException {
195198
return function.executeBool(frame, receiver);
196199
}
197200

198201
@Specialization(guards = "function != null")
199-
Object callObject(VirtualFrame frame, boolean receiver,
202+
static Object callObject(VirtualFrame frame, boolean receiver,
200203
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) {
201204
return function.execute(frame, receiver);
202205
}
203206

204207
// PNone
205208

206209
@Specialization(guards = "function != null")
207-
Object callObject(VirtualFrame frame, PNone receiver,
210+
static Object callObject(VirtualFrame frame, PNone receiver,
208211
@Cached("getBuiltin(receiver)") PythonUnaryBuiltinNode function) {
209212
return function.execute(frame, receiver);
210213
}
211214

212215
// Object
213216

214-
@Specialization(limit = "3")
217+
@Specialization
215218
Object callObject(VirtualFrame frame, Object receiver,
216219
@CachedLibrary("receiver") PythonObjectLibrary lib,
217220
@Cached("create(name, ignoreDescriptorException)") LookupSpecialMethodNode getattr,
@@ -236,7 +239,7 @@ public abstract static class LookupAndCallUnaryDynamicNode extends PNodeWithCont
236239

237240
public abstract Object executeObject(Object receiver, String name);
238241

239-
@Specialization(limit = "3")
242+
@Specialization(limit = "2")
240243
static Object doObject(Object receiver, String name,
241244
@CachedLibrary("receiver") PythonObjectLibrary lib,
242245
@Cached LookupSpecialMethodNode.Dynamic getattr,

0 commit comments

Comments
 (0)