[vm, compiler] Restore the performance of LoadUniqueObject.

The purpose of LoadUniqueObject (77c206f231) is to avoid the cost searching for matching object pool entries. Pass kPatchable to AddObject to skip the work of inserting / rehashing. This also fixes incorrect use of DirectChainedHashMap::Insert with an already-present key.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/23249
Bug: https://github.com/dart-lang/sdk/issues/38018
Change-Id: I30cc3212720d3ddfc9bc515b092a4cd6f6879b8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213027
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Ryan Macnak 2021-09-10 21:53:26 +00:00 committed by commit-bot@chromium.org
parent 8132940357
commit 802dfdfd62
3 changed files with 15 additions and 6 deletions

View file

@ -1671,8 +1671,11 @@ void Assembler::LoadObjectHelper(Register rd,
RELEASE_ASSERT(CanLoadFromObjectPool(object));
// Make sure that class CallPattern is able to decode this load from the
// object pool.
const auto index = is_unique ? object_pool_builder().AddObject(object)
: object_pool_builder().FindObject(object);
const auto index = is_unique
? object_pool_builder().AddObject(
object, ObjectPoolBuilderEntry::kPatchable)
: object_pool_builder().FindObject(
object, ObjectPoolBuilderEntry::kNotPatchable);
LoadWordFromPoolIndex(rd, index, pp, cond);
}

View file

@ -555,8 +555,11 @@ void Assembler::LoadObjectHelper(Register dst,
}
}
if (CanLoadFromObjectPool(object)) {
const intptr_t index = is_unique ? object_pool_builder().AddObject(object)
: object_pool_builder().FindObject(object);
const intptr_t index =
is_unique ? object_pool_builder().AddObject(
object, ObjectPoolBuilderEntry::kPatchable)
: object_pool_builder().FindObject(
object, ObjectPoolBuilderEntry::kNotPatchable);
LoadWordFromPoolIndex(dst, index);
return;
}

View file

@ -1287,8 +1287,11 @@ void Assembler::LoadObjectHelper(Register dst,
}
}
if (CanLoadFromObjectPool(object)) {
const intptr_t index = is_unique ? object_pool_builder().AddObject(object)
: object_pool_builder().FindObject(object);
const intptr_t index =
is_unique ? object_pool_builder().AddObject(
object, ObjectPoolBuilderEntry::kPatchable)
: object_pool_builder().FindObject(
object, ObjectPoolBuilderEntry::kNotPatchable);
LoadWordFromPoolIndex(dst, index);
return;
}