GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/env-inl.h Lines: 636 645 98.6 %
Date: 2021-05-30 04:11:56 Branches: 114 172 66.3 %

Line Branch Exec Source
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
913403
inline uv_loop_t* IsolateData::event_loop() const {
49
913403
  return event_loop_;
50
}
51
52
164123
inline NodeArrayBufferAllocator* IsolateData::node_allocator() const {
53
164123
  return node_allocator_;
54
}
55
56
33900
inline MultiIsolatePlatform* IsolateData::platform() const {
57
33900
  return platform_;
58
}
59
60
429
inline void IsolateData::set_worker_context(worker::Worker* context) {
61
429
  CHECK_NULL(worker_context_);  // Should be set only once.
62
429
  worker_context_ = context;
63
429
}
64
65
12641
inline worker::Worker* IsolateData::worker_context() const {
66
12641
  return worker_context_;
67
}
68
69
219714
inline v8::Local<v8::String> IsolateData::async_wrap_provider(int index) const {
70
439428
  return async_wrap_providers_[index].Get(isolate_);
71
}
72
73
3117258
inline AliasedUint32Array& AsyncHooks::fields() {
74
3117258
  return fields_;
75
}
76
77
1780297
inline AliasedFloat64Array& AsyncHooks::async_id_fields() {
78
1780297
  return async_id_fields_;
79
}
80
81
468
inline AliasedFloat64Array& AsyncHooks::async_ids_stack() {
82
468
  return async_ids_stack_;
83
}
84
85
862910
v8::Local<v8::Array> AsyncHooks::js_execution_async_resources() {
86
1725820
  if (UNLIKELY(js_execution_async_resources_.IsEmpty())) {
87
468
    js_execution_async_resources_.Reset(
88
936
        env()->isolate(), v8::Array::New(env()->isolate()));
89
  }
90
862910
  return PersistentToLocal::Strong(js_execution_async_resources_);
91
}
92
93
239
v8::Local<v8::Object> AsyncHooks::native_execution_async_resource(size_t i) {
94
239
  if (i >= native_execution_async_resources_.size()) return {};
95
239
  return PersistentToLocal::Strong(native_execution_async_resources_[i]);
96
}
97
98
219250
inline v8::Local<v8::String> AsyncHooks::provider_string(int idx) {
99
219250
  return env()->isolate_data()->async_wrap_provider(idx);
100
}
101
102
1
inline void AsyncHooks::no_force_checks() {
103
1
  fields_[kCheck] -= 1;
104
1
}
105
106
1232909
inline Environment* AsyncHooks::env() {
107
1232909
  return Environment::ForAsyncHooks(this);
108
}
109
110
// Remember to keep this code aligned with pushAsyncContext() in JS.
111
815785
inline void AsyncHooks::push_async_context(double async_id,
112
                                           double trigger_async_id,
113
                                           v8::Local<v8::Object> resource) {
114
  // Since async_hooks is experimental, do only perform the check
115
  // when async_hooks is enabled.
116
815785
  if (fields_[kCheck] > 0) {
117
815718
    CHECK_GE(async_id, -1);
118
815718
    CHECK_GE(trigger_async_id, -1);
119
  }
120
121
815884
  uint32_t offset = fields_[kStackLength];
122
815852
  if (offset * 2 >= async_ids_stack_.Length())
123
10
    grow_async_ids_stack();
124
815848
  async_ids_stack_[2 * offset] = async_id_fields_[kExecutionAsyncId];
125
815677
  async_ids_stack_[2 * offset + 1] = async_id_fields_[kTriggerAsyncId];
126
815812
  fields_[kStackLength] += 1;
127
815851
  async_id_fields_[kExecutionAsyncId] = async_id;
128
815868
  async_id_fields_[kTriggerAsyncId] = trigger_async_id;
129
130
#ifdef DEBUG
131
  for (uint32_t i = offset; i < native_execution_async_resources_.size(); i++)
132
    CHECK(native_execution_async_resources_[i].IsEmpty());
133
#endif
134
135
  // When this call comes from JS (as a way of increasing the stack size),
136
  // `resource` will be empty, because JS caches these values anyway, and
137
  // we should avoid creating strong global references that might keep
138
  // these JS resource objects alive longer than necessary.
139
815825
  if (!resource.IsEmpty()) {
140
815822
    native_execution_async_resources_.resize(offset + 1);
141
815497
    native_execution_async_resources_[offset].Reset(env()->isolate(), resource);
142
  }
143
815808
}
144
145
// Remember to keep this code aligned with popAsyncContext() in JS.
146
815224
inline bool AsyncHooks::pop_async_context(double async_id) {
147
  // In case of an exception then this may have already been reset, if the
148
  // stack was multiple MakeCallback()'s deep.
149
815224
  if (fields_[kStackLength] == 0) return false;
150
151
  // Ask for the async_id to be restored as a check that the stack
152
  // hasn't been corrupted.
153
  // Since async_hooks is experimental, do only perform the check
154
  // when async_hooks is enabled.
155

814230
  if (fields_[kCheck] > 0 && async_id_fields_[kExecutionAsyncId] != async_id) {
156
4
    fprintf(stderr,
157
            "Error: async hook stack has become corrupted ("
158
            "actual: %.f, expected: %.f)\n",
159
            async_id_fields_.GetValue(kExecutionAsyncId),
160
4
            async_id);
161
4
    DumpBacktrace(stderr);
162
4
    fflush(stderr);
163
4
    if (!env()->abort_on_uncaught_exception())
164
4
      exit(1);
165
    fprintf(stderr, "\n");
166
    fflush(stderr);
167
    ABORT_NO_BACKTRACE();
168
  }
169
170
814177
  uint32_t offset = fields_[kStackLength] - 1;
171
814162
  async_id_fields_[kExecutionAsyncId] = async_ids_stack_[2 * offset];
172
814238
  async_id_fields_[kTriggerAsyncId] = async_ids_stack_[2 * offset + 1];
173
814208
  fields_[kStackLength] = offset;
174
175

1628498
  if (LIKELY(offset < native_execution_async_resources_.size() &&
176
             !native_execution_async_resources_[offset].IsEmpty())) {
177
#ifdef DEBUG
178
    for (uint32_t i = offset + 1;
179
         i < native_execution_async_resources_.size();
180
         i++) {
181
      CHECK(native_execution_async_resources_[i].IsEmpty());
182
    }
183
#endif
184
814247
    native_execution_async_resources_.resize(offset);
185
1628393
    if (native_execution_async_resources_.size() <
186

1042829
            native_execution_async_resources_.capacity() / 2 &&
187
228626
        native_execution_async_resources_.size() > 16) {
188
      native_execution_async_resources_.shrink_to_fit();
189
    }
190
  }
191
192
1628343
  if (UNLIKELY(js_execution_async_resources()->Length() > offset)) {
193
96536
    v8::HandleScope handle_scope(env()->isolate());
194
144804
    USE(js_execution_async_resources()->Set(
195
        env()->context(),
196
        env()->length_string(),
197
241340
        v8::Integer::NewFromUnsigned(env()->isolate(), offset)));
198
  }
199
200
814176
  return fields_[kStackLength] > 0;
201
}
202
203
1781
void AsyncHooks::clear_async_id_stack() {
204
1781
  v8::Isolate* isolate = env()->isolate();
205
3562
  v8::HandleScope handle_scope(isolate);
206
3562
  if (!js_execution_async_resources_.IsEmpty()) {
207
3939
    USE(PersistentToLocal::Strong(js_execution_async_resources_)->Set(
208
        env()->context(),
209
        env()->length_string(),
210
6565
        v8::Integer::NewFromUnsigned(isolate, 0)));
211
  }
212
1781
  native_execution_async_resources_.clear();
213
1781
  native_execution_async_resources_.shrink_to_fit();
214
215
1781
  async_id_fields_[kExecutionAsyncId] = 0;
216
1781
  async_id_fields_[kTriggerAsyncId] = 0;
217
1781
  fields_[kStackLength] = 0;
218
1781
}
219
220
// The DefaultTriggerAsyncIdScope(AsyncWrap*) constructor is defined in
221
// async_wrap-inl.h to avoid a circular dependency.
222
223
267415
inline AsyncHooks::DefaultTriggerAsyncIdScope ::DefaultTriggerAsyncIdScope(
224
267415
    Environment* env, double default_trigger_async_id)
