9999import com .oracle .graal .python .nodes .function .builtins .clinic .ArgumentClinicProvider ;
100100import com .oracle .graal .python .nodes .object .BuiltinClassProfiles .IsBuiltinObjectProfile ;
101101import com .oracle .graal .python .nodes .object .GetDictIfExistsNode ;
102- import com .oracle .graal .python .nodes .object .GetOrCreateDictNode ;
103- import com .oracle .graal .python .nodes .object .SetDictNode ;
104102import com .oracle .graal .python .nodes .util .CannotCastException ;
105103import com .oracle .graal .python .nodes .util .CastToTruffleStringNode ;
106104import com .oracle .graal .python .runtime .PythonContext ;
@@ -141,8 +139,7 @@ public abstract static class ModuleNewNode extends PythonBuiltinNode {
141139
142140 @ Specialization
143141 @ SuppressWarnings ("unused" )
144- static Object doGeneric (Object cls , Object [] varargs , PKeyword [] kwargs ,
145- @ Bind Node inliningTarget ,
142+ static PythonModule doGeneric (Object cls , Object [] varargs , PKeyword [] kwargs ,
146143 @ Bind PythonLanguage language ,
147144 @ Cached TypeNodes .GetInstanceShape getInstanceShape ) {
148145 return PFactory .createPythonModule (language , cls , getInstanceShape .execute (cls ));
@@ -161,15 +158,12 @@ protected ArgumentClinicProvider getArgumentClinic() {
161158
162159 @ Specialization
163160 public PNone module (PythonModule self , TruffleString name , Object doc ,
164- @ Bind Node inliningTarget ,
165161 @ Cached WriteAttributeToObjectNode writeName ,
166162 @ Cached WriteAttributeToObjectNode writeDoc ,
167163 @ Cached WriteAttributeToObjectNode writePackage ,
168164 @ Cached WriteAttributeToObjectNode writeLoader ,
169- @ Cached WriteAttributeToObjectNode writeSpec ,
170- @ Cached GetOrCreateDictNode getDict ) {
171- // create dict if missing
172- getDict .execute (inliningTarget , self );
165+ @ Cached WriteAttributeToObjectNode writeSpec ) {
166+ assert GetDictIfExistsNode .getUncached ().execute (self ) != null : "PythonModule always have a dict" ;
173167
174168 // init
175169 writeName .execute (self , T___NAME__ , name );
@@ -216,19 +210,14 @@ public abstract static class ModuleDictNode extends PythonBinaryBuiltinNode {
216210
217211 @ Specialization (guards = "isNoValue(none)" )
218212 static Object doManaged (PythonModule self , @ SuppressWarnings ("unused" ) PNone none ,
219- @ Bind Node inliningTarget ,
220- @ Exclusive @ Cached GetDictIfExistsNode getDict ,
221- @ Cached SetDictNode setDict ) {
213+ @ Exclusive @ Cached GetDictIfExistsNode getDict ) {
222214 PDict dict = getDict .execute (self );
223- if (dict == null ) {
224- dict = createDict (inliningTarget , self , setDict );
225- }
215+ assert dict != null : "PythonModule always have a dict" ;
226216 return dict ;
227217 }
228218
229219 @ Specialization (guards = "isNoValue(none)" )
230220 static Object doNativeObject (PythonAbstractNativeObject self , @ SuppressWarnings ("unused" ) PNone none ,
231- @ Bind Node inliningTarget ,
232221 @ Exclusive @ Cached GetDictIfExistsNode getDict ,
233222 @ Cached PRaiseNode raiseNode ) {
234223 PDict dict = getDict .execute (self );
@@ -243,12 +232,6 @@ static Object doError(Object self, @SuppressWarnings("unused") Object dict,
243232 @ Bind Node inliningTarget ) {
244233 throw PRaiseNode .raiseStatic (inliningTarget , PythonBuiltinClassType .TypeError , ErrorMessages .DESCRIPTOR_DICT_FOR_MOD_OBJ_DOES_NOT_APPLY_FOR_P , self );
245234 }
246-
247- private static PDict createDict (Node inliningTarget , PythonModule self , SetDictNode setDict ) {
248- PDict dict = PFactory .createDictFixedStorage (PythonLanguage .get (inliningTarget ), self );
249- setDict .execute (inliningTarget , self , dict );
250- return dict ;
251- }
252235 }
253236
254237 @ Slot (value = SlotKind .tp_getattro , isComplex = true )
0 commit comments