Commit 99a85fa5 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[objects] initialize SmallOrderedHashTable padding

This fixes the test SmallOrderedHashMapAllocate in
test-code-stub-assembler.cc, which uses memcmp to check
SmallOrderedHashMap objects for equality:
https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20-%20nosnap%20-%20debug/24470


Change-Id: I1c1ad2e8923322c856191fac30f109a4e671b98e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1667417
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62350}
parent aaef2562
......@@ -3647,6 +3647,17 @@ TNode<CollectionType> CodeStubAssembler::AllocateSmallOrderedHashTable(
StoreMapNoWriteBarrier(table_obj, small_ordered_hash_map);
TNode<CollectionType> table = UncheckedCast<CollectionType>(table_obj);
{
// This store overlaps with the header fields stored below.
// Since it happens first, it effectively still just zero-initializes the
// padding.
constexpr int offset =
RoundDown<kTaggedSize>(CollectionType::PaddingOffset());
STATIC_ASSERT(offset + kTaggedSize == CollectionType::PaddingOffset() +
CollectionType::PaddingSize());
StoreObjectFieldNoWriteBarrier(table, offset, SmiConstant(0));
}
// Initialize the SmallOrderedHashTable fields.
StoreObjectByteNoWriteBarrier(
table, CollectionType::NumberOfBucketsOffset(),
......
......@@ -508,6 +508,8 @@ void SmallOrderedHashTable<Derived>::Initialize(Isolate* isolate,
SetNumberOfBuckets(num_buckets);
SetNumberOfElements(0);
SetNumberOfDeletedElements(0);
memset(reinterpret_cast<void*>(field_address(PaddingOffset())), 0,
PaddingSize());
Address hashtable_start = GetHashTableStartAddress(capacity);
memset(reinterpret_cast<byte*>(hashtable_start), kNotFound,
......
......@@ -527,8 +527,16 @@ class SmallOrderedHashTable : public HeapObject {
return NumberOfDeletedElementsOffset() + kOneByteSize;
}
static constexpr Offset PaddingOffset() {
return NumberOfBucketsOffset() + kOneByteSize;
}
static constexpr size_t PaddingSize() {
return RoundUp<kTaggedSize>(PaddingOffset()) - PaddingOffset();
}
static constexpr Offset DataTableStartOffset() {
return RoundUp<kTaggedSize>(NumberOfBucketsOffset());
return PaddingOffset() + PaddingSize();
}
static constexpr int DataTableSizeFor(int capacity) {
......
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