225
267415
    : async_hooks_(env->async_hooks()) {
226
267415
  if (env->async_hooks()->fields()[AsyncHooks::kCheck] > 0) {
227
267415
    CHECK_GE(default_trigger_async_id, 0);
228
  }
229
230
267415
  old_default_trigger_async_id_ =
231
534830
    async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId];
232
267415
  async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] =
233
267415
    default_trigger_async_id;
234
267415
}
235
236
534828
inline AsyncHooks::DefaultTriggerAsyncIdScope ::~DefaultTriggerAsyncIdScope() {
237
267414
  async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] =
238
534828
    old_default_trigger_async_id_;
239
267414
}
240
241
1232891
Environment* Environment::ForAsyncHooks(AsyncHooks* hooks) {
242
1232891
  return ContainerOf(&Environment::async_hooks_, hooks);
243
}
244
245
803878
inline size_t Environment::async_callback_scope_depth() const {
246
803878
  return async_callback_scope_depth_;
247
}
248
249
815004
inline void Environment::PushAsyncCallbackScope() {
250
815004
  async_callback_scope_depth_++;
251
815004
}
252
253
814704
inline void Environment::PopAsyncCallbackScope() {
254
814704
  async_callback_scope_depth_--;
255
814704
}
256
257
468
inline AliasedUint32Array& ImmediateInfo::fields() {
258
468
  return fields_;
259
}
260
261
199685
inline uint32_t ImmediateInfo::count() const {
262
199685
  return fields_[kCount];
263
}
264
265
310378
inline uint32_t ImmediateInfo::ref_count() const {
266
310378
  return fields_[kRefCount];
267
}
268
269
64162
inline bool ImmediateInfo::has_outstanding() const {
270
64162
  return fields_[kHasOutstanding] == 1;
271
}
272
273
33431
inline void ImmediateInfo::ref_count_inc(uint32_t increment) {
274
33431
  fields_[kRefCount] += increment;
275
33431
}
276
277
213725
inline void ImmediateInfo::ref_count_dec(uint32_t decrement) {
278
213725
  fields_[kRefCount] -= decrement;
279
213727
}
280
281
468
inline AliasedUint8Array& TickInfo::fields() {
282
468
  return fields_;
283
}
284
285
1441212
inline bool TickInfo::has_tick_scheduled() const {
286
1441212
  return fields_[kHasTickScheduled] == 1;
287
}
288
289
548851
inline bool TickInfo::has_rejection_to_warn() const {
290
548851
  return fields_[kHasRejectionToWarn] == 1;
291
}
292
293
5813
inline void Environment::AssignToContext(v8::Local<v8::Context> context,
294
                                         const ContextInfo& info) {
295
5813
  context->SetAlignedPointerInEmbedderData(
296
5813
      ContextEmbedderIndex::kEnvironment, this);
297
  // Used by Environment::GetCurrent to know that we are on a node context.
298
11626
  context->SetAlignedPointerInEmbedderData(
299
5813
    ContextEmbedderIndex::kContextTag, Environment::kNodeContextTagPtr);
300
  // Used to retrieve bindings
301
5813
  context->SetAlignedPointerInEmbedderData(
302
11626
      ContextEmbedderIndex::kBindingListIndex, &(this->bindings_));
303
304
#if HAVE_INSPECTOR
305
5813
  inspector_agent()->ContextCreated(context, info);
306
#endif  // HAVE_INSPECTOR
307
5813
}
308
309
959751
inline Environment* Environment::GetCurrent(v8::Isolate* isolate) {
310
959751
  if (UNLIKELY(!isolate->InContext())) return nullptr;
311
1916552
  v8::HandleScope handle_scope(isolate);
312
958249
  return GetCurrent(isolate->GetCurrentContext());
313
}
314
315
6019124
inline Environment* Environment::GetCurrent(v8::Local<v8::Context> context) {
316
6019124
  if (UNLIKELY(context.IsEmpty())) {
317
1
    return nullptr;
318
  }
319
6019123
  if (UNLIKELY(context->GetNumberOfEmbedderDataFields() <=
320
               ContextEmbedderIndex::kContextTag)) {
321
11
    return nullptr;
322
  }
323
12038940
  if (UNLIKELY(context->GetAlignedPointerFromEmbedderData(
324
                   ContextEmbedderIndex::kContextTag) !=
325
               Environment::kNodeContextTagPtr)) {
326
    return nullptr;
327
  }
328
  return static_cast<Environment*>(
329
6019470
      context->GetAlignedPointerFromEmbedderData(
330
6019470
          ContextEmbedderIndex::kEnvironment));
331
}
332
333
3325022
inline Environment* Environment::GetCurrent(
334
    const v8::FunctionCallbackInfo<v8::Value>& info) {
335
3325022
  return GetCurrent(info.GetIsolate()->GetCurrentContext());
336
}
337
338
template <typename T>
339
1259974
inline Environment* Environment::GetCurrent(
340
    const v8::PropertyCallbackInfo<T>& info) {
341
1259974
  return GetCurrent(info.GetIsolate()->GetCurrentContext());
342
}
343
344
template <typename T, typename U>
345
inline T* Environment::GetBindingData(const v8::PropertyCallbackInfo<U>& info) {
346
  return GetBindingData<T>(info.GetIsolate()->GetCurrentContext());
347
}
348
349
template <typename T>
350
708683
inline T* Environment::GetBindingData(
351
    const v8::FunctionCallbackInfo<v8::Value>& info) {
352
708683
  return GetBindingData<T>(info.GetIsolate()->GetCurrentContext());
353
}
354
355
template <typename T>
356
708684
inline T* Environment::GetBindingData(v8::Local<v8::Context> context) {
357
  BindingDataStore* map = static_cast<BindingDataStore*>(
358
708684
      context->GetAlignedPointerFromEmbedderData(
359
708684
          ContextEmbedderIndex::kBindingListIndex));
360
  DCHECK_NOT_NULL(map);
361
708684
  auto it = map->find(T::type_name);
362
708680
  if (UNLIKELY(it == map->end())) return nullptr;
363
708679
  T* result = static_cast<T*>(it->second.get());
364
  DCHECK_NOT_NULL(result);
365
  DCHECK_EQ(result->env(), GetCurrent(context));
366
708678
  return result;
367
}
368
369
template <typename T>
370
11508
inline T* Environment::AddBindingData(
371
    v8::Local<v8::Context> context,
372
    v8::Local<v8::Object> target) {
373
  DCHECK_EQ(GetCurrent(context), this);
374
  // This won't compile if T is not a BaseObject subclass.
375
23016
  BaseObjectPtr<T> item = MakeDetachedBaseObject<T>(this, target);
376
  BindingDataStore* map = static_cast<BindingDataStore*>(
377
11508
      context->GetAlignedPointerFromEmbedderData(
378
11508
          ContextEmbedderIndex::kBindingListIndex));
379
  DCHECK_NOT_NULL(map);
380
11508
  auto result = map->emplace(T::type_name, item);
381
11508
  CHECK(result.second);
382
  DCHECK_EQ(GetBindingData<T>(context), item.get());
383
23016
  return item.get();
384
}
385
386
26169266
inline v8::Isolate* Environment::isolate() const {
387
26169266
  return isolate_;
388
}
389
390
5659
inline Environment* Environment::from_timer_handle(uv_timer_t* handle) {
391
5659
  return ContainerOf(&Environment::timer_handle_, handle);
392
}
393
394
24186
inline uv_timer_t* Environment::timer_handle() {
395
24186
  return &timer_handle_;
396
}
397
398
199685
inline Environment* Environment::from_immediate_check_handle(
399
    uv_check_t* handle) {
400
199685
  return ContainerOf(&Environment::immediate_check_handle_, handle);
401
}
402
403
20804
inline uv_check_t* Environment::immediate_check_handle() {
404
20804
  return &immediate_check_handle_;
405
}
406
407
242167
inline uv_idle_t* Environment::immediate_idle_handle() {
408
242167
  return &immediate_idle_handle_;
409
}
410
411
31204
inline void Environment::RegisterHandleCleanup(uv_handle_t* handle,
412
                                               HandleCleanupCb cb,
413
                                               void* arg) {
414
31204
  handle_cleanup_queue_.push_back(HandleCleanup{handle, cb, arg});
415
31203
}
416
417
template <typename T, typename OnCloseCallback>
418
32695
inline void Environment::CloseHandle(T* handle, OnCloseCallback callback) {
419
32695
  handle_cleanup_waiting_++;
420
  static_assert(sizeof(T) >= sizeof(uv_handle_t), "T is a libuv handle");
421
  static_assert(offsetof(T, data) == offsetof(uv_handle_t, data),
422
                "T is a libuv handle");
423
  static_assert(offsetof(T, close_cb) == offsetof(uv_handle_t, close_cb),
424
                "T is a libuv handle");
425
  struct CloseData {
426
    Environment* env;
427
    OnCloseCallback callback;
428
    void* original_data;
429
  };
430
32695
  handle->data = new CloseData { this, callback, handle->data };
431
130811
  uv_close(reinterpret_cast<uv_handle_t*>(handle), [](uv_handle_t* handle) {
432
65401
    std::unique_ptr<CloseData> data { static_cast<CloseData*>(handle->data) };
433
32703
    data->env->handle_cleanup_waiting_--;
434
32699
    handle->data = data->original_data;
435
32698
    data->callback(reinterpret_cast<T*>(handle));
436
32702
  });
437
32700
}
438
439
83551
void Environment::IncreaseWaitingRequestCounter() {
440
83551
  request_waiting_++;
441
83551
}
442
443
83540
void Environment::DecreaseWaitingRequestCounter() {
444
83540
  request_waiting_--;
445
83540
  CHECK_GE(request_waiting_, 0);
446
83540
}
447
448
908169
inline uv_loop_t* Environment::event_loop() const {
449
908169
  return isolate_data()->event_loop();
450
}
451
452
163
inline void Environment::TryLoadAddon(
453
    const char* filename,
454
    int flags,
455
    const std::function<bool(binding::DLib*)>& was_loaded) {
456
163
  loaded_addons_.emplace_back(filename, flags);
457
163
  if (!was_loaded(&loaded_addons_.back())) {
458
8
    loaded_addons_.pop_back();
459
  }
460
163
}
461
462
#if HAVE_INSPECTOR
463
22909
inline bool Environment::is_in_inspector_console_call() const {
464
22909
  return is_in_inspector_console_call_;
465
}
466
467
45816
inline void Environment::set_is_in_inspector_console_call(bool value) {
468
45816
  is_in_inspector_console_call_ = value;
469
45816
}
470
#endif
471
472
5386183
inline AsyncHooks* Environment::async_hooks() {
473
5386183
  return &async_hooks_;
474
}
475
476
821852
inline ImmediateInfo* Environment::immediate_info() {
477
821852
  return &immediate_info_;
478
}
479
480
721019
inline TickInfo* Environment::tick_info() {
481
721019
  return &tick_info_;
482
}
483
484
54326
inline uint64_t Environment::timer_base() const {
485
54326
  return timer_base_;
486
}
487
488
1273661
inline std::shared_ptr<KVStore> Environment::env_vars() {
489
1273661
  return env_vars_;
490
}
491
492
5648
inline void Environment::set_env_vars(std::shared_ptr<KVStore> env_vars) {
493
5648
  env_vars_ = env_vars;
494
5648
}
495
496
17
inline bool Environment::printed_error() const {
497
17
  return printed_error_;
498
}
499
500
17
inline void Environment::set_printed_error(bool value) {
501
17
  printed_error_ = value;
502
17
}
503
504
9508
inline void Environment::set_trace_sync_io(bool value) {
505
9508
  trace_sync_io_ = value;
506
9508
}
507
508
83
inline bool Environment::abort_on_uncaught_exception() const {
509
83
  return options_->abort_on_uncaught_exception;
510
}
511
512
inline void Environment::set_force_context_aware(bool value) {
513
  options_->force_context_aware = value;
514
}
515
516
42
inline bool Environment::force_context_aware() const {
517
42
  return options_->force_context_aware;
518
}
519
520
417
inline void Environment::set_abort_on_uncaught_exception(bool value) {
521
417
  options_->abort_on_uncaught_exception = value;
522
417
}
523
524
498
inline AliasedUint32Array& Environment::should_abort_on_uncaught_toggle() {
525
498
  return should_abort_on_uncaught_toggle_;
526
}
527
528
307304
inline AliasedInt32Array& Environment::stream_base_state() {
529
307304
  return stream_base_state_;
530
}
531
532
42781
inline uint32_t Environment::get_next_module_id() {
533
42781
  return module_id_counter_++;
534
}
535
2205
inline uint32_t Environment::get_next_script_id() {
536
2205
  return script_id_counter_++;
537
}
538
32135
inline uint32_t Environment::get_next_function_id() {
539
32135
  return function_id_counter_++;
540
}
541
542
87510
ShouldNotAbortOnUncaughtScope::ShouldNotAbortOnUncaughtScope(
543
87510
    Environment* env)
