1 |
|
|
// Copyright Joyent, Inc. and other Node contributors. |
2 |
|
|
// |
3 |
|
|
// Permission is hereby granted, free of charge, to any person obtaining a |
4 |
|
|
// copy of this software and associated documentation files (the |
5 |
|
|
// "Software"), to deal in the Software without restriction, including |
6 |
|
|
// without limitation the rights to use, copy, modify, merge, publish, |
7 |
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit |
8 |
|
|
// persons to whom the Software is furnished to do so, subject to the |
9 |
|
|
// following conditions: |
10 |
|
|
// |
11 |
|
|
// The above copyright notice and this permission notice shall be included |
12 |
|
|
// in all copies or substantial portions of the Software. |
13 |
|
|
// |
14 |
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
15 |
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
16 |
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
17 |
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
18 |
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
19 |
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
20 |
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE. |
21 |
|
|
|
22 |
|
|
#ifndef SRC_ENV_INL_H_ |
23 |
|
|
#define SRC_ENV_INL_H_ |
24 |
|
|
|
25 |
|
|
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
26 |
|
|
|
27 |
|
|
#include "aliased_buffer.h" |
28 |
|
|
#include "callback_queue-inl.h" |
29 |
|
|
#include "env.h" |
30 |
|
|
#include "node.h" |
31 |
|
|
#include "util-inl.h" |
32 |
|
|
#include "uv.h" |
33 |
|
|
#include "v8.h" |
34 |
|
|
#include "node_perf_common.h" |
35 |
|
|
#include "node_context_data.h" |
36 |
|
|
|
37 |
|
|
#include <cstddef> |
38 |
|
|
#include <cstdint> |
39 |
|
|
|
40 |
|
|
#include <utility> |
41 |
|
|
|
42 |
|
|
namespace node { |
43 |
|
|
|
44 |
|
|
inline v8::Isolate* IsolateData::isolate() const { |
45 |
|
|
return isolate_; |
46 |
|
|
} |
47 |
|
|
|
48 |
|
962809 |
inline uv_loop_t* IsolateData::event_loop() const { |
49 |
|
962809 |
return event_loop_; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
165056 |
inline NodeArrayBufferAllocator* IsolateData::node_allocator() const { |
53 |
|
165056 |
return node_allocator_; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
56229 |
inline MultiIsolatePlatform* IsolateData::platform() const { |
57 |
|
56229 |
return platform_; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
581 |
inline void IsolateData::set_worker_context(worker::Worker* context) { |
61 |
✗✓ |
581 |
CHECK_NULL(worker_context_); // Should be set only once. |
62 |
|
581 |
worker_context_ = context; |
63 |
|
581 |
} |
64 |
|
|
|
65 |
|
14021 |
inline worker::Worker* IsolateData::worker_context() const { |
66 |
|
14021 |
return worker_context_; |
67 |
|
|
} |
68 |
|
|
|
69 |
|
204637 |
inline v8::Local<v8::String> IsolateData::async_wrap_provider(int index) const { |
70 |
|
204637 |
return async_wrap_providers_[index].Get(isolate_); |
71 |
|
|
} |
72 |
|
|
|
73 |
|
3017404 |
inline AliasedUint32Array& AsyncHooks::fields() { |
74 |
|
3017404 |
return fields_; |
75 |
|
|
} |
76 |
|
|
|
77 |
|
1698284 |
inline AliasedFloat64Array& AsyncHooks::async_id_fields() { |
78 |
|
1698284 |
return async_id_fields_; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
621 |
inline AliasedFloat64Array& AsyncHooks::async_ids_stack() { |
82 |
|
621 |
return async_ids_stack_; |
83 |
|
|
} |
84 |
|
|
|
85 |
|
801172 |
v8::Local<v8::Array> AsyncHooks::js_execution_async_resources() { |
86 |
✓✓ |
801172 |
if (UNLIKELY(js_execution_async_resources_.IsEmpty())) { |
87 |
|
621 |
js_execution_async_resources_.Reset( |
88 |
|
1242 |
env()->isolate(), v8::Array::New(env()->isolate())); |
89 |
|
|
} |
90 |
|
801172 |
return PersistentToLocal::Strong(js_execution_async_resources_); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
2402 |
v8::Local<v8::Object> AsyncHooks::native_execution_async_resource(size_t i) { |
94 |
✗✓ |
2402 |
if (i >= native_execution_async_resources_.size()) return {}; |
95 |
|
2402 |
return PersistentToLocal::Strong(native_execution_async_resources_[i]); |
96 |
|
|
} |
97 |
|
|
|
98 |
|
2983 |
inline void AsyncHooks::SetJSPromiseHooks(v8::Local<v8::Function> init, |
99 |
|
|
v8::Local<v8::Function> before, |
100 |
|
|
v8::Local<v8::Function> after, |
101 |
|
|
v8::Local<v8::Function> resolve) { |
102 |
|
2983 |
js_promise_hooks_[0].Reset(env()->isolate(), init); |
103 |
|
2983 |
js_promise_hooks_[1].Reset(env()->isolate(), before); |
104 |
|
2983 |
js_promise_hooks_[2].Reset(env()->isolate(), after); |
105 |
|
2983 |
js_promise_hooks_[3].Reset(env()->isolate(), resolve); |
106 |
✓✓ |
6074 |
for (auto it = contexts_.begin(); it != contexts_.end(); it++) { |
107 |
✗✓ |
3091 |
if (it->IsEmpty()) { |
108 |
|
|
it = contexts_.erase(it); |
109 |
|
|
it--; |
110 |
|
|
continue; |
111 |
|
|
} |
112 |
|
6182 |
PersistentToLocal::Weak(env()->isolate(), *it) |
113 |
|
3091 |
->SetPromiseHooks(init, before, after, resolve); |
114 |
|
|
} |
115 |
|
2983 |
} |
116 |
|
|
|
117 |
|
204289 |
inline v8::Local<v8::String> AsyncHooks::provider_string(int idx) { |
118 |
|
204289 |
return env()->isolate_data()->async_wrap_provider(idx); |
119 |
|
|
} |
120 |
|
|
|
121 |
|
1 |
inline void AsyncHooks::no_force_checks() { |
122 |
|
1 |
fields_[kCheck] -= 1; |
123 |
|
1 |
} |
124 |
|
|
|
125 |
|
1112945 |
inline Environment* AsyncHooks::env() { |
126 |
|
1112945 |
return Environment::ForAsyncHooks(this); |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
// Remember to keep this code aligned with pushAsyncContext() in JS. |
130 |
|
775575 |
inline void AsyncHooks::push_async_context(double async_id, |
131 |
|
|
double trigger_async_id, |
132 |
|
|
v8::Local<v8::Object> resource) { |
133 |
|
|
// Since async_hooks is experimental, do only perform the check |
134 |
|
|
// when async_hooks is enabled. |
135 |
✓✓ |
775575 |
if (fields_[kCheck] > 0) { |
136 |
✗✓ |
775572 |
CHECK_GE(async_id, -1); |
137 |
✗✓ |
775572 |
CHECK_GE(trigger_async_id, -1); |
138 |
|
|
} |
139 |
|
|
|
140 |
|
775575 |
uint32_t offset = fields_[kStackLength]; |
141 |
✓✓ |
775575 |
if (offset * 2 >= async_ids_stack_.Length()) |
142 |
|
4 |
grow_async_ids_stack(); |
143 |
|
775575 |
async_ids_stack_[2 * offset] = async_id_fields_[kExecutionAsyncId]; |
144 |
|
775575 |
async_ids_stack_[2 * offset + 1] = async_id_fields_[kTriggerAsyncId]; |
145 |
|
775575 |
fields_[kStackLength] += 1; |
146 |
|
775575 |
async_id_fields_[kExecutionAsyncId] = async_id; |
147 |
|
775575 |
async_id_fields_[kTriggerAsyncId] = trigger_async_id; |
148 |
|
|
|
149 |
|
|
#ifdef DEBUG |
150 |
|
|
for (uint32_t i = offset; i < native_execution_async_resources_.size(); i++) |
151 |
|
|
CHECK(native_execution_async_resources_[i].IsEmpty()); |
152 |
|
|
#endif |
153 |
|
|
|
154 |
|
|
// When this call comes from JS (as a way of increasing the stack size), |
155 |
|
|
// `resource` will be empty, because JS caches these values anyway, and |
156 |
|
|
// we should avoid creating strong global references that might keep |
157 |
|
|
// these JS resource objects alive longer than necessary. |
158 |
✓✓ |
775575 |
if (!resource.IsEmpty()) { |
159 |
|
775571 |
native_execution_async_resources_.resize(offset + 1); |
160 |
|
775571 |
native_execution_async_resources_[offset].Reset(env()->isolate(), resource); |
161 |
|
|
} |
162 |
|
775575 |
} |
163 |
|
|
|
164 |
|
|
// Remember to keep this code aligned with popAsyncContext() in JS. |
165 |
|
775209 |
inline bool AsyncHooks::pop_async_context(double async_id) { |
166 |
|
|
// In case of an exception then this may have already been reset, if the |
167 |
|
|
// stack was multiple MakeCallback()'s deep. |
168 |
✓✓ |
775209 |
if (fields_[kStackLength] == 0) return false; |
169 |
|
|
|
170 |
|
|
// Ask for the async_id to be restored as a check that the stack |
171 |
|
|
// hasn't been corrupted. |
172 |
|
|
// Since async_hooks is experimental, do only perform the check |
173 |
|
|
// when async_hooks is enabled. |
174 |
✓✓✓✓ ✓✓ |
774170 |
if (fields_[kCheck] > 0 && async_id_fields_[kExecutionAsyncId] != async_id) { |
175 |
|
4 |
fprintf(stderr, |
176 |
|
|
"Error: async hook stack has become corrupted (" |
177 |
|
|
"actual: %.f, expected: %.f)\n", |
178 |
|
|
async_id_fields_.GetValue(kExecutionAsyncId), |
179 |
|
|
async_id); |
180 |
|
4 |
DumpBacktrace(stderr); |
181 |
|
4 |
fflush(stderr); |
182 |
✓✗ |
4 |
if (!env()->abort_on_uncaught_exception()) |
183 |
|
4 |
exit(1); |
184 |
|
|
fprintf(stderr, "\n"); |
185 |
|
|
fflush(stderr); |
186 |
|
|
ABORT_NO_BACKTRACE(); |
187 |
|
|
} |
188 |
|
|
|
189 |
|
774166 |
uint32_t offset = fields_[kStackLength] - 1; |
190 |
|
774166 |
async_id_fields_[kExecutionAsyncId] = async_ids_stack_[2 * offset]; |
191 |
|
774166 |
async_id_fields_[kTriggerAsyncId] = async_ids_stack_[2 * offset + 1]; |
192 |
|
774166 |
fields_[kStackLength] = offset; |
193 |
|
|
|
194 |
|
1548332 |
if (LIKELY(offset < native_execution_async_resources_.size() && |
195 |
✓✗✓✗ ✓✗ |
1548332 |
!native_execution_async_resources_[offset].IsEmpty())) { |
196 |
|
|
#ifdef DEBUG |
197 |
|
|
for (uint32_t i = offset + 1; |
198 |
|
|
i < native_execution_async_resources_.size(); |
199 |
|
|
i++) { |
200 |
|
|
CHECK(native_execution_async_resources_[i].IsEmpty()); |
201 |
|
|
} |
202 |
|
|
#endif |
203 |
|
774166 |
native_execution_async_resources_.resize(offset); |
204 |
|
774166 |
if (native_execution_async_resources_.size() < |
205 |
✓✓✗✓ ✗✓ |
994804 |
native_execution_async_resources_.capacity() / 2 && |
206 |
|
220638 |
native_execution_async_resources_.size() > 16) { |
207 |
|
|
native_execution_async_resources_.shrink_to_fit(); |
208 |
|
|
} |
209 |
|
|
} |
210 |
|
|
|
211 |
✓✓ |
1548332 |
if (UNLIKELY(js_execution_async_resources()->Length() > offset)) { |
212 |
|
26385 |
v8::HandleScope handle_scope(env()->isolate()); |
213 |
|
52770 |
USE(js_execution_async_resources()->Set( |
214 |
|
|
env()->context(), |
215 |
|
|
env()->length_string(), |
216 |
|
105540 |
v8::Integer::NewFromUnsigned(env()->isolate(), offset))); |
217 |
|
|
} |
218 |
|
|
|
219 |
|
774166 |
return fields_[kStackLength] > 0; |
220 |
|
|
} |
221 |
|
|
|
222 |
|
1979 |
void AsyncHooks::clear_async_id_stack() { |
223 |
|
1979 |
v8::Isolate* isolate = env()->isolate(); |
224 |
|
1979 |
v8::HandleScope handle_scope(isolate); |
225 |
✓✓ |
1979 |
if (!js_execution_async_resources_.IsEmpty()) { |
226 |
|
2716 |
USE(PersistentToLocal::Strong(js_execution_async_resources_)->Set( |
227 |
|
|
env()->context(), |
228 |
|
|
env()->length_string(), |
229 |
|
5432 |
v8::Integer::NewFromUnsigned(isolate, 0))); |
230 |
|
|
} |
231 |
|
1979 |
native_execution_async_resources_.clear(); |
232 |
|
1979 |
native_execution_async_resources_.shrink_to_fit(); |
233 |
|
|
|
234 |
|
1979 |
async_id_fields_[kExecutionAsyncId] = 0; |
235 |
|
1979 |
async_id_fields_[kTriggerAsyncId] = 0; |
236 |
|
1979 |
fields_[kStackLength] = 0; |
237 |
|
1979 |
} |
238 |
|
|
|
239 |
|
6065 |
inline void AsyncHooks::AddContext(v8::Local<v8::Context> ctx) { |
240 |
|
23864 |
ctx->SetPromiseHooks( |
241 |
✓✓ |
6065 |
js_promise_hooks_[0].IsEmpty() ? |
242 |
|
6065 |
v8::Local<v8::Function>() : |
243 |
|
198 |
PersistentToLocal::Strong(js_promise_hooks_[0]), |
244 |
✓✓ |
6065 |
js_promise_hooks_[1].IsEmpty() ? |
245 |
|
6065 |
v8::Local<v8::Function>() : |
246 |
|
198 |
PersistentToLocal::Strong(js_promise_hooks_[1]), |
247 |
✓✓ |
6065 |
js_promise_hooks_[2].IsEmpty() ? |
248 |
|
6065 |
v8::Local<v8::Function>() : |
249 |
|
198 |
PersistentToLocal::Strong(js_promise_hooks_[2]), |
250 |
✓✗ |
6065 |
js_promise_hooks_[3].IsEmpty() ? |
251 |
|
6065 |
v8::Local<v8::Function>() : |
252 |
|
|
PersistentToLocal::Strong(js_promise_hooks_[3])); |
253 |
|
|
|
254 |
|
6065 |
size_t id = contexts_.size(); |
255 |
|
6065 |
contexts_.resize(id + 1); |
256 |
|
6065 |
contexts_[id].Reset(env()->isolate(), ctx); |
257 |
|
6065 |
contexts_[id].SetWeak(); |
258 |
|
6065 |
} |
259 |
|
|
|
260 |
|
498 |
inline void AsyncHooks::RemoveContext(v8::Local<v8::Context> ctx) { |
261 |
|
498 |
v8::Isolate* isolate = env()->isolate(); |
262 |
|
996 |
v8::HandleScope handle_scope(isolate); |
263 |
✓✓ |
4388 |
for (auto it = contexts_.begin(); it != contexts_.end(); it++) { |
264 |
✓✓ |
3890 |
if (it->IsEmpty()) { |
265 |
|
61 |
it = contexts_.erase(it); |
266 |
|
61 |
it--; |
267 |
|
61 |
continue; |
268 |
|
|
} |
269 |
|
|
v8::Local<v8::Context> saved_context = |
270 |
|
3829 |
PersistentToLocal::Weak(isolate, *it); |
271 |
✗✓ |
3829 |
if (saved_context == ctx) { |
272 |
|
|
it->Reset(); |
273 |
|
|
contexts_.erase(it); |
274 |
|
|
break; |
275 |
|
|
} |
276 |
|
|
} |
277 |
|
498 |
} |
278 |
|
|
|
279 |
|
|
// The DefaultTriggerAsyncIdScope(AsyncWrap*) constructor is defined in |
280 |
|
|
// async_wrap-inl.h to avoid a circular dependency. |
281 |
|
|
|
282 |
|
259686 |
inline AsyncHooks::DefaultTriggerAsyncIdScope ::DefaultTriggerAsyncIdScope( |
283 |
|
259686 |
Environment* env, double default_trigger_async_id) |
284 |
|
259686 |
: async_hooks_(env->async_hooks()) { |
285 |
✓✗ |
259686 |
if (env->async_hooks()->fields()[AsyncHooks::kCheck] > 0) { |
286 |
✗✓ |
259686 |
CHECK_GE(default_trigger_async_id, 0); |
287 |
|
|
} |
288 |
|
|
|
289 |
|
259686 |
old_default_trigger_async_id_ = |
290 |
|
259686 |
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId]; |
291 |
|
259686 |
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] = |
292 |
|
259686 |
default_trigger_async_id; |
293 |
|
259686 |
} |
294 |
|
|
|
295 |
|
519370 |
inline AsyncHooks::DefaultTriggerAsyncIdScope ::~DefaultTriggerAsyncIdScope() { |
296 |
|
259685 |
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] = |
297 |
|
259685 |
old_default_trigger_async_id_; |
298 |
|
259685 |
} |
299 |
|
|
|
300 |
|
1112945 |
Environment* Environment::ForAsyncHooks(AsyncHooks* hooks) { |
301 |
|
1112945 |
return ContainerOf(&Environment::async_hooks_, hooks); |
302 |
|
|
} |
303 |
|
|
|
304 |
|
775238 |
inline size_t Environment::async_callback_scope_depth() const { |
305 |
|
775238 |
return async_callback_scope_depth_; |
306 |
|
|
} |
307 |
|
|
|
308 |
|
787165 |
inline void Environment::PushAsyncCallbackScope() { |
309 |
|
787165 |
async_callback_scope_depth_++; |
310 |
|
787165 |
} |
311 |
|
|
|
312 |
|
786677 |
inline void Environment::PopAsyncCallbackScope() { |
313 |
|
786677 |
async_callback_scope_depth_--; |
314 |
|
786677 |
} |
315 |
|
|
|
316 |
|
621 |
inline AliasedUint32Array& ImmediateInfo::fields() { |
317 |
|
621 |
return fields_; |
318 |
|
|
} |
319 |
|
|
|
320 |
|
173322 |
inline uint32_t ImmediateInfo::count() const { |
321 |
|
173322 |
return fields_[kCount]; |
322 |
|
|
} |
323 |
|
|
|
324 |
|
261994 |
inline uint32_t ImmediateInfo::ref_count() const { |
325 |
|
261994 |
return fields_[kRefCount]; |
326 |
|
|
} |
327 |
|
|
|
328 |
|
41245 |
inline bool ImmediateInfo::has_outstanding() const { |
329 |
|
41245 |
return fields_[kHasOutstanding] == 1; |
330 |
|
|
} |
331 |
|
|
|
332 |
|
33358 |
inline void ImmediateInfo::ref_count_inc(uint32_t increment) { |
333 |
|
33358 |
fields_[kRefCount] += increment; |
334 |
|
33358 |
} |
335 |
|
|
|
336 |
|
188332 |
inline void ImmediateInfo::ref_count_dec(uint32_t decrement) { |
337 |
|
188332 |
fields_[kRefCount] -= decrement; |
338 |
|
188332 |
} |
339 |
|
|
|
340 |
|
621 |
inline AliasedUint8Array& TickInfo::fields() { |
341 |
|
621 |
return fields_; |
342 |
|
|
} |
343 |
|
|
|
344 |
|
1382231 |
inline bool TickInfo::has_tick_scheduled() const { |
345 |
|
1382231 |
return fields_[kHasTickScheduled] == 1; |
346 |
|
|
} |
347 |
|
|
|
348 |
|
508992 |
inline bool TickInfo::has_rejection_to_warn() const { |
349 |
|
508992 |
return fields_[kHasRejectionToWarn] == 1; |
350 |
|
|
} |
351 |
|
|
|
352 |
|
6065 |
inline void Environment::AssignToContext(v8::Local<v8::Context> context, |
353 |
|
|
const ContextInfo& info) { |
354 |
|
6065 |
context->SetAlignedPointerInEmbedderData( |
355 |
|
|
ContextEmbedderIndex::kEnvironment, this); |
356 |
|
|
// Used by Environment::GetCurrent to know that we are on a node context. |
357 |
|
6065 |
context->SetAlignedPointerInEmbedderData( |
358 |
|
|
ContextEmbedderIndex::kContextTag, Environment::kNodeContextTagPtr); |
359 |
|
|
// Used to retrieve bindings |
360 |
|
12130 |
context->SetAlignedPointerInEmbedderData( |
361 |
|
6065 |
ContextEmbedderIndex::kBindingListIndex, &(this->bindings_)); |
362 |
|
|
|
363 |
|
|
#if HAVE_INSPECTOR |
364 |
|
6065 |
inspector_agent()->ContextCreated(context, info); |
365 |
|
|
#endif // HAVE_INSPECTOR |
366 |
|
|
|
367 |
|
6065 |
this->async_hooks()->AddContext(context); |
368 |
|
6065 |
} |
369 |
|
|
|
370 |
|
829934 |
inline Environment* Environment::GetCurrent(v8::Isolate* isolate) { |
371 |
✓✓ |
829934 |
if (UNLIKELY(!isolate->InContext())) return nullptr; |
372 |
|
1657464 |
v8::HandleScope handle_scope(isolate); |
373 |
|
828732 |
return GetCurrent(isolate->GetCurrentContext()); |
374 |
|
|
} |
375 |
|
|
|
376 |
|
6080912 |
inline Environment* Environment::GetCurrent(v8::Local<v8::Context> context) { |
377 |
✓✓ |
6080912 |
if (UNLIKELY(context.IsEmpty())) { |
378 |
|
1 |
return nullptr; |
379 |
|
|
} |
380 |
|
6080911 |
if (UNLIKELY(context->GetNumberOfEmbedderDataFields() <= |
381 |
✓✓ |
6080911 |
ContextEmbedderIndex::kContextTag)) { |
382 |
|
11 |
return nullptr; |
383 |
|
|
} |
384 |
|
6080900 |
if (UNLIKELY(context->GetAlignedPointerFromEmbedderData( |
385 |
|
|
ContextEmbedderIndex::kContextTag) != |
386 |
✗✓ |
6080900 |
Environment::kNodeContextTagPtr)) { |
387 |
|
|
return nullptr; |
388 |
|
|
} |
389 |
|
|
return static_cast<Environment*>( |
390 |
|
6080900 |
context->GetAlignedPointerFromEmbedderData( |
391 |
|
6080900 |
ContextEmbedderIndex::kEnvironment)); |
392 |
|
|
} |
393 |
|
|
|
394 |
|
3559470 |
inline Environment* Environment::GetCurrent( |
395 |
|
|
const v8::FunctionCallbackInfo<v8::Value>& info) { |
396 |
|
3559470 |
return GetCurrent(info.GetIsolate()->GetCurrentContext()); |
397 |
|
|
} |
398 |
|
|
|
399 |
|
|
template <typename T> |
400 |
|
2608568 |
inline Environment* Environment::GetCurrent( |
401 |
|
|
const v8::PropertyCallbackInfo<T>& info) { |
402 |
|
2608568 |
return GetCurrent(info.GetIsolate()->GetCurrentContext()); |
403 |
|
|
} |
404 |
|
|
|
405 |
|
|
template <typename T, typename U> |
406 |
|
|
inline T* Environment::GetBindingData(const v8::PropertyCallbackInfo<U>& info) { |
407 |
|
|
return GetBindingData<T>(info.GetIsolate()->GetCurrentContext()); |
408 |
|
|
} |
409 |
|
|
|
410 |
|
|
template <typename T> |
411 |
|
748247 |
inline T* Environment::GetBindingData( |
412 |
|
|
const v8::FunctionCallbackInfo<v8::Value>& info) { |
413 |
|
748247 |
return GetBindingData<T>(info.GetIsolate()->GetCurrentContext()); |
414 |
|
|
} |
415 |
|
|
|
416 |
|
|
template <typename T> |
417 |
|
748249 |
inline T* Environment::GetBindingData(v8::Local<v8::Context> context) { |
418 |
|
|
BindingDataStore* map = static_cast<BindingDataStore*>( |
419 |
|
748249 |
context->GetAlignedPointerFromEmbedderData( |
420 |
|
|
ContextEmbedderIndex::kBindingListIndex)); |
421 |
|
|
DCHECK_NOT_NULL(map); |
422 |
|
748249 |
auto it = map->find(T::type_name); |
423 |
✗✓ |
748249 |
if (UNLIKELY(it == map->end())) return nullptr; |
424 |
|
748249 |
T* result = static_cast<T*>(it->second.get()); |
425 |
|
|
DCHECK_NOT_NULL(result); |
426 |
|
|
DCHECK_EQ(result->env(), GetCurrent(context)); |
427 |
|
748249 |
return result; |
428 |
|
|
} |
429 |
|
|
|
430 |
|
|
template <typename T> |
431 |
|
17447 |
inline T* Environment::AddBindingData( |
432 |
|
|
v8::Local<v8::Context> context, |
433 |
|
|
v8::Local<v8::Object> target) { |
434 |
|
|
DCHECK_EQ(GetCurrent(context), this); |
435 |
|
|
// This won't compile if T is not a BaseObject subclass. |
436 |
|
34894 |
BaseObjectPtr<T> item = MakeDetachedBaseObject<T>(this, target); |
437 |
|
|
BindingDataStore* map = static_cast<BindingDataStore*>( |
438 |
|
17447 |
context->GetAlignedPointerFromEmbedderData( |
439 |
|
|
ContextEmbedderIndex::kBindingListIndex)); |
440 |
|
|
DCHECK_NOT_NULL(map); |
441 |
|
17447 |
auto result = map->emplace(T::type_name, item); |
442 |
✗✓ |
17447 |
CHECK(result.second); |
443 |
|
|
DCHECK_EQ(GetBindingData<T>(context), item.get()); |
444 |
|
17447 |
return item.get(); |
445 |
|
|
} |
446 |
|
|
|
447 |
|
24669789 |
inline v8::Isolate* Environment::isolate() const { |
448 |
|
24669789 |
return isolate_; |
449 |
|
|
} |
450 |
|
|
|
451 |
|
6709 |
inline Environment* Environment::from_timer_handle(uv_timer_t* handle) { |
452 |
|
6709 |
return ContainerOf(&Environment::timer_handle_, handle); |
453 |
|
|
} |
454 |
|
|
|
455 |
|
26543 |
inline uv_timer_t* Environment::timer_handle() { |
456 |
|
26543 |
return &timer_handle_; |
457 |
|
|
} |
458 |
|
|
|
459 |
|
173322 |
inline Environment* Environment::from_immediate_check_handle( |
460 |
|
|
uv_check_t* handle) { |
461 |
|
173322 |
return ContainerOf(&Environment::immediate_check_handle_, handle); |
462 |
|
|
} |
463 |
|
|
|
464 |
|
21732 |
inline uv_check_t* Environment::immediate_check_handle() { |
465 |
|
21732 |
return &immediate_check_handle_; |
466 |
|
|
} |
467 |
|
|
|
468 |
|
216664 |
inline uv_idle_t* Environment::immediate_idle_handle() { |
469 |
|
216664 |
return &immediate_idle_handle_; |
470 |
|
|
} |
471 |
|
|
|
472 |
|
32598 |
inline void Environment::RegisterHandleCleanup(uv_handle_t* handle, |
473 |
|
|
HandleCleanupCb cb, |
474 |
|
|
void* arg) { |
475 |
|
32598 |
handle_cleanup_queue_.push_back(HandleCleanup{handle, cb, arg}); |
476 |
|
32598 |
} |
477 |
|
|
|
478 |
|
|
template <typename T, typename OnCloseCallback> |
479 |
|
34248 |
inline void Environment::CloseHandle(T* handle, OnCloseCallback callback) { |
480 |
|
34096 |
handle_cleanup_waiting_++; |
481 |
|
|
static_assert(sizeof(T) >= sizeof(uv_handle_t), "T is a libuv handle"); |
482 |
|
|
static_assert(offsetof(T, data) == offsetof(uv_handle_t, data), |
483 |
|
|
"T is a libuv handle"); |
484 |
|
|
static_assert(offsetof(T, close_cb) == offsetof(uv_handle_t, close_cb), |
485 |
|
|
"T is a libuv handle"); |
486 |
|
|
struct CloseData { |
487 |
|
|
Environment* env; |
488 |
|
|
OnCloseCallback callback; |
489 |
|
|
void* original_data; |
490 |
|
|
}; |
491 |
|
34172 |
handle->data = new CloseData { this, callback, handle->data }; |
492 |
|
34476 |
uv_close(reinterpret_cast<uv_handle_t*>(handle), [](uv_handle_t* handle) { |
493 |
|
68192 |
std::unique_ptr<CloseData> data { static_cast<CloseData*>(handle->data) }; |
494 |
|
34172 |
data->env->handle_cleanup_waiting_--; |
495 |
|
34172 |
handle->data = data->original_data; |
496 |
|
34172 |
data->callback(reinterpret_cast<T*>(handle)); |
497 |
|
|
}); |
498 |
|
34172 |
} |
499 |
|
|
|
500 |
|
89347 |
void Environment::IncreaseWaitingRequestCounter() { |
501 |
|
89347 |
request_waiting_++; |
502 |
|
89347 |
} |
503 |
|
|
|
504 |
|
89334 |
void Environment::DecreaseWaitingRequestCounter() { |
505 |
|
89334 |
request_waiting_--; |
506 |
✗✓ |
89334 |
CHECK_GE(request_waiting_, 0); |
507 |
|
89334 |
} |
508 |
|
|
|
509 |
|
957343 |
inline uv_loop_t* Environment::event_loop() const { |
510 |
|
957343 |
return isolate_data()->event_loop(); |
511 |
|
|
} |
512 |
|
|
|
513 |
|
164 |
inline void Environment::TryLoadAddon( |
514 |
|
|
const char* filename, |
515 |
|
|
int flags, |
516 |
|
|
const std::function<bool(binding::DLib*)>& was_loaded) { |
517 |
|
164 |
loaded_addons_.emplace_back(filename, flags); |
518 |
✓✓ |
164 |
if (!was_loaded(&loaded_addons_.back())) { |
519 |
|
8 |
loaded_addons_.pop_back(); |
520 |
|
|
} |
521 |
|
164 |
} |
522 |
|
|
|
523 |
|
|
#if HAVE_INSPECTOR |
524 |
|
44472 |
inline bool Environment::is_in_inspector_console_call() const { |
525 |
|
44472 |
return is_in_inspector_console_call_; |
526 |
|
|
} |
527 |
|
|
|
528 |
|
88942 |
inline void Environment::set_is_in_inspector_console_call(bool value) { |
529 |
|
88942 |
is_in_inspector_console_call_ = value; |
530 |
|
88942 |
} |
531 |
|
|
#endif |
532 |
|
|
|
533 |
|
5154958 |
inline AsyncHooks* Environment::async_hooks() { |
534 |
|
5154958 |
return &async_hooks_; |
535 |
|
|
} |
536 |
|
|
|
537 |
|
698872 |
inline ImmediateInfo* Environment::immediate_info() { |
538 |
|
698872 |
return &immediate_info_; |
539 |
|
|
} |
540 |
|
|
|
541 |
|
691758 |
inline TickInfo* Environment::tick_info() { |
542 |
|
691758 |
return &tick_info_; |
543 |
|
|
} |
544 |
|
|
|
545 |
|
60153 |
inline uint64_t Environment::timer_base() const { |
546 |
|
60153 |
return timer_base_; |
547 |
|
|
} |
548 |
|
|
|
549 |
|
1319045 |
inline std::shared_ptr<KVStore> Environment::env_vars() { |
550 |
|
1319045 |
return env_vars_; |
551 |
|
|
} |
552 |
|
|
|
553 |
|
6031 |
inline void Environment::set_env_vars(std::shared_ptr<KVStore> env_vars) { |
554 |
|
6031 |
env_vars_ = env_vars; |
555 |
|
6031 |
} |
556 |
|
|
|
557 |
|
17 |
inline bool Environment::printed_error() const { |
558 |
|
17 |
return printed_error_; |
559 |
|
|
} |
560 |
|
|
|
561 |
|
17 |
inline void Environment::set_printed_error(bool value) { |
562 |
|
17 |
printed_error_ = value; |
563 |
|
17 |
} |
564 |
|
|
|
565 |
|
9914 |
inline void Environment::set_trace_sync_io(bool value) { |
566 |
|
9914 |
trace_sync_io_ = value; |
567 |
|
9914 |
} |
568 |
|
|
|
569 |
|
84 |
inline bool Environment::abort_on_uncaught_exception() const { |
570 |
|
84 |
return options_->abort_on_uncaught_exception; |
571 |
|
|
} |
572 |
|
|
|
573 |
|
|
inline void Environment::set_force_context_aware(bool value) { |
574 |
|
|
options_->force_context_aware = value; |
575 |
|
|
} |
576 |
|
|
|
577 |
|
41 |
inline bool Environment::force_context_aware() const { |
578 |
|
41 |
return options_->force_context_aware; |
579 |
|
|
} |
580 |
|
|
|
581 |
|
569 |
inline void Environment::set_abort_on_uncaught_exception(bool value) { |
582 |
|
569 |
options_->abort_on_uncaught_exception = value; |
583 |
|
569 |
} |
584 |
|
|
|
585 |
|
651 |
inline AliasedUint32Array& Environment::should_abort_on_uncaught_toggle() { |
586 |
|
651 |
return should_abort_on_uncaught_toggle_; |
587 |
|
|
} |
588 |
|
|
|
589 |
|
303989 |
inline AliasedInt32Array& Environment::stream_base_state() { |
590 |
|
303989 |
return stream_base_state_; |
591 |
|
|
} |
592 |
|
|
|
593 |
|
45202 |
inline uint32_t Environment::get_next_module_id() { |
594 |
|
45202 |
return module_id_counter_++; |
595 |
|
|
} |
596 |
|
3111 |
inline uint32_t Environment::get_next_script_id() { |
597 |
|
3111 |
return script_id_counter_++; |
598 |
|
|
} |
599 |
|
32380 |
inline uint32_t Environment::get_next_function_id() { |
600 |
|
32380 |
return function_id_counter_++; |
601 |
|
|
} |
602 |
|
|
|
603 |
|
93146 |
ShouldNotAbortOnUncaughtScope::ShouldNotAbortOnUncaughtScope( |
604 |
|
93146 |
Environment* env) |
605 |
|
93146 |
: env_(env) { |
606 |
|
93146 |
env_->PushShouldNotAbortOnUncaughtScope(); |
607 |
|
93146 |
} |
608 |
|
|
|
609 |
|
186288 |
ShouldNotAbortOnUncaughtScope::~ShouldNotAbortOnUncaughtScope() { |
610 |
|
93144 |
Close(); |
611 |
|
93144 |
} |
612 |
|
|
|
613 |
|
93335 |
void ShouldNotAbortOnUncaughtScope::Close() { |
614 |
✓✓ |
93335 |
if (env_ != nullptr) { |
615 |
|
93144 |
env_->PopShouldNotAbortOnUncaughtScope(); |
616 |
|
93144 |
env_ = nullptr; |
617 |
|
|
} |
618 |
|
93335 |
} |
619 |
|
|
|
620 |
|
93146 |
inline void Environment::PushShouldNotAbortOnUncaughtScope() { |
621 |
|
93146 |
should_not_abort_scope_counter_++; |
622 |
|
93146 |
} |
623 |
|
|
|
624 |
|
93144 |
inline void Environment::PopShouldNotAbortOnUncaughtScope() { |
625 |
|
93144 |
should_not_abort_scope_counter_--; |
626 |
|
93144 |
} |
627 |
|
|
|
628 |
|
1 |
inline bool Environment::inside_should_not_abort_on_uncaught_scope() const { |
629 |
|
1 |
return should_not_abort_scope_counter_ > 0; |
630 |
|
|
} |
631 |
|
|
|
632 |
|
404250 |
inline std::vector<double>* Environment::destroy_async_id_list() { |
633 |
|
404250 |
return &destroy_async_id_list_; |
634 |
|
|
} |
635 |
|
|
|
636 |
|
204842 |
inline double Environment::new_async_id() { |
637 |
|
204842 |
async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] += 1; |
638 |
|
204842 |
return async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter]; |
639 |
|
|
} |
640 |
|
|
|
641 |
|
236268 |
inline double Environment::execution_async_id() { |
642 |
|
236268 |
return async_hooks()->async_id_fields()[AsyncHooks::kExecutionAsyncId]; |
643 |
|
|
} |
644 |
|
|
|
645 |
|
67815 |
inline double Environment::trigger_async_id() { |
646 |
|
67815 |
return async_hooks()->async_id_fields()[AsyncHooks::kTriggerAsyncId]; |
647 |
|
|
} |
648 |
|
|
|
649 |
|
204839 |
inline double Environment::get_default_trigger_async_id() { |
650 |
|
|
double default_trigger_async_id = |
651 |
|
204839 |
async_hooks()->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId]; |
652 |
|
|
// If defaultTriggerAsyncId isn't set, use the executionAsyncId |
653 |
✓✓ |
204839 |
if (default_trigger_async_id < 0) |
654 |
|
168428 |
default_trigger_async_id = execution_async_id(); |
655 |
|
204839 |
return default_trigger_async_id; |
656 |
|
|
} |
657 |
|
|
|
658 |
|
61045 |
inline std::shared_ptr<EnvironmentOptions> Environment::options() { |
659 |
|
61045 |
return options_; |
660 |
|
|
} |
661 |
|
|
|
662 |
|
15616 |
inline const std::vector<std::string>& Environment::argv() { |
663 |
|
15616 |
return argv_; |
664 |
|
|
} |
665 |
|
|
|
666 |
|
5983 |
inline const std::vector<std::string>& Environment::exec_argv() { |
667 |
|
5983 |
return exec_argv_; |
668 |
|
|
} |
669 |
|
|
|
670 |
|
10866 |
inline const std::string& Environment::exec_path() const { |
671 |
|
10866 |
return exec_path_; |
672 |
|
|
} |
673 |
|
|
|
674 |
|
11 |
inline std::string Environment::GetCwd() { |
675 |
|
|
char cwd[PATH_MAX_BYTES]; |
676 |
|
11 |
size_t size = PATH_MAX_BYTES; |
677 |
|
11 |
const int err = uv_cwd(cwd, &size); |
678 |
|
|
|
679 |
✓✗ |
11 |
if (err == 0) { |
680 |
✗✓ |
11 |
CHECK_GT(size, 0); |
681 |
|
11 |
return cwd; |
682 |
|
|
} |
683 |
|
|
|
684 |
|
|
// This can fail if the cwd is deleted. In that case, fall back to |
685 |
|
|
// exec_path. |
686 |
|
|
const std::string& exec_path = exec_path_; |
687 |
|
|
return exec_path.substr(0, exec_path.find_last_of(kPathSeparator)); |
688 |
|
|
} |
689 |
|
|
|
690 |
|
|
#if HAVE_INSPECTOR |
691 |
|
5428 |
inline void Environment::set_coverage_directory(const char* dir) { |
692 |
|
5428 |
coverage_directory_ = std::string(dir); |
693 |
|
5428 |
} |
694 |
|
|
|
695 |
|
5451 |
inline void Environment::set_coverage_connection( |
696 |
|
|
std::unique_ptr<profiler::V8CoverageConnection> connection) { |
697 |
✗✓ |
5451 |
CHECK_NULL(coverage_connection_); |
698 |
|
5451 |
std::swap(coverage_connection_, connection); |
699 |
|
5451 |
} |
700 |
|
|
|
701 |
|
16352 |
inline profiler::V8CoverageConnection* Environment::coverage_connection() { |
702 |
|
16352 |
return coverage_connection_.get(); |
703 |
|
|
} |
704 |
|
|
|
705 |
|
5412 |
inline const std::string& Environment::coverage_directory() const { |
706 |
|
5412 |
return coverage_directory_; |
707 |
|
|
} |
708 |
|
|
|
709 |
|
12 |
inline void Environment::set_cpu_profiler_connection( |
710 |
|
|
std::unique_ptr<profiler::V8CpuProfilerConnection> connection) { |
711 |
✗✓ |
12 |
CHECK_NULL(cpu_profiler_connection_); |
712 |
|
12 |
std::swap(cpu_profiler_connection_, connection); |
713 |
|
12 |
} |
714 |
|
|
|
715 |
|
|
inline profiler::V8CpuProfilerConnection* |
716 |
|
5467 |
Environment::cpu_profiler_connection() { |
717 |
|
5467 |
return cpu_profiler_connection_.get(); |
718 |
|
|
} |
719 |
|
|
|
720 |
|
12 |
inline void Environment::set_cpu_prof_interval(uint64_t interval) { |
721 |
|
12 |
cpu_prof_interval_ = interval; |
722 |
|
12 |
} |
723 |
|
|
|
724 |
|
12 |
inline uint64_t Environment::cpu_prof_interval() const { |
725 |
|
12 |
return cpu_prof_interval_; |
726 |
|
|
} |
727 |
|
|
|
728 |
|
12 |
inline void Environment::set_cpu_prof_name(const std::string& name) { |
729 |
|
12 |
cpu_prof_name_ = name; |
730 |
|
12 |
} |
731 |
|
|
|
732 |
|
12 |
inline const std::string& Environment::cpu_prof_name() const { |
733 |
|
12 |
return cpu_prof_name_; |
734 |
|
|
} |
735 |
|
|
|
736 |
|
12 |
inline void Environment::set_cpu_prof_dir(const std::string& dir) { |
737 |
|
12 |
cpu_prof_dir_ = dir; |
738 |
|
12 |
} |
739 |
|
|
|
740 |
|
12 |
inline const std::string& Environment::cpu_prof_dir() const { |
741 |
|
12 |
return cpu_prof_dir_; |
742 |
|
|
} |
743 |
|
|
|
744 |
|
12 |
inline void Environment::set_heap_profiler_connection( |
745 |
|
|
std::unique_ptr<profiler::V8HeapProfilerConnection> connection) { |
746 |
✗✓ |
12 |
CHECK_NULL(heap_profiler_connection_); |
747 |
|
12 |
std::swap(heap_profiler_connection_, connection); |
748 |
|
12 |
} |
749 |
|
|
|
750 |
|
|
inline profiler::V8HeapProfilerConnection* |
751 |
|
5455 |
Environment::heap_profiler_connection() { |
752 |
|
5455 |
return heap_profiler_connection_.get(); |
753 |
|
|
} |
754 |
|
|
|
755 |
|
12 |
inline void Environment::set_heap_prof_name(const std::string& name) { |
756 |
|
12 |
heap_prof_name_ = name; |
757 |
|
12 |
} |
758 |
|
|
|
759 |
|
12 |
inline const std::string& Environment::heap_prof_name() const { |
760 |
|
12 |
return heap_prof_name_; |
761 |
|
|
} |
762 |
|
|
|
763 |
|
12 |
inline void Environment::set_heap_prof_dir(const std::string& dir) { |
764 |
|
12 |
heap_prof_dir_ = dir; |
765 |
|
12 |
} |
766 |
|
|
|
767 |
|
12 |
inline const std::string& Environment::heap_prof_dir() const { |
768 |
|
12 |
return heap_prof_dir_; |
769 |
|
|
} |
770 |
|
|
|
771 |
|
12 |
inline void Environment::set_heap_prof_interval(uint64_t interval) { |
772 |
|
12 |
heap_prof_interval_ = interval; |
773 |
|
12 |
} |
774 |
|
|
|
775 |
|
12 |
inline uint64_t Environment::heap_prof_interval() const { |
776 |
|
12 |
return heap_prof_interval_; |
777 |
|
|
} |
778 |
|
|
|
779 |
|
|
#endif // HAVE_INSPECTOR |
780 |
|
|
|
781 |
|
|
inline |
782 |
|
11072 |
std::shared_ptr<ExclusiveAccess<HostPort>> Environment::inspector_host_port() { |
783 |
|
11072 |
return inspector_host_port_; |
784 |
|
|
} |
785 |
|
|
|
786 |
|
102729 |
inline std::shared_ptr<PerIsolateOptions> IsolateData::options() { |
787 |
|
102729 |
return options_; |
788 |
|
|
} |
789 |
|
|
|
790 |
|
257 |
inline void IsolateData::set_options( |
791 |
|
|
std::shared_ptr<PerIsolateOptions> options) { |
792 |
|
257 |
options_ = std::move(options); |
793 |
|
257 |
} |
794 |
|
|
|
795 |
|
|
template <typename Fn> |
796 |
|
90414 |
void Environment::SetImmediate(Fn&& cb, CallbackFlags::Flags flags) { |
797 |
|
180828 |
auto callback = native_immediates_.CreateCallback(std::move(cb), flags); |
798 |
|
90414 |
native_immediates_.Push(std::move(callback)); |
799 |
|
|
|
800 |
✓✓ |
90414 |
if (flags & CallbackFlags::kRefed) { |
801 |
✓✓ |
66702 |
if (immediate_info()->ref_count() == 0) |
802 |
|
50018 |
ToggleImmediateRef(true); |
803 |
|
66702 |
immediate_info()->ref_count_inc(1); |
804 |
|
|
} |
805 |
|
90414 |
} |
806 |
|
|
|
807 |
|
|
template <typename Fn> |
808 |
|
2649 |
void Environment::SetImmediateThreadsafe(Fn&& cb, CallbackFlags::Flags flags) { |
809 |
|
5298 |
auto callback = native_immediates_threadsafe_.CreateCallback( |
810 |
|
2649 |
std::move(cb), flags); |
811 |
|
|
{ |
812 |
|
5298 |
Mutex::ScopedLock lock(native_immediates_threadsafe_mutex_); |
813 |
|
2649 |
native_immediates_threadsafe_.Push(std::move(callback)); |
814 |
✓✓ |
2649 |
if (task_queues_async_initialized_) |
815 |
|
2052 |
uv_async_send(&task_queues_async_); |
816 |
|
|
} |
817 |
|
2649 |
} |
818 |
|
|
|
819 |
|
|
template <typename Fn> |
820 |
|
9257 |
void Environment::RequestInterrupt(Fn&& cb) { |
821 |
|
18514 |
auto callback = native_immediates_interrupts_.CreateCallback( |
822 |
|
9257 |
std::move(cb), CallbackFlags::kRefed); |
823 |
|
|
{ |
824 |
|
18514 |
Mutex::ScopedLock lock(native_immediates_threadsafe_mutex_); |
825 |
|
9257 |
native_immediates_interrupts_.Push(std::move(callback)); |
826 |
✓✓ |
9257 |
if (task_queues_async_initialized_) |
827 |
|
3678 |
uv_async_send(&task_queues_async_); |
828 |
|
|
} |
829 |
|
9257 |
RequestInterruptFromV8(); |
830 |
|
9257 |
} |
831 |
|
|
|
832 |
|
2915983 |
inline bool Environment::can_call_into_js() const { |
833 |
✓✓✓✓
|
2915983 |
return can_call_into_js_ && !is_stopping(); |
834 |
|
|
} |
835 |
|
|
|
836 |
|
1222 |
inline void Environment::set_can_call_into_js(bool can_call_into_js) { |
837 |
|
1222 |
can_call_into_js_ = can_call_into_js; |
838 |
|
1222 |
} |
839 |
|
|
|
840 |
|
1452630 |
inline bool Environment::has_run_bootstrapping_code() const { |
841 |
|
1452630 |
return has_run_bootstrapping_code_; |
842 |
|
|
} |
843 |
|
|
|
844 |
|
5466 |
inline void Environment::DoneBootstrapping() { |
845 |
|
5466 |
has_run_bootstrapping_code_ = true; |
846 |
|
|
// This adjusts the return value of base_object_created_after_bootstrap() so |
847 |
|
|
// that tests that check the count do not have to account for internally |
848 |
|
|
// created BaseObjects. |
849 |
|
5466 |
base_object_created_by_bootstrap_ = base_object_count_; |
850 |
|
5466 |
} |
851 |
|
|
|
852 |
|
19 |
inline bool Environment::has_serialized_options() const { |
853 |
|
19 |
return has_serialized_options_; |
854 |
|
|
} |
855 |
|
|
|
856 |
|
5449 |
inline void Environment::set_has_serialized_options(bool value) { |
857 |
|
5449 |
has_serialized_options_ = value; |
858 |
|
5449 |
} |
859 |
|
|
|
860 |
|
8034 |
inline bool Environment::is_main_thread() const { |
861 |
|
8034 |
return worker_context() == nullptr; |
862 |
|
|
} |
863 |
|
|
|
864 |
|
976 |
inline bool Environment::no_native_addons() const { |
865 |
✓✓ |
1948 |
return (flags_ & EnvironmentFlags::kNoNativeAddons) || |
866 |
✓✓ |
1948 |
!options_->allow_native_addons; |
867 |
|
|
} |
868 |
|
|
|
869 |
|
5433 |
inline bool Environment::should_not_register_esm_loader() const { |
870 |
|
5433 |
return flags_ & EnvironmentFlags::kNoRegisterESMLoader; |
871 |
|
|
} |
872 |
|
|
|
873 |
|
13936 |
inline bool Environment::owns_process_state() const { |
874 |
|
13936 |
return flags_ & EnvironmentFlags::kOwnsProcessState; |
875 |
|
|
} |
876 |
|
|
|
877 |
|
5460 |
inline bool Environment::owns_inspector() const { |
878 |
|
5460 |
return flags_ & EnvironmentFlags::kOwnsInspector; |
879 |
|
|
} |
880 |
|
|
|
881 |
|
114468 |
inline bool Environment::tracks_unmanaged_fds() const { |
882 |
|
114468 |
return flags_ & EnvironmentFlags::kTrackUnmanagedFds; |
883 |
|
|
} |
884 |
|
|
|
885 |
|
2609 |
inline bool Environment::hide_console_windows() const { |
886 |
|
2609 |
return flags_ & EnvironmentFlags::kHideConsoleWindows; |
887 |
|
|
} |
888 |
|
|
|
889 |
|
6238 |
inline bool Environment::no_global_search_paths() const { |
890 |
✓✗ |
12476 |
return (flags_ & EnvironmentFlags::kNoGlobalSearchPaths) || |
891 |
✗✓ |
12476 |
!options_->global_search_paths; |
892 |
|
|
} |
893 |
|
|
|
894 |
|
4 |
bool Environment::filehandle_close_warning() const { |
895 |
|
4 |
return emit_filehandle_warning_; |
896 |
|
|
} |
897 |
|
|
|
898 |
|
3 |
void Environment::set_filehandle_close_warning(bool on) { |
899 |
|
3 |
emit_filehandle_warning_ = on; |
900 |
|
3 |
} |
901 |
|
|
|
902 |
|
5296 |
void Environment::set_source_maps_enabled(bool on) { |
903 |
|
5296 |
source_maps_enabled_ = on; |
904 |
|
5296 |
} |
905 |
|
|
|
906 |
|
875 |
bool Environment::source_maps_enabled() const { |
907 |
|
875 |
return source_maps_enabled_; |
908 |
|
|
} |
909 |
|
|
|
910 |
|
6684 |
inline uint64_t Environment::thread_id() const { |
911 |
|
6684 |
return thread_id_; |
912 |
|
|
} |
913 |
|
|
|
914 |
|
14021 |
inline worker::Worker* Environment::worker_context() const { |
915 |
|
14021 |
return isolate_data()->worker_context(); |
916 |
|
|
} |
917 |
|
|
|
918 |
|
802 |
inline void Environment::add_sub_worker_context(worker::Worker* context) { |
919 |
|
802 |
sub_worker_contexts_.insert(context); |
920 |
|
802 |
} |
921 |
|
|
|
922 |
|
829 |
inline void Environment::remove_sub_worker_context(worker::Worker* context) { |
923 |
|
829 |
sub_worker_contexts_.erase(context); |
924 |
|
829 |
} |
925 |
|
|
|
926 |
|
|
template <typename Fn> |
927 |
|
24 |
inline void Environment::ForEachWorker(Fn&& iterator) { |
928 |
✓✓ |
26 |
for (worker::Worker* w : sub_worker_contexts_) iterator(w); |
929 |
|
24 |
} |
930 |
|
|
|
931 |
|
1588 |
inline void Environment::add_refs(int64_t diff) { |
932 |
|
1588 |
task_queues_async_refs_ += diff; |
933 |
✗✓ |
1588 |
CHECK_GE(task_queues_async_refs_, 0); |
934 |
✓✓ |
1588 |
if (task_queues_async_refs_ == 0) |
935 |
|
179 |
uv_unref(reinterpret_cast<uv_handle_t*>(&task_queues_async_)); |
936 |
|
|
else |
937 |
|
1409 |
uv_ref(reinterpret_cast<uv_handle_t*>(&task_queues_async_)); |
938 |
|
1588 |
} |
939 |
|
|
|
940 |
|
4403719 |
inline bool Environment::is_stopping() const { |
941 |
|
4403719 |
return is_stopping_.load(); |
942 |
|
|
} |
943 |
|
|
|
944 |
|
5157 |
inline void Environment::set_stopping(bool value) { |
945 |
|
5157 |
is_stopping_.store(value); |
946 |
|
5157 |
} |
947 |
|
|
|
948 |
|
14 |
inline std::list<node_module>* Environment::extra_linked_bindings() { |
949 |
|
14 |
return &extra_linked_bindings_; |
950 |
|
|
} |
951 |
|
|
|
952 |
|
10 |
inline node_module* Environment::extra_linked_bindings_head() { |
953 |
✓✓ |
10 |
return extra_linked_bindings_.size() > 0 ? |
954 |
|
10 |
&extra_linked_bindings_.front() : nullptr; |
955 |
|
|
} |
956 |
|
|
|
957 |
|
9 |
inline node_module* Environment::extra_linked_bindings_tail() { |
958 |
✓✓ |
9 |
return extra_linked_bindings_.size() > 0 ? |
959 |
|
9 |
&extra_linked_bindings_.back() : nullptr; |
960 |
|
|
} |
961 |
|
|
|
962 |
|
19 |
inline const Mutex& Environment::extra_linked_bindings_mutex() const { |
963 |
|
19 |
return extra_linked_bindings_mutex_; |
964 |
|
|
} |
965 |
|
|
|
966 |
|
40444 |
inline performance::PerformanceState* Environment::performance_state() { |
967 |
|
40444 |
return performance_state_.get(); |
968 |
|
|
} |
969 |
|
|
|
970 |
|
6550046 |
inline IsolateData* Environment::isolate_data() const { |
971 |
|
6550046 |
return isolate_data_; |
972 |
|
|
} |
973 |
|
|
|
974 |
|
|
std::unordered_map<char*, std::unique_ptr<v8::BackingStore>>* |
975 |
|
133406 |
Environment::released_allocated_buffers() { |
976 |
|
133406 |
return &released_allocated_buffers_; |
977 |
|
|
} |
978 |
|
|
|
979 |
|
8 |
inline void Environment::ThrowError(const char* errmsg) { |
980 |
|
8 |
ThrowError(v8::Exception::Error, errmsg); |
981 |
|
8 |
} |
982 |
|
|
|
983 |
|
|
inline void Environment::ThrowTypeError(const char* errmsg) { |
984 |
|
|
ThrowError(v8::Exception::TypeError, errmsg); |
985 |
|
|
} |
986 |
|
|
|
987 |
|
|
inline void Environment::ThrowRangeError(const char* errmsg) { |
988 |
|
|
ThrowError(v8::Exception::RangeError, errmsg); |
989 |
|
|
} |
990 |
|
|
|
991 |
|
8 |
inline void Environment::ThrowError( |
992 |
|
|
v8::Local<v8::Value> (*fun)(v8::Local<v8::String>), |
993 |
|
|
const char* errmsg) { |
994 |
|
16 |
v8::HandleScope handle_scope(isolate()); |
995 |
|
8 |
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg))); |
996 |
|
8 |
} |
997 |
|
|
|
998 |
|
7 |
inline void Environment::ThrowErrnoException(int errorno, |
999 |
|
|
const char* syscall, |
1000 |
|
|
const char* message, |
1001 |
|
|
const char* path) { |
1002 |
|
|
isolate()->ThrowException( |
1003 |
|
7 |
ErrnoException(isolate(), errorno, syscall, message, path)); |
1004 |
|
7 |
} |
1005 |
|
|
|
1006 |
|
14 |
inline void Environment::ThrowUVException(int errorno, |
1007 |
|
|
const char* syscall, |
1008 |
|
|
const char* message, |
1009 |
|
|
const char* path, |
1010 |
|
|
const char* dest) { |
1011 |
|
|
isolate()->ThrowException( |
1012 |
|
14 |
UVException(isolate(), errorno, syscall, message, path, dest)); |
1013 |
|
14 |
} |
1014 |
|
|
|
1015 |
|
|
inline v8::Local<v8::FunctionTemplate> |
1016 |
|
1469591 |
Environment::NewFunctionTemplate(v8::FunctionCallback callback, |
1017 |
|
|
v8::Local<v8::Signature> signature, |
1018 |
|
|
v8::ConstructorBehavior behavior, |
1019 |
|
|
v8::SideEffectType side_effect_type) { |
1020 |
|
|
return v8::FunctionTemplate::New(isolate(), callback, v8::Local<v8::Value>(), |
1021 |
|
1469591 |
signature, 0, behavior, side_effect_type); |
1022 |
|
|
} |
1023 |
|
|
|
1024 |
|
256033 |
inline void Environment::SetMethod(v8::Local<v8::Object> that, |
1025 |
|
|
const char* name, |
1026 |
|
|
v8::FunctionCallback callback) { |
1027 |
|
256033 |
v8::Local<v8::Context> context = isolate()->GetCurrentContext(); |
1028 |
|
|
v8::Local<v8::Function> function = |
1029 |
|
256033 |
NewFunctionTemplate(callback, v8::Local<v8::Signature>(), |
1030 |
|
|
v8::ConstructorBehavior::kThrow, |
1031 |
|
256033 |
v8::SideEffectType::kHasSideEffect) |
1032 |
|
256033 |
->GetFunction(context) |
1033 |
|
256033 |
.ToLocalChecked(); |
1034 |
|
|
// kInternalized strings are created in the old space. |
1035 |
|
256033 |
const v8::NewStringType type = v8::NewStringType::kInternalized; |
1036 |
|
|
v8::Local<v8::String> name_string = |
1037 |
|
512066 |
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked(); |
1038 |
|
512066 |
that->Set(context, name_string, function).Check(); |
1039 |
|
256033 |
function->SetName(name_string); // NODE_SET_METHOD() compatibility. |
1040 |
|
256033 |
} |
1041 |
|
|
|
1042 |
|
116396 |
inline void Environment::SetMethodNoSideEffect(v8::Local<v8::Object> that, |
1043 |
|
|
const char* name, |
1044 |
|
|
v8::FunctionCallback callback) { |
1045 |
|
116396 |
v8::Local<v8::Context> context = isolate()->GetCurrentContext(); |
1046 |
|
|
v8::Local<v8::Function> function = |
1047 |
|
116396 |
NewFunctionTemplate(callback, v8::Local<v8::Signature>(), |
1048 |
|
|
v8::ConstructorBehavior::kThrow, |
1049 |
|
116396 |
v8::SideEffectType::kHasNoSideEffect) |
1050 |
|
116396 |
->GetFunction(context) |
1051 |
|
116396 |
.ToLocalChecked(); |
1052 |
|
|
// kInternalized strings are created in the old space. |
1053 |
|
116396 |
const v8::NewStringType type = v8::NewStringType::kInternalized; |
1054 |
|
|
v8::Local<v8::String> name_string = |
1055 |
|
232792 |
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked(); |
1056 |
|
232792 |
that->Set(context, name_string, function).Check(); |
1057 |
|
116396 |
function->SetName(name_string); // NODE_SET_METHOD() compatibility. |
1058 |
|
116396 |
} |
1059 |
|
|
|
1060 |
|
727667 |
inline void Environment::SetProtoMethod(v8::Local<v8::FunctionTemplate> that, |
1061 |
|
|
const char* name, |
1062 |
|
|
v8::FunctionCallback callback) { |
1063 |
|
727667 |
v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that); |
1064 |
|
|
v8::Local<v8::FunctionTemplate> t = |
1065 |
|
|
NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow, |
1066 |
|
727667 |
v8::SideEffectType::kHasSideEffect); |
1067 |
|
|
// kInternalized strings are created in the old space. |
1068 |
|
727667 |
const v8::NewStringType type = v8::NewStringType::kInternalized; |
1069 |
|
|
v8::Local<v8::String> name_string = |
1070 |
|
1455334 |
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked(); |
1071 |
|
1455334 |
that->PrototypeTemplate()->Set(name_string, t); |
1072 |
|
727667 |
t->SetClassName(name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility. |
1073 |
|
727667 |
} |
1074 |
|
|
|
1075 |
|
119775 |
inline void Environment::SetProtoMethodNoSideEffect( |
1076 |
|
|
v8::Local<v8::FunctionTemplate> that, |
1077 |
|
|
const char* name, |
1078 |
|
|
v8::FunctionCallback callback) { |
1079 |
|
119775 |
v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that); |
1080 |
|
|
v8::Local<v8::FunctionTemplate> t = |
1081 |
|
|
NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow, |
1082 |
|
119775 |
v8::SideEffectType::kHasNoSideEffect); |
1083 |
|
|
// kInternalized strings are created in the old space. |
1084 |
|
119775 |
const v8::NewStringType type = v8::NewStringType::kInternalized; |
1085 |
|
|
v8::Local<v8::String> name_string = |
1086 |
|
239550 |
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked(); |
1087 |
|
239550 |
that->PrototypeTemplate()->Set(name_string, t); |
1088 |
|
119775 |
t->SetClassName(name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility. |
1089 |
|
119775 |
} |
1090 |
|
|
|
1091 |
|
33 |
inline void Environment::SetInstanceMethod(v8::Local<v8::FunctionTemplate> that, |
1092 |
|
|
const char* name, |
1093 |
|
|
v8::FunctionCallback callback) { |
1094 |
|
33 |
v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that); |
1095 |
|
|
v8::Local<v8::FunctionTemplate> t = |
1096 |
|
|
NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow, |
1097 |
|
33 |
v8::SideEffectType::kHasSideEffect); |
1098 |
|
|
// kInternalized strings are created in the old space. |
1099 |
|
33 |
const v8::NewStringType type = v8::NewStringType::kInternalized; |
1100 |
|
|
v8::Local<v8::String> name_string = |
1101 |
|
66 |
v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked(); |
1102 |
|
66 |
that->InstanceTemplate()->Set(name_string, t); |
1103 |
|
33 |
t->SetClassName(name_string); |
1104 |
|
33 |
} |
1105 |
|
|
|
1106 |
|
186052 |
inline void Environment::SetConstructorFunction( |
1107 |
|
|
v8::Local<v8::Object> that, |
1108 |
|
|
const char* name, |
1109 |
|
|
v8::Local<v8::FunctionTemplate> tmpl, |
1110 |
|
|
SetConstructorFunctionFlag flag) { |
1111 |
|
186052 |
SetConstructorFunction(that, OneByteString(isolate(), name), tmpl, flag); |
1112 |
|
186052 |
} |
1113 |
|
|
|
1114 |
|
196509 |
inline void Environment::SetConstructorFunction( |
1115 |
|
|
v8::Local<v8::Object> that, |
1116 |
|
|
v8::Local<v8::String> name, |
1117 |
|
|
v8::Local<v8::FunctionTemplate> tmpl, |
1118 |
|
|
SetConstructorFunctionFlag flag) { |
1119 |
✓✓ |
196509 |
if (LIKELY(flag == SetConstructorFunctionFlag::SET_CLASS_NAME)) |
1120 |
|
191280 |
tmpl->SetClassName(name); |
1121 |
|
196509 |
that->Set( |
1122 |
|
|
context(), |
1123 |
|
|
name, |
1124 |
|
393018 |
tmpl->GetFunction(context()).ToLocalChecked()).Check(); |
1125 |
|
196509 |
} |
1126 |
|
|
|
1127 |
|
368392 |
void Environment::AddCleanupHook(CleanupCallback fn, void* arg) { |
1128 |
|
736784 |
auto insertion_info = cleanup_hooks_.emplace(CleanupHookCallback { |
1129 |
|
368392 |
fn, arg, cleanup_hook_counter_++ |
1130 |
|
368392 |
}); |
1131 |
|
|
// Make sure there was no existing element with these values. |
1132 |
✗✓ |
368392 |
CHECK_EQ(insertion_info.second, true); |
1133 |
|
368392 |
} |
1134 |
|
|
|
1135 |
|
354677 |
void Environment::RemoveCleanupHook(CleanupCallback fn, void* arg) { |
1136 |
|
354677 |
CleanupHookCallback search { fn, arg, 0 }; |
1137 |
|
354677 |
cleanup_hooks_.erase(search); |
1138 |
|
354677 |
} |
1139 |
|
|
|
1140 |
|
944027 |
size_t CleanupHookCallback::Hash::operator()( |
1141 |
|
|
const CleanupHookCallback& cb) const { |
1142 |
|
944027 |
return std::hash<void*>()(cb.arg_); |
1143 |
|
|
} |
1144 |
|
|
|
1145 |
|
469447 |
bool CleanupHookCallback::Equal::operator()( |
1146 |
|
|
const CleanupHookCallback& a, const CleanupHookCallback& b) const { |
1147 |
✓✓✓✗
|
469447 |
return a.fn_ == b.fn_ && a.arg_ == b.arg_; |
1148 |
|
|
} |
1149 |
|
|
|
1150 |
|
467 |
BaseObject* CleanupHookCallback::GetBaseObject() const { |
1151 |
✓✓ |
467 |
if (fn_ == BaseObject::DeleteMe) |
1152 |
|
440 |
return static_cast<BaseObject*>(arg_); |
1153 |
|
|
else |
1154 |
|
27 |
return nullptr; |
1155 |
|
|
} |
1156 |
|
|
|
1157 |
|
|
template <typename T> |
1158 |
|
44 |
void Environment::ForEachBaseObject(T&& iterator) { |
1159 |
✓✓ |
978 |
for (const auto& hook : cleanup_hooks_) { |
1160 |
|
934 |
BaseObject* obj = hook.GetBaseObject(); |
1161 |
✓✓ |
934 |
if (obj != nullptr) |
1162 |
|
880 |
iterator(obj); |
1163 |
|
|
} |
1164 |
|
|
} |
1165 |
|
|
|
1166 |
|
|
template <typename T> |
1167 |
|
6 |
void Environment::ForEachBindingData(T&& iterator) { |
1168 |
|
|
BindingDataStore* map = static_cast<BindingDataStore*>( |
1169 |
|
12 |
context()->GetAlignedPointerFromEmbedderData( |
1170 |
|
|
ContextEmbedderIndex::kBindingListIndex)); |
1171 |
|
|
DCHECK_NOT_NULL(map); |
1172 |
✓✓ |
24 |
for (auto& it : *map) { |
1173 |
|
18 |
iterator(it.first, it.second); |
1174 |
|
|
} |
1175 |
|
6 |
} |
1176 |
|
|
|
1177 |
|
664912 |
void Environment::modify_base_object_count(int64_t delta) { |
1178 |
|
664912 |
base_object_count_ += delta; |
1179 |
|
664912 |
} |
1180 |
|
|
|
1181 |
|
14 |
int64_t Environment::base_object_created_after_bootstrap() const { |
1182 |
|
14 |
return base_object_count_ - base_object_created_by_bootstrap_; |
1183 |
|
|
} |
1184 |
|
|
|
1185 |
|
2 |
int64_t Environment::base_object_count() const { |
1186 |
|
2 |
return base_object_count_; |
1187 |
|
|
} |
1188 |
|
|
|
1189 |
|
17 |
void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) { |
1190 |
✗✓ |
17 |
CHECK(!main_utf16_); |
1191 |
|
17 |
main_utf16_ = std::move(str); |
1192 |
|
17 |
} |
1193 |
|
|
|
1194 |
|
568 |
void Environment::set_process_exit_handler( |
1195 |
|
|
std::function<void(Environment*, int)>&& handler) { |
1196 |
|
568 |
process_exit_handler_ = std::move(handler); |
1197 |
|
568 |
} |
1198 |
|
|
|
1199 |
|
|
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName) |
1200 |
|
|
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) |
1201 |
|
|
#define VS(PropertyName, StringValue) V(v8::String, PropertyName) |
1202 |
|
|
#define V(TypeName, PropertyName) \ |
1203 |
|
|
inline \ |
1204 |
|
|
v8::Local<TypeName> IsolateData::PropertyName() const { \ |
1205 |
|
|
return PropertyName ## _ .Get(isolate_); \ |
1206 |
|
|
} |
1207 |
|
41672 |
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP) |
1208 |
|
831874 |
PER_ISOLATE_SYMBOL_PROPERTIES(VY) |
1209 |
|
6165276 |
PER_ISOLATE_STRING_PROPERTIES(VS) |
1210 |
|
|
#undef V |
1211 |
|
|
#undef VS |
1212 |
|
|
#undef VY |
1213 |
|
|
#undef VP |
1214 |
|
|
|
1215 |
|
|
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName) |
1216 |
|
|
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) |
1217 |
|
|
#define VS(PropertyName, StringValue) V(v8::String, PropertyName) |
1218 |
|
|
#define V(TypeName, PropertyName) \ |
1219 |
|
|
inline v8::Local<TypeName> Environment::PropertyName() const { \ |
1220 |
|
|
return isolate_data()->PropertyName(); \ |
1221 |
|
|
} |
1222 |
|
41672 |
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP) |
1223 |
|
713934 |
PER_ISOLATE_SYMBOL_PROPERTIES(VY) |
1224 |
|
8855988 |
PER_ISOLATE_STRING_PROPERTIES(VS) |
1225 |
|
|
#undef V |
1226 |
|
|
#undef VS |
1227 |
|
|
#undef VY |
1228 |
|
|
#undef VP |
1229 |
|
|
|
1230 |
|
|
#define V(PropertyName, TypeName) \ |
1231 |
|
|
inline v8::Local<TypeName> Environment::PropertyName() const { \ |
1232 |
|
|
return PersistentToLocal::Strong(PropertyName ## _); \ |
1233 |
|
|
} \ |
1234 |
|
|
inline void Environment::set_ ## PropertyName(v8::Local<TypeName> value) { \ |
1235 |
|
|
PropertyName ## _.Reset(isolate(), value); \ |
1236 |
|
|
} |
1237 |
|
1227864 |
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) |
1238 |
|
3150307 |
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) |
1239 |
|
|
#undef V |
1240 |
|
|
|
1241 |
|
6841075 |
v8::Local<v8::Context> Environment::context() const { |
1242 |
|
6841075 |
return PersistentToLocal::Strong(context_); |
1243 |
|
|
} |
1244 |
|
|
|
1245 |
|
|
} // namespace node |
1246 |
|
|
|
1247 |
|
|
// These two files depend on each other. Including base_object-inl.h after this |
1248 |
|
|
// file is the easiest way to avoid issues with that circular dependency. |
1249 |
|
|
#include "base_object-inl.h" |
1250 |
|
|
|
1251 |
|
|
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
1252 |
|
|
|
1253 |
|
|
#endif // SRC_ENV_INL_H_ |