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 "node_context_data.h" |
32 |
|
|
#include "node_internals.h" |
33 |
|
|
#include "node_perf_common.h" |
34 |
|
|
#include "util-inl.h" |
35 |
|
|
#include "uv.h" |
36 |
|
|
#include "v8.h" |
37 |
|
|
|
38 |
|
|
#include <cstddef> |
39 |
|
|
#include <cstdint> |
40 |
|
|
|
41 |
|
|
#include <utility> |
42 |
|
|
|
43 |
|
|
namespace node { |
44 |
|
|
|
45 |
|
117157 |
NoArrayBufferZeroFillScope::NoArrayBufferZeroFillScope( |
46 |
|
117157 |
IsolateData* isolate_data) |
47 |
|
117157 |
: node_allocator_(isolate_data->node_allocator()) { |
48 |
✓✗ |
117157 |
if (node_allocator_ != nullptr) node_allocator_->zero_fill_field()[0] = 0; |
49 |
|
117157 |
} |
50 |
|
|
|
51 |
|
234314 |
NoArrayBufferZeroFillScope::~NoArrayBufferZeroFillScope() { |
52 |
✓✗ |
117157 |
if (node_allocator_ != nullptr) node_allocator_->zero_fill_field()[0] = 1; |
53 |
|
117157 |
} |
54 |
|
|
|
55 |
|
|
inline v8::Isolate* IsolateData::isolate() const { |
56 |
|
|
return isolate_; |
57 |
|
|
} |
58 |
|
|
|
59 |
|
1278382 |
inline uv_loop_t* IsolateData::event_loop() const { |
60 |
|
1278382 |
return event_loop_; |
61 |
|
|
} |
62 |
|
|
|
63 |
|
123815 |
inline NodeArrayBufferAllocator* IsolateData::node_allocator() const { |
64 |
|
123815 |
return node_allocator_; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
84734 |
inline MultiIsolatePlatform* IsolateData::platform() const { |
68 |
|
84734 |
return platform_; |
69 |
|
|
} |
70 |
|
|
|
71 |
|
725 |
inline void IsolateData::set_worker_context(worker::Worker* context) { |
72 |
✗✓ |
725 |
CHECK_NULL(worker_context_); // Should be set only once. |
73 |
|
725 |
worker_context_ = context; |
74 |
|
725 |
} |
75 |
|
|
|
76 |
|
16149 |
inline worker::Worker* IsolateData::worker_context() const { |
77 |
|
16149 |
return worker_context_; |
78 |
|
|
} |
79 |
|
|
|
80 |
|
213207 |
inline v8::Local<v8::String> IsolateData::async_wrap_provider(int index) const { |
81 |
|
213207 |
return async_wrap_providers_[index].Get(isolate_); |
82 |
|
|
} |
83 |
|
|
|
84 |
|
2682007 |
inline AliasedUint32Array& AsyncHooks::fields() { |
85 |
|
2682007 |
return fields_; |
86 |
|
|
} |
87 |
|
|
|
88 |
|
1668730 |
inline AliasedFloat64Array& AsyncHooks::async_id_fields() { |
89 |
|
1668730 |
return async_id_fields_; |
90 |
|
|
} |
91 |
|
|
|
92 |
|
772 |
inline AliasedFloat64Array& AsyncHooks::async_ids_stack() { |
93 |
|
772 |
return async_ids_stack_; |
94 |
|
|
} |
95 |
|
|
|
96 |
|
841126 |
v8::Local<v8::Array> AsyncHooks::js_execution_async_resources() { |
97 |
✓✓ |
841126 |
if (UNLIKELY(js_execution_async_resources_.IsEmpty())) { |
98 |
|
772 |
js_execution_async_resources_.Reset( |
99 |
|
1544 |
env()->isolate(), v8::Array::New(env()->isolate())); |
100 |
|
|
} |
101 |
|
841126 |
return PersistentToLocal::Strong(js_execution_async_resources_); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
2406 |
v8::Local<v8::Object> AsyncHooks::native_execution_async_resource(size_t i) { |
105 |
✗✓ |
2406 |
if (i >= native_execution_async_resources_.size()) return {}; |
106 |
|
2406 |
return native_execution_async_resources_[i]; |
107 |
|
|
} |
108 |
|
|
|
109 |
|
212859 |
inline v8::Local<v8::String> AsyncHooks::provider_string(int idx) { |
110 |
|
212859 |
return env()->isolate_data()->async_wrap_provider(idx); |
111 |
|
|
} |
112 |
|
|
|
113 |
|
1 |
inline void AsyncHooks::no_force_checks() { |
114 |
|
1 |
fields_[kCheck] -= 1; |
115 |
|
1 |
} |
116 |
|
|
|
117 |
|
421249 |
inline Environment* AsyncHooks::env() { |
118 |
|
421249 |
return Environment::ForAsyncHooks(this); |
119 |
|
|
} |
120 |
|
|
|
121 |
|
421249 |
Environment* Environment::ForAsyncHooks(AsyncHooks* hooks) { |
122 |
|
421249 |
return ContainerOf(&Environment::async_hooks_, hooks); |
123 |
|
|
} |
124 |
|
|
|
125 |
|
813176 |
inline size_t Environment::async_callback_scope_depth() const { |
126 |
|
813176 |
return async_callback_scope_depth_; |
127 |
|
|
} |
128 |
|
|
|
129 |
|
827301 |
inline void Environment::PushAsyncCallbackScope() { |
130 |
|
827301 |
async_callback_scope_depth_++; |
131 |
|
827301 |
} |
132 |
|
|
|
133 |
|
826756 |
inline void Environment::PopAsyncCallbackScope() { |
134 |
|
826756 |
async_callback_scope_depth_--; |
135 |
|
826756 |
} |
136 |
|
|
|
137 |
|
772 |
inline AliasedUint32Array& ImmediateInfo::fields() { |
138 |
|
772 |
return fields_; |
139 |
|
|
} |
140 |
|
|
|
141 |
|
200693 |
inline uint32_t ImmediateInfo::count() const { |
142 |
|
200693 |
return fields_[kCount]; |
143 |
|
|
} |
144 |
|
|
|
145 |
|
293261 |
inline uint32_t ImmediateInfo::ref_count() const { |
146 |
|
293261 |
return fields_[kRefCount]; |
147 |
|
|
} |
148 |
|
|
|
149 |
|
42347 |
inline bool ImmediateInfo::has_outstanding() const { |
150 |
|
42347 |
return fields_[kHasOutstanding] == 1; |
151 |
|
|
} |
152 |
|
|
|
153 |
|
33771 |
inline void ImmediateInfo::ref_count_inc(uint32_t increment) { |
154 |
|
33771 |
fields_[kRefCount] += increment; |
155 |
|
33771 |
} |
156 |
|
|
|
157 |
|
218094 |
inline void ImmediateInfo::ref_count_dec(uint32_t decrement) { |
158 |
|
218094 |
fields_[kRefCount] -= decrement; |
159 |
|
218094 |
} |
160 |
|
|
|
161 |
|
772 |
inline AliasedUint8Array& TickInfo::fields() { |
162 |
|
772 |
return fields_; |
163 |
|
|
} |
164 |
|
|
|
165 |
|
1479563 |
inline bool TickInfo::has_tick_scheduled() const { |
166 |
|
1479563 |
return fields_[kHasTickScheduled] == 1; |
167 |
|
|
} |
168 |
|
|
|
169 |
|
533487 |
inline bool TickInfo::has_rejection_to_warn() const { |
170 |
|
533487 |
return fields_[kHasRejectionToWarn] == 1; |
171 |
|
|
} |
172 |
|
|
|
173 |
|
76490 |
inline Environment* Environment::GetCurrent(v8::Isolate* isolate) { |
174 |
✓✓ |
76490 |
if (UNLIKELY(!isolate->InContext())) return nullptr; |
175 |
|
149488 |
v8::HandleScope handle_scope(isolate); |
176 |
|
74744 |
return GetCurrent(isolate->GetCurrentContext()); |
177 |
|
|
} |
178 |
|
|
|
179 |
|
7712665 |
inline Environment* Environment::GetCurrent(v8::Local<v8::Context> context) { |
180 |
✓✓ |
7712665 |
if (UNLIKELY(context.IsEmpty())) { |
181 |
|
1 |
return nullptr; |
182 |
|
|
} |
183 |
|
7712664 |
if (UNLIKELY(context->GetNumberOfEmbedderDataFields() <= |
184 |
✓✓ |
7712664 |
ContextEmbedderIndex::kContextTag)) { |
185 |
|
11 |
return nullptr; |
186 |
|
|
} |
187 |
|
7712653 |
if (UNLIKELY(context->GetAlignedPointerFromEmbedderData( |
188 |
|
|
ContextEmbedderIndex::kContextTag) != |
189 |
✗✓ |
7712653 |
Environment::kNodeContextTagPtr)) { |
190 |
|
|
return nullptr; |
191 |
|
|
} |
192 |
|
|
return static_cast<Environment*>( |
193 |
|
7712653 |
context->GetAlignedPointerFromEmbedderData( |
194 |
|
7712653 |
ContextEmbedderIndex::kEnvironment)); |
195 |
|
|
} |
196 |
|
|
|
197 |
|
5847667 |
inline Environment* Environment::GetCurrent( |
198 |
|
|
const v8::FunctionCallbackInfo<v8::Value>& info) { |
199 |
|
5847667 |
return GetCurrent(info.GetIsolate()->GetCurrentContext()); |
200 |
|
|
} |
201 |
|
|
|
202 |
|
|
template <typename T> |
203 |
|
2166584 |
inline Environment* Environment::GetCurrent( |
204 |
|
|
const v8::PropertyCallbackInfo<T>& info) { |
205 |
|
2166584 |
return GetCurrent(info.GetIsolate()->GetCurrentContext()); |
206 |
|
|
} |
207 |
|
|
|
208 |
|
|
template <typename T, typename U> |
209 |
|
|
inline T* Environment::GetBindingData(const v8::PropertyCallbackInfo<U>& info) { |
210 |
|
|
return GetBindingData<T>(info.GetIsolate()->GetCurrentContext()); |
211 |
|
|
} |
212 |
|
|
|
213 |
|
|
template <typename T> |
214 |
|
1003078 |
inline T* Environment::GetBindingData( |
215 |
|
|
const v8::FunctionCallbackInfo<v8::Value>& info) { |
216 |
|
1003078 |
return GetBindingData<T>(info.GetIsolate()->GetCurrentContext()); |
217 |
|
|
} |
218 |
|
|
|
219 |
|
|
template <typename T> |
220 |
|
1003080 |
inline T* Environment::GetBindingData(v8::Local<v8::Context> context) { |
221 |
|
|
BindingDataStore* map = static_cast<BindingDataStore*>( |
222 |
|
1003080 |
context->GetAlignedPointerFromEmbedderData( |
223 |
|
|
ContextEmbedderIndex::kBindingListIndex)); |
224 |
|
|
DCHECK_NOT_NULL(map); |
225 |
|
1003080 |
auto it = map->find(T::type_name); |
226 |
✗✓ |
1003080 |
if (UNLIKELY(it == map->end())) return nullptr; |
227 |
|
1003080 |
T* result = static_cast<T*>(it->second.get()); |
228 |
|
|
DCHECK_NOT_NULL(result); |
229 |
|
|
DCHECK_EQ(result->env(), GetCurrent(context)); |
230 |
|
1003080 |
return result; |
231 |
|
|
} |
232 |
|
|
|
233 |
|
|
template <typename T> |
234 |
|
25624 |
inline T* Environment::AddBindingData( |
235 |
|
|
v8::Local<v8::Context> context, |
236 |
|
|
v8::Local<v8::Object> target) { |
237 |
|
|
DCHECK_EQ(GetCurrent(context), this); |
238 |
|
|
// This won't compile if T is not a BaseObject subclass. |
239 |
|
51248 |
BaseObjectPtr<T> item = MakeDetachedBaseObject<T>(this, target); |
240 |
|
|
BindingDataStore* map = static_cast<BindingDataStore*>( |
241 |
|
25624 |
context->GetAlignedPointerFromEmbedderData( |
242 |
|
|
ContextEmbedderIndex::kBindingListIndex)); |
243 |
|
|
DCHECK_NOT_NULL(map); |
244 |
|
25624 |
auto result = map->emplace(T::type_name, item); |
245 |
✗✓ |
25624 |
CHECK(result.second); |
246 |
|
|
DCHECK_EQ(GetBindingData<T>(context), item.get()); |
247 |
|
25624 |
return item.get(); |
248 |
|
|
} |
249 |
|
|
|
250 |
|
26112490 |
inline v8::Isolate* Environment::isolate() const { |
251 |
|
26112490 |
return isolate_; |
252 |
|
|
} |
253 |
|
|
|
254 |
|
7557 |
inline Environment* Environment::from_timer_handle(uv_timer_t* handle) { |
255 |
|
7557 |
return ContainerOf(&Environment::timer_handle_, handle); |
256 |
|
|
} |
257 |
|
|
|
258 |
|
31460 |
inline uv_timer_t* Environment::timer_handle() { |
259 |
|
31460 |
return &timer_handle_; |
260 |
|
|
} |
261 |
|
|
|
262 |
|
200693 |
inline Environment* Environment::from_immediate_check_handle( |
263 |
|
|
uv_check_t* handle) { |
264 |
|
200693 |
return ContainerOf(&Environment::immediate_check_handle_, handle); |
265 |
|
|
} |
266 |
|
|
|
267 |
|
24304 |
inline uv_check_t* Environment::immediate_check_handle() { |
268 |
|
24304 |
return &immediate_check_handle_; |
269 |
|
|
} |
270 |
|
|
|
271 |
|
246745 |
inline uv_idle_t* Environment::immediate_idle_handle() { |
272 |
|
246745 |
return &immediate_idle_handle_; |
273 |
|
|
} |
274 |
|
|
|
275 |
|
36456 |
inline void Environment::RegisterHandleCleanup(uv_handle_t* handle, |
276 |
|
|
HandleCleanupCb cb, |
277 |
|
|
void* arg) { |
278 |
|
36456 |
handle_cleanup_queue_.push_back(HandleCleanup{handle, cb, arg}); |
279 |
|
36456 |
} |
280 |
|
|
|
281 |
|
|
template <typename T, typename OnCloseCallback> |
282 |
|
38210 |
inline void Environment::CloseHandle(T* handle, OnCloseCallback callback) { |
283 |
|
38050 |
handle_cleanup_waiting_++; |
284 |
|
|
static_assert(sizeof(T) >= sizeof(uv_handle_t), "T is a libuv handle"); |
285 |
|
|
static_assert(offsetof(T, data) == offsetof(uv_handle_t, data), |
286 |
|
|
"T is a libuv handle"); |
287 |
|
|
static_assert(offsetof(T, close_cb) == offsetof(uv_handle_t, close_cb), |
288 |
|
|
"T is a libuv handle"); |
289 |
|
|
struct CloseData { |
290 |
|
|
Environment* env; |
291 |
|
|
OnCloseCallback callback; |
292 |
|
|
void* original_data; |
293 |
|
|
}; |
294 |
|
38130 |
handle->data = new CloseData { this, callback, handle->data }; |
295 |
|
38450 |
uv_close(reinterpret_cast<uv_handle_t*>(handle), [](uv_handle_t* handle) { |
296 |
|
76100 |
std::unique_ptr<CloseData> data { static_cast<CloseData*>(handle->data) }; |
297 |
|
38130 |
data->env->handle_cleanup_waiting_--; |
298 |
|
38130 |
handle->data = data->original_data; |
299 |
|
38130 |
data->callback(reinterpret_cast<T*>(handle)); |
300 |
|
|
}); |
301 |
|
38130 |
} |
302 |
|
|
|
303 |
|
93793 |
void Environment::IncreaseWaitingRequestCounter() { |
304 |
|
93793 |
request_waiting_++; |
305 |
|
93793 |
} |
306 |
|
|
|
307 |
|
93784 |
void Environment::DecreaseWaitingRequestCounter() { |
308 |
|
93784 |
request_waiting_--; |
309 |
✗✓ |
93784 |
CHECK_GE(request_waiting_, 0); |
310 |
|
93784 |
} |
311 |
|
|
|
312 |
|
1272272 |
inline uv_loop_t* Environment::event_loop() const { |
313 |
|
1272272 |
return isolate_data()->event_loop(); |
314 |
|
|
} |
315 |
|
|
|
316 |
|
|
#if HAVE_INSPECTOR |
317 |
|
70467 |
inline bool Environment::is_in_inspector_console_call() const { |
318 |
|
70467 |
return is_in_inspector_console_call_; |
319 |
|
|
} |
320 |
|
|
|
321 |
|
140932 |
inline void Environment::set_is_in_inspector_console_call(bool value) { |
322 |
|
140932 |
is_in_inspector_console_call_ = value; |
323 |
|
140932 |
} |
324 |
|
|
#endif |
325 |
|
|
|
326 |
|
6025617 |
inline AsyncHooks* Environment::async_hooks() { |
327 |
|
6025617 |
return &async_hooks_; |
328 |
|
|
} |
329 |
|
|
|
330 |
|
788938 |
inline ImmediateInfo* Environment::immediate_info() { |
331 |
|
788938 |
return &immediate_info_; |
332 |
|
|
} |
333 |
|
|
|
334 |
|
740589 |
inline TickInfo* Environment::tick_info() { |
335 |
|
740589 |
return &tick_info_; |
336 |
|
|
} |
337 |
|
|
|
338 |
|
101266 |
inline uint64_t Environment::timer_base() const { |
339 |
|
101266 |
return timer_base_; |
340 |
|
|
} |
341 |
|
|
|
342 |
|
1405178 |
inline std::shared_ptr<KVStore> Environment::env_vars() { |
343 |
|
1405178 |
return env_vars_; |
344 |
|
|
} |
345 |
|
|
|
346 |
|
6823 |
inline void Environment::set_env_vars(std::shared_ptr<KVStore> env_vars) { |
347 |
|
6823 |
env_vars_ = env_vars; |
348 |
|
6823 |
} |
349 |
|
|
|
350 |
|
22 |
inline bool Environment::printed_error() const { |
351 |
|
22 |
return printed_error_; |
352 |
|
|
} |
353 |
|
|
|
354 |
|
22 |
inline void Environment::set_printed_error(bool value) { |
355 |
|
22 |
printed_error_ = value; |
356 |
|
22 |
} |
357 |
|
|
|
358 |
|
10946 |
inline void Environment::set_trace_sync_io(bool value) { |
359 |
|
10946 |
trace_sync_io_ = value; |
360 |
|
10946 |
} |
361 |
|
|
|
362 |
|
124 |
inline bool Environment::abort_on_uncaught_exception() const { |
363 |
|
124 |
return options_->abort_on_uncaught_exception; |
364 |
|
|
} |
365 |
|
|
|
366 |
|
|
inline void Environment::set_force_context_aware(bool value) { |
367 |
|
|
options_->force_context_aware = value; |
368 |
|
|
} |
369 |
|
|
|
370 |
|
41 |
inline bool Environment::force_context_aware() const { |
371 |
|
41 |
return options_->force_context_aware; |
372 |
|
|
} |
373 |
|
|
|
374 |
|
11301 |
inline void Environment::set_exiting(bool value) { |
375 |
✓✓ |
11301 |
exiting_[0] = value ? 1 : 0; |
376 |
|
11301 |
} |
377 |
|
|
|
378 |
|
772 |
inline AliasedUint32Array& Environment::exiting() { |
379 |
|
772 |
return exiting_; |
380 |
|
|
} |
381 |
|
|
|
382 |
|
718 |
inline void Environment::set_abort_on_uncaught_exception(bool value) { |
383 |
|
718 |
options_->abort_on_uncaught_exception = value; |
384 |
|
718 |
} |
385 |
|
|
|
386 |
|
802 |
inline AliasedUint32Array& Environment::should_abort_on_uncaught_toggle() { |
387 |
|
802 |
return should_abort_on_uncaught_toggle_; |
388 |
|
|
} |
389 |
|
|
|
390 |
|
308058 |
inline AliasedInt32Array& Environment::stream_base_state() { |
391 |
|
308058 |
return stream_base_state_; |
392 |
|
|
} |
393 |
|
|
|
394 |
|
50939 |
inline uint32_t Environment::get_next_module_id() { |
395 |
|
50939 |
return module_id_counter_++; |
396 |
|
|
} |
397 |
|
5793 |
inline uint32_t Environment::get_next_script_id() { |
398 |
|
5793 |
return script_id_counter_++; |
399 |
|
|
} |
400 |
|
36093 |
inline uint32_t Environment::get_next_function_id() { |
401 |
|
36093 |
return function_id_counter_++; |
402 |
|
|
} |
403 |
|
|
|
404 |
|
107144 |
ShouldNotAbortOnUncaughtScope::ShouldNotAbortOnUncaughtScope( |
405 |
|
107144 |
Environment* env) |
406 |
|
107144 |
: env_(env) { |
407 |
|
107144 |
env_->PushShouldNotAbortOnUncaughtScope(); |
408 |
|
107144 |
} |
409 |
|
|
|
410 |
|
214282 |
ShouldNotAbortOnUncaughtScope::~ShouldNotAbortOnUncaughtScope() { |
411 |
|
107141 |
Close(); |
412 |
|
107141 |
} |
413 |
|
|
|
414 |
|
107333 |
void ShouldNotAbortOnUncaughtScope::Close() { |
415 |
✓✓ |
107333 |
if (env_ != nullptr) { |
416 |
|
107141 |
env_->PopShouldNotAbortOnUncaughtScope(); |
417 |
|
107141 |
env_ = nullptr; |
418 |
|
|
} |
419 |
|
107333 |
} |
420 |
|
|
|
421 |
|
107144 |
inline void Environment::PushShouldNotAbortOnUncaughtScope() { |
422 |
|
107144 |
should_not_abort_scope_counter_++; |
423 |
|
107144 |
} |
424 |
|
|
|
425 |
|
107141 |
inline void Environment::PopShouldNotAbortOnUncaughtScope() { |
426 |
|
107141 |
should_not_abort_scope_counter_--; |
427 |
|
107141 |
} |
428 |
|
|
|
429 |
|
1 |
inline bool Environment::inside_should_not_abort_on_uncaught_scope() const { |
430 |
|
1 |
return should_not_abort_scope_counter_ > 0; |
431 |
|
|
} |
432 |
|
|
|
433 |
|
430801 |
inline std::vector<double>* Environment::destroy_async_id_list() { |
434 |
|
430801 |
return &destroy_async_id_list_; |
435 |
|
|
} |
436 |
|
|
|
437 |
|
213414 |
inline double Environment::new_async_id() { |
438 |
|
213414 |
async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] += 1; |
439 |
|
213414 |
return async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter]; |
440 |
|
|
} |
441 |
|
|
|
442 |
|
245063 |
inline double Environment::execution_async_id() { |
443 |
|
245063 |
return async_hooks()->async_id_fields()[AsyncHooks::kExecutionAsyncId]; |
444 |
|
|
} |
445 |
|
|
|
446 |
|
65774 |
inline double Environment::trigger_async_id() { |
447 |
|
65774 |
return async_hooks()->async_id_fields()[AsyncHooks::kTriggerAsyncId]; |
448 |
|
|
} |
449 |
|
|
|
450 |
|
213411 |
inline double Environment::get_default_trigger_async_id() { |
451 |
|
|
double default_trigger_async_id = |
452 |
|
213411 |
async_hooks()->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId]; |
453 |
|
|
// If defaultTriggerAsyncId isn't set, use the executionAsyncId |
454 |
✓✓ |
213411 |
if (default_trigger_async_id < 0) |
455 |
|
179223 |
default_trigger_async_id = execution_async_id(); |
456 |
|
213411 |
return default_trigger_async_id; |
457 |
|
|
} |
458 |
|
|
|
459 |
|
72863 |
inline std::shared_ptr<EnvironmentOptions> Environment::options() { |
460 |
|
72863 |
return options_; |
461 |
|
|
} |
462 |
|
|
|
463 |
|
17230 |
inline const std::vector<std::string>& Environment::argv() { |
464 |
|
17230 |
return argv_; |
465 |
|
|
} |
466 |
|
|
|
467 |
|
6749 |
inline const std::vector<std::string>& Environment::exec_argv() { |
468 |
|
6749 |
return exec_argv_; |
469 |
|
|
} |
470 |
|
|
|
471 |
|
12152 |
inline const std::string& Environment::exec_path() const { |
472 |
|
12152 |
return exec_path_; |
473 |
|
|
} |
474 |
|
|
|
475 |
|
|
#if HAVE_INSPECTOR |
476 |
|
6071 |
inline void Environment::set_coverage_directory(const char* dir) { |
477 |
|
6071 |
coverage_directory_ = std::string(dir); |
478 |
|
6071 |
} |
479 |
|
|
|
480 |
|
6095 |
inline void Environment::set_coverage_connection( |
481 |
|
|
std::unique_ptr<profiler::V8CoverageConnection> connection) { |
482 |
✗✓ |
6095 |
CHECK_NULL(coverage_connection_); |
483 |
|
6095 |
std::swap(coverage_connection_, connection); |
484 |
|
6095 |
} |
485 |
|
|
|
486 |
|
18284 |
inline profiler::V8CoverageConnection* Environment::coverage_connection() { |
487 |
|
18284 |
return coverage_connection_.get(); |
488 |
|
|
} |
489 |
|
|
|
490 |
|
6056 |
inline const std::string& Environment::coverage_directory() const { |
491 |
|
6056 |
return coverage_directory_; |
492 |
|
|
} |
493 |
|
|
|
494 |
|
12 |
inline void Environment::set_cpu_profiler_connection( |
495 |
|
|
std::unique_ptr<profiler::V8CpuProfilerConnection> connection) { |
496 |
✗✓ |
12 |
CHECK_NULL(cpu_profiler_connection_); |
497 |
|
12 |
std::swap(cpu_profiler_connection_, connection); |
498 |
|
12 |
} |
499 |
|
|
|
500 |
|
|
inline profiler::V8CpuProfilerConnection* |
501 |
|
6111 |
Environment::cpu_profiler_connection() { |
502 |
|
6111 |
return cpu_profiler_connection_.get(); |
503 |
|
|
} |
504 |
|
|
|
505 |
|
12 |
inline void Environment::set_cpu_prof_interval(uint64_t interval) { |
506 |
|
12 |
cpu_prof_interval_ = interval; |
507 |
|
12 |
} |
508 |
|
|
|
509 |
|
12 |
inline uint64_t Environment::cpu_prof_interval() const { |
510 |
|
12 |
return cpu_prof_interval_; |
511 |
|
|
} |
512 |
|
|
|
513 |
|
12 |
inline void Environment::set_cpu_prof_name(const std::string& name) { |
514 |
|
12 |
cpu_prof_name_ = name; |
515 |
|
12 |
} |
516 |
|
|
|
517 |
|
12 |
inline const std::string& Environment::cpu_prof_name() const { |
518 |
|
12 |
return cpu_prof_name_; |
519 |
|
|
} |
520 |
|
|
|
521 |
|
12 |
inline void Environment::set_cpu_prof_dir(const std::string& dir) { |
522 |
|
12 |
cpu_prof_dir_ = dir; |
523 |
|
12 |
} |
524 |
|
|
|
525 |
|
12 |
inline const std::string& Environment::cpu_prof_dir() const { |
526 |
|
12 |
return cpu_prof_dir_; |
527 |
|
|
} |
528 |
|
|
|
529 |
|
12 |
inline void Environment::set_heap_profiler_connection( |
530 |
|
|
std::unique_ptr<profiler::V8HeapProfilerConnection> connection) { |
531 |
✗✓ |
12 |
CHECK_NULL(heap_profiler_connection_); |
532 |
|
12 |
std::swap(heap_profiler_connection_, connection); |
533 |
|
12 |
} |
534 |
|
|
|
535 |
|
|
inline profiler::V8HeapProfilerConnection* |
536 |
|
6099 |
Environment::heap_profiler_connection() { |
537 |
|
6099 |
return heap_profiler_connection_.get(); |
538 |
|
|
} |
539 |
|
|
|
540 |
|
12 |
inline void Environment::set_heap_prof_name(const std::string& name) { |
541 |
|
12 |
heap_prof_name_ = name; |
542 |
|
12 |
} |
543 |
|
|
|
544 |
|
12 |
inline const std::string& Environment::heap_prof_name() const { |
545 |
|
12 |
return heap_prof_name_; |
546 |
|
|
} |
547 |
|
|
|
548 |
|
12 |
inline void Environment::set_heap_prof_dir(const std::string& dir) { |
549 |
|
12 |
heap_prof_dir_ = dir; |
550 |
|
12 |
} |
551 |
|
|
|
552 |
|
12 |
inline const std::string& Environment::heap_prof_dir() const { |
553 |
|
12 |
return heap_prof_dir_; |
554 |
|
|
} |
555 |
|
|
|
556 |
|
12 |
inline void Environment::set_heap_prof_interval(uint64_t interval) { |
557 |
|
12 |
heap_prof_interval_ = interval; |
558 |
|
12 |
} |
559 |
|
|
|
560 |
|
12 |
inline uint64_t Environment::heap_prof_interval() const { |
561 |
|
12 |
return heap_prof_interval_; |
562 |
|
|
} |
563 |
|
|
|
564 |
|
|
#endif // HAVE_INSPECTOR |
565 |
|
|
|
566 |
|
|
inline |
567 |
|
12432 |
std::shared_ptr<ExclusiveAccess<HostPort>> Environment::inspector_host_port() { |
568 |
|
12432 |
return inspector_host_port_; |
569 |
|
|
} |
570 |
|
|
|
571 |
|
65102 |
inline std::shared_ptr<PerIsolateOptions> IsolateData::options() { |
572 |
|
65102 |
return options_; |
573 |
|
|
} |
574 |
|
|
|
575 |
|
285 |
inline void IsolateData::set_options( |
576 |
|
|
std::shared_ptr<PerIsolateOptions> options) { |
577 |
|
285 |
options_ = std::move(options); |
578 |
|
285 |
} |
579 |
|
|
|
580 |
|
|
template <typename Fn> |
581 |
|
92419 |
void Environment::SetImmediate(Fn&& cb, CallbackFlags::Flags flags) { |
582 |
|
184838 |
auto callback = native_immediates_.CreateCallback(std::move(cb), flags); |
583 |
|
92419 |
native_immediates_.Push(std::move(callback)); |
584 |
|
|
|
585 |
✓✓ |
92419 |
if (flags & CallbackFlags::kRefed) { |
586 |
✓✓ |
67528 |
if (immediate_info()->ref_count() == 0) |
587 |
|
50346 |
ToggleImmediateRef(true); |
588 |
|
67528 |
immediate_info()->ref_count_inc(1); |
589 |
|
|
} |
590 |
|
92419 |
} |
591 |
|
|
|
592 |
|
|
template <typename Fn> |
593 |
|
2308 |
void Environment::SetImmediateThreadsafe(Fn&& cb, CallbackFlags::Flags flags) { |
594 |
|
4616 |
auto callback = native_immediates_threadsafe_.CreateCallback( |
595 |
|
2308 |
std::move(cb), flags); |
596 |
|
|
{ |
597 |
|
4616 |
Mutex::ScopedLock lock(native_immediates_threadsafe_mutex_); |
598 |
|
2308 |
native_immediates_threadsafe_.Push(std::move(callback)); |
599 |
✓✓ |
2308 |
if (task_queues_async_initialized_) |
600 |
|
2299 |
uv_async_send(&task_queues_async_); |
601 |
|
|
} |
602 |
|
2308 |
} |
603 |
|
|
|
604 |
|
|
template <typename Fn> |
605 |
|
10523 |
void Environment::RequestInterrupt(Fn&& cb) { |
606 |
|
21046 |
auto callback = native_immediates_interrupts_.CreateCallback( |
607 |
|
10523 |
std::move(cb), CallbackFlags::kRefed); |
608 |
|
|
{ |
609 |
|
21046 |
Mutex::ScopedLock lock(native_immediates_threadsafe_mutex_); |
610 |
|
10523 |
native_immediates_interrupts_.Push(std::move(callback)); |
611 |
✓✓ |
10523 |
if (task_queues_async_initialized_) |
612 |
|
4307 |
uv_async_send(&task_queues_async_); |
613 |
|
|
} |
614 |
|
10523 |
RequestInterruptFromV8(); |
615 |
|
10523 |
} |
616 |
|
|
|
617 |
|
3204154 |
inline bool Environment::can_call_into_js() const { |
618 |
✓✓✓✓
|
3204154 |
return can_call_into_js_ && !is_stopping(); |
619 |
|
|
} |
620 |
|
|
|
621 |
|
1622 |
inline void Environment::set_can_call_into_js(bool can_call_into_js) { |
622 |
|
1622 |
can_call_into_js_ = can_call_into_js; |
623 |
|
1622 |
} |
624 |
|
|
|
625 |
|
1546286 |
inline bool Environment::has_run_bootstrapping_code() const { |
626 |
|
1546286 |
return has_run_bootstrapping_code_; |
627 |
|
|
} |
628 |
|
|
|
629 |
|
6110 |
inline void Environment::DoneBootstrapping() { |
630 |
|
6110 |
has_run_bootstrapping_code_ = true; |
631 |
|
|
// This adjusts the return value of base_object_created_after_bootstrap() so |
632 |
|
|
// that tests that check the count do not have to account for internally |
633 |
|
|
// created BaseObjects. |
634 |
|
6110 |
base_object_created_by_bootstrap_ = base_object_count_; |
635 |
|
6110 |
} |
636 |
|
|
|
637 |
|
19 |
inline bool Environment::has_serialized_options() const { |
638 |
|
19 |
return has_serialized_options_; |
639 |
|
|
} |
640 |
|
|
|
641 |
|
6680 |
inline void Environment::set_has_serialized_options(bool value) { |
642 |
|
6680 |
has_serialized_options_ = value; |
643 |
|
6680 |
} |
644 |
|
|
|
645 |
|
9370 |
inline bool Environment::is_main_thread() const { |
646 |
|
9370 |
return worker_context() == nullptr; |
647 |
|
|
} |
648 |
|
|
|
649 |
|
1133 |
inline bool Environment::no_native_addons() const { |
650 |
✓✓ |
2262 |
return (flags_ & EnvironmentFlags::kNoNativeAddons) || |
651 |
✓✓ |
2262 |
!options_->allow_native_addons; |
652 |
|
|
} |
653 |
|
|
|
654 |
|
6073 |
inline bool Environment::should_not_register_esm_loader() const { |
655 |
|
6073 |
return flags_ & EnvironmentFlags::kNoRegisterESMLoader; |
656 |
|
|
} |
657 |
|
|
|
658 |
|
15866 |
inline bool Environment::owns_process_state() const { |
659 |
|
15866 |
return flags_ & EnvironmentFlags::kOwnsProcessState; |
660 |
|
|
} |
661 |
|
|
|
662 |
|
6104 |
inline bool Environment::owns_inspector() const { |
663 |
|
6104 |
return flags_ & EnvironmentFlags::kOwnsInspector; |
664 |
|
|
} |
665 |
|
|
|
666 |
|
16612 |
inline bool Environment::should_create_inspector() const { |
667 |
|
16612 |
return (flags_ & EnvironmentFlags::kNoCreateInspector) == 0; |
668 |
|
|
} |
669 |
|
|
|
670 |
|
134398 |
inline bool Environment::tracks_unmanaged_fds() const { |
671 |
|
134398 |
return flags_ & EnvironmentFlags::kTrackUnmanagedFds; |
672 |
|
|
} |
673 |
|
|
|
674 |
|
3821 |
inline bool Environment::hide_console_windows() const { |
675 |
|
3821 |
return flags_ & EnvironmentFlags::kHideConsoleWindows; |
676 |
|
|
} |
677 |
|
|
|
678 |
|
7029 |
inline bool Environment::no_global_search_paths() const { |
679 |
✓✗ |
14058 |
return (flags_ & EnvironmentFlags::kNoGlobalSearchPaths) || |
680 |
✗✓ |
14058 |
!options_->global_search_paths; |
681 |
|
|
} |
682 |
|
|
|
683 |
|
1728 |
inline bool Environment::no_browser_globals() const { |
684 |
|
|
// configure --no-browser-globals |
685 |
|
|
#ifdef NODE_NO_BROWSER_GLOBALS |
686 |
|
|
return true; |
687 |
|
|
#else |
688 |
|
1728 |
return flags_ & EnvironmentFlags::kNoBrowserGlobals; |
689 |
|
|
#endif |
690 |
|
|
} |
691 |
|
|
|
692 |
|
4 |
bool Environment::filehandle_close_warning() const { |
693 |
|
4 |
return emit_filehandle_warning_; |
694 |
|
|
} |
695 |
|
|
|
696 |
|
3 |
void Environment::set_filehandle_close_warning(bool on) { |
697 |
|
3 |
emit_filehandle_warning_ = on; |
698 |
|
3 |
} |
699 |
|
|
|
700 |
|
5910 |
void Environment::set_source_maps_enabled(bool on) { |
701 |
|
5910 |
source_maps_enabled_ = on; |
702 |
|
5910 |
} |
703 |
|
|
|
704 |
|
1424 |
bool Environment::source_maps_enabled() const { |
705 |
|
1424 |
return source_maps_enabled_; |
706 |
|
|
} |
707 |
|
|
|
708 |
|
7629 |
inline uint64_t Environment::thread_id() const { |
709 |
|
7629 |
return thread_id_; |
710 |
|
|
} |
711 |
|
|
|
712 |
|
16149 |
inline worker::Worker* Environment::worker_context() const { |
713 |
|
16149 |
return isolate_data()->worker_context(); |
714 |
|
|
} |
715 |
|
|
|
716 |
|
953 |
inline void Environment::add_sub_worker_context(worker::Worker* context) { |
717 |
|
953 |
sub_worker_contexts_.insert(context); |
718 |
|
953 |
} |
719 |
|
|
|
720 |
|
980 |
inline void Environment::remove_sub_worker_context(worker::Worker* context) { |
721 |
|
980 |
sub_worker_contexts_.erase(context); |
722 |
|
980 |
} |
723 |
|
|
|
724 |
|
|
template <typename Fn> |
725 |
|
25 |
inline void Environment::ForEachWorker(Fn&& iterator) { |
726 |
✓✓ |
27 |
for (worker::Worker* w : sub_worker_contexts_) iterator(w); |
727 |
|
25 |
} |
728 |
|
|
|
729 |
|
4794932 |
inline bool Environment::is_stopping() const { |
730 |
|
4794932 |
return is_stopping_.load(); |
731 |
|
|
} |
732 |
|
|
|
733 |
|
5938 |
inline void Environment::set_stopping(bool value) { |
734 |
|
5938 |
is_stopping_.store(value); |
735 |
|
5938 |
} |
736 |
|
|
|
737 |
|
14 |
inline std::list<node_module>* Environment::extra_linked_bindings() { |
738 |
|
14 |
return &extra_linked_bindings_; |
739 |
|
|
} |
740 |
|
|
|
741 |
|
10 |
inline node_module* Environment::extra_linked_bindings_head() { |
742 |
✓✓ |
10 |
return extra_linked_bindings_.size() > 0 ? |
743 |
|
10 |
&extra_linked_bindings_.front() : nullptr; |
744 |
|
|
} |
745 |
|
|
|
746 |
|
9 |
inline node_module* Environment::extra_linked_bindings_tail() { |
747 |
✓✓ |
9 |
return extra_linked_bindings_.size() > 0 ? |
748 |
|
9 |
&extra_linked_bindings_.back() : nullptr; |
749 |
|
|
} |
750 |
|
|
|
751 |
|
19 |
inline const Mutex& Environment::extra_linked_bindings_mutex() const { |
752 |
|
19 |
return extra_linked_bindings_mutex_; |
753 |
|
|
} |
754 |
|
|
|
755 |
|
42498 |
inline performance::PerformanceState* Environment::performance_state() { |
756 |
|
42498 |
return performance_state_.get(); |
757 |
|
|
} |
758 |
|
|
|
759 |
|
8892424 |
inline IsolateData* Environment::isolate_data() const { |
760 |
|
8892424 |
return isolate_data_; |
761 |
|
|
} |
762 |
|
|
|
763 |
|
8 |
inline void Environment::ThrowError(const char* errmsg) { |
764 |
|
8 |
ThrowError(v8::Exception::Error, errmsg); |
765 |
|
8 |
} |
766 |
|
|
|
767 |
|
|
inline void Environment::ThrowTypeError(const char* errmsg) { |
768 |
|
|
ThrowError(v8::Exception::TypeError, errmsg); |
769 |
|
|
} |
770 |
|
|
|
771 |
|
|
inline void Environment::ThrowRangeError(const char* errmsg) { |
772 |
|
|
ThrowError(v8::Exception::RangeError, errmsg); |
773 |
|
|
} |
774 |
|
|
|
775 |
|
8 |
inline void Environment::ThrowError( |
776 |
|
|
v8::Local<v8::Value> (*fun)(v8::Local<v8::String>), |
777 |
|
|
const char* errmsg) { |
778 |
|
16 |
v8::HandleScope handle_scope(isolate()); |
779 |
|
8 |
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg))); |
780 |
|
8 |
} |
781 |
|
|
|
782 |
|
7 |
inline void Environment::ThrowErrnoException(int errorno, |
783 |
|
|
const char* syscall, |
784 |
|
|
const char* message, |
785 |
|
|
const char* path) { |
786 |
|
|
isolate()->ThrowException( |
787 |
|
7 |
ErrnoException(isolate(), errorno, syscall, message, path)); |
788 |
|
7 |
} |
789 |
|
|
|
790 |
|
15 |
inline void Environment::ThrowUVException(int errorno, |
791 |
|
|
const char* syscall, |
792 |
|
|
const char* message, |
793 |
|
|
const char* path, |
794 |
|
|
const char* dest) { |
795 |
|
|
isolate()->ThrowException( |
796 |
|
15 |
UVException(isolate(), errorno, syscall, message, path, dest)); |
797 |
|
15 |
} |
798 |
|
|
|
799 |
|
1484054 |
void Environment::AddCleanupHook(CleanupCallback fn, void* arg) { |
800 |
|
2968108 |
auto insertion_info = cleanup_hooks_.emplace(CleanupHookCallback { |
801 |
|
1484054 |
fn, arg, cleanup_hook_counter_++ |
802 |
|
1484054 |
}); |
803 |
|
|
// Make sure there was no existing element with these values. |
804 |
✗✓ |
1484054 |
CHECK_EQ(insertion_info.second, true); |
805 |
|
1484054 |
} |
806 |
|
|
|
807 |
|
1455217 |
void Environment::RemoveCleanupHook(CleanupCallback fn, void* arg) { |
808 |
|
1455217 |
CleanupHookCallback search { fn, arg, 0 }; |
809 |
|
1455217 |
cleanup_hooks_.erase(search); |
810 |
|
1455217 |
} |
811 |
|
|
|
812 |
|
3274008 |
size_t CleanupHookCallback::Hash::operator()( |
813 |
|
|
const CleanupHookCallback& cb) const { |
814 |
|
3274008 |
return std::hash<void*>()(cb.arg_); |
815 |
|
|
} |
816 |
|
|
|
817 |
|
1638563 |
bool CleanupHookCallback::Equal::operator()( |
818 |
|
|
const CleanupHookCallback& a, const CleanupHookCallback& b) const { |
819 |
✓✓✓✗
|
1638563 |
return a.fn_ == b.fn_ && a.arg_ == b.arg_; |
820 |
|
|
} |
821 |
|
|
|
822 |
|
595 |
BaseObject* CleanupHookCallback::GetBaseObject() const { |
823 |
✓✓ |
595 |
if (fn_ == BaseObject::DeleteMe) |
824 |
|
567 |
return static_cast<BaseObject*>(arg_); |
825 |
|
|
else |
826 |
|
28 |
return nullptr; |
827 |
|
|
} |
828 |
|
|
|
829 |
|
|
template <typename T> |
830 |
|
54 |
void Environment::ForEachBaseObject(T&& iterator) { |
831 |
✓✓ |
1220 |
for (const auto& hook : cleanup_hooks_) { |
832 |
|
1166 |
BaseObject* obj = hook.GetBaseObject(); |
833 |
✓✓ |
1166 |
if (obj != nullptr) |
834 |
|
1110 |
iterator(obj); |
835 |
|
|
} |
836 |
|
54 |
} |
837 |
|
|
|
838 |
|
2853392 |
void Environment::modify_base_object_count(int64_t delta) { |
839 |
|
2853392 |
base_object_count_ += delta; |
840 |
|
2853392 |
} |
841 |
|
|
|
842 |
|
14 |
int64_t Environment::base_object_created_after_bootstrap() const { |
843 |
|
14 |
return base_object_count_ - base_object_created_by_bootstrap_; |
844 |
|
|
} |
845 |
|
|
|
846 |
|
2 |
int64_t Environment::base_object_count() const { |
847 |
|
2 |
return base_object_count_; |
848 |
|
|
} |
849 |
|
|
|
850 |
|
17 |
void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) { |
851 |
✗✓ |
17 |
CHECK(!main_utf16_); |
852 |
|
17 |
main_utf16_ = std::move(str); |
853 |
|
17 |
} |
854 |
|
|
|
855 |
|
716 |
void Environment::set_process_exit_handler( |
856 |
|
|
std::function<void(Environment*, int)>&& handler) { |
857 |
|
716 |
process_exit_handler_ = std::move(handler); |
858 |
|
716 |
} |
859 |
|
|
|
860 |
|
|
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName) |
861 |
|
|
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) |
862 |
|
|
#define VS(PropertyName, StringValue) V(v8::String, PropertyName) |
863 |
|
|
#define V(TypeName, PropertyName) \ |
864 |
|
|
inline \ |
865 |
|
|
v8::Local<TypeName> IsolateData::PropertyName() const { \ |
866 |
|
|
return PropertyName ## _ .Get(isolate_); \ |
867 |
|
|
} |
868 |
|
60646 |
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP) |
869 |
|
1167506 |
PER_ISOLATE_SYMBOL_PROPERTIES(VY) |
870 |
|
8092016 |
PER_ISOLATE_STRING_PROPERTIES(VS) |
871 |
|
|
#undef V |
872 |
|
|
#undef VS |
873 |
|
|
#undef VY |
874 |
|
|
#undef VP |
875 |
|
|
|
876 |
|
|
#define V(PropertyName, TypeName) \ |
877 |
|
|
inline v8::Local<TypeName> IsolateData::PropertyName() const { \ |
878 |
|
|
return PropertyName##_.Get(isolate_); \ |
879 |
|
|
} \ |
880 |
|
|
inline void IsolateData::set_##PropertyName(v8::Local<TypeName> value) { \ |
881 |
|
|
PropertyName##_.Set(isolate_, value); \ |
882 |
|
|
} |
883 |
|
1178584 |
PER_ISOLATE_TEMPLATE_PROPERTIES(V) |
884 |
|
|
#undef V |
885 |
|
|
|
886 |
|
|
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName) |
887 |
|
|
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) |
888 |
|
|
#define VS(PropertyName, StringValue) V(v8::String, PropertyName) |
889 |
|
|
#define V(TypeName, PropertyName) \ |
890 |
|
|
inline v8::Local<TypeName> Environment::PropertyName() const { \ |
891 |
|
|
return isolate_data()->PropertyName(); \ |
892 |
|
|
} |
893 |
|
60646 |
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP) |
894 |
|
1048380 |
PER_ISOLATE_SYMBOL_PROPERTIES(VY) |
895 |
|
11691900 |
PER_ISOLATE_STRING_PROPERTIES(VS) |
896 |
|
|
#undef V |
897 |
|
|
#undef VS |
898 |
|
|
#undef VY |
899 |
|
|
#undef VP |
900 |
|
|
|
901 |
|
|
#define V(PropertyName, TypeName) \ |
902 |
|
|
inline v8::Local<TypeName> Environment::PropertyName() const { \ |
903 |
|
|
return isolate_data()->PropertyName(); \ |
904 |
|
|
} \ |
905 |
|
|
inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \ |
906 |
|
|
DCHECK(isolate_data()->PropertyName().IsEmpty()); \ |
907 |
|
|
isolate_data()->set_##PropertyName(value); \ |
908 |
|
|
} |
909 |
|
884260 |
PER_ISOLATE_TEMPLATE_PROPERTIES(V) |
910 |
|
|
#undef V |
911 |
|
|
|
912 |
|
|
#define V(PropertyName, TypeName) \ |
913 |
|
|
inline v8::Local<TypeName> Environment::PropertyName() const { \ |
914 |
|
|
return PersistentToLocal::Strong(PropertyName##_); \ |
915 |
|
|
} \ |
916 |
|
|
inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \ |
917 |
|
|
PropertyName##_.Reset(isolate(), value); \ |
918 |
|
|
} |
919 |
|
10704254 |
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) |
920 |
|
|
#undef V |
921 |
|
|
|
922 |
|
9121785 |
v8::Local<v8::Context> Environment::context() const { |
923 |
|
9121785 |
return PersistentToLocal::Strong(context_); |
924 |
|
|
} |
925 |
|
|
|
926 |
|
|
} // namespace node |
927 |
|
|
|
928 |
|
|
// These two files depend on each other. Including base_object-inl.h after this |
929 |
|
|
// file is the easiest way to avoid issues with that circular dependency. |
930 |
|
|
#include "base_object-inl.h" |
931 |
|
|
|
932 |
|
|
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
933 |
|
|
|
934 |
|
|
#endif // SRC_ENV_INL_H_ |