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) {
// deoptimization entries).
for (StrongRootsEntry* current = strong_roots_head_; current;
current = current->next) {
v->VisitRootPointers(Root::kStrongRoots, nullptr, current->start,
v->VisitRootPointers(Root::kStrongRoots, current->label, current->start,
current->end);
}
v->Synchronize(VisitorSynchronization::kStrongRoots);
......@@ -6419,11 +6419,12 @@ size_t Heap::OldArrayBufferBytes() {
return array_buffer_sweeper()->OldBytes();
}
StrongRootsEntry* Heap::RegisterStrongRoots(FullObjectSlot start,
StrongRootsEntry* Heap::RegisterStrongRoots(const char* label,
FullObjectSlot start,
FullObjectSlot end) {
base::MutexGuard guard(&strong_roots_mutex_);
StrongRootsEntry* entry = new StrongRootsEntry();
StrongRootsEntry* entry = new StrongRootsEntry(label);
entry->start = start;
entry->end = end;
entry->prev = nullptr;
......@@ -7084,8 +7085,8 @@ Address* StrongRootBlockAllocator::allocate(size_t n) {
sizeof(StrongRootsEntry*));
memset(ret, kNullAddress, n * sizeof(Address));
*header =
heap_->RegisterStrongRoots(FullObjectSlot(ret), FullObjectSlot(ret + n));
*header = heap_->RegisterStrongRoots(
"StrongRootBlockAllocator", FullObjectSlot(ret), FullObjectSlot(ret + n));
return ret;
}
......
......@@ -186,12 +186,13 @@ enum class SkipRoot {
kWeak
};
class StrongRootsEntry {
StrongRootsEntry() = default;
class StrongRootsEntry final {
explicit StrongRootsEntry(const char* label) : label(label) {}
// Label that identifies the roots in tooling.
const char* label;
FullObjectSlot start;
FullObjectSlot end;
StrongRootsEntry* prev;
StrongRootsEntry* next;
......@@ -931,7 +932,7 @@ class Heap {
V8_INLINE void SetMessageListeners(TemplateList value);
V8_INLINE void SetPendingOptimizeForTestBytecode(Object bytecode);
StrongRootsEntry* RegisterStrongRoots(FullObjectSlot start,
StrongRootsEntry* RegisterStrongRoots(const char* label, FullObjectSlot start,
FullObjectSlot end);
void UnregisterStrongRoots(StrongRootsEntry* entry);
void UpdateStrongRoots(StrongRootsEntry* entry, FullObjectSlot start,
......
......@@ -1190,9 +1190,9 @@ void Serializer::ObjectSerializer::SerializeCode(Map map, int size) {
}
Serializer::HotObjectsList::HotObjectsList(Heap* heap) : heap_(heap) {
strong_roots_entry_ =
heap->RegisterStrongRoots(FullObjectSlot(&circular_queue_[0]),
FullObjectSlot(&circular_queue_[kSize]));
strong_roots_entry_ = heap->RegisterStrongRoots(
"Serializer::HotObjectsList", FullObjectSlot(&circular_queue_[0]),
FullObjectSlot(&circular_queue_[kSize]));
}
Serializer::HotObjectsList::~HotObjectsList() {
heap_->UnregisterStrongRoots(strong_roots_entry_);
......
......@@ -205,8 +205,9 @@ IdentityMapBase::RawEntry IdentityMapBase::InsertEntry(Address key) {
values_ = NewPointerArray(capacity_);
memset(values_, 0, sizeof(uintptr_t) * capacity_);
strong_roots_entry_ = heap_->RegisterStrongRoots(
FullObjectSlot(keys_), FullObjectSlot(keys_ + capacity_));
strong_roots_entry_ =
heap_->RegisterStrongRoots("IdentityMapBase", FullObjectSlot(keys_),
FullObjectSlot(keys_ + capacity_));
} else {
// Rehash if there was a GC, then insert.
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