Skip to content

Commit 4ff5117

Browse files
committed
Add profile to GetMroSequenceStorageNode.
1 parent c0476bc commit 4ff5117

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
import com.oracle.truffle.api.nodes.ControlFlowException;
100100
import com.oracle.truffle.api.nodes.Node;
101101
import com.oracle.truffle.api.object.Shape;
102+
import com.oracle.truffle.api.profiles.ConditionProfile;
102103
import com.oracle.truffle.api.profiles.ValueProfile;
103104
import com.oracle.truffle.llvm.spi.ReferenceLibrary;
104105

@@ -210,24 +211,25 @@ public abstract static class GetMroStorageNode extends PNodeWithContext {
210211
public abstract MroSequenceStorage execute(Object obj);
211212

212213
@Specialization
213-
MroSequenceStorage doPythonClass(PythonManagedClass obj) {
214+
static MroSequenceStorage doPythonClass(PythonManagedClass obj) {
214215
return obj.getMethodResolutionOrder();
215216
}
216217

217218
@Specialization
218-
MroSequenceStorage doBuiltinClass(PythonBuiltinClassType obj,
219+
static MroSequenceStorage doBuiltinClass(PythonBuiltinClassType obj,
219220
@CachedContext(PythonLanguage.class) PythonContext context) {
220221
return context.getCore().lookupType(obj).getMethodResolutionOrder();
221222
}
222223

223224
@Specialization
224-
MroSequenceStorage doNativeClass(PythonNativeClass obj,
225+
static MroSequenceStorage doNativeClass(PythonNativeClass obj,
225226
@Cached GetTypeMemberNode getTpMroNode,
226227
@Cached PRaiseNode raise,
228+
@Cached("createBinaryProfile()") ConditionProfile lazyTypeInitProfile,
227229
@Cached("createClassProfile()") ValueProfile tpMroProfile,
228-
@Cached("createClassProfile()") ValueProfile storageProfile) {
230+
@Cached("createIdentityProfile()") ValueProfile storageProfile) {
229231
Object tupleObj = getTpMroNode.execute(obj, NativeMember.TP_MRO);
230-
if (tupleObj == PNone.NO_VALUE) {
232+
if (lazyTypeInitProfile.profile(tupleObj == PNone.NO_VALUE)) {
231233
// Special case: lazy type initialization (should happen at most only once per type)
232234
CompilerDirectives.transferToInterpreter();
233235

@@ -242,7 +244,7 @@ MroSequenceStorage doNativeClass(PythonNativeClass obj,
242244
}
243245
Object profiled = tpMroProfile.profile(tupleObj);
244246
if (profiled instanceof PTuple) {
245-
SequenceStorage sequenceStorage = storageProfile.profile(((PTuple) tupleObj).getSequenceStorage());
247+
SequenceStorage sequenceStorage = storageProfile.profile(((PTuple) profiled).getSequenceStorage());
246248
if (sequenceStorage instanceof MroSequenceStorage) {
247249
return (MroSequenceStorage) sequenceStorage;
248250
}

0 commit comments

Comments
 (0)