Skip to content

Commit 0809939

Browse files
committed
Add fast-path for slot lookup in LookupAndCallBinaryNode#getBinaryBuiltin
1 parent 9113932 commit 0809939

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@
4747
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
4848
import com.oracle.graal.python.builtins.objects.PNone;
4949
import com.oracle.graal.python.builtins.objects.PNotImplemented;
50+
import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor.BinaryBuiltinDescriptor;
5051
import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
5152
import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod;
5253
import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
54+
import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
5355
import com.oracle.graal.python.builtins.objects.type.TypeNodes;
5456
import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode;
5557
import com.oracle.graal.python.nodes.ErrorMessages;
@@ -174,6 +176,15 @@ private CallBinaryMethodNode ensureReverseDispatch() {
174176
}
175177

176178
protected final PythonBinaryBuiltinNode getBinaryBuiltin(PythonBuiltinClassType clazz) {
179+
if (SpecialMethodSlot.canBeSpecial(name)) {
180+
SpecialMethodSlot slot = SpecialMethodSlot.findSpecialSlot(name);
181+
if (slot != null) {
182+
Object attribute = slot.getValue(clazz);
183+
if (attribute instanceof BinaryBuiltinDescriptor) {
184+
return ((BinaryBuiltinDescriptor) attribute).createNode();
185+
}
186+
}
187+
}
177188
Object attribute = LookupAttributeInMRONode.Dynamic.getUncached().execute(clazz, name);
178189
if (attribute instanceof PBuiltinFunction) {
179190
PBuiltinFunction builtinFunction = (PBuiltinFunction) attribute;

0 commit comments

Comments
 (0)