v8 14.1.146 (node 25.0.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
name-provider.h
Go to the documentation of this file.
1// Copyright 2020 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_NAME_PROVIDER_H_
6#define INCLUDE_CPPGC_NAME_PROVIDER_H_
7
8#include "v8config.h" // NOLINT(build/include_directory)
9
10namespace cppgc {
11
12/**
13 * NameProvider allows for providing a human-readable name for garbage-collected
14 * objects.
15 *
16 * There's two cases of names to distinguish:
17 * a. Explicitly specified names via using NameProvider. Such names are always
18 * preserved in the system.
19 * b. Internal names that Oilpan infers from a C++ type on the class hierarchy
20 * of the object. This is not necessarily the type of the actually
21 * instantiated object.
22 *
23 * Depending on the build configuration, Oilpan may hide names, i.e., represent
24 * them with kHiddenName, of case b. to avoid exposing internal details.
25 */
27 public:
28 /**
29 * Name that is used when hiding internals.
30 */
31 static constexpr const char kHiddenName[] = "InternalNode";
32
33 /**
34 * Name that is used in case compiler support is missing for composing a name
35 * from C++ types.
36 */
37 static constexpr const char kNoNameDeducible[] = "<No name>";
38
39 /**
40 * Indicating whether the build supports extracting C++ names as object names.
41 *
42 * @returns true if C++ names should be hidden and represented by kHiddenName.
43 */
44 static constexpr bool SupportsCppClassNamesAsObjectNames() {
45#if CPPGC_SUPPORTS_OBJECT_NAMES
46 return true;
47#else // !CPPGC_SUPPORTS_OBJECT_NAMES
48 return false;
49#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
50 }
51
52 virtual ~NameProvider() = default;
53
54 /**
55 * Specifies a name for the garbage-collected object. Such names will never
56 * be hidden, as they are explicitly specified by the user of this API.
57 *
58 * Implementations of this function must not allocate garbage-collected
59 * objects or otherwise modify the cppgc heap.
60 *
61 * V8 may call this function while generating a heap snapshot or at other
62 * times. If V8 is currently generating a heap snapshot (according to
63 * HeapProfiler::IsTakingSnapshot), then the returned string must stay alive
64 * until the snapshot generation has completed. Otherwise, the returned string
65 * must stay alive forever. If you need a place to store a temporary string
66 * during snapshot generation, use HeapProfiler::CopyNameForHeapSnapshot.
67 *
68 * @returns a human readable name for the object.
69 */
70 virtual const char* GetHumanReadableName() const = 0;
71};
72
73} // namespace cppgc
74
75#endif // INCLUDE_CPPGC_NAME_PROVIDER_H_
static constexpr bool SupportsCppClassNamesAsObjectNames()
virtual ~NameProvider()=default
virtual const char * GetHumanReadableName() const =0
static constexpr const char kNoNameDeducible[]
static constexpr const char kHiddenName[]
#define V8_EXPORT
Definition v8config.h:860