Commit 1a4ea3bc authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

cppgc: Reorder Heap registration in HeapRegistry

HeapRegistry requires a valid PageBackend for querying containment.
Reorder fields to guarantee that a backend is indeed available.

Bug: chromium:1056170
Change-Id: I32c0251d67ff99cd3609946154526f648c16c617
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2916818
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74748}
parent 6596e8c6
......@@ -216,13 +216,14 @@ class V8_EXPORT_PRIVATE HeapBase : public cppgc::HeapHandle {
std::unique_ptr<v8::base::LsanPageAllocator> lsan_page_allocator_;
#endif // LEAK_SANITIZER
HeapRegistry::Subscription heap_registry_subscription_{*this};
#if defined(CPPGC_CAGED_HEAP)
CagedHeap caged_heap_;
#endif // CPPGC_CAGED_HEAP
std::unique_ptr<PageBackend> page_backend_;
// HeapRegistry requires access to page_backend_.
HeapRegistry::Subscription heap_registry_subscription_{*this};
std::unique_ptr<StatsCollector> stats_collector_;
std::unique_ptr<heap::base::Stack> stack_;
std::unique_ptr<PreFinalizerHandler> prefinalizer_handler_;
......
......@@ -8,6 +8,7 @@
#include <vector>
#include "src/base/lazy-instance.h"
#include "src/base/logging.h"
#include "src/base/platform/mutex.h"
#include "src/heap/cppgc/heap-base.h"
#include "src/heap/cppgc/page-memory.h"
......@@ -42,6 +43,10 @@ void HeapRegistry::RegisterHeap(HeapBase& heap) {
void HeapRegistry::UnregisterHeap(HeapBase& heap) {
v8::base::MutexGuard guard(g_heap_registry_mutex.Pointer());
// HeapRegistry requires access to PageBackend which means it must still
// be present by the time a heap is removed from the registry.
DCHECK_NOT_NULL(heap.page_backend());
auto& storage = GetHeapRegistryStorage();
const auto pos = std::find(storage.begin(), storage.end(), &heap);
DCHECK_NE(storage.end(), pos);
......
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