GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_external_reference.h Lines: 10 10 100.0 %
Date: 2021-05-29 04:12:01 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_NODE_EXTERNAL_REFERENCE_H_
2
#define SRC_NODE_EXTERNAL_REFERENCE_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include <cinttypes>
7
#include <vector>
8
#include "v8.h"
9
10
namespace node {
11
12
// This class manages the external references from the V8 heap
13
// to the C++ addresses in Node.js.
14
4774
class ExternalReferenceRegistry {
15
 public:
16
  ExternalReferenceRegistry();
17
18
#define ALLOWED_EXTERNAL_REFERENCE_TYPES(V)                                    \
19
  V(v8::FunctionCallback)                                                      \
20
  V(v8::AccessorGetterCallback)                                                \
21
  V(v8::AccessorSetterCallback)                                                \
22
  V(v8::AccessorNameGetterCallback)                                            \
23
  V(v8::AccessorNameSetterCallback)                                            \
24
  V(v8::GenericNamedPropertyDefinerCallback)                                   \
25
  V(v8::GenericNamedPropertyDeleterCallback)                                   \
26
  V(v8::GenericNamedPropertyEnumeratorCallback)                                \
27
  V(v8::GenericNamedPropertyQueryCallback)                                     \
28
  V(v8::GenericNamedPropertySetterCallback)
29
30
#define V(ExternalReferenceType)                                               \
31
  void Register(ExternalReferenceType addr) { RegisterT(addr); }
32
1522906
  ALLOWED_EXTERNAL_REFERENCE_TYPES(V)
33
38192
#undef V
34
28644
35
4774
  // This can be called only once.
36
9548
  const std::vector<intptr_t>& external_references();
37
9548
38
  bool is_empty() { return external_references_.empty(); }
39
40
 private:
41
  template <typename T>
42
1575420
  void RegisterT(T* address) {
43
1575420
    external_references_.push_back(reinterpret_cast<intptr_t>(address));
44
1575420
  }
45
  bool is_finalized_ = false;
46
  std::vector<intptr_t> external_references_;
47
};
48
49
#define EXTERNAL_REFERENCE_BINDING_LIST_BASE(V)                                \
50
  V(async_wrap)                                                                \
51
  V(binding)                                                                   \
52
  V(buffer)                                                                    \
53
  V(contextify)                                                                \
54
  V(credentials)                                                               \
55
  V(env_var)                                                                   \
56
  V(errors)                                                                    \
57
  V(fs)                                                                        \
58
  V(fs_dir)                                                                    \
59
  V(fs_event_wrap)                                                             \
60
  V(handle_wrap)                                                               \
61
  V(heap_utils)                                                                \
62
  V(messaging)                                                                 \
63
  V(native_module)                                                             \
64
  V(process_methods)                                                           \
65
  V(process_object)                                                            \
66
  V(task_queue)                                                                \
67
  V(url)                                                                       \
68
  V(util)                                                                      \
69
  V(serdes)                                                                    \
70
  V(string_decoder)                                                            \
71
  V(stream_wrap)                                                               \
72
  V(trace_events)                                                              \
73
  V(timers)                                                                    \
74
  V(types)                                                                     \
75
  V(uv)                                                                        \
76
  V(v8)                                                                        \
77
  V(worker)
78
79
#if NODE_HAVE_I18N_SUPPORT
80
#define EXTERNAL_REFERENCE_BINDING_LIST_I18N(V) V(icu)
81
#else
82
#define EXTERNAL_REFERENCE_BINDING_LIST_I18N(V)
83
#endif  // NODE_HAVE_I18N_SUPPORT
84
85
#if HAVE_INSPECTOR
86
#define EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V)                           \
87
  V(inspector)                                                                 \
88
  V(profiler)
89
#else
90
#define EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V)
91
#endif  // HAVE_INSPECTOR
92
93
#define EXTERNAL_REFERENCE_BINDING_LIST(V)                                     \
94
  EXTERNAL_REFERENCE_BINDING_LIST_BASE(V)                                      \
95
  EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V)                                 \
96
  EXTERNAL_REFERENCE_BINDING_LIST_I18N(V)
97
98
}  // namespace node
99
100
// Declare all the external reference registration functions here,
101
// and define them later with #NODE_MODULE_EXTERNAL_REFERENCE(modname, func);
102
#define V(modname)                                                             \
103
  void _register_external_reference_##modname(                                 \
104
      node::ExternalReferenceRegistry* registry);
105
EXTERNAL_REFERENCE_BINDING_LIST(V)
106
#undef V
107
108
#define NODE_MODULE_EXTERNAL_REFERENCE(modname, func)                          \
109
  void _register_external_reference_##modname(                                 \
110
      node::ExternalReferenceRegistry* registry) {                             \
111
    func(registry);                                                            \
112
  }
113
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
114
#endif  // SRC_NODE_EXTERNAL_REFERENCE_H_