544
87510
    : env_(env) {
545
87510
  env_->PushShouldNotAbortOnUncaughtScope();
546
87510
}
547
548
175018
ShouldNotAbortOnUncaughtScope::~ShouldNotAbortOnUncaughtScope() {
549
87509
  Close();
550
87509
}
551
552
87691
void ShouldNotAbortOnUncaughtScope::Close() {
553
87691
  if (env_ != nullptr) {
554
87509
    env_->PopShouldNotAbortOnUncaughtScope();
555
87509
    env_ = nullptr;
556
  }
557
87691
}
558
559
87510
inline void Environment::PushShouldNotAbortOnUncaughtScope() {
560
87510
  should_not_abort_scope_counter_++;
561
87510
}
562
563
87509
inline void Environment::PopShouldNotAbortOnUncaughtScope() {
564
87509
  should_not_abort_scope_counter_--;
565
87509
}
566
567
1
inline bool Environment::inside_should_not_abort_on_uncaught_scope() const {
568
1
  return should_not_abort_scope_counter_ > 0;
569
}
570
571
387871
inline std::vector<double>* Environment::destroy_async_id_list() {
572
387871
  return &destroy_async_id_list_;
573
}
574
575
219934
inline double Environment::new_async_id() {
576
219934
  async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] += 1;
