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: 2020-11-20 19:51:53 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
4601
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
910998
  ALLOWED_EXTERNAL_REFERENCE_TYPES(V)
33
27606
#undef V
34
27606
35
4601
  // This can be called only once.
36
9202
  const std::vector<intptr_t>& external_references();
37
9202
38
  bool is_empty() { return external_references_.empty(); }
39
40
 private:
41
  template <typename T>
42
957008
  void RegisterT(T* address) {
43
957008
    external_references_.push_back(reinterpret_cast<intptr_t>(address));
44
957008
  }
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
  V(worker)
69
70
#if NODE_HAVE_I18N_SUPPORT
71
#define EXTERNAL_REFERENCE_BINDING_LIST_I18N(V) V(icu)
72
#else
73
#define EXTERNAL_REFERENCE_BINDING_LIST_I18N(V)
74
#endif  // NODE_HAVE_I18N_SUPPORT
75
76
#if HAVE_INSPECTOR
77
#define EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V) V(inspector)
78
#else
79
#define EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V)
80
#endif  // HAVE_INSPECTOR
81
82
#define EXTERNAL_REFERENCE_BINDING_LIST(V)                                     \
83
  EXTERNAL_REFERENCE_BINDING_LIST_BASE(V)                                      \
84
  EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V)                                 \
85
  EXTERNAL_REFERENCE_BINDING_LIST_I18N(V)
86
87
}  // namespace node
88
89
// Declare all the external reference registration functions here,
90
// and define them later with #NODE_MODULE_EXTERNAL_REFERENCE(modname, func);
91
#define V(modname)                                                             \
92
  void _register_external_reference_##modname(                                 \
93
      node::ExternalReferenceRegistry* registry);
94
EXTERNAL_REFERENCE_BINDING_LIST(V)
95
#undef V
96
97
#define NODE_MODULE_EXTERNAL_REFERENCE(modname, func)                          \
98
  void _register_external_reference_##modname(                                 \
99
      node::ExternalReferenceRegistry* registry) {                             \
100
    func(registry);                                                            \
101
  }
102
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
103
#endif  // SRC_NODE_EXTERNAL_REFERENCE_H_