Commit 6b8d86b8 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

heap: Annote strong roots with a label

This aids debugging as it gives the root set a name.

Bug: chromium:1164553, chromium:1186901
Change-Id: I2c2aed369823b059629b35bb170b4966b47156d0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2933661
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74960}
parent 8b0cbd23
...@@ -4713,7 +4713,7 @@ void Heap::IterateRoots(RootVisitor* v, base::EnumSet<SkipRoot> options) { ...@@ -4713,7 +4713,7 @@ void Heap::IterateRoots(RootVisitor* v, base::EnumSet<SkipRoot> options) {
// deoptimization entries). // deoptimization entries).
for (StrongRootsEntry* current = strong_roots_head_; current; for (StrongRootsEntry* current = strong_roots_head_; current;
current = current->next) { current = current->next) {
v->VisitRootPointers(Root::kStrongRoots, nullptr, current->start, v->VisitRootPointers(Root::kStrongRoots, current->label, current->start,
current->end); current->end);
} }
v->Synchronize(VisitorSynchronization::kStrongRoots); v->Synchronize(VisitorSynchronization::kStrongRoots);
...@@ -6419,11 +6419,12 @@ size_t Heap::OldArrayBufferBytes() { ...@@ -6419,11 +6419,12 @@ size_t Heap::OldArrayBufferBytes() {
return array_buffer_sweeper()->OldBytes(); return array_buffer_sweeper()->OldBytes();
} }
StrongRootsEntry* Heap::RegisterStrongRoots(FullObjectSlot start, StrongRootsEntry* Heap::RegisterStrongRoots(const char* label,
FullObjectSlot start,
FullObjectSlot end) { FullObjectSlot end) {
base::MutexGuard guard(&strong_roots_mutex_); base::MutexGuard guard(&strong_roots_mutex_);
StrongRootsEntry* entry = new StrongRootsEntry(); StrongRootsEntry* entry = new StrongRootsEntry(label);
entry->start = start; entry->start = start;
entry->end = end; entry->end = end;
entry->prev = nullptr; entry->prev = nullptr;
...@@ -7084,8 +7085,8 @@ Address* StrongRootBlockAllocator::allocate(size_t n) { ...@@ -7084,8 +7085,8 @@ Address* StrongRootBlockAllocator::allocate(size_t n) {
sizeof(StrongRootsEntry*)); sizeof(StrongRootsEntry*));
memset(ret, kNullAddress, n * sizeof(Address)); memset(ret, kNullAddress, n * sizeof(Address));
*header = *header = heap_->RegisterStrongRoots(
heap_->RegisterStrongRoots(FullObjectSlot(ret), FullObjectSlot(ret + n)); "StrongRootBlockAllocator", FullObjectSlot(ret), FullObjectSlot(ret + n));
return ret; return ret;
} }
......
...@@ -186,12 +186,13 @@ enum class SkipRoot { ...@@ -186,12 +186,13 @@ enum class SkipRoot {
kWeak kWeak
}; };
class StrongRootsEntry { class StrongRootsEntry final {
StrongRootsEntry() = default; explicit StrongRootsEntry(const char* label) : label(label) {}
// Label that identifies the roots in tooling.
const char* label;
FullObjectSlot start; FullObjectSlot start;
FullObjectSlot end; FullObjectSlot end;
StrongRootsEntry* prev; StrongRootsEntry* prev;
StrongRootsEntry* next; StrongRootsEntry* next;
...@@ -931,7 +932,7 @@ class Heap { ...@@ -931,7 +932,7 @@ class Heap {
V8_INLINE void SetMessageListeners(TemplateList value); V8_INLINE void SetMessageListeners(TemplateList value);
V8_INLINE void SetPendingOptimizeForTestBytecode(Object bytecode); V8_INLINE void SetPendingOptimizeForTestBytecode(Object bytecode);
StrongRootsEntry* RegisterStrongRoots(FullObjectSlot start, StrongRootsEntry* RegisterStrongRoots(const char* label, FullObjectSlot start,
FullObjectSlot end); FullObjectSlot end);
void UnregisterStrongRoots(StrongRootsEntry* entry); void UnregisterStrongRoots(StrongRootsEntry* entry);
void UpdateStrongRoots(StrongRootsEntry* entry, FullObjectSlot start, void UpdateStrongRoots(StrongRootsEntry* entry, FullObjectSlot start,
......
...@@ -1190,9 +1190,9 @@ void Serializer::ObjectSerializer::SerializeCode(Map map, int size) { ...@@ -1190,9 +1190,9 @@ void Serializer::ObjectSerializer::SerializeCode(Map map, int size) {
} }
Serializer::HotObjectsList::HotObjectsList(Heap* heap) : heap_(heap) { Serializer::HotObjectsList::HotObjectsList(Heap* heap) : heap_(heap) {
strong_roots_entry_ = strong_roots_entry_ = heap->RegisterStrongRoots(
heap->RegisterStrongRoots(FullObjectSlot(&circular_queue_[0]), "Serializer::HotObjectsList", FullObjectSlot(&circular_queue_[0]),
FullObjectSlot(&circular_queue_[kSize])); FullObjectSlot(&circular_queue_[kSize]));
} }
Serializer::HotObjectsList::~HotObjectsList() { Serializer::HotObjectsList::~HotObjectsList() {
heap_->UnregisterStrongRoots(strong_roots_entry_); heap_->UnregisterStrongRoots(strong_roots_entry_);
......
...@@ -205,8 +205,9 @@ IdentityMapBase::RawEntry IdentityMapBase::InsertEntry(Address key) { ...@@ -205,8 +205,9 @@ IdentityMapBase::RawEntry IdentityMapBase::InsertEntry(Address key) {
values_ = NewPointerArray(capacity_); values_ = NewPointerArray(capacity_);
memset(values_, 0, sizeof(uintptr_t) * capacity_); memset(values_, 0, sizeof(uintptr_t) * capacity_);
strong_roots_entry_ = heap_->RegisterStrongRoots( strong_roots_entry_ =
FullObjectSlot(keys_), FullObjectSlot(keys_ + capacity_)); heap_->RegisterStrongRoots("IdentityMapBase", FullObjectSlot(keys_),
FullObjectSlot(keys_ + capacity_));
} else { } else {
// Rehash if there was a GC, then insert. // Rehash if there was a GC, then insert.
if (gc_counter_ != heap_->gc_count()) Rehash(); if (gc_counter_ != heap_->gc_count()) Rehash();
......
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