577
219934
  return async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter];
578
}
579
580
251827
inline double Environment::execution_async_id() {
581
251827
  return async_hooks()->async_id_fields()[AsyncHooks::kExecutionAsyncId];
582
}
583
584
65969
inline double Environment::trigger_async_id() {
585
65969
  return async_hooks()->async_id_fields()[AsyncHooks::kTriggerAsyncId];
586
}
587
588
219931
inline double Environment::get_default_trigger_async_id() {
589
  double default_trigger_async_id =
590
219931
    async_hooks()->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId];
591
  // If defaultTriggerAsyncId isn't set, use the executionAsyncId
592
219931
  if (default_trigger_async_id < 0)
593
174438
    default_trigger_async_id = execution_async_id();
594
219931
  return default_trigger_async_id;
595
}
596
597
59026
inline std::shared_ptr<EnvironmentOptions> Environment::options() {
598
59026
  return options_;
599
}
600
601
15069
inline const std::vector<std::string>& Environment::argv() {
602
15069
  return argv_;
603
}
604
605
5746
inline const std::vector<std::string>& Environment::exec_argv() {
606
5746
  return exec_argv_;
607
}
608
609
10402
inline const std::string& Environment::exec_path() const {
610
10402
  return exec_path_;
611
}
612
613
11
inline std::string Environment::GetCwd() {
614
  char cwd[PATH_MAX_BYTES];
615
11
  size_t size = PATH_MAX_BYTES;
616
11
  const int err = uv_cwd(cwd, &size);
617
618
11
  if (err == 0) {
619
11
    CHECK_GT(size, 0);
620
11
    return cwd;
621
  }
622
623
  // This can fail if the cwd is deleted. In that case, fall back to
624
  // exec_path.
625
  const std::string& exec_path = exec_path_;
626
  return exec_path.substr(0, exec_path.find_last_of(kPathSeparator));
627
}
628
629
#if HAVE_INSPECTOR
630
5195
inline void Environment::set_coverage_directory(const char* dir) {
631
5195
  coverage_directory_ = std::string(dir);
632
5195
}
633
634
5215
inline void Environment::set_coverage_connection(
635
    std::unique_ptr<profiler::V8CoverageConnection> connection) {
636
5215
  CHECK_NULL(coverage_connection_);
637
5216
  std::swap(coverage_connection_, connection);
638
5216
}
639
640
15646
inline profiler::V8CoverageConnection* Environment::coverage_connection() {
641
15646
  return coverage_connection_.get();
642
}
643
644
5180
inline const std::string& Environment::coverage_directory() const {
645
5180
  return coverage_directory_;
646
}
647
648
12
inline void Environment::set_cpu_profiler_connection(
649
    std::unique_ptr<profiler::V8CpuProfilerConnection> connection) {
650
12
  CHECK_NULL(cpu_profiler_connection_);
651
12
  std::swap(cpu_profiler_connection_, connection);
652
12
}
653
654
inline profiler::V8CpuProfilerConnection*
655
5233
Environment::cpu_profiler_connection() {
656
5233
  return cpu_profiler_connection_.get();
657
}
658
659
12
inline void Environment::set_cpu_prof_interval(uint64_t interval) {
660
12
  cpu_prof_interval_ = interval;
661
12
}
662
663
12
inline uint64_t Environment::cpu_prof_interval() const {
664
12
  return cpu_prof_interval_;
665
}
666
667
12
inline void Environment::set_cpu_prof_name(const std::string& name) {
668
12
  cpu_prof_name_ = name;
669
12
}
670
671
12
inline const std::string& Environment::cpu_prof_name() const {
672
12
  return cpu_prof_name_;
673
}
674
675
12
inline void Environment::set_cpu_prof_dir(const std::string& dir) {
676
12
  cpu_prof_dir_ = dir;
677
12
}
678
679
12
inline const std::string& Environment::cpu_prof_dir() const {
680
12
  return cpu_prof_dir_;
681
}
682
683
12
inline void Environment::set_heap_profiler_connection(
684
    std::unique_ptr<profiler::V8HeapProfilerConnection> connection) {
685
12
  CHECK_NULL(heap_profiler_connection_);
686
12
  std::swap(heap_profiler_connection_, connection);
687
12
}
688
689
inline profiler::V8HeapProfilerConnection*
690
5220
Environment::heap_profiler_connection() {
691
5220
  return heap_profiler_connection_.get();
692
}
693
694
12
inline void Environment::set_heap_prof_name(const std::string& name) {
695
12
  heap_prof_name_ = name;
696
12
}
697
698
12
inline const std::string& Environment::heap_prof_name() const {
699
12
  return heap_prof_name_;
700
}
701
702
12
inline void Environment::set_heap_prof_dir(const std::string& dir) {
703
12
  heap_prof_dir_ = dir;
704
12
}
705
706
12
inline const std::string& Environment::heap_prof_dir() const {
707
12
  return heap_prof_dir_;
708
}
709
710
12
inline void Environment::set_heap_prof_interval(uint64_t interval) {
711
12
  heap_prof_interval_ = interval;
712
12
}
713
714
12
inline uint64_t Environment::heap_prof_interval() const {
715
12
  return heap_prof_interval_;
716
}
717
718
#endif  // HAVE_INSPECTOR
719
720
inline
721
10602
std::shared_ptr<ExclusiveAccess<HostPort>> Environment::inspector_host_port() {
722
10602
  return inspector_host_port_;
723
}
724
725
87217
inline std::shared_ptr<PerIsolateOptions> IsolateData::options() {
726
87217
  return options_;
727
}
728
729
112
inline void IsolateData::set_options(
730
    std::shared_ptr<PerIsolateOptions> options) {
731
112
  options_ = std::move(options);
732
112
}
733
734
template <typename Fn>
735
56463
void Environment::SetImmediate(Fn&& cb, CallbackFlags::Flags flags) {
736
112926
  auto callback = native_immediates_.CreateCallback(std::move(cb), flags);
737
56463
  native_immediates_.Push(std::move(callback));
738
739






56463
  if (flags & CallbackFlags::kRefed) {
740






33431
    if (immediate_info()->ref_count() == 0)
741
25125
      ToggleImmediateRef(true);
742
33431
    immediate_info()->ref_count_inc(1);
743
  }
744
56463
}
745
746
template <typename Fn>
747
1206
void Environment::SetImmediateThreadsafe(Fn&& cb, CallbackFlags::Flags flags) {
748
  auto callback = native_immediates_threadsafe_.CreateCallback(
749
2415
      std::move(cb), flags);
750
  {
751
2415
    Mutex::ScopedLock lock(native_immediates_threadsafe_mutex_);
752
1209
    native_immediates_threadsafe_.Push(std::move(callback));
753

1209
    if (task_queues_async_initialized_)
754
946
      uv_async_send(&task_queues_async_);
755
  }
756
1209
}
757
758
template <typename Fn>
759
8659
void Environment::RequestInterrupt(Fn&& cb) {
760
  auto callback = native_immediates_interrupts_.CreateCallback(
761
17319
      std::move(cb), CallbackFlags::kRefed);
762
  {
763
17320
    Mutex::ScopedLock lock(native_immediates_threadsafe_mutex_);
764
8660
    native_immediates_interrupts_.Push(std::move(callback));
765
8660
    if (task_queues_async_initialized_)
766
3317
      uv_async_send(&task_queues_async_);
767
  }
768
8660
  RequestInterruptFromV8();
769
8660
}
770
771
2973771
inline bool Environment::can_call_into_js() const {
772

2973771
  return can_call_into_js_ && !is_stopping();
773
}
774
775
1005
inline void Environment::set_can_call_into_js(bool can_call_into_js) {
776
1005
  can_call_into_js_ = can_call_into_js;
777
1007
}
778
779
1402535
inline bool Environment::has_run_bootstrapping_code() const {
780
1402535
  return has_run_bootstrapping_code_;
781
}
782
783
5234
inline void Environment::DoneBootstrapping() {
784
5234
  has_run_bootstrapping_code_ = true;
785
  // This adjusts the return value of base_object_created_after_bootstrap() so
786
  // that tests that check the count do not have to account for internally
787
  // created BaseObjects.
788
5234
  base_object_created_by_bootstrap_ = base_object_count_;
789
5234
}
790
791
19
inline bool Environment::has_serialized_options() const {
792
19
  return has_serialized_options_;
793
}
794
795
5201
inline void Environment::set_has_serialized_options(bool value) {
796
5201
  has_serialized_options_ = value;
797
5201
}
798
799
7042
inline bool Environment::is_main_thread() const {
800
7042
  return worker_context() == nullptr;
801
}
802
803
5201
inline bool Environment::should_not_register_esm_loader() const {
804
5201
  return flags_ & EnvironmentFlags::kNoRegisterESMLoader;
805
}
806
807
12860
inline bool Environment::owns_process_state() const {
808
12860
  return flags_ & EnvironmentFlags::kOwnsProcessState;
809
}
810
811
5226
inline bool Environment::owns_inspector() const {
812
5226
  return flags_ & EnvironmentFlags::kOwnsInspector;
813
}
814
815
110306
inline bool Environment::tracks_unmanaged_fds() const {
816
110306
  return flags_ & EnvironmentFlags::kTrackUnmanagedFds;
817
}
818
819
2
bool Environment::filehandle_close_warning() const {
820
2
  return emit_filehandle_warning_;
821
}
822
823
2
void Environment::set_filehandle_close_warning(bool on) {
824
2
  emit_filehandle_warning_ = on;
825
2
}
826
827
16
void Environment::set_source_maps_enabled(bool on) {
828
16
  source_maps_enabled_ = on;
829
16
}
830
831
935
bool Environment::source_maps_enabled() const {
832
935
  return source_maps_enabled_;
833
}
834
835
6145
inline uint64_t Environment::thread_id() const {
836
6145
  return thread_id_;
837
}
838
839
12641
inline worker::Worker* Environment::worker_context() const {
840
12641
  return isolate_data()->worker_context();
841
}
842
843
652
inline void Environment::add_sub_worker_context(worker::Worker* context) {
844
652
  sub_worker_contexts_.insert(context);
845
652
}
846
847
678
inline void Environment::remove_sub_worker_context(worker::Worker* context) {
848
678
  sub_worker_contexts_.erase(context);
849
678
}
850
851
template <typename Fn>
852
24
inline void Environment::ForEachWorker(Fn&& iterator) {
853
24
  for (worker::Worker* w : sub_worker_contexts_) iterator(w);
854
24
}
855
856
1288
inline void Environment::add_refs(int64_t diff) {
857
1288
  task_queues_async_refs_ += diff;
858
1288
  CHECK_GE(task_queues_async_refs_, 0);
859
1288
  if (task_queues_async_refs_ == 0)
860
170
    uv_unref(reinterpret_cast<uv_handle_t*>(&task_queues_async_));
861
  else
862
1118
    uv_ref(reinterpret_cast<uv_handle_t*>(&task_queues_async_));
863
1288
}
864
865
4516274
inline bool Environment::is_stopping() const {
866
4516274
  return is_stopping_.load();
867
}
868
869
4865
inline void Environment::set_stopping(bool value) {
870
4865
  is_stopping_.store(value);
871
4865
}
872
873
3
inline std::list<node_module>* Environment::extra_linked_bindings() {
874
3
  return &extra_linked_bindings_;
875
}
876
877
7
inline node_module* Environment::extra_linked_bindings_head() {
878
10
  return extra_linked_bindings_.size() > 0 ?
879
10
      &extra_linked_bindings_.front() : nullptr;
880
}
881
882
7
inline const Mutex& Environment::extra_linked_bindings_mutex() const {
883
7
  return extra_linked_bindings_mutex_;
884
}
885
886
43616
inline performance::PerformanceState* Environment::performance_state() {
887
43616
  return performance_state_.get();
888
}
889
890
5435023
inline IsolateData* Environment::isolate_data() const {
891
5435023
  return isolate_data_;
892
}
893
894
std::unordered_map<char*, std::unique_ptr<v8::BackingStore>>*
895
134942
    Environment::released_allocated_buffers() {
896
134942
  return &released_allocated_buffers_;
897
}
898
899
8
inline void Environment::ThrowError(const char* errmsg) {
900
8
  ThrowError(v8::Exception::Error, errmsg);
901
8
}
902
903
inline void Environment::ThrowTypeError(const char* errmsg) {
904
  ThrowError(v8::Exception::TypeError, errmsg);
905
}
906
907
inline void Environment::ThrowRangeError(const char* errmsg) {
908
  ThrowError(v8::Exception::RangeError, errmsg);
909
}
910
911
8
inline void Environment::ThrowError(
912
    v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
913
    const char* errmsg) {
914
16
  v8::HandleScope handle_scope(isolate());
915
8
  isolate()->ThrowException(fun(OneByteString(isolate(), errmsg)));
916
8
}
917
918
7
inline void Environment::ThrowErrnoException(int errorno,
919
                                             const char* syscall,
920
                                             const char* message,
921
                                             const char* path) {
922
  isolate()->ThrowException(
923
7
      ErrnoException(isolate(), errorno, syscall, message, path));
924
7
}
925
926
14
inline void Environment::ThrowUVException(int errorno,
927
                                          const char* syscall,
928
                                          const char* message,
929
                                          const char* path,
930
                                          const char* dest) {
931
  isolate()->ThrowException(
932
14
      UVException(isolate(), errorno, syscall, message, path, dest));
933
14
}
934
935
inline v8::Local<v8::FunctionTemplate>
936
1492560
    Environment::NewFunctionTemplate(v8::FunctionCallback callback,
937
                                     v8::Local<v8::Signature> signature,
938
                                     v8::ConstructorBehavior behavior,
939
                                     v8::SideEffectType side_effect_type) {
940
  return v8::FunctionTemplate::New(isolate(), callback, v8::Local<v8::Value>(),
941
1492560
                                   signature, 0, behavior, side_effect_type);
942
}
943
944
247583
inline void Environment::SetMethod(v8::Local<v8::Object> that,
945
                                   const char* name,
946
                                   v8::FunctionCallback callback) {
947
247583
  v8::Local<v8::Context> context = isolate()->GetCurrentContext();
948
  v8::Local<v8::Function> function =
949
495150
      NewFunctionTemplate(callback, v8::Local<v8::Signature>(),
950
                          v8::ConstructorBehavior::kThrow,
951
247577
                          v8::SideEffectType::kHasSideEffect)
952
495156
          ->GetFunction(context)
953
247577
          .ToLocalChecked();
954
  // kInternalized strings are created in the old space.
955
247577
  const v8::NewStringType type = v8::NewStringType::kInternalized;
956
  v8::Local<v8::String> name_string =
957
495165
      v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
958
495178
  that->Set(context, name_string, function).Check();
959
247590
  function->SetName(name_string);  // NODE_SET_METHOD() compatibility.
960
247598
}
961
962
103992
inline void Environment::SetMethodNoSideEffect(v8::Local<v8::Object> that,
963
                                               const char* name,
964
                                               v8::FunctionCallback callback) {
965
103992
  v8::Local<v8::Context> context = isolate()->GetCurrentContext();
966
  v8::Local<v8::Function> function =
967
207986
      NewFunctionTemplate(callback, v8::Local<v8::Signature>(),
968
                          v8::ConstructorBehavior::kThrow,
969
103995
                          v8::SideEffectType::kHasNoSideEffect)
970
207991
          ->GetFunction(context)
971
103995
          .ToLocalChecked();
972
  // kInternalized strings are created in the old space.
973
103995
  const v8::NewStringType type = v8::NewStringType::kInternalized;
974
  v8::Local<v8::String> name_string =
975
207986
      v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
976
207987
  that->Set(context, name_string, function).Check();
977
103996
  function->SetName(name_string);  // NODE_SET_METHOD() compatibility.
978
103997
}
979
980
724229
inline void Environment::SetProtoMethod(v8::Local<v8::FunctionTemplate> that,
981
                                        const char* name,
982
                                        v8::FunctionCallback callback) {
983
724229
  v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
984
  v8::Local<v8::FunctionTemplate> t =
985
      NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow,
986
724226
                          v8::SideEffectType::kHasSideEffect);
