40
40
*/
41
41
package com .oracle .graal .python .builtins .objects .common ;
42
42
43
- import com .oracle .graal .python .PythonLanguage ;
44
43
import com .oracle .graal .python .builtins .objects .PNone ;
45
- import com .oracle .graal .python .builtins .objects .common .DynamicObjectStorage .DynamicObjectStorageSetStringKey ;
46
44
import com .oracle .graal .python .builtins .objects .common .EconomicMapStorage .EconomicMapSetStringKey ;
47
45
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodesFactory .HashingStorageAddAllToOtherNodeGen ;
48
46
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodesFactory .HashingStorageCopyNodeGen ;
74
72
import com .oracle .truffle .api .dsl .NeverDefault ;
75
73
import com .oracle .truffle .api .dsl .Specialization ;
76
74
import com .oracle .truffle .api .frame .Frame ;
77
- import com .oracle .truffle .api .frame .FrameDescriptor ;
78
75
import com .oracle .truffle .api .library .CachedLibrary ;
79
76
import com .oracle .truffle .api .nodes .LoopNode ;
80
77
import com .oracle .truffle .api .nodes .Node ;
@@ -131,12 +128,6 @@ static Object keywords(Frame frame, KeywordsStorage self, Object key, long keyHa
131
128
@ Cached KeywordsStorage .GetItemNode getNode ) {
132
129
return getNode .execute (frame , self , key , keyHash );
133
130
}
134
-
135
- @ Specialization
136
- static Object locals (Frame frame , LocalsStorage self , Object key , long keyHash ,
137
- @ Cached LocalsStorage .GetItemNode getNode ) {
138
- return getNode .execute (frame , self , key , keyHash );
139
- }
140
131
}
141
132
142
133
@ GenerateUncached
@@ -197,12 +188,6 @@ static Object keywords(Frame frame, KeywordsStorage self, Object key,
197
188
@ Cached KeywordsStorage .GetItemNode getNode ) {
198
189
return getNode .execute (frame , self , key , -1 );
199
190
}
200
-
201
- @ Specialization
202
- static Object locals (Frame frame , LocalsStorage self , Object key ,
203
- @ Cached LocalsStorage .GetItemNode getNode ) {
204
- return getNode .execute (frame , self , key , -1 );
205
- }
206
191
}
207
192
208
193
abstract static class SpecializedSetStringKey extends Node {
@@ -219,7 +204,7 @@ static EconomicMapStorage doEconomicMap(EconomicMapStorage s) {
219
204
}
220
205
221
206
@ Specialization
222
- static EconomicMapStorage doEmptyStorage (EmptyStorage s ) {
207
+ static EconomicMapStorage doEmptyStorage (@ SuppressWarnings ( "unused" ) EmptyStorage s ) {
223
208
return EconomicMapStorage .create ();
224
209
}
225
210
@@ -244,17 +229,9 @@ static EconomicMapStorage doDynamicObjectStorage(DynamicObjectStorage s,
244
229
return result ;
245
230
}
246
231
247
- @ Specialization
248
- static EconomicMapStorage doLocals (LocalsStorage s ,
249
- @ Shared ("economicSpecPut" ) @ Cached EconomicMapSetStringKey specializedPutNode ) {
250
- EconomicMapStorage result = EconomicMapStorage .create (s .lengthHint ());
251
- s .addAllTo (result , specializedPutNode );
252
- return result ;
253
- }
254
-
255
232
@ Specialization
256
233
static EconomicMapStorage doKeywords (KeywordsStorage s ,
257
- @ Shared ( "economicSpecPut" ) @ Cached EconomicMapSetStringKey specializedPutNode ) {
234
+ @ Cached EconomicMapSetStringKey specializedPutNode ) {
258
235
EconomicMapStorage result = EconomicMapStorage .create (s .length ());
259
236
s .addAllTo (result , specializedPutNode );
260
237
return result ;
@@ -264,7 +241,6 @@ static EconomicMapStorage doKeywords(KeywordsStorage s,
264
241
@ GenerateUncached
265
242
@ ImportStatic (PGuards .class )
266
243
public abstract static class HashingStorageSetItemWithHash extends Node {
267
- static final int DOM_SIZE_THRESHOLD = DynamicObjectStorage .SIZE_THRESHOLD ;
268
244
269
245
@ NeverDefault
270
246
public static HashingStorageSetItemWithHash create () {
@@ -298,15 +274,15 @@ static HashingStorage empty(Frame frame, @SuppressWarnings("unused") EmptyStorag
298
274
}
299
275
300
276
@ Specialization (guards = "!self.shouldTransitionOnPut()" )
301
- static HashingStorage domStringKey (DynamicObjectStorage self , TruffleString key , long keyHash , Object value ,
277
+ static HashingStorage domStringKey (DynamicObjectStorage self , TruffleString key , @ SuppressWarnings ( "unused" ) long keyHash , Object value ,
302
278
@ Shared ("invalidateMro" ) @ Cached BranchProfile invalidateMroProfile ,
303
279
@ Shared ("dylib" ) @ CachedLibrary (limit = "3" ) DynamicObjectLibrary dylib ) {
304
280
self .setStringKey (key , value , dylib , invalidateMroProfile );
305
281
return self ;
306
282
}
307
283
308
284
@ Specialization (guards = {"!self.shouldTransitionOnPut()" , "isBuiltinString(inliningTarget, key, profile)" }, limit = "1" )
309
- static HashingStorage domPStringKey (DynamicObjectStorage self , Object key , long keyHash , Object value ,
285
+ static HashingStorage domPStringKey (DynamicObjectStorage self , Object key , @ SuppressWarnings ( "unused" ) long keyHash , Object value ,
310
286
@ SuppressWarnings ("unused" ) @ Bind ("this" ) Node inliningTarget ,
311
287
@ SuppressWarnings ("unused" ) @ Shared ("isBuiltin" ) @ Cached IsBuiltinObjectProfile profile ,
312
288
@ Cached CastToTruffleStringNode castStr ,
@@ -317,7 +293,7 @@ static HashingStorage domPStringKey(DynamicObjectStorage self, Object key, long
317
293
}
318
294
319
295
@ Specialization (guards = {"self.shouldTransitionOnPut() || !isBuiltinString(inliningTarget, key, profile)" }, limit = "1" )
320
- static HashingStorage domTransition (Frame frame , DynamicObjectStorage self , Object key , long keyHash , Object value ,
296
+ static HashingStorage domTransition (Frame frame , DynamicObjectStorage self , Object key , @ SuppressWarnings ( "unused" ) long keyHash , Object value ,
321
297
@ SuppressWarnings ("unused" ) @ Bind ("this" ) Node inliningTarget ,
322
298
@ SuppressWarnings ("unused" ) @ Shared ("isBuiltin" ) @ Cached IsBuiltinObjectProfile profile ,
323
299
@ Shared ("dylib" ) @ CachedLibrary (limit = "3" ) DynamicObjectLibrary dylib ,
@@ -328,34 +304,12 @@ static HashingStorage domTransition(Frame frame, DynamicObjectStorage self, Obje
328
304
return result ;
329
305
}
330
306
331
- @ Specialization (guards = "self.lengthHint() < DOM_SIZE_THRESHOLD" )
332
- HashingStorage localsStringKey (LocalsStorage self , TruffleString key , long keyHash , Object value ,
333
- @ Shared ("invalidateMro" ) @ Cached BranchProfile invalidateMroProfile ,
334
- @ Shared ("dylib" ) @ CachedLibrary (limit = "3" ) DynamicObjectLibrary dylib ,
335
- @ Cached DynamicObjectStorageSetStringKey specializedPutNode ) {
336
- DynamicObjectStorage result = new DynamicObjectStorage (PythonLanguage .get (this ));
337
- self .addAllTo (result , specializedPutNode );
338
- return domStringKey (result , key , keyHash , value , invalidateMroProfile , dylib );
339
- }
340
-
341
- @ Specialization (guards = "!isTruffleString(key) || lengthHint >= DOM_SIZE_THRESHOLD" )
342
- static HashingStorage localsGenericKey (Frame frame , LocalsStorage self , Object key , long keyHash , Object value ,
343
- @ Bind ("this" ) Node inliningTarget ,
344
- @ Bind ("self.lengthHint()" ) int lengthHint ,
345
- @ Shared ("isBuiltin" ) @ Cached IsBuiltinObjectProfile profile ,
346
- @ Shared ("economicPut" ) @ Cached ObjectHashMap .PutNode putNode ,
347
- @ Shared ("economicSpecPut" ) @ Cached EconomicMapSetStringKey specializedPutNode ) {
348
- EconomicMapStorage result = EconomicMapStorage .create (lengthHint );
349
- self .addAllTo (result , specializedPutNode );
350
- return economicMap (frame , result , key , keyHash , value , inliningTarget , profile , putNode );
351
- }
352
-
353
307
@ Specialization
354
308
static HashingStorage keywords (Frame frame , KeywordsStorage self , Object key , long keyHash , Object value ,
355
309
@ Bind ("this" ) Node inliningTarget ,
356
310
@ Shared ("isBuiltin" ) @ Cached IsBuiltinObjectProfile profile ,
357
311
@ Shared ("economicPut" ) @ Cached ObjectHashMap .PutNode putNode ,
358
- @ Shared ( "economicSpecPut" ) @ Cached EconomicMapSetStringKey specializedPutNode ) {
312
+ @ Cached EconomicMapSetStringKey specializedPutNode ) {
359
313
// TODO: do we want to try DynamicObjectStorage if the key is a string?
360
314
EconomicMapStorage result = EconomicMapStorage .create (self .length ());
361
315
self .addAllTo (result , specializedPutNode );
@@ -371,7 +325,6 @@ static HashingStorage keywords(Frame frame, KeywordsStorage self, Object key, lo
371
325
@ GenerateUncached
372
326
@ ImportStatic (PGuards .class )
373
327
public abstract static class HashingStorageSetItem extends Node {
374
- static final int DOM_SIZE_THRESHOLD = DynamicObjectStorage .SIZE_THRESHOLD ;
375
328
376
329
@ NeverDefault
377
330
public static HashingStorageSetItem create () {
@@ -448,36 +401,13 @@ static HashingStorage domTransition(Frame frame, DynamicObjectStorage self, Obje
448
401
return result ;
449
402
}
450
403
451
- @ Specialization (guards = "self.lengthHint() < DOM_SIZE_THRESHOLD" )
452
- HashingStorage localsStringKey (LocalsStorage self , TruffleString key , Object value ,
453
- @ Shared ("invalidateMro" ) @ Cached BranchProfile invalidateMroProfile ,
454
- @ Shared ("dylib" ) @ CachedLibrary (limit = "3" ) DynamicObjectLibrary dylib ,
455
- @ Cached DynamicObjectStorageSetStringKey specializedPutNode ) {
456
- DynamicObjectStorage result = new DynamicObjectStorage (PythonLanguage .get (this ));
457
- self .addAllTo (result , specializedPutNode );
458
- return domStringKey (result , key , value , invalidateMroProfile , dylib );
459
- }
460
-
461
- @ Specialization (guards = "!isTruffleString(key) || lengthHint >= DOM_SIZE_THRESHOLD" )
462
- static HashingStorage localsGenericKey (Frame frame , LocalsStorage self , Object key , Object value ,
463
- @ Bind ("this" ) Node inliningTarget ,
464
- @ Bind ("self.lengthHint()" ) int lengthHint ,
465
- @ Shared ("isBuiltin" ) @ Cached IsBuiltinObjectProfile profile ,
466
- @ Shared ("hash" ) @ Cached PyObjectHashNode hashNode ,
467
- @ Shared ("economicPut" ) @ Cached ObjectHashMap .PutNode putNode ,
468
- @ Shared ("economicSpecPut" ) @ Cached EconomicMapSetStringKey specializedPutNode ) {
469
- EconomicMapStorage result = EconomicMapStorage .create (lengthHint );
470
- self .addAllTo (result , specializedPutNode );
471
- return economicMap (frame , result , key , value , inliningTarget , profile , hashNode , putNode );
472
- }
473
-
474
404
@ Specialization
475
405
static HashingStorage keywords (Frame frame , KeywordsStorage self , Object key , Object value ,
476
406
@ Bind ("this" ) Node inliningTarget ,
477
407
@ Shared ("hash" ) @ Cached PyObjectHashNode hashNode ,
478
408
@ Shared ("isBuiltin" ) @ Cached IsBuiltinObjectProfile profile ,
479
409
@ Shared ("economicPut" ) @ Cached ObjectHashMap .PutNode putNode ,
480
- @ Shared ( "economicSpecPut" ) @ Cached EconomicMapSetStringKey specializedPutNode ) {
410
+ @ Cached EconomicMapSetStringKey specializedPutNode ) {
481
411
// TODO: do we want to try DynamicObjectStorage if the key is a string?
482
412
EconomicMapStorage result = EconomicMapStorage .create (self .length ());
483
413
self .addAllTo (result , specializedPutNode );
@@ -560,7 +490,8 @@ static Object domPStringKey(DynamicObjectStorage self, Object key, boolean isPop
560
490
}
561
491
562
492
@ Specialization (guards = "!isBuiltinString(inliningTarget, key, profile)" , limit = "1" )
563
- static Object domOther (Frame frame , DynamicObjectStorage self , Object key , @ SuppressWarnings ("unused" ) boolean isPop , @ SuppressWarnings ("unused" ) PHashingCollection toUpdate ,
493
+ static Object domOther (Frame frame , @ SuppressWarnings ("unused" ) DynamicObjectStorage self , Object key , @ SuppressWarnings ("unused" ) boolean isPop ,
494
+ @ SuppressWarnings ("unused" ) PHashingCollection toUpdate ,
564
495
@ SuppressWarnings ("unused" ) @ Bind ("this" ) Node inliningTarget ,
565
496
@ SuppressWarnings ("unused" ) @ Shared ("isBuiltin" ) @ Cached IsBuiltinObjectProfile profile ,
566
497
@ Shared ("hash" ) @ Cached PyObjectHashNode hashNode ) {
@@ -580,23 +511,12 @@ static Object empty(Frame frame, @SuppressWarnings("unused") EmptyStorage self,
580
511
static Object keywords (Frame frame , KeywordsStorage self , Object key , boolean isPop , PHashingCollection toUpdate ,
581
512
@ Shared ("hash" ) @ Cached PyObjectHashNode hashNode ,
582
513
@ Shared ("economicRemove" ) @ Cached ObjectHashMap .RemoveNode removeNode ,
583
- @ Shared ( "economicSpecPut" ) @ Cached EconomicMapSetStringKey specializedPutNode ) {
514
+ @ Cached EconomicMapSetStringKey specializedPutNode ) {
584
515
EconomicMapStorage newStorage = EconomicMapStorage .create (self .length ());
585
516
self .addAllTo (newStorage , specializedPutNode );
586
517
toUpdate .setDictStorage (newStorage );
587
518
return economicMap (frame , newStorage , key , isPop , toUpdate , hashNode , removeNode );
588
519
}
589
-
590
- @ Specialization
591
- static Object locals (Frame frame , LocalsStorage self , Object key , boolean isPop , PHashingCollection toUpdate ,
592
- @ Shared ("hash" ) @ Cached PyObjectHashNode hashNode ,
593
- @ Shared ("economicRemove" ) @ Cached ObjectHashMap .RemoveNode removeNode ,
594
- @ Shared ("economicSpecPut" ) @ Cached EconomicMapSetStringKey specializedPutNode ) {
595
- EconomicMapStorage newStorage = EconomicMapStorage .create (self .lengthHint ());
596
- self .addAllTo (newStorage , specializedPutNode );
597
- toUpdate .setDictStorage (newStorage );
598
- return economicMap (frame , newStorage , key , isPop , toUpdate , hashNode , removeNode );
599
- }
600
520
}
601
521
602
522
@ GenerateUncached
@@ -633,12 +553,6 @@ static int empty(EmptyStorage self) {
633
553
static int keywords (KeywordsStorage self ) {
634
554
return self .length ();
635
555
}
636
-
637
- @ Specialization
638
- static int locals (LocalsStorage self ,
639
- @ Cached LocalsStorage .LengthNode lengthNode ) {
640
- return lengthNode .execute (self );
641
- }
642
556
}
643
557
644
558
@ GenerateUncached
@@ -683,7 +597,7 @@ static HashingStorage economic(EconomicMapStorage map) {
683
597
}
684
598
685
599
@ Specialization
686
- static EmptyStorage empty (EmptyStorage map ) {
600
+ static EmptyStorage empty (@ SuppressWarnings ( "unused" ) EmptyStorage map ) {
687
601
return EmptyStorage .INSTANCE ;
688
602
}
689
603
@@ -697,11 +611,6 @@ static DynamicObjectStorage dom(DynamicObjectStorage dom,
697
611
static HashingStorage keywords (KeywordsStorage self ) {
698
612
return self .copy ();
699
613
}
700
-
701
- @ Specialization
702
- static HashingStorage locals (LocalsStorage self ) {
703
- return self .copy ();
704
- }
705
614
}
706
615
707
616
@ ValueType
@@ -783,16 +692,6 @@ static HashingStorageIterator empty(@SuppressWarnings("unused") EmptyStorage sel
783
692
static HashingStorageIterator keywords (@ SuppressWarnings ("unused" ) KeywordsStorage self ) {
784
693
return new HashingStorageIterator ();
785
694
}
786
-
787
- @ Specialization
788
- static HashingStorageIterator locals (LocalsStorage self ,
789
- @ Cached BranchProfile calculateLen ) {
790
- if (self .len == -1 ) {
791
- calculateLen .enter ();
792
- self .calculateLength ();
793
- }
794
- return new HashingStorageIterator ();
795
- }
796
695
}
797
696
798
697
@ GenerateUncached
@@ -832,18 +731,6 @@ static HashingStorageIterator keywords(@SuppressWarnings("unused") KeywordsStora
832
731
it .index = self .length ();
833
732
return it ;
834
733
}
835
-
836
- @ Specialization
837
- static HashingStorageIterator locals (LocalsStorage self ,
838
- @ Cached BranchProfile calculateLen ) {
839
- if (self .len == -1 ) {
840
- calculateLen .enter ();
841
- self .calculateLength ();
842
- }
843
- HashingStorageIterator it = new HashingStorageIterator (true );
844
- it .index = self .len ;
845
- return it ;
846
- }
847
734
}
848
735
849
736
@ GenerateUncached
@@ -945,38 +832,6 @@ static boolean keywords(KeywordsStorage self, HashingStorageIterator it) {
945
832
static boolean keywordsReverse (@ SuppressWarnings ("unused" ) KeywordsStorage self , HashingStorageIterator it ) {
946
833
return --it .index >= 0 ;
947
834
}
948
-
949
- @ Specialization (guards = "!it.isReverse" )
950
- static boolean locals (LocalsStorage self , HashingStorageIterator it ) {
951
- FrameDescriptor fd = self .frame .getFrameDescriptor ();
952
- it .index ++;
953
- while (it .index < fd .getNumberOfSlots ()) {
954
- Object identifier = fd .getSlotName (it .index );
955
- if (identifier != null && self .getValue (it .index ) != null ) {
956
- // Update the code in HashingStorageIteratorKey if this assumption changes:
957
- assert identifier instanceof TruffleString ;
958
- return true ;
959
- }
960
- it .index ++;
961
- }
962
- return false ;
963
- }
964
-
965
- @ Specialization (guards = "it.isReverse" )
966
- static boolean localsReverse (LocalsStorage self , HashingStorageIterator it ) {
967
- FrameDescriptor fd = self .frame .getFrameDescriptor ();
968
- it .index --;
969
- while (it .index >= 0 ) {
970
- Object identifier = fd .getSlotName (it .index );
971
- if (identifier != null && self .getValue (it .index ) != null ) {
972
- // Update the code in HashingStorageIteratorKey if this assumption changes:
973
- assert identifier instanceof TruffleString ;
974
- return true ;
975
- }
976
- it .index --;
977
- }
978
- return false ;
979
- }
980
835
}
981
836
982
837
@ GenerateUncached
@@ -1013,11 +868,6 @@ static boolean empty(EmptyStorage self, HashingStorageIterator it) {
1013
868
static Object keywords (KeywordsStorage self , HashingStorageIterator it ) {
1014
869
return self .keywords [it .index ].getValue ();
1015
870
}
1016
-
1017
- @ Specialization
1018
- static Object locals (LocalsStorage self , HashingStorageIterator it ) {
1019
- return LocalsStorage .getValue (self .frame , it .index );
1020
- }
1021
871
}
1022
872
1023
873
@ GenerateUncached
@@ -1054,11 +904,6 @@ static boolean empty(EmptyStorage self, HashingStorageIterator it) {
1054
904
static Object keywords (KeywordsStorage self , HashingStorageIterator it ) {
1055
905
return self .keywords [it .index ].getName ();
1056
906
}
1057
-
1058
- @ Specialization
1059
- static TruffleString locals (LocalsStorage self , HashingStorageIterator it ) {
1060
- return (TruffleString ) self .frame .getFrameDescriptor ().getSlotName (it .index );
1061
- }
1062
907
}
1063
908
1064
909
@ GenerateUncached
@@ -1088,12 +933,6 @@ static long keywords(KeywordsStorage self, HashingStorageIterator it,
1088
933
@ Shared ("hash" ) @ Cached TruffleString .HashCodeNode hashNode ) {
1089
934
return PyObjectHashNode .hash (self .keywords [it .index ].getName (), hashNode );
1090
935
}
1091
-
1092
- @ Specialization
1093
- static long locals (LocalsStorage self , HashingStorageIterator it ,
1094
- @ Shared ("hash" ) @ Cached TruffleString .HashCodeNode hashNode ) {
1095
- return PyObjectHashNode .hash ((TruffleString ) self .frame .getFrameDescriptor ().getSlotName (it .index ), hashNode );
1096
- }
1097
936
}
1098
937
1099
938
@ GenerateUncached
@@ -1415,7 +1254,6 @@ public abstract static class HashingStorageAreDisjointCallback extends HashingSt
1415
1254
1416
1255
@ Specialization
1417
1256
static HashingStorage doGeneric (Frame frame , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage ,
1418
- @ Cached ObjectHashMap .PutNode putResultNode ,
1419
1257
@ Cached HashingStorageGetItemWithHash getFromOther ,
1420
1258
@ Cached HashingStorageIteratorKey iterKey ,
1421
1259
@ Cached HashingStorageIteratorKeyHash iterHash ) {
0 commit comments