Commit 0b1b88cb authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Remove unneeded LazyInstance

We don't need that complexity for initializing a static array.

R=cbruni@chromium.org

Bug: v8:8562, v8:8600
Change-Id: I35ba00dc7a11eeff6c6eadbcb8899a697ccfb415
Reviewed-on: https://chromium-review.googlesource.com/c/1380113Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58310}
parent 3c216bfc
...@@ -68,48 +68,32 @@ const char* ElementsKindToString(ElementsKind kind) { ...@@ -68,48 +68,32 @@ const char* ElementsKindToString(ElementsKind kind) {
return accessor->name(); return accessor->name();
} }
ElementsKind kFastElementsKindSequence[kFastElementsKindCount] = {
struct InitializeFastElementsKindSequence { PACKED_SMI_ELEMENTS, // 0
static void Construct(void* fast_elements_kind_sequence_ptr_arg) { HOLEY_SMI_ELEMENTS, // 1
auto fast_elements_kind_sequence_ptr = PACKED_DOUBLE_ELEMENTS, // 2
reinterpret_cast<ElementsKind**>(fast_elements_kind_sequence_ptr_arg); HOLEY_DOUBLE_ELEMENTS, // 3
ElementsKind* fast_elements_kind_sequence = PACKED_ELEMENTS, // 4
new ElementsKind[kFastElementsKindCount]; HOLEY_ELEMENTS // 5
*fast_elements_kind_sequence_ptr = fast_elements_kind_sequence; };
STATIC_ASSERT(PACKED_SMI_ELEMENTS == FIRST_FAST_ELEMENTS_KIND); STATIC_ASSERT(PACKED_SMI_ELEMENTS == FIRST_FAST_ELEMENTS_KIND);
fast_elements_kind_sequence[0] = PACKED_SMI_ELEMENTS; // Verify that kFastElementsKindPackedToHoley is correct.
fast_elements_kind_sequence[1] = HOLEY_SMI_ELEMENTS; STATIC_ASSERT(PACKED_SMI_ELEMENTS + kFastElementsKindPackedToHoley ==
fast_elements_kind_sequence[2] = PACKED_DOUBLE_ELEMENTS;
fast_elements_kind_sequence[3] = HOLEY_DOUBLE_ELEMENTS;
fast_elements_kind_sequence[4] = PACKED_ELEMENTS;
fast_elements_kind_sequence[5] = HOLEY_ELEMENTS;
// Verify that kFastElementsKindPackedToHoley is correct.
STATIC_ASSERT(PACKED_SMI_ELEMENTS + kFastElementsKindPackedToHoley ==
HOLEY_SMI_ELEMENTS); HOLEY_SMI_ELEMENTS);
STATIC_ASSERT(PACKED_DOUBLE_ELEMENTS + kFastElementsKindPackedToHoley == STATIC_ASSERT(PACKED_DOUBLE_ELEMENTS + kFastElementsKindPackedToHoley ==
HOLEY_DOUBLE_ELEMENTS); HOLEY_DOUBLE_ELEMENTS);
STATIC_ASSERT(PACKED_ELEMENTS + kFastElementsKindPackedToHoley == STATIC_ASSERT(PACKED_ELEMENTS + kFastElementsKindPackedToHoley ==
HOLEY_ELEMENTS); HOLEY_ELEMENTS);
}
};
static base::LazyInstance<ElementsKind*,
InitializeFastElementsKindSequence>::type
fast_elements_kind_sequence = LAZY_INSTANCE_INITIALIZER;
ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_number) { ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_number) {
DCHECK(sequence_number >= 0 && DCHECK(sequence_number >= 0 &&
sequence_number < kFastElementsKindCount); sequence_number < kFastElementsKindCount);
return fast_elements_kind_sequence.Get()[sequence_number]; return kFastElementsKindSequence[sequence_number];
} }
int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind) { int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind) {
for (int i = 0; i < kFastElementsKindCount; ++i) { for (int i = 0; i < kFastElementsKindCount; ++i) {
if (fast_elements_kind_sequence.Get()[i] == elements_kind) { if (kFastElementsKindSequence[i] == elements_kind) {
return i; return i;
} }
} }
......
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