V8  latest master commit
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 
11 #include "cppgc/trace-trait.h"
12 #include "v8config.h" // NOLINT(build/include_directory)
13 
14 namespace cppgc {
15 namespace internal {
16 
17 using GCInfoIndex = uint16_t;
18 
20  public:
21  RegisteredGCInfoIndex(FinalizationCallback finalization_callback,
22  TraceCallback trace_callback, bool has_v_table);
23  GCInfoIndex GetIndex() const { return index_; }
24 
25  private:
26  const GCInfoIndex index_;
27 };
28 
29 // Trait determines how the garbage collector treats objects wrt. to traversing,
30 // finalization, and naming.
31 template <typename T>
32 struct GCInfoTrait {
33  static GCInfoIndex Index() {
34  static_assert(sizeof(T), "T must be fully defined");
35  static const RegisteredGCInfoIndex registered_index(
37  std::is_polymorphic<T>::value);
38  return registered_index.GetIndex();
39  }
40 };
41 
42 } // namespace internal
43 } // namespace cppgc
44 
45 #endif // INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
finalizer-trait.h
cppgc::internal::GCInfoIndex
uint16_t GCInfoIndex
Definition: gc-info.h:17
cppgc::TraceCallback
void(*)(Visitor *, const void *) TraceCallback
Definition: trace-trait.h:24
cppgc::internal::RegisteredGCInfoIndex
Definition: gc-info.h:19
cppgc::internal::GCInfoTrait
Definition: gc-info.h:32
cppgc::internal::RegisteredGCInfoIndex::GetIndex
GCInfoIndex GetIndex() const
Definition: gc-info.h:23
cppgc
Definition: allocation.h:18
v8config.h
V8_EXPORT
#define V8_EXPORT
Definition: v8config.h:467
cppgc::internal::GCInfoTrait::Index
static GCInfoIndex Index()
Definition: gc-info.h:33
trace-trait.h
cppgc::internal::FinalizerTrait
Definition: finalizer-trait.h:65
cppgc::TraceTrait
Definition: trace-trait.h:35
cppgc::internal::FinalizationCallback
void(*)(void *) FinalizationCallback
Definition: finalizer-trait.h:15