|
62 | 62 | import com.oracle.graal.python.builtins.objects.common.HashingStorageNodesFactory.HashingStorageSetItemWithHashNodeGen; |
63 | 63 | import com.oracle.graal.python.builtins.objects.common.KeywordsStorage.GetKeywordsStorageItemNode; |
64 | 64 | import com.oracle.graal.python.builtins.objects.common.ObjectHashMap.PutNode; |
| 65 | +import com.oracle.graal.python.builtins.objects.common.ObjectHashMap.PutUnsafeNode; |
65 | 66 | import com.oracle.graal.python.lib.PyObjectHashNode; |
66 | 67 | import com.oracle.graal.python.lib.PyObjectRichCompareBool; |
67 | 68 | import com.oracle.graal.python.lib.PyUnicodeCheckExactNode; |
@@ -121,7 +122,7 @@ public static boolean mayHaveSideEffectingEq(HashingStorage storage) { |
121 | 122 |
|
122 | 123 | public static boolean mayHaveSideEffects(PHashingCollection wrapper) { |
123 | 124 | HashingStorage s = wrapper.getDictStorage(); |
124 | | - return !(s instanceof EconomicMapStorage && ((EconomicMapStorage) s).map.hasSideEffect()); |
| 125 | + return !(s instanceof EconomicMapStorage && ((EconomicMapStorage) s).map.hasSideEffectingKeys()); |
125 | 126 | } |
126 | 127 | } |
127 | 128 |
|
@@ -252,7 +253,7 @@ abstract static class SpecializedSetStringKey extends Node { |
252 | 253 | public abstract void execute(Node inliningTarget, HashingStorage self, TruffleString key, Object value); |
253 | 254 | } |
254 | 255 |
|
255 | | - static EconomicMapStorage dynamicObjectStorageToEconomicMap(Node inliningTarget, DynamicObjectStorage s, DynamicObjectLibrary dylib, PyObjectHashNode hashNode, PutNode putNode) { |
| 256 | + static EconomicMapStorage dynamicObjectStorageToEconomicMap(Node inliningTarget, DynamicObjectStorage s, DynamicObjectLibrary dylib, PyObjectHashNode hashNode, PutUnsafeNode putNode) { |
256 | 257 | // TODO: shouldn't we invalidate all MRO assumptions in this case? |
257 | 258 | DynamicObject store = s.store; |
258 | 259 | EconomicMapStorage result = EconomicMapStorage.create(dylib.getShape(store).getPropertyCount()); |
@@ -287,24 +288,16 @@ public final HashingStorage executeCached(Frame frame, HashingStorage self, Obje |
287 | 288 |
|
288 | 289 | @Specialization |
289 | 290 | static HashingStorage economicMap(Frame frame, Node inliningTarget, EconomicMapStorage self, Object key, long keyHash, Object value, |
290 | | - @Exclusive @Cached PyUnicodeCheckExactNode isBuiltinString, |
291 | | - @Exclusive @Cached ObjectHashMap.PutNode putNode) { |
| 291 | + @Exclusive @Cached PutNode putNode) { |
292 | 292 | putNode.execute(frame, inliningTarget, self.map, key, keyHash, value); |
293 | | - if (!self.map.hasSideEffect() && !isBuiltinString.execute(inliningTarget, key)) { |
294 | | - self.map.setSideEffectingKeysFlag(); |
295 | | - } |
296 | 293 | return self; |
297 | 294 | } |
298 | 295 |
|
299 | 296 | @Specialization |
300 | 297 | static HashingStorage empty(Frame frame, Node inliningTarget, @SuppressWarnings("unused") EmptyStorage self, Object key, long keyHash, Object value, |
301 | | - @Exclusive @Cached PyUnicodeCheckExactNode isBuiltinString, |
302 | | - @Exclusive @Cached ObjectHashMap.PutNode putNode) { |
| 298 | + @Exclusive @Cached PutNode putNode) { |
303 | 299 | EconomicMapStorage storage = EconomicMapStorage.create(1); |
304 | 300 | putNode.execute(frame, inliningTarget, storage.map, key, keyHash, value); |
305 | | - if (!isBuiltinString.execute(inliningTarget, key)) { |
306 | | - storage.map.setSideEffectingKeysFlag(); |
307 | | - } |
308 | 301 | return storage; |
309 | 302 | } |
310 | 303 |
|
@@ -335,17 +328,16 @@ static HashingStorage dom(Frame frame, Node inliningTarget, DynamicObjectStorage |
335 | 328 | @Specialization |
336 | 329 | @InliningCutoff |
337 | 330 | static HashingStorage keywords(Frame frame, Node inliningTarget, KeywordsStorage self, Object key, long keyHash, Object value, |
338 | | - @Exclusive @Cached PyUnicodeCheckExactNode isBuiltinString, |
339 | | - @Exclusive @Cached ObjectHashMap.PutNode putNode, |
| 331 | + @Exclusive @Cached PutNode putNode, |
340 | 332 | @Cached EconomicMapSetStringKey specializedPutNode) { |
341 | 333 | // TODO: do we want to try DynamicObjectStorage if the key is a string? |
342 | 334 | EconomicMapStorage result = EconomicMapStorage.create(self.length()); |
343 | 335 | self.addAllTo(inliningTarget, result, specializedPutNode); |
344 | | - return economicMap(frame, inliningTarget, result, key, keyHash, value, isBuiltinString, putNode); |
| 336 | + return economicMap(frame, inliningTarget, result, key, keyHash, value, putNode); |
345 | 337 | } |
346 | 338 |
|
347 | 339 | @Specialization |
348 | | - static HashingStorage foreign(Frame frame, Node inliningTarget, ForeignHashingStorage self, Object key, long keyHash, Object value, |
| 340 | + static HashingStorage foreign(Node inliningTarget, ForeignHashingStorage self, Object key, long keyHash, Object value, |
349 | 341 | @Cached ForeignHashingStorage.PutNode putNode) { |
350 | 342 | putNode.execute(inliningTarget, self, key, value); |
351 | 343 | return self; |
@@ -373,8 +365,9 @@ static HashingStorage domStringKey(Node inliningTarget, DynamicObjectStorage sel |
373 | 365 | static HashingStorage domTransition(Frame frame, Node inliningTarget, DynamicObjectStorage self, Object key, @SuppressWarnings("unused") long keyHash, Object value, |
374 | 366 | @SuppressWarnings("unused") boolean transition, DynamicObjectLibrary dylib, |
375 | 367 | @Cached PyObjectHashNode hashNode, |
376 | | - @Cached ObjectHashMap.PutNode putNode) { |
377 | | - EconomicMapStorage result = dynamicObjectStorageToEconomicMap(inliningTarget, self, dylib, hashNode, putNode); |
| 368 | + @Cached PutUnsafeNode putUnsafeNode, |
| 369 | + @Cached PutNode putNode) { |
| 370 | + EconomicMapStorage result = dynamicObjectStorageToEconomicMap(inliningTarget, self, dylib, hashNode, putUnsafeNode); |
378 | 371 | putNode.execute(frame, inliningTarget, result.map, key, keyHash, value); |
379 | 372 | return result; |
380 | 373 | } |
@@ -415,27 +408,22 @@ public final HashingStorage execute(Node inliningTarget, HashingStorage self, Tr |
415 | 408 |
|
416 | 409 | @Specialization |
417 | 410 | static HashingStorage economicMap(Frame frame, Node inliningTarget, EconomicMapStorage self, Object key, Object value, |
418 | | - @Exclusive @Cached PyUnicodeCheckExactNode isBuiltinString, |
419 | 411 | @Exclusive @Cached PyObjectHashNode hashNode, |
420 | | - @Exclusive @Cached ObjectHashMap.PutNode putNode) { |
| 412 | + @Exclusive @Cached PutNode putNode) { |
421 | 413 | putNode.execute(frame, inliningTarget, self.map, key, hashNode.execute(frame, inliningTarget, key), value); |
422 | | - if (!self.map.hasSideEffect() && !isBuiltinString.execute(inliningTarget, key)) { |
423 | | - self.map.setSideEffectingKeysFlag(); |
424 | | - } |
425 | 414 | return self; |
426 | 415 | } |
427 | 416 |
|
428 | 417 | @Specialization |
429 | 418 | static HashingStorage empty(Frame frame, Node inliningTarget, @SuppressWarnings("unused") EmptyStorage self, Object key, Object value, |
430 | | - @Exclusive @Cached PyUnicodeCheckExactNode isBuiltinString, |
431 | 419 | @Exclusive @Cached PyObjectHashNode hashNode, |
432 | | - @Exclusive @Cached ObjectHashMap.PutNode putNode) { |
| 420 | + @Exclusive @Cached PutNode putNode) { |
433 | 421 | // The ObjectHashMap.PutNode is @Exclusive because profiles for a put into a freshly new |
434 | 422 | // allocated map can be quite different to profiles in the other situations when we are |
435 | 423 | // putting into a map that already has or will have some more items in it |
436 | 424 | // It is also @Cached(inline = false) because inlining it triggers GR-44836 |
437 | 425 | // TODO: do we want to try DynamicObjectStorage if the key is a string? |
438 | | - return economicMap(frame, inliningTarget, EconomicMapStorage.create(1), key, value, isBuiltinString, hashNode, putNode); |
| 426 | + return economicMap(frame, inliningTarget, EconomicMapStorage.create(1), key, value, hashNode, putNode); |
439 | 427 | } |
440 | 428 |
|
441 | 429 | @Specialization(guards = "!self.shouldTransitionOnPut()") |
@@ -466,13 +454,12 @@ static HashingStorage dom(Frame frame, Node inliningTarget, DynamicObjectStorage |
466 | 454 | @InliningCutoff |
467 | 455 | static HashingStorage keywords(Frame frame, Node inliningTarget, KeywordsStorage self, Object key, Object value, |
468 | 456 | @Exclusive @Cached PyObjectHashNode hashNode, |
469 | | - @Exclusive @Cached PyUnicodeCheckExactNode isBuiltinString, |
470 | | - @Exclusive @Cached ObjectHashMap.PutNode putNode, |
| 457 | + @Exclusive @Cached PutNode putNode, |
471 | 458 | @Cached EconomicMapSetStringKey specializedPutNode) { |
472 | 459 | // TODO: do we want to try DynamicObjectStorage if the key is a string? |
473 | 460 | EconomicMapStorage result = EconomicMapStorage.create(self.length()); |
474 | 461 | self.addAllTo(inliningTarget, result, specializedPutNode); |
475 | | - return economicMap(frame, inliningTarget, result, key, value, isBuiltinString, hashNode, putNode); |
| 462 | + return economicMap(frame, inliningTarget, result, key, value, hashNode, putNode); |
476 | 463 | } |
477 | 464 |
|
478 | 465 | @Specialization |
@@ -504,8 +491,9 @@ static HashingStorage domStringKey(Node inliningTarget, DynamicObjectStorage sel |
504 | 491 | static HashingStorage domTransition(Frame frame, Node inliningTarget, DynamicObjectStorage self, Object key, Object value, |
505 | 492 | @SuppressWarnings("unused") boolean transition, DynamicObjectLibrary dylib, |
506 | 493 | @Cached PyObjectHashNode hashNode, |
507 | | - @Cached ObjectHashMap.PutNode putNode) { |
508 | | - EconomicMapStorage result = dynamicObjectStorageToEconomicMap(inliningTarget, self, dylib, hashNode, putNode); |
| 494 | + @Cached PutUnsafeNode putUnsafeNode, |
| 495 | + @Cached PutNode putNode) { |
| 496 | + EconomicMapStorage result = dynamicObjectStorageToEconomicMap(inliningTarget, self, dylib, hashNode, putUnsafeNode); |
509 | 497 | putNode.execute(frame, inliningTarget, result.map, key, hashNode.execute(frame, inliningTarget, key), value); |
510 | 498 | return result; |
511 | 499 | } |
@@ -1365,7 +1353,7 @@ public abstract static class HashingStorageXorCallback extends HashingStorageFor |
1365 | 1353 |
|
1366 | 1354 | @Specialization |
1367 | 1355 | static ResultAndOther doGeneric(Frame frame, Node inliningTarget, HashingStorage storage, HashingStorageIterator it, ResultAndOther acc, |
1368 | | - @Cached ObjectHashMap.PutNode putResultNode, |
| 1356 | + @Cached PutNode putResultNode, |
1369 | 1357 | @Cached HashingStorageGetItemWithHash getFromOther, |
1370 | 1358 | @Cached HashingStorageIteratorKey iterKey, |
1371 | 1359 | @Cached HashingStorageIteratorValue iterValue, |
@@ -1417,7 +1405,7 @@ public abstract static class HashingStorageIntersectCallback extends HashingStor |
1417 | 1405 |
|
1418 | 1406 | @Specialization |
1419 | 1407 | static ResultAndOther doGeneric(Frame frame, Node inliningTarget, HashingStorage storage, HashingStorageIterator it, ResultAndOther acc, |
1420 | | - @Cached ObjectHashMap.PutNode putResultNode, |
| 1408 | + @Cached PutNode putResultNode, |
1421 | 1409 | @Cached HashingStorageGetItemWithHash getFromOther, |
1422 | 1410 | @Cached HashingStorageIteratorKey iterKey, |
1423 | 1411 | @Cached HashingStorageIteratorKeyHash iterHash) { |
@@ -1463,7 +1451,7 @@ public abstract static class HashingStorageDiffCallback extends HashingStorageFo |
1463 | 1451 |
|
1464 | 1452 | @Specialization |
1465 | 1453 | static ResultAndOther doGeneric(Frame frame, Node inliningTarget, HashingStorage storage, HashingStorageIterator it, ResultAndOther acc, |
1466 | | - @Cached ObjectHashMap.PutNode putResultNode, |
| 1454 | + @Cached PutNode putResultNode, |
1467 | 1455 | @Cached HashingStorageGetItemWithHash getFromOther, |
1468 | 1456 | @Cached HashingStorageIteratorKey iterKey, |
1469 | 1457 | @Cached HashingStorageIteratorKeyHash iterHash, |
|
0 commit comments