10000 Support calling PyType_Modified on any Python class · oracle/graalpython@11936fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 11936fb

Browse files
timfelelkorchi
authored andcommitted
Support calling PyType_Modified on any Python class
(cherry picked from commit cef2e89)
1 parent 10573cb commit 11936fb

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,24 @@ static Object doIt(PythonAbstractNativeObject clazz,
228228

229229
@CApiBuiltin(ret = ArgDescriptor.Void, args = {PyTypeObject}, call = Direct)
230230
abstract static class PyType_Modified extends CApiUnaryBuiltinNode {
231-
232231
@TruffleBoundary
233232
@Specialization
234-
static Object doIt(PythonAbstractNativeObject clazz,
233+
static Object doIt(PythonAbstractClass object,
235234
@Bind("this") Node inliningTarget) {
236-
PythonContext context = PythonContext.get(inliningTarget);
237-
CyclicAssumption nativeClassStableAssumption = context.getNativeClassStableAssumption(clazz, false);
238-
if (nativeClassStableAssumption != null) {
239-
nativeClassStableAssumption.invalidate("PyType_Modified(\"" + TypeNodes.GetNameNode.executeUncached(clazz).toJavaStringUncached() + "\") called");
235+
if (object instanceof PythonAbstractNativeObject clazz) {
236+
PythonContext context = PythonContext.get(inliningTarget);
237+
CyclicAssumption nativeClassStableAssumption = context.getNativeClassStableAssumption(clazz, false);
238+
if (nativeClassStableAssumption != null) {
239+
nativeClassStableAssumption.invalidate("PyType_Modified(\"" + TypeNodes.GetNameNode.executeUncached(clazz).toJavaStringUncached() + "\") called");
240+
}
241+
MroSequenceStorage mroStorage = TypeNodes.GetMroStorageNode.executeUncached(clazz);
242+
mroStorage.lookupChanged();
243+
// Reload slots from native, which also invalidates cached slot lookups
244+
clazz.setTpSlots(TpSlots.fromNative(clazz, context));
245+
} else {
246+
MroSequenceStorage mroStorage = TypeNodes.GetMroStorageNode.executeUncached(object);
247+
mroStorage.lookupChanged();
240248
}
241-
MroSequenceStorage mroStorage = TypeNodes.GetMroStorageNode.executeUncached(clazz);
242-
mroStorage.lookupChanged();
243-
// Reload slots from native, which also invalidates cached slot lookups
244-
clazz.setTpSlots(TpSlots.fromNative(clazz, context));
245249
return PNone.NO_VALUE;
246250
}
247251
}

0 commit comments

Comments
 (0)
3085
0