Commit aec2874d authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Read gc_state() only once for DCHECK

That DCHECK could fail even though GC was in the right state. It could
happen that the first load gets the old value NOT_IN_GC, since this
isn't TEAR_DOWN a second load needs to be performed. The load then
returns TEAR_DOWN but that doesn't match NOT_IN_GC either.

Fix this by only loading gc_state() once.

Bug: v8:10315
Change-Id: Ibcad540fa4d5f578c9936c472b294bbccebdc09a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2418719Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70021}
parent 3cb8b399
......@@ -15,13 +15,15 @@ namespace internal {
AllocationResult LocalHeap::AllocateRaw(int size_in_bytes, AllocationType type,
AllocationOrigin origin,
AllocationAlignment alignment) {
#if DEBUG
DCHECK_EQ(LocalHeap::Current(), this);
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK_IMPLIES(type == AllocationType::kCode,
alignment == AllocationAlignment::kCodeAligned);
DCHECK(heap()->gc_state() == Heap::TEAR_DOWN ||
heap()->gc_state() == Heap::NOT_IN_GC);
Heap::HeapState state = heap()->gc_state();
DCHECK(state == Heap::TEAR_DOWN || state == Heap::NOT_IN_GC);
#endif
bool large_object = size_in_bytes > kMaxRegularHeapObjectSize;
CHECK_EQ(type, AllocationType::kOld);
......
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