987
  // kInternalized strings are created in the old space.
988
724225
  const v8::NewStringType type = v8::NewStringType::kInternalized;
989
  v8::Local<v8::String> name_string =
990
1448447
      v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
991
1448443
  that->PrototypeTemplate()->Set(name_string, t);
992
724223
  t->SetClassName(name_string);  // NODE_SET_PROTOTYPE_METHOD() compatibility.
993
724226
}
994
995
170068
inline void Environment::SetProtoMethodNoSideEffect(
996
    v8::Local<v8::FunctionTemplate> that,
997
    const char* name,
998
    v8::FunctionCallback callback) {
999
170068
  v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
1000
  v8::Local<v8::FunctionTemplate> t =
1001
      NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow,
1002
170068
                          v8::SideEffectType::kHasNoSideEffect);
1003
  // kInternalized strings are created in the old space.
1004
170068
  const v8::NewStringType type = v8::NewStringType::kInternalized;
1005
  v8::Local<v8::String> name_string =
1006
340136
      v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
1007
340136
  that->PrototypeTemplate()->Set(name_string, t);
1008
170068
  t->SetClassName(name_string);  // NODE_SET_PROTOTYPE_METHOD() compatibility.
1009
170068
}
1010
1011
32
inline void Environment::SetInstanceMethod(v8::Local<v8::FunctionTemplate> that,
1012
                                           const char* name,
1013
                                           v8::FunctionCallback callback) {
1014
32
  v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
1015
  v8::Local<v8::FunctionTemplate> t =
1016
      NewFunctionTemplate(callback, signature, v8::ConstructorBehavior::kThrow,
1017
32
                          v8::SideEffectType::kHasSideEffect);
1018
  // kInternalized strings are created in the old space.
1019
32
  const v8::NewStringType type = v8::NewStringType::kInternalized;
1020
  v8::Local<v8::String> name_string =
1021
64
      v8::String::NewFromUtf8(isolate(), name, type).ToLocalChecked();
1022
64
  that->InstanceTemplate()->Set(name_string, t);
1023
32
  t->SetClassName(name_string);
1024
32
}
1025
1026
186284
inline void Environment::SetConstructorFunction(
1027
    v8::Local<v8::Object> that,
1028
    const char* name,
1029
    v8::Local<v8::FunctionTemplate> tmpl,
1030
    SetConstructorFunctionFlag flag) {
1031
186284
  SetConstructorFunction(that, OneByteString(isolate(), name), tmpl, flag);
1032
186283
}
1033
1034
196016
inline void Environment::SetConstructorFunction(
1035
    v8::Local<v8::Object> that,
1036
    v8::Local<v8::String> name,
1037
    v8::Local<v8::FunctionTemplate> tmpl,
1038
    SetConstructorFunctionFlag flag) {
1039
196016
  if (LIKELY(flag == SetConstructorFunctionFlag::SET_CLASS_NAME))
1040
190929
    tmpl->SetClassName(name);
1041
392035
  that->Set(
1042
      context(),
1043
      name,
1044
980087
      tmpl->GetFunction(context()).ToLocalChecked()).Check();
1045
196018
}
1046
1047
339468
void Environment::AddCleanupHook(CleanupCallback fn, void* arg) {
1048
678937
  auto insertion_info = cleanup_hooks_.emplace(CleanupHookCallback {
1049
339468
    fn, arg, cleanup_hook_counter_++
1050
339468
  });
1051
  // Make sure there was no existing element with these values.
1052
339469
  CHECK_EQ(insertion_info.second, true);
1053
339469
}
1054
1055
325604
void Environment::RemoveCleanupHook(CleanupCallback fn, void* arg) {
1056
325604
  CleanupHookCallback search { fn, arg, 0 };
1057
325600
  cleanup_hooks_.erase(search);
1058
325612
}
1059
1060
871577
size_t CleanupHookCallback::Hash::operator()(
1061
    const CleanupHookCallback& cb) const {
1062
871577
  return std::hash<void*>()(cb.arg_);
1063
}
1064
1065
432935
bool CleanupHookCallback::Equal::operator()(
1066
    const CleanupHookCallback& a, const CleanupHookCallback& b) const {
1067

432935
  return a.fn_ == b.fn_ && a.arg_ == b.arg_;
1068
}
1069
1070
451
BaseObject* CleanupHookCallback::GetBaseObject() const {
1071
451
  if (fn_ == BaseObject::DeleteMe)
1072
429
    return static_cast<BaseObject*>(arg_);
1073
  else
1074
22
    return nullptr;
1075
}
1076
1077
template <typename T>
1078
22
void Environment::ForEachBaseObject(T&& iterator) {
1079

473
  for (const auto& hook : cleanup_hooks_) {
1080
451
    BaseObject* obj = hook.GetBaseObject();
1081

451
    if (obj != nullptr)
1082
429
      iterator(obj);
1083
  }
1084
22
}
1085
1086
template <typename T>
1087
8
void Environment::ForEachBindingData(T&& iterator) {
1088
  BindingDataStore* map = static_cast<BindingDataStore*>(
1089
24
      context()->GetAlignedPointerFromEmbedderData(
1090
8
          ContextEmbedderIndex::kBindingListIndex));
1091
  DCHECK_NOT_NULL(map);
1092
24
  for (auto& it : *map) {
1093
16
    iterator(it.first, it.second);
1094
  }
1095
8
}
1096
1097
653173
void Environment::modify_base_object_count(int64_t delta) {
1098
653173
  base_object_count_ += delta;
1099
653173
}
1100
1101
14
int64_t Environment::base_object_created_after_bootstrap() const {
1102
14
  return base_object_count_ - base_object_created_by_bootstrap_;
1103
}
1104
1105
2
int64_t Environment::base_object_count() const {
1106
2
  return base_object_count_;
1107
}
1108
1109
15
void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) {
1110
15
  CHECK(!main_utf16_);
1111
15
  main_utf16_ = std::move(str);
1112
15
}
1113
1114
417
void Environment::set_process_exit_handler(
1115
    std::function<void(Environment*, int)>&& handler) {
1116
417
  process_exit_handler_ = std::move(handler);
1117
417
}
1118
1119
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
1120
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
1121
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
1122
#define V(TypeName, PropertyName)                                             \
1123
  inline                                                                      \
