Commit 79e396e5 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[cleanup] Don't unroll the name dictionary lookup loop.

This doesn't seem to provide any noticable performance wins, and just
adds more (generated) code. On a synthetic micro-benchmark for accessing
dictionary elements I was able to measure only a <1% difference for
loads and barely 1-2% for stores. That doesn't seem to be enough of a
reason to add four unrolled iterations of the lookup loop in all kinds
of places.

Bug: v8:5787, v8:8834
Change-Id: Iab8f71bf70a5518589ed4999a5be21d268ba1081
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1563774
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60770}
parent 98cde3f4
......@@ -8436,14 +8436,12 @@ TNode<HeapObject> CodeStubAssembler::LoadName<GlobalDictionary>(
template <typename Dictionary>
void CodeStubAssembler::NameDictionaryLookup(
TNode<Dictionary> dictionary, TNode<Name> unique_name, Label* if_found,
TVariable<IntPtrT>* var_name_index, Label* if_not_found, int inlined_probes,
LookupMode mode) {
TVariable<IntPtrT>* var_name_index, Label* if_not_found, LookupMode mode) {
static_assert(std::is_same<Dictionary, NameDictionary>::value ||
std::is_same<Dictionary, GlobalDictionary>::value,
"Unexpected NameDictionary");
DCHECK_EQ(MachineType::PointerRepresentation(), var_name_index->rep());
DCHECK_IMPLIES(mode == kFindInsertionIndex,
inlined_probes == 0 && if_found == nullptr);
DCHECK_IMPLIES(mode == kFindInsertionIndex, if_found == nullptr);
Comment("NameDictionaryLookup");
CSA_ASSERT(this, IsUniqueName(unique_name));
......@@ -8456,29 +8454,13 @@ void CodeStubAssembler::NameDictionaryLookup(
TNode<IntPtrT> entry = Signed(WordAnd(hash, mask));
Node* undefined = UndefinedConstant();
for (int i = 0; i < inlined_probes; i++) {
TNode<IntPtrT> index = EntryToIndex<Dictionary>(entry);
*var_name_index = index;
TNode<HeapObject> current =
CAST(UnsafeLoadFixedArrayElement(dictionary, index));
GotoIf(WordEqual(current, undefined), if_not_found);
current = LoadName<Dictionary>(current);
GotoIf(WordEqual(current, unique_name), if_found);
// See Dictionary::NextProbe().
count = IntPtrConstant(i + 1);
entry = Signed(WordAnd(IntPtrAdd(entry, count), mask));
}
if (mode == kFindInsertionIndex) {
// Appease the variable merging algorithm for "Goto(&loop)" below.
*var_name_index = IntPtrConstant(0);
}
TVARIABLE(IntPtrT, var_count, count);
TVARIABLE(IntPtrT, var_entry, entry);
Variable* loop_vars[] = {&var_count, &var_entry, var_name_index};
Label loop(this, 3, loop_vars);
Label loop(this, arraysize(loop_vars), loop_vars);
Goto(&loop);
BIND(&loop);
{
......@@ -8487,7 +8469,8 @@ void CodeStubAssembler::NameDictionaryLookup(
TNode<IntPtrT> index = EntryToIndex<Dictionary>(entry);
*var_name_index = index;
TNode<HeapObject> current = CAST(LoadFixedArrayElement(dictionary, index));
TNode<HeapObject> current =
CAST(UnsafeLoadFixedArrayElement(dictionary, index));
GotoIf(WordEqual(current, undefined), if_not_found);
if (mode == kFindExisting) {
current = LoadName<Dictionary>(current);
......@@ -8511,11 +8494,10 @@ template V8_EXPORT_PRIVATE void
CodeStubAssembler::NameDictionaryLookup<NameDictionary>(TNode<NameDictionary>,
TNode<Name>, Label*,
TVariable<IntPtrT>*,
Label*, int,
LookupMode);
Label*, LookupMode);
template V8_EXPORT_PRIVATE void CodeStubAssembler::NameDictionaryLookup<
GlobalDictionary>(TNode<GlobalDictionary>, TNode<Name>, Label*,
TVariable<IntPtrT>*, Label*, int, LookupMode);
TVariable<IntPtrT>*, Label*, LookupMode);
Node* CodeStubAssembler::ComputeUnseededHash(Node* key) {
// See v8::internal::ComputeUnseededHash()
......@@ -8664,7 +8646,7 @@ void CodeStubAssembler::FindInsertionEntry<NameDictionary>(
TVariable<IntPtrT>* var_key_index) {
Label done(this);
NameDictionaryLookup<NameDictionary>(dictionary, key, nullptr, var_key_index,
&done, 0, kFindInsertionIndex);
&done, kFindInsertionIndex);
BIND(&done);
}
......
......@@ -2658,7 +2658,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// control goes to {if_found} and {var_name_index} contains an index of the
// key field of the entry found. If the key is not found control goes to
// {if_not_found}.
static const int kInlinedDictionaryProbes = 4;
enum LookupMode { kFindExisting, kFindInsertionIndex };
template <typename Dictionary>
......@@ -2669,7 +2668,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Name> unique_name, Label* if_found,
TVariable<IntPtrT>* var_name_index,
Label* if_not_found,
int inlined_probes = kInlinedDictionaryProbes,
LookupMode mode = kFindExisting);
Node* ComputeUnseededHash(Node* key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment