File: name-provider.h

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (75 lines) | stat: -rw-r--r-- 2,629 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef INCLUDE_CPPGC_NAME_PROVIDER_H_
#define INCLUDE_CPPGC_NAME_PROVIDER_H_

#include "v8config.h"  // NOLINT(build/include_directory)

namespace cppgc {

/**
 * NameProvider allows for providing a human-readable name for garbage-collected
 * objects.
 *
 * There's two cases of names to distinguish:
 * a. Explicitly specified names via using NameProvider. Such names are always
 *    preserved in the system.
 * b. Internal names that Oilpan infers from a C++ type on the class hierarchy
 *    of the object. This is not necessarily the type of the actually
 *    instantiated object.
 *
 * Depending on the build configuration, Oilpan may hide names, i.e., represent
 * them with kHiddenName, of case b. to avoid exposing internal details.
 */
class V8_EXPORT NameProvider {
 public:
  /**
   * Name that is used when hiding internals.
   */
  static constexpr const char kHiddenName[] = "InternalNode";

  /**
   * Name that is used in case compiler support is missing for composing a name
   * from C++ types.
   */
  static constexpr const char kNoNameDeducible[] = "<No name>";

  /**
   * Indicating whether the build supports extracting C++ names as object names.
   *
   * @returns true if C++ names should be hidden and represented by kHiddenName.
   */
  static constexpr bool SupportsCppClassNamesAsObjectNames() {
#if CPPGC_SUPPORTS_OBJECT_NAMES
    return true;
#else   // !CPPGC_SUPPORTS_OBJECT_NAMES
    return false;
#endif  // !CPPGC_SUPPORTS_OBJECT_NAMES
  }

  virtual ~NameProvider() = default;

  /**
   * Specifies a name for the garbage-collected object. Such names will never
   * be hidden, as they are explicitly specified by the user of this API.
   *
   * Implementations of this function must not allocate garbage-collected
   * objects or otherwise modify the cppgc heap.
   *
   * V8 may call this function while generating a heap snapshot or at other
   * times. If V8 is currently generating a heap snapshot (according to
   * HeapProfiler::IsTakingSnapshot), then the returned string must stay alive
   * until the snapshot generation has completed. Otherwise, the returned string
   * must stay alive forever. If you need a place to store a temporary string
   * during snapshot generation, use HeapProfiler::CopyNameForHeapSnapshot.
   *
   * @returns a human readable name for the object.
   */
  virtual const char* GetHumanReadableName() const = 0;
};

}  // namespace cppgc

#endif  // INCLUDE_CPPGC_NAME_PROVIDER_H_