Skip to content

Commit 72b6c3c

Browse files
committed
user subclasses are heaptypes. use a basic way to check this
1 parent 9469aed commit 72b6c3c

File tree

1 file changed

+8
-3
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
public abstract class TypeNodes {
103103

104104
public abstract static class GetTypeFlagsNode extends PNodeWithContext {
105+
private static final int HEAPTYPE = 1 << 9;
105106

106107
public abstract long execute(PythonAbstractClass clazz);
107108

@@ -113,7 +114,7 @@ long doInitialized(PythonManagedClass clazz) {
113114
@Specialization
114115
long doGeneric(PythonManagedClass clazz) {
115116
if (!isInitialized(clazz)) {
116-
return getValue(clazz.getFlagsContainer());
117+
return getValue(clazz, clazz.getFlagsContainer());
117118
}
118119
return clazz.getFlagsContainer().flags;
119120
}
@@ -125,12 +126,16 @@ long doNative(PythonNativeClass clazz,
125126
}
126127

127128
@TruffleBoundary
128-
private static long getValue(FlagsContainer fc) {
129+
private static long getValue(PythonManagedClass clazz, FlagsContainer fc) {
129130
// This method is only called from C code, i.e., the flags of the initial super class
130131
// must be available.
131132
if (fc.initialDominantBase != null) {
132133
fc.flags = doSlowPath(fc.initialDominantBase);
133134
fc.initialDominantBase = null;
135+
if (clazz instanceof PythonClass) {
136+
// user classes are heap types
137+
fc.flags |= HEAPTYPE;
138+
}
134139
}
135140
return fc.flags;
136141
}
@@ -142,7 +147,7 @@ public static long doSlowPath(PythonAbstractClass clazz) {
142147
if (isInitialized(mclazz)) {
143148
return mclazz.getFlagsContainer().flags;
144149
} else {
145-
return getValue(mclazz.getFlagsContainer());
150+
return getValue(mclazz, mclazz.getFlagsContainer());
146151
}
147152
} else if (PGuards.isNativeClass(clazz)) {
148153
return doNativeGeneric((PythonNativeClass) clazz, createReadNode());

0 commit comments

Comments
 (0)