99
99
import com .oracle .graal .python .nodes .function .builtins .clinic .ArgumentClinicProvider ;
100
100
import com .oracle .graal .python .nodes .object .BuiltinClassProfiles .IsBuiltinObjectProfile ;
101
101
import 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 ;
104
102
import com .oracle .graal .python .nodes .util .CannotCastException ;
105
103
import com .oracle .graal .python .nodes .util .CastToTruffleStringNode ;
106
104
import com .oracle .graal .python .runtime .PythonContext ;
@@ -141,8 +139,7 @@ public abstract static class ModuleNewNode extends PythonBuiltinNode {
141
139
142
140
@ Specialization
143
141
@ 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 ,
146
143
@ Bind PythonLanguage language ,
147
144
@ Cached TypeNodes .GetInstanceShape getInstanceShape ) {
148
145
return PFactory .createPythonModule (language , cls , getInstanceShape .execute (cls ));
@@ -161,15 +158,12 @@ protected ArgumentClinicProvider getArgumentClinic() {
161
158
162
159
@ Specialization
163
160
public PNone module (PythonModule self , TruffleString name , Object doc ,
164
- @ Bind Node inliningTarget ,
165
161
@ Cached WriteAttributeToObjectNode writeName ,
166
162
@ Cached WriteAttributeToObjectNode writeDoc ,
167
163
@ Cached WriteAttributeToObjectNode writePackage ,
168
164
@ 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" ;
173
167
174
168
// init
175
169
writeName .execute (self , T___NAME__ , name );
@@ -216,19 +210,14 @@ public abstract static class ModuleDictNode extends PythonBinaryBuiltinNode {
216
210
217
211
@ Specialization (guards = "isNoValue(none)" )
218
212
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 ) {
222
214
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" ;
226
216
return dict ;
227
217
}
228
218
229
219
@ Specialization (guards = "isNoValue(none)" )
230
220
static Object doNativeObject (PythonAbstractNativeObject self , @ SuppressWarnings ("unused" ) PNone none ,
231
- @ Bind Node inliningTarget ,
232
221
@ Exclusive @ Cached GetDictIfExistsNode getDict ,
233
222
@ Cached PRaiseNode raiseNode ) {
234
223
PDict dict = getDict .execute (self );
@@ -243,12 +232,6 @@ static Object doError(Object self, @SuppressWarnings("unused") Object dict,
243
232
@ Bind Node inliningTarget ) {
244
233
throw PRaiseNode .raiseStatic (inliningTarget , PythonBuiltinClassType .TypeError , ErrorMessages .DESCRIPTOR_DICT_FOR_MOD_OBJ_DOES_NOT_APPLY_FOR_P , self );
245
234
}
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
- }
252
235
}
253
236
254
237
@ Slot (value = SlotKind .tp_getattro , isComplex = true )
0 commit comments