|
45 | 45 | import static com.oracle.graal.python.runtime.exception.PythonErrorType.AttributeError;
|
46 | 46 |
|
47 | 47 | import com.oracle.graal.python.builtins.objects.PNone;
|
| 48 | +import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary; |
48 | 49 | import com.oracle.graal.python.nodes.attributes.GetAttributeNodeGen.GetAnyAttributeNodeGen;
|
49 | 50 | import com.oracle.graal.python.nodes.attributes.GetAttributeNodeGen.GetFixedAttributeNodeGen;
|
50 | 51 | import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
|
51 | 52 | import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
|
| 53 | +import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodNode; |
52 | 54 | import com.oracle.graal.python.nodes.expression.ExpressionNode;
|
53 | 55 | import com.oracle.graal.python.nodes.frame.ReadNode;
|
54 | 56 | import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
|
@@ -113,40 +115,41 @@ public final StatementNode makeWriteNode(ExpressionNode rhs) {
|
113 | 115 |
|
114 | 116 | abstract static class GetAttributeBaseNode extends Node {
|
115 | 117 |
|
116 |
| - @Child private LookupInheritedAttributeNode lookupGetattrNode; |
| 118 | + @Child private LookupSpecialMethodNode lookupGetattrNode; |
117 | 119 | @Child private CallBinaryMethodNode callBinaryMethodNode;
|
| 120 | + @Child private PythonObjectLibrary lib = PythonObjectLibrary.getFactory().createDispatched(1); |
118 | 121 |
|
119 | 122 | @CompilationFinal private ConditionProfile hasGetattrProfile;
|
120 | 123 |
|
121 | 124 | int dispatchGetAttrOrRethrowInt(VirtualFrame frame, Object object, Object key, PException pe) throws UnexpectedResultException {
|
122 |
| - return ensureCallGetattrNode().executeInt(frame, lookupGetattrOrRethrow(object, pe), object, key); |
| 125 | + return ensureCallGetattrNode().executeInt(frame, lookupGetattrOrRethrow(frame, object, pe), object, key); |
123 | 126 | }
|
124 | 127 |
|
125 | 128 | long dispatchGetAttrOrRethrowLong(VirtualFrame frame, Object object, Object key, PException pe) throws UnexpectedResultException {
|
126 |
| - return ensureCallGetattrNode().executeLong(frame, lookupGetattrOrRethrow(object, pe), object, key); |
| 129 | + return ensureCallGetattrNode().executeLong(frame, lookupGetattrOrRethrow(frame, object, pe), object, key); |
127 | 130 | }
|
128 | 131 |
|
129 | 132 | boolean dispatchGetAttrOrRethrowBool(VirtualFrame frame, Object object, Object key, PException pe) throws UnexpectedResultException {
|
130 |
| - return ensureCallGetattrNode().executeBool(frame, lookupGetattrOrRethrow(object, pe), object, key); |
| 133 | + return ensureCallGetattrNode().executeBool(frame, lookupGetattrOrRethrow(frame, object, pe), object, key); |
131 | 134 | }
|
132 | 135 |
|
133 | 136 | Object dispatchGetAttrOrRethrowObject(VirtualFrame frame, Object object, Object key, PException pe) {
|
134 |
| - return ensureCallGetattrNode().executeObject(frame, lookupGetattrOrRethrow(object, pe), object, key); |
| 137 | + return ensureCallGetattrNode().executeObject(frame, lookupGetattrOrRethrow(frame, object, pe), object, key); |
135 | 138 | }
|
136 | 139 |
|
137 | 140 | /** Lookup {@code __getattr__} or rethrow {@code pe} if it does not exist. */
|
138 |
| - private Object lookupGetattrOrRethrow(Object object, PException pe) { |
139 |
| - Object getattrAttribute = ensureLookupGetattrNode().execute(object); |
| 141 | + private Object lookupGetattrOrRethrow(VirtualFrame frame, Object object, PException pe) { |
| 142 | + Object getattrAttribute = ensureLookupGetattrNode().execute(frame, lib.getLazyPythonClass(object), object); |
140 | 143 | if (ensureHasGetattrProfile().profile(getattrAttribute == PNone.NO_VALUE)) {
|
141 | 144 | throw pe;
|
142 | 145 | }
|
143 | 146 | return getattrAttribute;
|
144 | 147 | }
|
145 | 148 |
|
146 |
| - private LookupInheritedAttributeNode ensureLookupGetattrNode() { |
| 149 | + private LookupSpecialMethodNode ensureLookupGetattrNode() { |
147 | 150 | if (lookupGetattrNode == null) {
|
148 | 151 | CompilerDirectives.transferToInterpreterAndInvalidate();
|
149 |
| - lookupGetattrNode = insert(LookupInheritedAttributeNode.create(__GETATTR__)); |
| 152 | + lookupGetattrNode = insert(LookupSpecialMethodNode.create(__GETATTR__)); |
150 | 153 | }
|
151 | 154 | return lookupGetattrNode;
|
152 | 155 | }
|
|
0 commit comments