v8  9.0.257(node16.0.0)
V8 is Google's open source JavaScript engine
gc-info.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_INTERNAL_GC_INFO_H_
6 #define INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
7 
8 #include <stdint.h>
9 
10 #include "cppgc/internal/finalizer-trait.h"
11 #include "cppgc/internal/name-trait.h"
12 #include "cppgc/trace-trait.h"
13 #include "v8config.h" // NOLINT(build/include_directory)
14 
15 namespace cppgc {
16 namespace internal {
17 
18 using GCInfoIndex = uint16_t;
19 
20 class V8_EXPORT RegisteredGCInfoIndex final {
21  public:
22  RegisteredGCInfoIndex(FinalizationCallback finalization_callback,
23  TraceCallback trace_callback,
24  NameCallback name_callback, bool has_v_table);
25  GCInfoIndex GetIndex() const { return index_; }
26 
27  private:
28  const GCInfoIndex index_;
29 };
30 
31 // Trait determines how the garbage collector treats objects wrt. to traversing,
32 // finalization, and naming.
33 template <typename T>
34 struct GCInfoTrait {
35  static GCInfoIndex Index() {
36  static_assert(sizeof(T), "T must be fully defined");
37  static const RegisteredGCInfoIndex registered_index(
38  FinalizerTrait<T>::kCallback, TraceTrait<T>::Trace,
39  NameTrait<T>::GetName, std::is_polymorphic<T>::value);
40  return registered_index.GetIndex();
41  }
42 };
43 
44 } // namespace internal
45 } // namespace cppgc
46 
47 #endif // INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
cppgc::internal::GCInfoTrait
Definition: gc-info.h:34
cppgc
Definition: allocation.h:17
cppgc::internal::RegisteredGCInfoIndex::RegisteredGCInfoIndex
RegisteredGCInfoIndex(FinalizationCallback finalization_callback, TraceCallback trace_callback, NameCallback name_callback, bool has_v_table)
V8_EXPORT
#define V8_EXPORT
Definition: v8config.h:512
cppgc::internal::FinalizerTrait
Definition: finalizer-trait.h:65
cppgc::internal::RegisteredGCInfoIndex::GetIndex
GCInfoIndex GetIndex() const
Definition: gc-info.h:25
cppgc::internal
Definition: allocation.h:22
cppgc::internal::BasicMember::TraceTrait
friend struct cppgc::TraceTrait
Definition: member.h:208
cppgc::internal::GCInfoTrait::Index
static GCInfoIndex Index()
Definition: gc-info.h:35