1124
  v8::Local<TypeName> IsolateData::PropertyName() const {                     \
1125
    return PropertyName ## _ .Get(isolate_);                                  \
1126
  }
1127
217
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
1128
74973
  PER_ISOLATE_SYMBOL_PROPERTIES(VY)
1129
7081927
  PER_ISOLATE_STRING_PROPERTIES(VS)
1130
263140
#undef V
1131
16948
#undef VS
1132
8819
#undef VY
1133
4728
#undef VP
1134
30128
1135
116706
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
1136
17439
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
1137
22856
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
1138
84026
#define V(TypeName, PropertyName)                                             \
1139
86392
  inline v8::Local<TypeName> Environment::PropertyName() const {              \
1140
101
    return isolate_data()->PropertyName();                                    \
1141
118
  }
1142
32401
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
1143
102291
  PER_ISOLATE_SYMBOL_PROPERTIES(VY)
1144
3625509
  PER_ISOLATE_STRING_PROPERTIES(VS)
1145
123574
#undef V
1146
2525
#undef VS
1147
12988
#undef VY
1148
3126
#undef VP
1149
43445
1150
92075
#define V(PropertyName, TypeName)                                             \
1151
8492
  inline v8::Local<TypeName> Environment::PropertyName() const {              \
1152
15023
    return PersistentToLocal::Strong(PropertyName ## _);                      \
1153
50801
  }                                                                           \
1154
36829
  inline void Environment::set_ ## PropertyName(v8::Local<TypeName> value) {  \
1155
68
    PropertyName ## _.Reset(isolate(), value);                                \
1156
68
  }
1157
425629
  ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
1158
1759097
  ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1159
197552
#undef V
1160
187882
1161
6810110
v8::Local<v8::Context> Environment::context() const {
1162
7156704
  return PersistentToLocal::Strong(context_);
1163
527719
}
1164
89806
1165
74144
}  // namespace node
1166
15795
1167
28325
// These two files depend on each other. Including base_object-inl.h after this
1168
28705
// file is the easiest way to avoid issues with that circular dependency.
1169
51916
#include "base_object-inl.h"
1170
46675
1171
67011
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
1172
65621
1173
16170
#endif  // SRC_ENV_INL_H_