[vm/concurrency] Allow bool/null in maps/sets without forcing to rehash copied graphs

Even though all canonical objects can be shared, they might cause
re-hashing on the receiver side due to user-defined get:hashCode
implementation.

This is why we do not consider the canonical bit (of a key in a map) when
determining whether rehashing is needed.

Though some well-known classes will have a properly behaved
get:hashCode, the most important being for kNullCid.
=> So we'll allow kNullCid, kBoolCid.

This makes receiving json data much faster due to not needing to re-hash
anymore (was done due to `null` values in the map backing store).

TEST=Existing test suite.

Change-Id: Ie6d39da7fe27ce8925644cf2c17a3944a9e936b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207080
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Martin Kustermann 2021-07-15 17:14:55 +00:00 committed by commit-bot@chromium.org
parent fd49e189e6
commit b9ad67691c

View file

@ -182,8 +182,10 @@ static bool MightNeedReHashing(ObjectPtr object) {
if (cid == kExternalTwoByteStringCid) return false;
if (cid == kMintCid) return false;
if (cid == kDoubleCid) return false;
if (cid == kBoolCid) return false;
if (cid == kSendPortCid) return false;
if (cid == kCapabilityCid) return false;
if (cid == kNullCid) return false;
// These are shared and use identity hash codes. If they are used as a key in
// a map or a value in a set, they will already have the identity hash code