@@ -135,14 +135,16 @@ private HashingStorage.InitNode getInitNode() {
135
135
}
136
136
137
137
@ Specialization (guards = "args.length == 1" )
138
- Object doVarargs (VirtualFrame frame , PDict self , Object [] args , PKeyword [] kwargs ) {
139
- self .setDictStorage (getInitNode ().execute (frame , args [0 ], kwargs ));
138
+ Object doVarargs (VirtualFrame frame , PDict self , Object [] args , PKeyword [] kwargs ,
139
+ @ Cached SetDictStorageNode setStorage ) {
140
+ setStorage .execute (self , getInitNode ().execute (frame , args [0 ], kwargs ));
140
141
return PNone .NONE ;
141
142
}
142
143
143
144
@ Specialization (guards = "args.length == 0" )
144
- Object doKeywords (VirtualFrame frame , PDict self , @ SuppressWarnings ("unused" ) Object [] args , PKeyword [] kwargs ) {
145
- self .setDictStorage (getInitNode ().execute (frame , NO_VALUE , kwargs ));
145
+ Object doKeywords (VirtualFrame frame , PDict self , @ SuppressWarnings ("unused" ) Object [] args , PKeyword [] kwargs ,
146
+ @ Cached SetDictStorageNode setStorage ) {
147
+ setStorage .execute (self , getInitNode ().execute (frame , NO_VALUE , kwargs ));
146
148
return PNone .NONE ;
147
149
}
148
150
@@ -157,17 +159,19 @@ Object doGeneric(@SuppressWarnings("unused") PDict self, Object[] args, @Suppres
157
159
@ GenerateNodeFactory
158
160
public abstract static class SetDefaultNode extends PythonBuiltinNode {
159
161
160
- @ Specialization (guards = "lib.hasKeyWithFrame(dict.getDictStorage( ), key, hasFrame, frame)" , limit = "3" )
162
+ @ Specialization (guards = "lib.hasKeyWithFrame(getStorage.execute(dict ), key, hasFrame, frame)" , limit = "3" )
161
163
public Object setDefault (VirtualFrame frame , PDict dict , Object key , @ SuppressWarnings ("unused" ) Object defaultValue ,
162
164
@ SuppressWarnings ("unused" ) @ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
163
- @ CachedLibrary ("dict.getDictStorage()" ) HashingStorageLibrary lib ) {
164
- return lib .getItemWithFrame (dict .getDictStorage (), key , hasFrame , frame );
165
+ @ Cached GetDictStorageNode getStorage ,
166
+ @ CachedLibrary ("getStorage.execute(dict)" ) HashingStorageLibrary lib ) {
167
+ return lib .getItemWithFrame (getStorage .execute (dict ), key , hasFrame , frame );
165
168
}
166
169
167
- @ Specialization (guards = "!lib.hasKeyWithFrame(dict.getDictStorage( ), key, hasFrame, frame)" , limit = "3" )
170
+ @ Specialization (guards = "!lib.hasKeyWithFrame(getStorage.execute(dict ), key, hasFrame, frame)" , limit = "3" )
168
171
public Object setDefault (VirtualFrame frame , PDict dict , Object key , Object defaultValue ,
169
172
@ Cached ("create()" ) HashingCollectionNodes .SetItemNode setItemNode ,
170
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("dict.getDictStorage()" ) HashingStorageLibrary lib ,
173
+ @ SuppressWarnings ("unused" ) @ Cached GetDictStorageNode getStorage ,
174
+ @ SuppressWarnings ("unused" ) @ CachedLibrary ("getStorage.execute(dict)" ) HashingStorageLibrary lib ,
171
175
@ SuppressWarnings ("unused" ) @ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
172
176
@ Cached ("createBinaryProfile()" ) ConditionProfile defaultValProfile ) {
173
177
Object value = defaultValue ;
@@ -184,9 +188,8 @@ public Object setDefault(VirtualFrame frame, PDict dict, Object key, Object defa
184
188
@ GenerateNodeFactory
185
189
public abstract static class PopNode extends PythonTernaryBuiltinNode {
186
190
187
- protected void removeItem (VirtualFrame frame , PDict dict , Object key ,
188
- HashingStorageLibrary lib , ConditionProfile hasFrame , BranchProfile updatedStorage ) {
189
- HashingStorage storage = dict .getDictStorage ();
191
+ protected void removeItem (VirtualFrame frame , PDict dict , Object key , HashingStorage storage ,
192
+ HashingStorageLibrary lib , ConditionProfile hasFrame , BranchProfile updatedStorage , SetDictStorageNode setStorage ) {
190
193
HashingStorage newStore = null ;
191
194
// TODO: FIXME: this might call __hash__ twice
192
195
boolean hasKey = lib .hasKeyWithFrame (storage , key , hasFrame , frame );
@@ -197,7 +200,7 @@ protected void removeItem(VirtualFrame frame, PDict dict, Object key,
197
200
if (hasKey ) {
198
201
if (newStore != storage ) {
199
202
updatedStorage .enter ();
200
- dict . setDictStorage ( newStore );
203
+ setStorage . execute ( dict , newStore );
201
204
}
202
205
}
203
206
}
@@ -208,10 +211,13 @@ public Object popDefault(VirtualFrame frame, PDict dict, Object key, Object defa
208
211
@ Cached ConditionProfile hasKey ,
209
212
@ Cached ConditionProfile hasDefault ,
210
213
@ Cached ConditionProfile hasFrame ,
211
- @ CachedLibrary ("dict.getDictStorage()" ) HashingStorageLibrary lib ) {
212
- Object retVal = lib .getItemWithFrame (dict .getDictStorage (), key , hasFrame , frame );
214
+ @ Cached GetDictStorageNode getStorage ,
215
+ @ Cached SetDictStorageNode setStorage ,
216
+ @ CachedLibrary ("getStorage.execute(dict)" ) HashingStorageLibrary lib ) {
217
+ HashingStorage dictStorage = getStorage .execute (dict );
218
+ Object retVal = lib .getItemWithFrame (dictStorage , key , hasFrame , frame );
213
219
if (hasKey .profile (retVal != null )) {
214
- removeItem (frame , dict , key , lib , hasFrame , updatedStorage );
220
+ removeItem (frame , dict , key , dictStorage , lib , hasFrame , updatedStorage , setStorage );
215
221
return retVal ;
216
222
} else if (hasDefault .profile (defaultValue != PNone .NO_VALUE )) {
217
223
return defaultValue ;
@@ -228,8 +234,9 @@ public abstract static class PopItemNode extends PythonUnaryBuiltinNode {
228
234
229
235
@ Specialization (limit = "3" )
230
236
public Object popItem (PDict dict ,
231
- @ CachedLibrary ("dict.getDictStorage()" ) HashingStorageLibrary lib ) {
232
- HashingStorage storage = dict .getDictStorage ();
237
+ @ Cached GetDictStorageNode getStorage ,
238
+ @ CachedLibrary ("getStorage.execute(dict)" ) HashingStorageLibrary lib ) {
239
+ HashingStorage storage = getStorage .execute (dict );
233
240
for (DictEntry entry : lib .entries (storage )) {
234
241
PTuple result = factory ().createTuple (new Object []{entry .getKey (), entry .getValue ()});
235
242
lib .delItem (storage , entry .getKey ());
@@ -267,9 +274,10 @@ public PDictView items(PDict self) {
267
274
public abstract static class GetNode extends PythonTernaryBuiltinNode {
268
275
@ Specialization (limit = "getCallSiteInlineCacheMaxDepth()" )
269
276
public Object doWithDefault (VirtualFrame frame , PDict self , Object key , Object defaultValue ,
270
- @ CachedLibrary (value = "self.getDictStorage()" ) HashingStorageLibrary hlib ,
277
+ @ Cached GetDictStorageNode getStorage ,
278
+ @ CachedLibrary (value = "getStorage.execute(self)" ) HashingStorageLibrary hlib ,
271
279
@ Cached ConditionProfile profile ) {
272
- final Object value = hlib .getItemWithFrame (self . getDictStorage ( ), key , profile , frame );
280
+ final Object value = hlib .getItemWithFrame (getStorage . execute ( self ), key , profile , frame );
273
281
return value != null ? value : (defaultValue == PNone .NO_VALUE ? PNone .NONE : defaultValue );
274
282
}
275
283
}
@@ -279,10 +287,11 @@ public Object doWithDefault(VirtualFrame frame, PDict self, Object key, Object d
279
287
public abstract static class GetItemNode extends PythonBinaryBuiltinNode {
280
288
@ Specialization (limit = "getCallSiteInlineCacheMaxDepth()" )
281
289
Object getItem (VirtualFrame frame , PDict self , Object key ,
282
- @ CachedLibrary (value = "self.getDictStorage()" ) HashingStorageLibrary hlib ,
290
+ @ Cached GetDictStorageNode getStorage ,
291
+ @ CachedLibrary (value = "getStorage.execute(self)" ) HashingStorageLibrary hlib ,
283
292
@ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile profile ,
284
293
@ Cached DispatchMissingNode missing ) {
285
- final Object result = hlib .getItemWithFrame (self . getDictStorage ( ), key , profile , frame );
294
+ final Object result = hlib .getItemWithFrame (getStorage . execute ( self ), key , profile , frame );
286
295
if (result == null ) {
287
296
return missing .execute (frame , self , key );
288
297
}
@@ -353,9 +362,11 @@ public abstract static class DelItemNode extends PythonBinaryBuiltinNode {
353
362
@ Specialization
354
363
Object run (VirtualFrame frame , PDict self , Object key ,
355
364
@ Cached BranchProfile updatedStorage ,
365
+ @ Cached SetDictStorageNode setStorage ,
366
+ @ Cached GetDictStorageNode getStorage ,
356
367
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
357
368
@ CachedLibrary (limit = "3" ) HashingStorageLibrary lib ) {
358
- HashingStorage storage = self . getDictStorage ( );
369
+ HashingStorage storage = getStorage . execute ( self );
359
370
HashingStorage newStore = null ;
360
371
// TODO: FIXME: this might call __hash__ twice
361
372
boolean hasKey = lib .hasKeyWithFrame (storage , key , hasFrame , frame );
@@ -366,7 +377,7 @@ Object run(VirtualFrame frame, PDict self, Object key,
366
377
if (hasKey ) {
367
378
if (newStore != storage ) {
368
379
updatedStorage .enter ();
369
- self . setDictStorage ( newStore );
380
+ setStorage . execute ( self , newStore );
370
381
}
371
382
return PNone .NONE ;
372
383
}
@@ -405,22 +416,24 @@ public abstract static class EqNode extends PythonBinaryBuiltinNode {
405
416
@ Specialization (limit = "1" )
406
417
Object doDictDict (VirtualFrame frame , PDict self , PDict other ,
407
418
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
408
- @ CachedLibrary ("self.getDictStorage()" ) HashingStorageLibrary lib ) {
419
+ @ Cached GetDictStorageNode getStorage ,
420
+ @ CachedLibrary ("getStorage.execute(self)" ) HashingStorageLibrary lib ) {
409
421
if (hasFrame .profile (frame != null )) {
410
- return lib .equalsWithState (self . getDictStorage ( ), other . getDictStorage ( ), PArguments .getThreadState (frame ));
422
+ return lib .equalsWithState (getStorage . execute ( self ), getStorage . execute ( other ), PArguments .getThreadState (frame ));
411
423
} else {
412
- return lib .equals (self . getDictStorage ( ), other . getDictStorage ( ));
424
+ return lib .equals (getStorage . execute ( self ), getStorage . execute ( other ));
413
425
}
414
426
}
415
427
416
428
@ Specialization (limit = "1" )
417
429
Object doDictProxy (VirtualFrame frame , PDict self , PMappingproxy other ,
418
430
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
419
- @ CachedLibrary ("self.getDictStorage()" ) HashingStorageLibrary lib ) {
431
+ @ Cached GetDictStorageNode getStorage ,
432
+ @ CachedLibrary ("getStorage.execute(self)" ) HashingStorageLibrary lib ) {
420
433
if (hasFrame .profile (frame != null )) {
421
- return lib .equalsWithState (self . getDictStorage ( ), other . getDictStorage ( ), PArguments .getThreadState (frame ));
434
+ return lib .equalsWithState (getStorage . execute ( self ), getStorage . execute ( other ), PArguments .getThreadState (frame ));
422
435
} else {
423
- return lib .equals (self . getDictStorage ( ), other . getDictStorage ( ));
436
+ return lib .equals (getStorage . execute ( self ), getStorage . execute ( other ));
424
437
}
425
438
}
426
439
@@ -438,8 +451,9 @@ public abstract static class ContainsNode extends PythonBinaryBuiltinNode {
438
451
@ Specialization (limit = "getCallSiteInlineCacheMaxDepth()" )
439
452
boolean run (VirtualFrame frame , PDict self , Object key ,
440
453
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
441
- @ CachedLibrary ("self.getDictStorage()" ) HashingStorageLibrary lib ) {
442
- return lib .hasKeyWithFrame (self .getDictStorage (), key , hasFrame , frame );
454
+ @ Cached GetDictStorageNode getStorage ,
455
+ @ CachedLibrary ("getStorage.execute(self)" ) HashingStorageLibrary lib ) {
456
+ return lib .hasKeyWithFrame (getStorage .execute (self ), key , hasFrame , frame );
443
457
}
444
458
}
445
459
@@ -458,8 +472,9 @@ public boolean repr(PDict self,
458
472
public abstract static class LenNode extends PythonUnaryBuiltinNode {
459
473
@ Specialization (limit = "1" )
460
474
public int len (PDict self ,
461
- @ CachedLibrary ("self.getDictStorage()" ) HashingStorageLibrary lib ) {
462
- return lib .length (self .getDictStorage ());
475
+ @ Cached GetDictStorageNode getStorage ,
476
+ @ CachedLibrary ("getStorage.execute(self)" ) HashingStorageLibrary lib ) {
477
+ return lib .length (getStorage .execute (self ));
463
478
}
464
479
}
465
480
@@ -470,8 +485,9 @@ public abstract static class CopyNode extends PythonUnaryBuiltinNode {
470
485
471
486
@ Specialization (limit = "1" )
472
487
public PDict copy (@ SuppressWarnings ("unused" ) VirtualFrame frame , PDict dict ,
473
- @ CachedLibrary ("dict.getDictStorage()" ) HashingStorageLibrary lib ) {
474
- return factory ().createDict (lib .copy (dict .getDictStorage ()));
488
+ @ Cached GetDictStorageNode getStorage ,
489
+ @ CachedLibrary ("getStorage.execute(dict)" ) HashingStorageLibrary lib ) {
490
+ return factory ().createDict (lib .copy (getStorage .execute (dict )));
475
491
}
476
492
}
477
493
@@ -482,9 +498,10 @@ public abstract static class ClearNode extends PythonUnaryBuiltinNode {
482
498
483
499
@ Specialization (limit = "3" )
484
500
public PDict clear (PDict dict ,
485
- @ CachedLibrary ("dict.getDictStorage()" ) HashingStorageLibrary lib ,
501
+ @ Cached GetDictStorageNode getStorage ,
502
+ @ CachedLibrary ("getStorage.execute(dict)" ) HashingStorageLibrary lib ,
486
503
@ Cached SetDictStorageNode setStorage ) {
487
- HashingStorage newStorage = lib .clear (dict . getDictStorage ( ));
504
+ HashingStorage newStorage = lib .clear (getStorage . execute ( dict ));
488
505
setStorage .execute (dict , newStorage );
489
506
return dict ;
490
507
}
0 commit comments