@@ -115,10 +115,11 @@ public EconomicMapStorage(EconomicMap<? extends Object, ? extends Object> map) {
115
115
this (map .size ());
116
116
final PythonObjectLibrary lib = PythonObjectLibrary .getUncached ();
117
117
MapCursor <? extends Object , ? extends Object > c = map .getEntries ();
118
+ ConditionProfile findProfile = ConditionProfile .createBinaryProfile ();
118
119
while (c .advance ()) {
119
120
Object key = c .getKey ();
120
121
assert key instanceof Integer || key instanceof String ;
121
- this .map .put (new DictKey (key , key .hashCode ()), c .getValue (), lib , lib );
122
+ this .map .put (new DictKey (key , key .hashCode ()), c .getValue (), lib , lib , findProfile );
122
123
}
123
124
}
124
125
@@ -149,30 +150,33 @@ static class GetItemWithState {
149
150
150
151
@ Specialization
151
152
static Object getItemString (EconomicMapStorage self , String key , @ SuppressWarnings ("unused" ) ThreadState state ,
153
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
152
154
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
153
155
DictKey newKey = new DictKey (key , key .hashCode ());
154
- return self .map .get (newKey , lib , lib );
156
+ return self .map .get (newKey , lib , lib , findProfile );
155
157
}
156
158
157
159
@ SuppressWarnings ("unused" )
158
160
@ Specialization (guards = {"!isNativeString(key)" , "isBuiltinString(key, isBuiltinClassProfile, getClassNode)" })
159
161
static Object getItemPString (EconomicMapStorage self , PString key , @ SuppressWarnings ("unused" ) ThreadState state ,
162
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
160
163
@ Exclusive @ Cached ("createClassProfile()" ) ValueProfile profile ,
161
164
@ Exclusive @ Cached IsBuiltinClassProfile isBuiltinClassProfile ,
162
165
@ Exclusive @ Cached GetLazyClassNode getClassNode ,
163
166
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
164
167
final String k = EconomicMapStorage .toString (key , profile );
165
- return getItemString (self , k , state , lib );
168
+ return getItemString (self , k , state , findProfile , lib );
166
169
}
167
170
168
171
@ Specialization (replaces = "getItemString" , limit = "3" )
169
172
static Object getItemGeneric (EconomicMapStorage self , Object key , ThreadState state ,
170
173
@ CachedLibrary ("key" ) PythonObjectLibrary lib ,
171
174
@ CachedLibrary (limit = "2" ) PythonObjectLibrary otherlib ,
175
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
172
176
@ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile gotState ) {
173
177
final long h = self .getHashWithState (key , lib , state , gotState );
174
178
DictKey newKey = new DictKey (key , h );
175
- return self .map .get (newKey , lib , otherlib );
179
+ return self .map .get (newKey , lib , otherlib , findProfile );
176
180
}
177
181
}
178
182
@@ -183,29 +187,32 @@ static class SetItemWithState {
183
187
184
188
@ Specialization
185
189
static HashingStorage setItemString (EconomicMapStorage self , String key , Object value , ThreadState state ,
190
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
186
191
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
187
192
DictKey newKey = new DictKey (key , key .hashCode ());
188
- self .map .put (newKey , value , lib , lib );
193
+ self .map .put (newKey , value , lib , lib , findProfile );
189
194
return self ;
190
195
}
191
196
192
197
@ Specialization (guards = {"!isNativeString(key)" , "isBuiltinString(key, isBuiltinClassProfile, getClassNode)" })
193
198
static HashingStorage setItemPString (EconomicMapStorage self , PString key , Object value , ThreadState state ,
194
199
@ Exclusive @ Cached ("createClassProfile()" ) ValueProfile profile ,
200
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
195
201
@ Exclusive @ Cached IsBuiltinClassProfile isBuiltinClassProfile ,
196
202
@ Exclusive @ Cached GetLazyClassNode getClassNode ,
197
203
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
198
204
final String k = EconomicMapStorage .toString (key , profile );
199
- return setItemString (self , k , value , state , lib );
205
+ return setItemString (self , k , value , state , findProfile , lib );
200
206
}
201
207
202
208
@ Specialization (replaces = "setItemString" , limit = "3" )
203
209
static HashingStorage setItemGeneric (EconomicMapStorage self , Object key , Object value , ThreadState state ,
204
210
@ CachedLibrary ("key" ) PythonObjectLibrary lib ,
205
211
@ CachedLibrary (limit = "2" ) PythonObjectLibrary otherlib ,
212
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
206
213
@ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile gotState ) {
207
214
DictKey newKey = new DictKey (key , self .getHashWithState (key , lib , state , gotState ));
208
- self .map .put (newKey , value , lib , otherlib );
215
+ self .map .put (newKey , value , lib , otherlib , findProfile );
209
216
return self ;
210
217
}
211
218
}
@@ -272,14 +279,15 @@ public static class EqualsWithState {
272
279
@ TruffleBoundary
273
280
@ Specialization
274
281
static boolean equalSameType (EconomicMapStorage self , EconomicMapStorage other , ThreadState state ,
282
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
275
283
@ CachedLibrary (limit = "2" ) PythonObjectLibrary compareLib1 ,
276
284
@ CachedLibrary (limit = "2" ) PythonObjectLibrary compareLib2 ) {
277
285
if (self .map .size () != other .map .size ()) {
278
286
return false ;
279
287
}
280
288
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
281
289
while (cursor .advance ()) {
282
- Object otherValue = other .map .get (cursor .getKey (), compareLib1 , compareLib2 );
290
+ Object otherValue = other .map .get (cursor .getKey (), compareLib1 , compareLib2 , findProfile );
283
291
if (otherValue != null && !compareLib1 .equalsWithState (otherValue , cursor .getValue (), compareLib2 , state )) {
284
292
return false ;
285
293
}
@@ -313,6 +321,7 @@ public static class CompareKeys {
313
321
@ TruffleBoundary
314
322
@ Specialization
315
323
static int compareSameType (EconomicMapStorage self , EconomicMapStorage other ,
324
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
316
325
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
317
326
int size = self .map .size ();
318
327
int size2 = other .map .size ();
@@ -321,7 +330,7 @@ static int compareSameType(EconomicMapStorage self, EconomicMapStorage other,
321
330
}
322
331
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
323
332
while (cursor .advance ()) {
324
- if (!other .map .containsKey (cursor .getKey (), lib , lib )) {
333
+ if (!other .map .containsKey (cursor .getKey (), lib , lib , findProfile )) {
325
334
return 1 ;
326
335
}
327
336
}
@@ -360,12 +369,13 @@ public static class Intersect {
360
369
@ TruffleBoundary
361
370
@ Specialization
362
371
static HashingStorage intersectSameType (EconomicMapStorage self , EconomicMapStorage other ,
372
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
363
373
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
364
374
EconomicMapStorage result = EconomicMapStorage .create ();
365
375
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
366
376
while (cursor .advance ()) {
367
- if (other .map .containsKey (cursor .getKey (), lib , lib )) {
368
- result .map .put (cursor .getKey (), cursor .getValue (), lib , lib );
377
+ if (other .map .containsKey (cursor .getKey (), lib , lib , findProfile )) {
378
+ result .map .put (cursor .getKey (), cursor .getValue (), lib , lib , findProfile );
369
379
}
370
380
}
371
381
return result ;
@@ -374,13 +384,14 @@ static HashingStorage intersectSameType(EconomicMapStorage self, EconomicMapStor
374
384
@ TruffleBoundary
375
385
@ Specialization (limit = "4" )
376
386
static HashingStorage intersectGeneric (EconomicMapStorage self , HashingStorage other ,
387
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
377
388
@ CachedLibrary ("other" ) HashingStorageLibrary hlib ,
378
389
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
379
390
EconomicMapStorage result = EconomicMapStorage .create ();
380
391
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
381
392
while (cursor .advance ()) {
382
393
if (hlib .hasKey (other , cursor .getKey ().value )) {
383
- result .map .put (cursor .getKey (), cursor .getValue (), lib , lib );
394
+ result .map .put (cursor .getKey (), cursor .getValue (), lib , lib , findProfile );
384
395
}
385
396
}
386
397
return result ;
@@ -392,12 +403,13 @@ public static class Diff {
392
403
@ TruffleBoundary
393
404
@ Specialization
394
405
static HashingStorage diffSameType (EconomicMapStorage self , EconomicMapStorage other ,
406
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
395
407
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
396
408
EconomicMapStorage result = EconomicMapStorage .create ();
397
409
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
398
410
while (cursor .advance ()) {
399
- if (!other .map .containsKey (cursor .getKey (), lib , lib )) {
400
- result .map .put (cursor .getKey (), cursor .getValue (), lib , lib );
411
+ if (!other .map .containsKey (cursor .getKey (), lib , lib , findProfile )) {
412
+ result .map .put (cursor .getKey (), cursor .getValue (), lib , lib , findProfile );
401
413
}
402
414
}
403
415
return result ;
@@ -406,13 +418,14 @@ static HashingStorage diffSameType(EconomicMapStorage self, EconomicMapStorage o
406
418
@ TruffleBoundary
407
419
@ Specialization (limit = "4" )
408
420
static HashingStorage diffGeneric (EconomicMapStorage self , HashingStorage other ,
421
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile findProfile ,
409
422
@ CachedLibrary ("other" ) HashingStorageLibrary hlib ,
410
423
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
411
424
EconomicMapStorage result = EconomicMapStorage .create ();
412
425
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
413
426
while (cursor .advance ()) {
414
427
if (!hlib .hasKey (other , cursor .getKey ().value )) {
415
- result .map .put (cursor .getKey (), cursor .getValue (), lib , lib );
428
+ result .map .put (cursor .getKey (), cursor .getValue (), lib , lib , findProfile );
416
429
}
417
430
}
418
431
return result ;
0 commit comments