Skip to content

Commit 8b7de23

Browse files
committed
use LookupSpecialMethodNode in GetAttributeNode
1 parent 4c7453f commit 8b7de23

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/GetAttributeNode.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@
4545
import static com.oracle.graal.python.runtime.exception.PythonErrorType.AttributeError;
4646

4747
import com.oracle.graal.python.builtins.objects.PNone;
48+
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
4849
import com.oracle.graal.python.nodes.attributes.GetAttributeNodeGen.GetAnyAttributeNodeGen;
4950
import com.oracle.graal.python.nodes.attributes.GetAttributeNodeGen.GetFixedAttributeNodeGen;
5051
import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
5152
import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
53+
import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodNode;
5254
import com.oracle.graal.python.nodes.expression.ExpressionNode;
5355
import com.oracle.graal.python.nodes.frame.ReadNode;
5456
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
@@ -113,40 +115,41 @@ public final StatementNode makeWriteNode(ExpressionNode rhs) {
113115

114116
abstract static class GetAttributeBaseNode extends Node {
115117

116-
@Child private LookupInheritedAttributeNode lookupGetattrNode;
118+
@Child private LookupSpecialMethodNode lookupGetattrNode;
117119
@Child private CallBinaryMethodNode callBinaryMethodNode;
120+
@Child private PythonObjectLibrary lib = PythonObjectLibrary.getFactory().createDispatched(1);
118121

119122
@CompilationFinal private ConditionProfile hasGetattrProfile;
120123

121124
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);
123126
}
124127

125128
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);
127130
}
128131

129132
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);
131134
}
132135

133136
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);
135138
}
136139

137140
/** 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);
140143
if (ensureHasGetattrProfile().profile(getattrAttribute == PNone.NO_VALUE)) {
141144
throw pe;
142145
}
143146
return getattrAttribute;
144147
}
145148

146-
private LookupInheritedAttributeNode ensureLookupGetattrNode() {
149+
private LookupSpecialMethodNode ensureLookupGetattrNode() {
147150
if (lookupGetattrNode == null) {
148151
CompilerDirectives.transferToInterpreterAndInvalidate();
149-
lookupGetattrNode = insert(LookupInheritedAttributeNode.create(__GETATTR__));
152+
lookupGetattrNode = insert(LookupSpecialMethodNode.create(__GETATTR__));
150153
}
151154
return lookupGetattrNode;
152155
}

0 commit comments

Comments
 (0)