103103import com .oracle .graal .python .nodes .attributes .WriteAttributeToPythonObjectNode ;
104104import com .oracle .graal .python .nodes .object .GetDictIfExistsNode ;
105105import com .oracle .graal .python .nodes .util .CastToTruffleStringNode ;
106+ import com .oracle .graal .python .runtime .PythonContext ;
106107import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
107108import com .oracle .graal .python .runtime .sequence .storage .MroSequenceStorage ;
108109import com .oracle .graal .python .runtime .sequence .storage .SequenceStorage ;
127128import com .oracle .truffle .api .object .DynamicObject ;
128129import com .oracle .truffle .api .object .DynamicObjectLibrary ;
129130import com .oracle .truffle .api .object .Shape ;
130- import com .oracle .truffle .api .profiles .InlinedExactClassProfile ;
131131import com .oracle .truffle .api .strings .TruffleString ;
132132import com .oracle .truffle .api .utilities .CyclicAssumption ;
133133
@@ -222,12 +222,14 @@ abstract static class PyTruffle_Type_Modified extends CApiTernaryBuiltinNode {
222222
223223 @ TruffleBoundary
224224 @ Specialization (guards = "isNoValue(mroTuple)" )
225- int doIt (PythonNativeClass clazz , TruffleString name , @ SuppressWarnings ("unused" ) PNone mroTuple ) {
226- CyclicAssumption nativeClassStableAssumption = getContext ().getNativeClassStableAssumption (clazz , false );
225+ static int doIt (PythonAbstractNativeObject clazz , TruffleString name , @ SuppressWarnings ("unused" ) PNone mroTuple ,
226+ @ Bind ("this" ) Node inliningTarget ) {
227+ PythonContext context = PythonContext .get (inliningTarget );
228+ CyclicAssumption nativeClassStableAssumption = context .getNativeClassStableAssumption (clazz , false );
227229 if (nativeClassStableAssumption != null ) {
228230 nativeClassStableAssumption .invalidate ("PyType_Modified(\" " + name .toJavaStringUncached () + "\" ) (without MRO) called" );
229231 }
230- SpecialMethodSlot .reinitializeSpecialMethodSlots (PythonNativeClass . cast ( clazz ), getLanguage ());
232+ SpecialMethodSlot .reinitializeSpecialMethodSlots (clazz , context . getLanguage ());
231233 // TODO: this is called from two places: at the end of PyType_Ready, and theoretically
232234 // could be called from:
233235 //
@@ -243,22 +245,22 @@ int doIt(PythonNativeClass clazz, TruffleString name, @SuppressWarnings("unused"
243245
244246 @ TruffleBoundary
245247 @ Specialization
246- int doIt (PythonNativeClass clazz , TruffleString name , PTuple mroTuple ,
247- @ Bind ("this" ) Node inliningTarget ,
248- @ Cached InlinedExactClassProfile profile ) {
249- CyclicAssumption nativeClassStableAssumption = getContext () .getNativeClassStableAssumption (clazz , false );
248+ static int doIt (PythonAbstractNativeObject clazz , TruffleString name , PTuple mroTuple ,
249+ @ Bind ("this" ) Node inliningTarget ) {
250+ PythonContext context = PythonContext . get ( inliningTarget );
251+ CyclicAssumption nativeClassStableAssumption = context .getNativeClassStableAssumption (clazz , false );
250252 if (nativeClassStableAssumption != null ) {
251253 nativeClassStableAssumption .invalidate ("PyType_Modified(\" " + name .toJavaStringUncached () + "\" ) called" );
252254 }
253- SequenceStorage sequenceStorage = profile . profile ( inliningTarget , mroTuple .getSequenceStorage () );
255+ SequenceStorage sequenceStorage = mroTuple .getSequenceStorage ();
254256 if (sequenceStorage instanceof MroSequenceStorage ) {
255257 ((MroSequenceStorage ) sequenceStorage ).lookupChanged ();
256258 } else {
257259 CompilerDirectives .transferToInterpreterAndInvalidate ();
258260 throw new IllegalStateException ("invalid MRO object for native type \" " + name .toJavaStringUncached () + "\" " );
259261 }
260- SpecialMethodSlot .reinitializeSpecialMethodSlots (PythonNativeClass .cast (clazz ), getLanguage ());
261- TpSlots .updateAllSlots (clazz );
262+ SpecialMethodSlot .reinitializeSpecialMethodSlots (PythonNativeClass .cast (clazz ), context . getLanguage ());
263+ clazz . setTpSlots ( TpSlots .fromNative (clazz , context ) );
262264 return 0 ;
263265 }
264266 }
0 commit comments