GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_contextify.h Lines: 16 16 100.0 %
Date: 2019-09-16 22:31:04 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_NODE_CONTEXTIFY_H_
2
#define SRC_NODE_CONTEXTIFY_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "base_object-inl.h"
7
#include "node_context_data.h"
8
#include "node_errors.h"
9
10
namespace node {
11
namespace contextify {
12
13
2730
struct ContextOptions {
14
  v8::Local<v8::String> name;
15
  v8::Local<v8::String> origin;
16
  v8::Local<v8::Boolean> allow_code_gen_strings;
17
  v8::Local<v8::Boolean> allow_code_gen_wasm;
18
};
19
20
class ContextifyContext {
21
 public:
22
  ContextifyContext(Environment* env,
23
                    v8::Local<v8::Object> sandbox_obj,
24
                    const ContextOptions& options);
25
  ~ContextifyContext();
26
  static void CleanupHook(void* arg);
27
28
  v8::MaybeLocal<v8::Object> CreateDataWrapper(Environment* env);
29
  v8::MaybeLocal<v8::Context> CreateV8Context(Environment* env,
30
                                              v8::Local<v8::Object> sandbox_obj,
31
                                              const ContextOptions& options);
32
  static void Init(Environment* env, v8::Local<v8::Object> target);
33
34
  static ContextifyContext* ContextFromContextifiedSandbox(
35
      Environment* env,
36
      const v8::Local<v8::Object>& sandbox);
37
38
31805850
  inline Environment* env() const {
39
31805850
    return env_;
40
  }
41
42
31803719
  inline v8::Local<v8::Context> context() const {
43
31803719
    return PersistentToLocal::Default(env()->isolate(), context_);
44
  }
45
46
6054218
  inline v8::Local<v8::Object> global_proxy() const {
47
12108436
    return context()->Global();
48
  }
49
50
12871049
  inline v8::Local<v8::Object> sandbox() const {
51
    return v8::Local<v8::Object>::Cast(
52
38613147
        context()->GetEmbedderData(ContextEmbedderIndex::kSandboxObject));
53
  }
54
55
56
  template <typename T>
57
  static ContextifyContext* Get(const v8::PropertyCallbackInfo<T>& args);
58
59
 private:
60
  static void MakeContext(const v8::FunctionCallbackInfo<v8::Value>& args);
61
  static void IsContext(const v8::FunctionCallbackInfo<v8::Value>& args);
62
  static void CompileFunction(
63
      const v8::FunctionCallbackInfo<v8::Value>& args);
64
  static void WeakCallback(
65
      const v8::WeakCallbackInfo<ContextifyContext>& data);
66
  static void PropertyGetterCallback(
67
      v8::Local<v8::Name> property,
68
      const v8::PropertyCallbackInfo<v8::Value>& args);
69
  static void PropertySetterCallback(
70
      v8::Local<v8::Name> property,
71
      v8::Local<v8::Value> value,
72
      const v8::PropertyCallbackInfo<v8::Value>& args);
73
  static void PropertyDescriptorCallback(
74
      v8::Local<v8::Name> property,
75
      const v8::PropertyCallbackInfo<v8::Value>& args);
76
  static void PropertyDefinerCallback(
77
      v8::Local<v8::Name> property,
78
      const v8::PropertyDescriptor& desc,
79
      const v8::PropertyCallbackInfo<v8::Value>& args);
80
  static void PropertyDeleterCallback(
81
      v8::Local<v8::Name> property,
82
      const v8::PropertyCallbackInfo<v8::Boolean>& args);
83
  static void PropertyEnumeratorCallback(
84
      const v8::PropertyCallbackInfo<v8::Array>& args);
85
  static void IndexedPropertyGetterCallback(
86
      uint32_t index,
87
      const v8::PropertyCallbackInfo<v8::Value>& args);
88
  static void IndexedPropertySetterCallback(
89
      uint32_t index,
90
      v8::Local<v8::Value> value,
91
      const v8::PropertyCallbackInfo<v8::Value>& args);
92
  static void IndexedPropertyDescriptorCallback(
93
      uint32_t index,
94
      const v8::PropertyCallbackInfo<v8::Value>& args);
95
  static void IndexedPropertyDefinerCallback(
96
      uint32_t index,
97
      const v8::PropertyDescriptor& desc,
98
      const v8::PropertyCallbackInfo<v8::Value>& args);
99
  static void IndexedPropertyDeleterCallback(
100
      uint32_t index,
101
      const v8::PropertyCallbackInfo<v8::Boolean>& args);
102
  Environment* const env_;
103
  v8::Global<v8::Context> context_;
104
};
105
106
class ContextifyScript : public BaseObject {
107
 public:
108
2
  SET_NO_MEMORY_INFO()
109
2
  SET_MEMORY_INFO_NAME(ContextifyScript)
110
2
  SET_SELF_SIZE(ContextifyScript)
111
112
  ContextifyScript(Environment* env, v8::Local<v8::Object> object);
113
  ~ContextifyScript() override;
114
115
  static void Init(Environment* env, v8::Local<v8::Object> target);
116
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
117
  static bool InstanceOf(Environment* env, const v8::Local<v8::Value>& args);
118
  static void CreateCachedData(
119
      const v8::FunctionCallbackInfo<v8::Value>& args);
120
  static void RunInThisContext(const v8::FunctionCallbackInfo<v8::Value>& args);
121
  static void RunInContext(const v8::FunctionCallbackInfo<v8::Value>& args);
122
  static bool EvalMachine(Environment* env,
123
                          const int64_t timeout,
124
                          const bool display_errors,
125
                          const bool break_on_sigint,
126
                          const bool break_on_first_line,
127
                          const v8::FunctionCallbackInfo<v8::Value>& args);
128
129
2005
  inline uint32_t id() { return id_; }
130
131
 private:
132
  v8::Global<v8::UnboundScript> script_;
133
  uint32_t id_;
134
};
135
136
class CompiledFnEntry final : public BaseObject {
137
 public:
138
186
  SET_NO_MEMORY_INFO()
139
186
  SET_MEMORY_INFO_NAME(CompiledFnEntry)
140
186
  SET_SELF_SIZE(CompiledFnEntry)
141
142
  CompiledFnEntry(Environment* env,
143
                  v8::Local<v8::Object> object,
144
                  uint32_t id,
145
                  v8::Local<v8::ScriptOrModule> script);
146
  ~CompiledFnEntry();
147
148
 private:
149
  uint32_t id_;
150
  v8::Global<v8::ScriptOrModule> script_;
151
152
  static void WeakCallback(const v8::WeakCallbackInfo<CompiledFnEntry>& data);
153
};
154
155
}  // namespace contextify
156
}  // namespace node
157
158
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
159
160
#endif  // SRC_NODE_CONTEXTIFY_H_