GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: node_realm-inl.h Lines: 27 27 100.0 %
Date: 2022-11-20 04:28:36 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_NODE_REALM_INL_H_
2
#define SRC_NODE_REALM_INL_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "cleanup_queue-inl.h"
7
#include "node_realm.h"
8
9
namespace node {
10
11
inline Realm* Realm::GetCurrent(v8::Isolate* isolate) {
12
  if (UNLIKELY(!isolate->InContext())) return nullptr;
13
  v8::HandleScope handle_scope(isolate);
14
  return GetCurrent(isolate->GetCurrentContext());
15
}
16
17
inline Realm* Realm::GetCurrent(v8::Local<v8::Context> context) {
18
  if (UNLIKELY(!ContextEmbedderTag::IsNodeContext(context))) return nullptr;
19
  return static_cast<Realm*>(
20
      context->GetAlignedPointerFromEmbedderData(ContextEmbedderIndex::kRealm));
21
}
22
23
inline Realm* Realm::GetCurrent(
24
    const v8::FunctionCallbackInfo<v8::Value>& info) {
25
  return GetCurrent(info.GetIsolate()->GetCurrentContext());
26
}
27
28
template <typename T>
29
inline Realm* Realm::GetCurrent(const v8::PropertyCallbackInfo<T>& info) {
30
  return GetCurrent(info.GetIsolate()->GetCurrentContext());
31
}
32
33
16110398
inline Environment* Realm::env() const {
34
16110398
  return env_;
35
}
36
37
2130578
inline v8::Isolate* Realm::isolate() const {
38
2130578
  return isolate_;
39
}
40
41
1645889
inline bool Realm::has_run_bootstrapping_code() const {
42
1645889
  return has_run_bootstrapping_code_;
43
}
44
45
template <typename T>
46
81
void Realm::ForEachBaseObject(T&& iterator) const {
47
81
  cleanup_queue_.ForEachBaseObject(std::forward<T>(iterator));
48
81
}
49
50
2919712
void Realm::modify_base_object_count(int64_t delta) {
51
2919712
  base_object_count_ += delta;
52
2919712
}
53
54
14
int64_t Realm::base_object_created_after_bootstrap() const {
55
14
  return base_object_count_ - base_object_created_by_bootstrap_;
56
}
57
58
2
int64_t Realm::base_object_count() const {
59
2
  return base_object_count_;
60
}
61
62
#define V(PropertyName, TypeName)                                              \
63
  inline v8::Local<TypeName> Realm::PropertyName() const {                     \
64
    return PersistentToLocal::Strong(PropertyName##_);                         \
65
  }                                                                            \
66
  inline void Realm::set_##PropertyName(v8::Local<TypeName> value) {           \
67
    PropertyName##_.Reset(isolate(), value);                                   \
68
  }
69
10049124
PER_REALM_STRONG_PERSISTENT_VALUES(V)
70
#undef V
71
72
9549310
v8::Local<v8::Context> Realm::context() const {
73
9549310
  return PersistentToLocal::Strong(context_);
74
}
75
76
1466830
void Realm::AddCleanupHook(CleanupQueue::Callback fn, void* arg) {
77
1466830
  cleanup_queue_.Add(fn, arg);
78
1466830
}
79
80
1452882
void Realm::RemoveCleanupHook(CleanupQueue::Callback fn, void* arg) {
81
1452882
  cleanup_queue_.Remove(fn, arg);
82
1452882
}
83
84
6515
bool Realm::HasCleanupHooks() const {
85
6515
  return !cleanup_queue_.empty();
86
}
87
88
}  // namespace node
89
90
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
91
92
#endif  // SRC_NODE_REALM_INL_H_