Commit 5f7af3cd authored by cbruni's avatar cbruni Committed by Commit bot

[collections] Shuffle OrderedHashTable fields around for future optimization

A future linear version of the hash table will only need the element count and
deleted element count. Hence moving them to the beginning of the underlying
fixed array makes the transition easier.

BUG=v8:5717

Review-Url: https://codereview.chromium.org/2630373002
Cr-Commit-Position: refs/heads/master@{#42459}
parent d9adbc0f
......@@ -140,11 +140,11 @@ macro FIXED_ARRAY_SET(array, index, value) = (%_FixedArraySet(array, (index) | 0
# TODO(adamk): Find a more robust way to force Smi representation.
macro FIXED_ARRAY_SET_SMI(array, index, value) = (FIXED_ARRAY_SET(array, index, (value) | 0));
macro ORDERED_HASH_TABLE_BUCKET_COUNT(table) = (FIXED_ARRAY_GET(table, 0));
macro ORDERED_HASH_TABLE_ELEMENT_COUNT(table) = (FIXED_ARRAY_GET(table, 1));
macro ORDERED_HASH_TABLE_SET_ELEMENT_COUNT(table, count) = (FIXED_ARRAY_SET_SMI(table, 1, count));
macro ORDERED_HASH_TABLE_DELETED_COUNT(table) = (FIXED_ARRAY_GET(table, 2));
macro ORDERED_HASH_TABLE_SET_DELETED_COUNT(table, count) = (FIXED_ARRAY_SET_SMI(table, 2, count));
macro ORDERED_HASH_TABLE_BUCKET_COUNT(table) = (FIXED_ARRAY_GET(table, 2));
macro ORDERED_HASH_TABLE_ELEMENT_COUNT(table) = (FIXED_ARRAY_GET(table, 0));
macro ORDERED_HASH_TABLE_SET_ELEMENT_COUNT(table, count) = (FIXED_ARRAY_SET_SMI(table, 0, count));
macro ORDERED_HASH_TABLE_DELETED_COUNT(table) = (FIXED_ARRAY_GET(table, 1));
macro ORDERED_HASH_TABLE_SET_DELETED_COUNT(table, count) = (FIXED_ARRAY_SET_SMI(table, 1, count));
macro ORDERED_HASH_TABLE_BUCKET_AT(table, bucket) = (FIXED_ARRAY_GET(table, 3 + (bucket)));
macro ORDERED_HASH_TABLE_SET_BUCKET_AT(table, bucket, entry) = (FIXED_ARRAY_SET(table, 3 + (bucket), entry));
......
......@@ -2866,10 +2866,12 @@ class FixedArray: public FixedArrayBase {
void CopyTo(int pos, FixedArray* dest, int dest_pos, int len);
// Garbage collection support.
static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; }
static constexpr int SizeFor(int length) {
return kHeaderSize + length * kPointerSize;
}
// Code Generation support.
static int OffsetOfElementAt(int index) { return SizeFor(index); }
static constexpr int OffsetOfElementAt(int index) { return SizeFor(index); }
// Garbage collection support.
inline Object** RawFieldOfElementAt(int index);
......@@ -4271,22 +4273,23 @@ class OrderedHashTable: public FixedArray {
static const int kNotFound = -1;
static const int kMinCapacity = 4;
static const int kNumberOfBucketsIndex = 0;
static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1;
static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1;
static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1;
static const int kNumberOfElementsIndex = 0;
// The next table is stored at the same index as the nof elements.
static const int kNextTableIndex = kNumberOfElementsIndex;
static const int kNumberOfBucketsOffset =
kHeaderSize + kNumberOfBucketsIndex * kPointerSize;
static const int kNumberOfElementsOffset =
kHeaderSize + kNumberOfElementsIndex * kPointerSize;
static const int kNumberOfDeletedElementsOffset =
kHeaderSize + kNumberOfDeletedElementsIndex * kPointerSize;
static const int kHashTableStartOffset =
kHeaderSize + kHashTableStartIndex * kPointerSize;
static const int kNextTableOffset =
kHeaderSize + kNextTableIndex * kPointerSize;
static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1;
static const int kNumberOfBucketsIndex = kNumberOfDeletedElementsIndex + 1;
static const int kHashTableStartIndex = kNumberOfBucketsIndex + 1;
static constexpr const int kNumberOfElementsOffset =
FixedArray::OffsetOfElementAt(kNumberOfElementsIndex);
static constexpr const int kNextTableOffset =
FixedArray::OffsetOfElementAt(kNextTableIndex);
static constexpr const int kNumberOfDeletedElementsOffset =
FixedArray::OffsetOfElementAt(kNumberOfDeletedElementsIndex);
static constexpr const int kNumberOfBucketsOffset =
FixedArray::OffsetOfElementAt(kNumberOfBucketsIndex);
static constexpr const int kHashTableStartOffset =
FixedArray::OffsetOfElementAt(kHashTableStartIndex);
static const int kEntrySize = entrysize + 1;
static const int kChainOffset = entrysize;
......
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