Skip to content

Commit edbf8ab

Browse files
committed
adapt GetAttributeNode builtin to the new builtin LazyPythonClass mechanism
1 parent 715931a commit edbf8ab

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
8282
import com.oracle.graal.python.nodes.object.GetClassNode;
8383
import com.oracle.graal.python.nodes.object.GetLazyClassNode;
84+
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
8485
import com.oracle.truffle.api.CompilerDirectives;
8586
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
8687
import com.oracle.truffle.api.dsl.Cached;
@@ -478,8 +479,10 @@ protected PNone doIt(Object object, Object key,
478479
@Builtin(name = __DICT__, minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2, isGetter = true, isSetter = true)
479480
@GenerateNodeFactory
480481
static abstract class DictNode extends PythonBinaryBuiltinNode {
482+
private final IsBuiltinClassProfile isBuiltinClassProfile = IsBuiltinClassProfile.create();
483+
481484
protected boolean isExactObjectInstance(PythonObject self) {
482-
return lookupClass(PythonBuiltinClassType.PythonObject) == self.getPythonClass();
485+
return isBuiltinClassProfile.profileObject(self, PythonBuiltinClassType.PythonObject);
483486
}
484487

485488
@SuppressWarnings("unused")

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
4848
import com.oracle.graal.python.nodes.expression.ExpressionNode;
4949
import com.oracle.graal.python.nodes.frame.ReadNode;
50+
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
5051
import com.oracle.graal.python.nodes.statement.StatementNode;
5152
import com.oracle.graal.python.runtime.exception.PException;
5253
import com.oracle.truffle.api.CompilerDirectives;
@@ -63,7 +64,7 @@ public abstract class GetAttributeNode extends ExpressionNode implements ReadNod
6364

6465
@Child LookupAndCallBinaryNode dispatchNode = LookupAndCallBinaryNode.create(__GETATTRIBUTE__);
6566
@Child LookupAndCallBinaryNode dispatchGetAttr;
66-
@CompilationFinal private ConditionProfile errorProfile = ConditionProfile.createBinaryProfile();
67+
@CompilationFinal private IsBuiltinClassProfile isBuiltinClassProfile = IsBuiltinClassProfile.create();
6768

6869
protected GetAttributeNode(String key) {
6970
this.key = key;
@@ -88,7 +89,7 @@ protected int doItInt(Object object) throws UnexpectedResultException {
8889
try {
8990
return dispatchNode.executeInt(object, key);
9091
} catch (PException pe) {
91-
pe.expect(AttributeError, getCore(), errorProfile);
92+
pe.expect(AttributeError, isBuiltinClassProfile);
9293
return getDispatchGetAttr().executeInt(object, key);
9394
}
9495
}
@@ -98,7 +99,7 @@ protected boolean doItBoolean(Object object) throws UnexpectedResultException {
9899
try {
99100
return dispatchNode.executeBool(object, key);
100101
} catch (PException pe) {
101-
pe.expect(AttributeError, getCore(), errorProfile);
102+
pe.expect(AttributeError, isBuiltinClassProfile);
102103
return getDispatchGetAttr().executeBool(object, key);
103104
}
104105
}
@@ -108,7 +109,7 @@ protected Object doIt(Object object) {
108109
try {
109110
return dispatchNode.executeObject(object, key);
110111
} catch (PException pe) {
111-
pe.expect(AttributeError, getCore(), errorProfile);
112+
pe.expect(AttributeError, isBuiltinClassProfile);
112113
return getDispatchGetAttr().executeObject(object, key);
113114
}
114115
}

0 commit comments

Comments
 (0)