Commit 3bc5db7b authored by Seth Brenith's avatar Seth Brenith Committed by V8 LUCI CQ

Fix some incorrect retainers in heap snapshots

JSWeakRef and WeakCell both have weak pointers, which should be marked
as such in heap profiler snapshots.

Bug: v8:12112
Change-Id: Ie7aaa2cd3e44552427679e650e462d64704725d1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3299592Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#78133}
parent 74d0c0aa
......@@ -27,6 +27,7 @@
#include "src/objects/js-generator-inl.h"
#include "src/objects/js-promise-inl.h"
#include "src/objects/js-regexp-inl.h"
#include "src/objects/js-weak-refs-inl.h"
#include "src/objects/literal-objects-inl.h"
#include "src/objects/objects-body-descriptors.h"
#include "src/objects/objects-inl.h"
......@@ -824,6 +825,8 @@ void V8HeapExplorer::ExtractReferences(HeapEntry* entry, HeapObject obj) {
ExtractJSPromiseReferences(entry, JSPromise::cast(obj));
} else if (obj.IsJSGeneratorObject()) {
ExtractJSGeneratorObjectReferences(entry, JSGeneratorObject::cast(obj));
} else if (obj.IsJSWeakRef()) {
ExtractJSWeakRefReferences(entry, JSWeakRef::cast(obj));
}
ExtractJSObjectReferences(entry, JSObject::cast(obj));
} else if (obj.IsString()) {
......@@ -869,6 +872,8 @@ void V8HeapExplorer::ExtractReferences(HeapEntry* entry, HeapObject obj) {
ExtractEphemeronHashTableReferences(entry, EphemeronHashTable::cast(obj));
} else if (obj.IsFixedArray()) {
ExtractFixedArrayReferences(entry, FixedArray::cast(obj));
} else if (obj.IsWeakCell()) {
ExtractWeakCellReferences(entry, WeakCell::cast(obj));
} else if (obj.IsHeapNumber()) {
if (snapshot_->capture_numeric_value()) {
ExtractNumberReference(entry, obj);
......@@ -1216,6 +1221,20 @@ void V8HeapExplorer::ExtractAccessorPairReferences(HeapEntry* entry,
AccessorPair::kSetterOffset);
}
void V8HeapExplorer::ExtractJSWeakRefReferences(HeapEntry* entry,
JSWeakRef js_weak_ref) {
SetWeakReference(entry, "target", js_weak_ref.target(),
JSWeakRef::kTargetOffset);
}
void V8HeapExplorer::ExtractWeakCellReferences(HeapEntry* entry,
WeakCell weak_cell) {
SetWeakReference(entry, "target", weak_cell.target(),
WeakCell::kTargetOffset);
SetWeakReference(entry, "unregister_token", weak_cell.unregister_token(),
WeakCell::kUnregisterTokenOffset);
}
void V8HeapExplorer::TagBuiltinCodeObject(Object code, const char* name) {
DCHECK(code.IsCode() || (V8_EXTERNAL_CODE_SPACE_BOOL && code.IsCodeT()));
TagObject(code, names_->GetFormatted("(%s builtin)", name));
......
......@@ -398,6 +398,8 @@ class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator {
void ExtractAccessorPairReferences(HeapEntry* entry, AccessorPair accessors);
void ExtractCodeReferences(HeapEntry* entry, Code code);
void ExtractCellReferences(HeapEntry* entry, Cell cell);
void ExtractJSWeakRefReferences(HeapEntry* entry, JSWeakRef js_weak_ref);
void ExtractWeakCellReferences(HeapEntry* entry, WeakCell weak_cell);
void ExtractFeedbackCellReferences(HeapEntry* entry,
FeedbackCell feedback_cell);
void ExtractPropertyCellReferences(HeapEntry* entry, PropertyCell cell);
......
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