|
42 | 42 |
|
43 | 43 | import com.oracle.graal.python.builtins.objects.PNone; |
44 | 44 | import com.oracle.graal.python.builtins.objects.PNotImplemented; |
| 45 | +import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary; |
45 | 46 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode; |
46 | 47 | import com.oracle.graal.python.nodes.PNodeWithContext; |
47 | 48 | import com.oracle.graal.python.nodes.SpecialMethodNames; |
48 | 49 | import com.oracle.graal.python.nodes.classes.IsSubtypeNode; |
49 | 50 | import com.oracle.graal.python.nodes.object.GetClassNode; |
| 51 | +import com.oracle.graal.python.runtime.PythonOptions; |
50 | 52 | import com.oracle.graal.python.util.Supplier; |
51 | 53 | import com.oracle.truffle.api.CompilerDirectives; |
52 | 54 | import com.oracle.truffle.api.dsl.Cached; |
53 | 55 | import com.oracle.truffle.api.dsl.ImportStatic; |
54 | 56 | import com.oracle.truffle.api.dsl.Specialization; |
55 | 57 | import com.oracle.truffle.api.frame.VirtualFrame; |
| 58 | +import com.oracle.truffle.api.library.CachedLibrary; |
56 | 59 | import com.oracle.truffle.api.nodes.Node; |
57 | 60 | import com.oracle.truffle.api.profiles.BranchProfile; |
58 | 61 |
|
59 | 62 | // cpython://Objects/abstract.c#ternary_op |
60 | 63 | // Order operations are tried until either a valid result or error: v.op(v,w,z), w.op(v,w,z), z.op(v,w,z) |
61 | | -@ImportStatic({SpecialMethodNames.class}) |
| 64 | +@ImportStatic({SpecialMethodNames.class, PythonOptions.class}) |
62 | 65 | public abstract class LookupAndCallTernaryNode extends Node { |
63 | 66 | public abstract static class NotImplementedHandler extends PNodeWithContext { |
64 | 67 | public abstract Object execute(Object arg, Object arg2, Object arg3); |
@@ -100,26 +103,30 @@ protected boolean isReversible() { |
100 | 103 | return isReversible; |
101 | 104 | } |
102 | 105 |
|
103 | | - @Specialization(guards = "!isReversible()") |
| 106 | + @Specialization(guards = "!isReversible()", limit = "getCallSiteInlineCacheMaxDepth()") |
104 | 107 | Object callObject( |
105 | 108 | VirtualFrame frame, |
106 | 109 | Object arg1, |
107 | 110 | int arg2, |
108 | 111 | Object arg3, |
109 | | - @Cached("create()") GetClassNode getclass, |
110 | | - @Cached("create(__GETATTRIBUTE__)") LookupAndCallBinaryNode getattr) { |
111 | | - return dispatchNode.execute(frame, getattr.executeObject(frame, getclass.execute(arg1), name), arg1, arg2, arg3); |
| 112 | + @CachedLibrary("arg1") PythonObjectLibrary libArg1, |
| 113 | + @Cached("create(name, ignoreDescriptorException)") LookupSpecialMethodNode getattr) { |
| 114 | + Object klass = libArg1.getLazyPythonClass(arg1); |
| 115 | + Object value = libArg1.getDelegatedValue(arg1); |
| 116 | + return dispatchNode.execute(frame, getattr.execute(frame, klass, value), value, arg2, arg3); |
112 | 117 | } |
113 | 118 |
|
114 | | - @Specialization(guards = "!isReversible()") |
| 119 | + @Specialization(guards = "!isReversible()", limit = "getCallSiteInlineCacheMaxDepth()") |
115 | 120 | Object callObject( |
116 | 121 | VirtualFrame frame, |
117 | 122 | Object arg1, |
118 | 123 | Object arg2, |
119 | 124 | Object arg3, |
120 | | - @Cached("create()") GetClassNode getclass, |
121 | | - @Cached("create(__GETATTRIBUTE__)") LookupAndCallBinaryNode getattr) { |
122 | | - return dispatchNode.execute(frame, getattr.executeObject(frame, getclass.execute(arg1), name), arg1, arg2, arg3); |
| 125 | + @CachedLibrary("arg1") PythonObjectLibrary libArg1, |
| 126 | + @Cached("create(name, ignoreDescriptorException)") LookupSpecialMethodNode getattr) { |
| 127 | + Object klass = libArg1.getLazyPythonClass(arg1); |
| 128 | + Object value = libArg1.getDelegatedValue(arg1); |
| 129 | + return dispatchNode.execute(frame, getattr.execute(frame, klass, value), value, arg2, arg3); |
123 | 130 | } |
124 | 131 |
|
125 | 132 | private CallTernaryMethodNode ensureReverseDispatch() { |
|
0 commit comments