Skip to content

Commit 8284613

Browse files
committed
deps: V8: cherry-pick fa7509f48d15
Original commit message: [cppgc] add cppgc::Visitor::TraceExternal() This allows tracking externally-managed memory owned by cppgc-managed objects in the heap snapshots. To accompany this API, a class cppgc::External is added to abstract over externally-managed structures. Design doc: https://docs.google.com/document/d/1-kHbj9SNL3wMXZz_GZiDw6kHUJ1IvicFzEmqC_um0Wg/edit#heading=h.n1atlriavj6v Change-Id: I7a27eaa45e29d3c14936997d115a112a6e54458c Refs: v8/v8@fa7509f
1 parent 0c7e2a5 commit 8284613

14 files changed

+383
-116
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.13',
39+
'v8_embedder_string': '-node.14',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ filegroup(
567567
"include/cppgc/default-platform.h",
568568
"include/cppgc/ephemeron-pair.h",
569569
"include/cppgc/explicit-management.h",
570+
"include/cppgc/external.h",
570571
"include/cppgc/garbage-collected.h",
571572
"include/cppgc/heap.h",
572573
"include/cppgc/heap-consistency.h",

deps/v8/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6920,6 +6920,7 @@ v8_header_set("cppgc_headers") {
69206920
"include/cppgc/default-platform.h",
69216921
"include/cppgc/ephemeron-pair.h",
69226922
"include/cppgc/explicit-management.h",
6923+
"include/cppgc/external.h",
69236924
"include/cppgc/garbage-collected.h",
69246925
"include/cppgc/heap-consistency.h",
69256926
"include/cppgc/heap-handle.h",

deps/v8/include/cppgc/external.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef INCLUDE_CPPGC_EXTERNAL_H_
6+
#define INCLUDE_CPPGC_EXTERNAL_H_
7+
8+
#include <cstddef>
9+
10+
namespace cppgc {
11+
12+
class Visitor;
13+
14+
class External {
15+
public:
16+
virtual void Trace(cppgc::Visitor*) const {}
17+
virtual const char* GetHumanReadableName() const = 0;
18+
virtual size_t GetSize() const = 0;
19+
};
20+
21+
} // namespace cppgc
22+
23+
#endif // INCLUDE_CPPGC_EXTERNAL_H_

deps/v8/include/cppgc/visitor.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
namespace cppgc {
2424

25+
class External;
26+
2527
namespace internal {
2628
template <typename T, typename WeaknessPolicy, typename LocationPolicy,
2729
typename CheckingPolicy>
@@ -306,6 +308,11 @@ class V8_EXPORT Visitor {
306308
callback_data);
307309
}
308310

311+
/**
312+
* Trace method for members with externally-managed memory.
313+
*/
314+
void TraceExternal(const External* external) { VisitExternal(external); }
315+
309316
/**
310317
* Registers a slot containing a reference to an object allocated on a
311318
* compactable space. Such references maybe be arbitrarily moved by the GC.
@@ -359,6 +366,7 @@ class V8_EXPORT Visitor {
359366
virtual void VisitWeakContainer(const void* self, TraceDescriptor strong_desc,
360367
TraceDescriptor weak_desc,
361368
WeakCallback callback, const void* data) {}
369+
virtual void VisitExternal(const External* external) {}
362370
virtual void HandleMovableReference(const void**) {}
363371

364372
virtual void VisitMultipleUncompressedMember(

0 commit comments

Comments
 (0)