|
87 | 87 | import com.oracle.graal.python.builtins.objects.common.PHashingCollection;
|
88 | 88 | import com.oracle.graal.python.builtins.objects.common.SequenceNodes.GetObjectArrayNode;
|
89 | 89 | import com.oracle.graal.python.builtins.objects.common.SequenceNodesFactory.GetObjectArrayNodeGen;
|
| 90 | +import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; |
90 | 91 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.GetInternalObjectArrayNode;
|
91 | 92 | import com.oracle.graal.python.builtins.objects.dict.PDict;
|
92 | 93 | import com.oracle.graal.python.builtins.objects.function.PFunction;
|
|
126 | 127 | import com.oracle.truffle.api.CompilerDirectives;
|
127 | 128 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
128 | 129 | import com.oracle.truffle.api.dsl.Cached;
|
| 130 | +import com.oracle.truffle.api.dsl.Cached.Shared; |
129 | 131 | import com.oracle.truffle.api.dsl.CachedContext;
|
130 | 132 | import com.oracle.truffle.api.dsl.Fallback;
|
131 | 133 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
@@ -224,16 +226,36 @@ static long doBuiltinClass(PythonBuiltinClass clazz) {
|
224 | 226 | }
|
225 | 227 |
|
226 | 228 | @Specialization
|
227 |
| - static long doOther(PythonClass clazz) { |
| 229 | + static long doPythonClass(PythonClass clazz, |
| 230 | + @Cached GetMroStorageNode getMroStorageNode, |
| 231 | + @Cached SequenceStorageNodes.LenNode lenNode, |
| 232 | + @Cached SequenceStorageNodes.GetItemDynamicNode getItemNode, |
| 233 | + @Shared("getTpFlagsNode") @Cached CExtNodes.GetTypeMemberNode getTpFlagsNode) { |
| 234 | + |
228 | 235 | // according to 'type_new' in 'typeobject.c', all have DEFAULT, HEAPTYPE, and BASETYPE.
|
229 | 236 | // The HAVE_GC is inherited. But we do not mimic this behavior in every detail, so it
|
230 | 237 | // should be fine to just set it.
|
231 |
| - return DEFAULT | HEAPTYPE | BASETYPE | HAVE_GC; |
| 238 | + long result = DEFAULT | HEAPTYPE | BASETYPE | HAVE_GC; |
| 239 | + |
| 240 | + // flags are inherited |
| 241 | + MroSequenceStorage mroStorage = getMroStorageNode.execute(clazz); |
| 242 | + int n = lenNode.execute(mroStorage); |
| 243 | + for (int i = 0; i < n; i++) { |
| 244 | + Object mroEntry = getItemNode.execute(mroStorage, i); |
| 245 | + if (mroEntry instanceof PythonBuiltinClass) { |
| 246 | + result |= doBuiltinClass((PythonBuiltinClass) mroEntry); |
| 247 | + } else if (mroEntry instanceof PythonBuiltinClassType) { |
| 248 | + result |= doBuiltinClassType((PythonBuiltinClassType) mroEntry); |
| 249 | + } else if (mroEntry instanceof PythonAbstractNativeObject) { |
| 250 | + result |= doNative((PythonAbstractNativeObject) mroEntry, CExtNodes.GetTypeMemberNode.getUncached()); |
| 251 | + } |
| 252 | + } |
| 253 | + return result; |
232 | 254 | }
|
233 | 255 |
|
234 | 256 | @Specialization
|
235 | 257 | static long doNative(PythonNativeClass clazz,
|
236 |
| - @Cached CExtNodes.GetTypeMemberNode getTpFlagsNode) { |
| 258 | + @Shared("getTpFlagsNode") @Cached CExtNodes.GetTypeMemberNode getTpFlagsNode) { |
237 | 259 | return (long) getTpFlagsNode.execute(clazz, NativeMember.TP_FLAGS);
|
238 | 260 | }
|
239 | 261 | }
|
|
0 commit comments