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: 5 5 100.0 %
Date: 2020-08-17 22:13:26 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
4390
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
869220
  ALLOWED_EXTERNAL_REFERENCE_TYPES(V)
33
#undef V
34
35
  // This can be called only once.
36
  const std::vector<intptr_t>& external_references();
37
38
  bool is_empty() { return external_references_.empty(); }
39
40
 private:
41
  template <typename T>
42
869220
  void RegisterT(T* address) {
43
869220
    external_references_.push_back(reinterpret_cast<intptr_t>(address));
44
869220
  }
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(credentials)                                                               \
54
  V(env_var)                                                                   \
55
  V(errors)                                                                    \
56
  V(handle_wrap)                                                               \
57
  V(messaging)                                                                 \
58
  V(native_module)                                                             \
59
  V(process_methods)                                                           \
60
  V(process_object)                                                            \
61
  V(task_queue)                                                                \
62
  V(url)                                                                       \
63
  V(util)                                                                      \
64
  V(string_decoder)                                                            \
65
  V(trace_events)                                                              \
66
  V(timers)                                                                    \
67
  V(types)
68
69
#if NODE_HAVE_I18N_SUPPORT
70
#define EXTERNAL_REFERENCE_BINDING_LIST_I18N(V) V(icu)
71
#else
72
#define EXTERNAL_REFERENCE_BINDING_LIST_I18N(V)
73
#endif  // NODE_HAVE_I18N_SUPPORT
74
75
#if HAVE_INSPECTOR
76
#define EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V) V(inspector)
77
#else
78
#define EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V)
79
#endif  // HAVE_INSPECTOR
80
81
#define EXTERNAL_REFERENCE_BINDING_LIST(V)                                     \
82
  EXTERNAL_REFERENCE_BINDING_LIST_BASE(V)                                      \
83
  EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V)                                 \
84
  EXTERNAL_REFERENCE_BINDING_LIST_I18N(V)
85
86
}  // namespace node
87
88
// Declare all the external reference registration functions here,
89
// and define them later with #NODE_MODULE_EXTERNAL_REFERENCE(modname, func);
90
#define V(modname)                                                             \
91
  void _register_external_reference_##modname(                                 \
92
      node::ExternalReferenceRegistry* registry);
93
EXTERNAL_REFERENCE_BINDING_LIST(V)
94
#undef V
95
96
#define NODE_MODULE_EXTERNAL_REFERENCE(modname, func)                          \
97
  void _register_external_reference_##modname(                                 \
98
      node::ExternalReferenceRegistry* registry) {                             \
99
    func(registry);                                                            \
100
  }
101
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
102
#endif  // SRC_NODE_EXTERNAL_REFERENCE_H_