GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/env.h Lines: 47 47 100.0 %
Date: 2020-11-21 04:10:54 Branches: 0 0 - %

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_H_
23
#define SRC_ENV_H_
24
25
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
27
#include "aliased_buffer.h"
28
#if HAVE_INSPECTOR
29
#include "inspector_agent.h"
30
#include "inspector_profiler.h"
31
#endif
32
#include "callback_queue.h"
33
#include "debug_utils.h"
34
#include "handle_wrap.h"
35
#include "node.h"
36
#include "node_binding.h"
37
#include "node_main_instance.h"
38
#include "node_options.h"
39
#include "node_perf_common.h"
40
#include "req_wrap.h"
41
#include "util.h"
42
#include "uv.h"
43
#include "v8.h"
44
45
#include <array>
46
#include <atomic>
47
#include <cstdint>
48
#include <functional>
49
#include <iostream>
50
#include <list>
51
#include <unordered_map>
52
#include <unordered_set>
53
#include <vector>
54
55
namespace node {
56
57
namespace contextify {
58
class ContextifyScript;
59
class CompiledFnEntry;
60
}
61
62
namespace performance {
63
class PerformanceState;
64
}
65
66
namespace tracing {
67
class AgentWriterHandle;
68
}
69
70
#if HAVE_INSPECTOR
71
namespace profiler {
72
class V8CoverageConnection;
73
class V8CpuProfilerConnection;
74
class V8HeapProfilerConnection;
75
}  // namespace profiler
76
77
namespace inspector {
78
class ParentInspectorHandle;
79
}
80
#endif  // HAVE_INSPECTOR
81
82
namespace worker {
83
class Worker;
84
}
85
86
namespace loader {
87
class ModuleWrap;
88
89
struct PackageConfig {
90
  enum class Exists { Yes, No };
91
  enum class IsValid { Yes, No };
92
  enum class HasMain { Yes, No };
93
  enum class HasName { Yes, No };
94
  enum PackageType : uint32_t { None = 0, CommonJS, Module };
95
96
  const Exists exists;
97
  const IsValid is_valid;
98
  const HasMain has_main;
99
  const std::string main;
100
  const HasName has_name;
101
  const std::string name;
102
  const PackageType type;
103
104
  v8::Global<v8::Value> exports;
105
};
106
}  // namespace loader
107
108
enum class FsStatsOffset {
109
  kDev = 0,
110
  kMode,
111
  kNlink,
112
  kUid,
113
  kGid,
114
  kRdev,
115
  kBlkSize,
116
  kIno,
117
  kSize,
118
  kBlocks,
119
  kATimeSec,
120
  kATimeNsec,
121
  kMTimeSec,
122
  kMTimeNsec,
123
  kCTimeSec,
124
  kCTimeNsec,
125
  kBirthTimeSec,
126
  kBirthTimeNsec,
127
  kFsStatsFieldsNumber
128
};
129
130
// Stat fields buffers contain twice the number of entries in an uv_stat_t
131
// because `fs.StatWatcher` needs room to store 2 `fs.Stats` instances.
132
constexpr size_t kFsStatsBufferLength =
133
    static_cast<size_t>(FsStatsOffset::kFsStatsFieldsNumber) * 2;
134
135
// PER_ISOLATE_* macros: We have a lot of per-isolate properties
136
// and adding and maintaining their getters and setters by hand would be
137
// difficult so let's make the preprocessor generate them for us.
138
//
139
// In each macro, `V` is expected to be the name of a macro or function which
140
// accepts the number of arguments provided in each tuple in the macro body,
141
// typically two. The named function will be invoked against each tuple.
142
//
143
// Make sure that any macro V defined for use with the PER_ISOLATE_* macros is
144
// undefined again after use.
145
146
// Private symbols are per-isolate primitives but Environment proxies them
147
// for the sake of convenience.  Strings should be ASCII-only and have a
148
// "node:" prefix to avoid name clashes with third-party code.
149
#define PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(V)                              \
150
  V(alpn_buffer_private_symbol, "node:alpnBuffer")                            \
151
  V(arrow_message_private_symbol, "node:arrowMessage")                        \
152
  V(contextify_context_private_symbol, "node:contextify:context")             \
153
  V(contextify_global_private_symbol, "node:contextify:global")               \
154
  V(decorated_private_symbol, "node:decorated")                               \
155
  V(napi_type_tag, "node:napi:type_tag")                                      \
156
  V(napi_wrapper, "node:napi:wrapper")                                        \
157
  V(untransferable_object_private_symbol, "node:untransferableObject")        \
158
159
// Symbols are per-isolate primitives but Environment proxies them
160
// for the sake of convenience.
161
#define PER_ISOLATE_SYMBOL_PROPERTIES(V)                                       \
162
  V(async_id_symbol, "async_id_symbol")                                        \
163
  V(handle_onclose_symbol, "handle_onclose")                                   \
164
  V(no_message_symbol, "no_message_symbol")                                    \
165
  V(messaging_deserialize_symbol, "messaging_deserialize_symbol")              \
166
  V(messaging_transfer_symbol, "messaging_transfer_symbol")                    \
167
  V(messaging_clone_symbol, "messaging_clone_symbol")                          \
168
  V(messaging_transfer_list_symbol, "messaging_transfer_list_symbol")          \
169
  V(oninit_symbol, "oninit")                                                   \
170
  V(owner_symbol, "owner_symbol")                                              \
171
  V(onpskexchange_symbol, "onpskexchange")                                     \
172
  V(resource_symbol, "resource_symbol")                                        \
173
  V(trigger_async_id_symbol, "trigger_async_id_symbol")                        \
174
175
// Strings are per-isolate primitives but Environment proxies them
176
// for the sake of convenience.  Strings should be ASCII-only.
177
#define PER_ISOLATE_STRING_PROPERTIES(V)                                       \
178
  V(ack_string, "ack")                                                         \
179
  V(address_string, "address")                                                 \
180
  V(aliases_string, "aliases")                                                 \
181
  V(args_string, "args")                                                       \
182
  V(asn1curve_string, "asn1Curve")                                             \
183
  V(async_ids_stack_string, "async_ids_stack")                                 \
184
  V(bits_string, "bits")                                                       \
185
  V(block_list_string, "blockList")                                            \
186
  V(buffer_string, "buffer")                                                   \
187
  V(bytes_parsed_string, "bytesParsed")                                        \
188
  V(bytes_read_string, "bytesRead")                                            \
189
  V(bytes_written_string, "bytesWritten")                                      \
190
  V(cached_data_produced_string, "cachedDataProduced")                         \
191
  V(cached_data_rejected_string, "cachedDataRejected")                         \
192
  V(cached_data_string, "cachedData")                                          \
193
  V(cache_key_string, "cacheKey")                                              \
194
  V(change_string, "change")                                                   \
195
  V(channel_string, "channel")                                                 \
196
  V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite")           \
197
  V(clone_unsupported_type_str, "Cannot transfer object of unsupported type.") \
198
  V(code_string, "code")                                                       \
199
  V(commonjs_string, "commonjs")                                               \
200
  V(config_string, "config")                                                   \
201
  V(constants_string, "constants")                                             \
202
  V(crypto_dh_string, "dh")                                                    \
203
  V(crypto_dsa_string, "dsa")                                                  \
204
  V(crypto_ec_string, "ec")                                                    \
205
  V(crypto_ed25519_string, "ed25519")                                          \
206
  V(crypto_ed448_string, "ed448")                                              \
207
  V(crypto_x25519_string, "x25519")                                            \
208
  V(crypto_x448_string, "x448")                                                \
209
  V(crypto_rsa_string, "rsa")                                                  \
210
  V(crypto_rsa_pss_string, "rsa-pss")                                          \
211
  V(cwd_string, "cwd")                                                         \
212
  V(data_string, "data")                                                       \
213
  V(deserialize_info_string, "deserializeInfo")                                \
214
  V(dest_string, "dest")                                                       \
215
  V(destroyed_string, "destroyed")                                             \
216
  V(detached_string, "detached")                                               \
217
  V(dh_string, "DH")                                                           \
218
  V(divisor_length_string, "divisorLength")                                    \
219
  V(dns_a_string, "A")                                                         \
220
  V(dns_aaaa_string, "AAAA")                                                   \
221
  V(dns_caa_string, "CAA")                                                     \
222
  V(dns_critical_string, "critical")                                           \
223
  V(dns_cname_string, "CNAME")                                                 \
224
  V(dns_mx_string, "MX")                                                       \
225
  V(dns_naptr_string, "NAPTR")                                                 \
226
  V(dns_ns_string, "NS")                                                       \
227
  V(dns_ptr_string, "PTR")                                                     \
228
  V(dns_soa_string, "SOA")                                                     \
229
  V(dns_srv_string, "SRV")                                                     \
230
  V(dns_txt_string, "TXT")                                                     \
231
  V(done_string, "done")                                                       \
232
  V(duration_string, "duration")                                               \
233
  V(ecdh_string, "ECDH")                                                       \
234
  V(emit_string, "emit")                                                       \
235
  V(emit_warning_string, "emitWarning")                                        \
236
  V(empty_object_string, "{}")                                                 \
237
  V(encoding_string, "encoding")                                               \
238
  V(entries_string, "entries")                                                 \
239
  V(entry_type_string, "entryType")                                            \
240
  V(env_pairs_string, "envPairs")                                              \
241
  V(env_var_settings_string, "envVarSettings")                                 \
242
  V(errno_string, "errno")                                                     \
243
  V(error_string, "error")                                                     \
244
  V(exchange_string, "exchange")                                               \
245
  V(exit_code_string, "exitCode")                                              \
246
  V(expire_string, "expire")                                                   \
247
  V(exponent_string, "exponent")                                               \
248
  V(exports_string, "exports")                                                 \
249
  V(ext_key_usage_string, "ext_key_usage")                                     \
250
  V(external_stream_string, "_externalStream")                                 \
251
  V(family_string, "family")                                                   \
252
  V(fatal_exception_string, "_fatalException")                                 \
253
  V(fd_string, "fd")                                                           \
254
  V(fields_string, "fields")                                                   \
255
  V(file_string, "file")                                                       \
256
  V(fingerprint256_string, "fingerprint256")                                   \
257
  V(fingerprint_string, "fingerprint")                                         \
258
  V(flags_string, "flags")                                                     \
259
  V(fragment_string, "fragment")                                               \
260
  V(function_string, "function")                                               \
261
  V(get_data_clone_error_string, "_getDataCloneError")                         \
262
  V(get_shared_array_buffer_id_string, "_getSharedArrayBufferId")              \
263
  V(gid_string, "gid")                                                         \
264
  V(h2_string, "h2")                                                           \
265
  V(handle_string, "handle")                                                   \
266
  V(help_text_string, "helpText")                                              \
267
  V(homedir_string, "homedir")                                                 \
268
  V(host_string, "host")                                                       \
269
  V(hostmaster_string, "hostmaster")                                           \
270
  V(http_1_1_string, "http/1.1")                                               \
271
  V(identity_string, "identity")                                               \
272
  V(ignore_string, "ignore")                                                   \
273
  V(infoaccess_string, "infoAccess")                                           \
274
  V(inherit_string, "inherit")                                                 \
275
  V(input_string, "input")                                                     \
276
  V(internal_binding_string, "internalBinding")                                \
277
  V(internal_string, "internal")                                               \
278
  V(ipv4_string, "IPv4")                                                       \
279
  V(ipv6_string, "IPv6")                                                       \
280
  V(isclosing_string, "isClosing")                                             \
281
  V(issuer_string, "issuer")                                                   \
282
  V(issuercert_string, "issuerCertificate")                                    \
283
  V(jwk_d_string, "d")                                                         \
284
  V(jwk_dp_string, "dp")                                                       \
285
  V(jwk_dq_string, "dq")                                                       \
286
  V(jwk_dsa_string, "DSA")                                                     \
287
  V(jwk_e_string, "e")                                                         \
288
  V(jwk_ec_string, "EC")                                                       \
289
  V(jwk_g_string, "g")                                                         \
290
  V(jwk_k_string, "k")                                                         \
291
  V(jwk_p_string, "p")                                                         \
292
  V(jwk_q_string, "q")                                                         \
293
  V(jwk_qi_string, "qi")                                                       \
294
  V(jwk_kty_string, "kty")                                                     \
295
  V(jwk_n_string, "n")                                                         \
296
  V(jwk_oct_string, "oct")                                                     \
297
  V(jwk_rsa_string, "RSA")                                                     \
298
  V(jwk_x_string, "x")                                                         \
299
  V(jwk_y_string, "y")                                                         \
300
  V(kill_signal_string, "killSignal")                                          \
301
  V(kind_string, "kind")                                                       \
302
  V(length_string, "length")                                                   \
303
  V(library_string, "library")                                                 \
304
  V(mac_string, "mac")                                                         \
305
  V(max_buffer_string, "maxBuffer")                                            \
306
  V(message_port_constructor_string, "MessagePort")                            \
307
  V(message_port_string, "messagePort")                                        \
308
  V(message_string, "message")                                                 \
309
  V(messageerror_string, "messageerror")                                       \
310
  V(minttl_string, "minttl")                                                   \
311
  V(module_string, "module")                                                   \
312
  V(modulus_string, "modulus")                                                 \
313
  V(modulus_length_string, "modulusLength")                                    \
314
  V(name_string, "name")                                                       \
315
  V(named_curve_string, "namedCurve")                                          \
316
  V(netmask_string, "netmask")                                                 \
317
  V(next_string, "next")                                                       \
318
  V(nistcurve_string, "nistCurve")                                             \
319
  V(node_string, "node")                                                       \
320
  V(nsname_string, "nsname")                                                   \
321
  V(ocsp_request_string, "OCSPRequest")                                        \
322
  V(oncertcb_string, "oncertcb")                                               \
323
  V(onchange_string, "onchange")                                               \
324
  V(onclienthello_string, "onclienthello")                                     \
325
  V(oncomplete_string, "oncomplete")                                           \
326
  V(onconnection_string, "onconnection")                                       \
327
  V(ondone_string, "ondone")                                                   \
328
  V(onerror_string, "onerror")                                                 \
329
  V(onexit_string, "onexit")                                                   \
330
  V(onhandshakedone_string, "onhandshakedone")                                 \
331
  V(onhandshakestart_string, "onhandshakestart")                               \
332
  V(onkeylog_string, "onkeylog")                                               \
333
  V(onmessage_string, "onmessage")                                             \
334
  V(onnewsession_string, "onnewsession")                                       \
335
  V(onocspresponse_string, "onocspresponse")                                   \
336
  V(onreadstart_string, "onreadstart")                                         \
337
  V(onreadstop_string, "onreadstop")                                           \
338
  V(onshutdown_string, "onshutdown")                                           \
339
  V(onsignal_string, "onsignal")                                               \
340
  V(onunpipe_string, "onunpipe")                                               \
341
  V(onwrite_string, "onwrite")                                                 \
342
  V(openssl_error_stack, "opensslErrorStack")                                  \
343
  V(options_string, "options")                                                 \
344
  V(order_string, "order")                                                     \
345
  V(output_string, "output")                                                   \
346
  V(parse_error_string, "Parse Error")                                         \
347
  V(password_string, "password")                                               \
348
  V(path_string, "path")                                                       \
349
  V(pending_handle_string, "pendingHandle")                                    \
350
  V(pid_string, "pid")                                                         \
351
  V(pipe_source_string, "pipeSource")                                          \
352
  V(pipe_string, "pipe")                                                       \
353
  V(pipe_target_string, "pipeTarget")                                          \
354
  V(port1_string, "port1")                                                     \
355
  V(port2_string, "port2")                                                     \
356
  V(port_string, "port")                                                       \
357
  V(preference_string, "preference")                                           \
358
  V(primordials_string, "primordials")                                         \
359
  V(priority_string, "priority")                                               \
360
  V(process_string, "process")                                                 \
361
  V(promise_string, "promise")                                                 \
362
  V(psk_string, "psk")                                                         \
363
  V(pubkey_string, "pubkey")                                                   \
364
  V(public_exponent_string, "publicExponent")                                  \
365
  V(query_string, "query")                                                     \
366
  V(http3_alpn_string, "h3-29")                                                \
367
  V(rate_string, "rate")                                                       \
368
  V(raw_string, "raw")                                                         \
369
  V(read_host_object_string, "_readHostObject")                                \
370
  V(readable_string, "readable")                                               \
371
  V(reason_string, "reason")                                                   \
372
  V(refresh_string, "refresh")                                                 \
373
  V(regexp_string, "regexp")                                                   \
374
  V(rename_string, "rename")                                                   \
375
  V(replacement_string, "replacement")                                         \
376
  V(require_string, "require")                                                 \
377
  V(retry_string, "retry")                                                     \
378
  V(scheme_string, "scheme")                                                   \
379
  V(scopeid_string, "scopeid")                                                 \
380
  V(serial_number_string, "serialNumber")                                      \
381
  V(serial_string, "serial")                                                   \
382
  V(servername_string, "servername")                                           \
383
  V(service_string, "service")                                                 \
384
  V(session_id_string, "sessionId")                                            \
385
  V(shell_string, "shell")                                                     \
386
  V(signal_string, "signal")                                                   \
387
  V(sink_string, "sink")                                                       \
388
  V(size_string, "size")                                                       \
389
  V(sni_context_err_string, "Invalid SNI context")                             \
390
  V(sni_context_string, "sni_context")                                         \
391
  V(source_string, "source")                                                   \
392
  V(stack_string, "stack")                                                     \
393
  V(standard_name_string, "standardName")                                      \
394
  V(start_time_string, "startTime")                                            \
395
  V(state_string, "state")                                                     \
396
  V(stats_string, "stats")                                                     \
397
  V(status_string, "status")                                                   \
398
  V(stdio_string, "stdio")                                                     \
399
  V(subject_string, "subject")                                                 \
400
  V(subjectaltname_string, "subjectaltname")                                   \
401
  V(syscall_string, "syscall")                                                 \
402
  V(target_string, "target")                                                   \
403
  V(thread_id_string, "threadId")                                              \
404
  V(ticketkeycallback_string, "onticketkeycallback")                           \
405
  V(timeout_string, "timeout")                                                 \
406
  V(tls_ticket_string, "tlsTicket")                                            \
407
  V(transfer_string, "transfer")                                               \
408
  V(ttl_string, "ttl")                                                         \
409
  V(type_string, "type")                                                       \
410
  V(uid_string, "uid")                                                         \
411
  V(unknown_string, "<unknown>")                                               \
412
  V(url_special_ftp_string, "ftp:")                                            \
413
  V(url_special_file_string, "file:")                                          \
414
  V(url_special_http_string, "http:")                                          \
415
  V(url_special_https_string, "https:")                                        \
416
  V(url_special_ws_string, "ws:")                                              \
417
  V(url_special_wss_string, "wss:")                                            \
418
  V(url_string, "url")                                                         \
419
  V(username_string, "username")                                               \
420
  V(valid_from_string, "valid_from")                                           \
421
  V(valid_to_string, "valid_to")                                               \
422
  V(value_string, "value")                                                     \
423
  V(verify_error_string, "verifyError")                                        \
424
  V(version_string, "version")                                                 \
425
  V(weight_string, "weight")                                                   \
426
  V(windows_hide_string, "windowsHide")                                        \
427
  V(windows_verbatim_arguments_string, "windowsVerbatimArguments")             \
428
  V(wrap_string, "wrap")                                                       \
429
  V(writable_string, "writable")                                               \
430
  V(write_host_object_string, "_writeHostObject")                              \
431
  V(write_queue_size_string, "writeQueueSize")                                 \
432
  V(x_forwarded_string, "x-forwarded-for")                                     \
433
  V(zero_return_string, "ZERO_RETURN")
434
435
#if defined(NODE_EXPERIMENTAL_QUIC) && NODE_EXPERIMENTAL_QUIC
436
# define QUIC_ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)                       \
437
  V(quicclientsession_instance_template, v8::ObjectTemplate)                   \
438
  V(quicserversession_instance_template, v8::ObjectTemplate)                   \
439
  V(quicserverstream_instance_template, v8::ObjectTemplate)                    \
440
  V(quicsocketsendwrap_instance_template, v8::ObjectTemplate)
441
#else
442
# define QUIC_ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
443
#endif
444
445
#define ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)                             \
446
  V(async_wrap_ctor_template, v8::FunctionTemplate)                            \
447
  V(async_wrap_object_ctor_template, v8::FunctionTemplate)                     \
448
  V(base_object_ctor_template, v8::FunctionTemplate)                           \
449
  V(binding_data_ctor_template, v8::FunctionTemplate)                          \
450
  V(blocklist_instance_template, v8::ObjectTemplate)                           \
451
  V(compiled_fn_entry_template, v8::ObjectTemplate)                            \
452
  V(dir_instance_template, v8::ObjectTemplate)                                 \
453
  V(fd_constructor_template, v8::ObjectTemplate)                               \
454
  V(fdclose_constructor_template, v8::ObjectTemplate)                          \
455
  V(filehandlereadwrap_template, v8::ObjectTemplate)                           \
456
  V(fsreqpromise_constructor_template, v8::ObjectTemplate)                     \
457
  V(handle_wrap_ctor_template, v8::FunctionTemplate)                           \
458
  V(histogram_instance_template, v8::ObjectTemplate)                           \
459
  V(http2settings_constructor_template, v8::ObjectTemplate)                    \
460
  V(http2stream_constructor_template, v8::ObjectTemplate)                      \
461
  V(http2ping_constructor_template, v8::ObjectTemplate)                        \
462
  V(i18n_converter_template, v8::ObjectTemplate)                               \
463
  V(libuv_stream_wrap_ctor_template, v8::FunctionTemplate)                     \
464
  V(message_port_constructor_template, v8::FunctionTemplate)                   \
465
  V(microtask_queue_ctor_template, v8::FunctionTemplate)                       \
466
  V(pipe_constructor_template, v8::FunctionTemplate)                           \
467
  V(promise_wrap_template, v8::ObjectTemplate)                                 \
468
  V(sab_lifetimepartner_constructor_template, v8::FunctionTemplate)            \
469
  V(script_context_constructor_template, v8::FunctionTemplate)                 \
470
  V(secure_context_constructor_template, v8::FunctionTemplate)                 \
471
  V(shutdown_wrap_template, v8::ObjectTemplate)                                \
472
  V(streambaseoutputstream_constructor_template, v8::ObjectTemplate)           \
473
  V(qlogoutputstream_constructor_template, v8::ObjectTemplate)                 \
474
  V(tcp_constructor_template, v8::FunctionTemplate)                            \
475
  V(tty_constructor_template, v8::FunctionTemplate)                            \
476
  V(write_wrap_template, v8::ObjectTemplate)                                   \
477
  V(worker_heap_snapshot_taker_template, v8::ObjectTemplate)                   \
478
  QUIC_ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
479
480
#if defined(NODE_EXPERIMENTAL_QUIC) && NODE_EXPERIMENTAL_QUIC
481
# define QUIC_ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)                          \
482
  V(quic_on_socket_close_function, v8::Function)                               \
483
  V(quic_on_socket_server_busy_function, v8::Function)                         \
484
  V(quic_on_session_cert_function, v8::Function)                               \
485
  V(quic_on_session_client_hello_function, v8::Function)                       \
486
  V(quic_on_session_close_function, v8::Function)                              \
487
  V(quic_on_session_handshake_function, v8::Function)                          \
488
  V(quic_on_session_keylog_function, v8::Function)                             \
489
  V(quic_on_session_path_validation_function, v8::Function)                    \
490
  V(quic_on_session_use_preferred_address_function, v8::Function)              \
491
  V(quic_on_session_qlog_function, v8::Function)                               \
492
  V(quic_on_session_ready_function, v8::Function)                              \
493
  V(quic_on_session_status_function, v8::Function)                             \
494
  V(quic_on_session_ticket_function, v8::Function)                             \
495
  V(quic_on_session_version_negotiation_function, v8::Function)                \
496
  V(quic_on_stream_close_function, v8::Function)                               \
497
  V(quic_on_stream_error_function, v8::Function)                               \
498
  V(quic_on_stream_ready_function, v8::Function)                               \
499
  V(quic_on_stream_reset_function, v8::Function)                               \
500
  V(quic_on_stream_headers_function, v8::Function)                             \
501
  V(quic_on_stream_blocked_function, v8::Function)
502
#else
503
# define QUIC_ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
504
#endif
505
506
#define ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)                                \
507
  V(async_hooks_after_function, v8::Function)                                  \
508
  V(async_hooks_before_function, v8::Function)                                 \
509
  V(async_hooks_callback_trampoline, v8::Function)                             \
510
  V(async_hooks_binding, v8::Object)                                           \
511
  V(async_hooks_destroy_function, v8::Function)                                \
512
  V(async_hooks_init_function, v8::Function)                                   \
513
  V(async_hooks_promise_resolve_function, v8::Function)                        \
514
  V(buffer_prototype_object, v8::Object)                                       \
515
  V(crypto_key_object_constructor, v8::Function)                               \
516
  V(crypto_key_object_handle_constructor, v8::Function)                        \
517
  V(crypto_key_object_private_constructor, v8::Function)                       \
518
  V(crypto_key_object_public_constructor, v8::Function)                        \
519
  V(crypto_key_object_secret_constructor, v8::Function)                        \
520
  V(domexception_function, v8::Function)                                       \
521
  V(enhance_fatal_stack_after_inspector, v8::Function)                         \
522
  V(enhance_fatal_stack_before_inspector, v8::Function)                        \
523
  V(fs_use_promises_symbol, v8::Symbol)                                        \
524
  V(host_import_module_dynamically_callback, v8::Function)                     \
525
  V(host_initialize_import_meta_object_callback, v8::Function)                 \
526
  V(http2session_on_altsvc_function, v8::Function)                             \
527
  V(http2session_on_error_function, v8::Function)                              \
528
  V(http2session_on_frame_error_function, v8::Function)                        \
529
  V(http2session_on_goaway_data_function, v8::Function)                        \
530
  V(http2session_on_headers_function, v8::Function)                            \
531
  V(http2session_on_origin_function, v8::Function)                             \
532
  V(http2session_on_ping_function, v8::Function)                               \
533
  V(http2session_on_priority_function, v8::Function)                           \
534
  V(http2session_on_settings_function, v8::Function)                           \
535
  V(http2session_on_stream_close_function, v8::Function)                       \
536
  V(http2session_on_stream_trailers_function, v8::Function)                    \
537
  V(internal_binding_loader, v8::Function)                                     \
538
  V(immediate_callback_function, v8::Function)                                 \
539
  V(inspector_console_extension_installer, v8::Function)                       \
540
  V(messaging_deserialize_create_object, v8::Function)                         \
541
  V(message_port, v8::Object)                                                  \
542
  V(native_module_require, v8::Function)                                       \
543
  V(performance_entry_callback, v8::Function)                                  \
544
  V(performance_entry_template, v8::Function)                                  \
545
  V(prepare_stack_trace_callback, v8::Function)                                \
546
  V(process_object, v8::Object)                                                \
547
  V(primordials, v8::Object)                                                   \
548
  V(promise_hook_handler, v8::Function)                                        \
549
  V(promise_reject_callback, v8::Function)                                     \
550
  V(script_data_constructor_function, v8::Function)                            \
551
  V(source_map_cache_getter, v8::Function)                                     \
552
  V(tick_callback_function, v8::Function)                                      \
553
  V(timers_callback_function, v8::Function)                                    \
554
  V(tls_wrap_constructor_function, v8::Function)                               \
555
  V(trace_category_state_function, v8::Function)                               \
556
  V(udp_constructor_function, v8::Function)                                    \
557
  V(url_constructor_function, v8::Function)                                    \
558
  QUIC_ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
559
560
class Environment;
561
struct AllocatedBuffer;
562
563
typedef size_t SnapshotIndex;
564
9164
class IsolateData : public MemoryRetainer {
565
 public:
566
  IsolateData(v8::Isolate* isolate,
567
              uv_loop_t* event_loop,
568
              MultiIsolatePlatform* platform = nullptr,
569
              ArrayBufferAllocator* node_allocator = nullptr,
570
              const std::vector<size_t>* indexes = nullptr);
571
22
  SET_MEMORY_INFO_NAME(IsolateData)
572
22
  SET_SELF_SIZE(IsolateData)
573
  void MemoryInfo(MemoryTracker* tracker) const override;
574
  std::vector<size_t> Serialize(v8::SnapshotCreator* creator);
575
576
  inline uv_loop_t* event_loop() const;
577
  inline MultiIsolatePlatform* platform() const;
578
  inline std::shared_ptr<PerIsolateOptions> options();
579
  inline void set_options(std::shared_ptr<PerIsolateOptions> options);
580
581
  inline NodeArrayBufferAllocator* node_allocator() const;
582
583
  inline worker::Worker* worker_context() const;
584
  inline void set_worker_context(worker::Worker* context);
585
586
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
587
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
588
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
589
#define V(TypeName, PropertyName)                                             \
590
  inline v8::Local<TypeName> PropertyName() const;
591
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
592
  PER_ISOLATE_SYMBOL_PROPERTIES(VY)
593
  PER_ISOLATE_STRING_PROPERTIES(VS)
594
#undef V
595
#undef VY
596
#undef VS
597
#undef VP
598
  inline v8::Local<v8::String> async_wrap_provider(int index) const;
599
600
  size_t max_young_gen_size = 1;
601
  std::unordered_map<const char*, v8::Eternal<v8::String>> static_str_map;
602
603
  inline v8::Isolate* isolate() const;
604
  IsolateData(const IsolateData&) = delete;
605
  IsolateData& operator=(const IsolateData&) = delete;
606
  IsolateData(IsolateData&&) = delete;
607
  IsolateData& operator=(IsolateData&&) = delete;
608
609
 private:
610
  void DeserializeProperties(const std::vector<size_t>* indexes);
611
  void CreateProperties();
612
613
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
614
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
615
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
616
#define V(TypeName, PropertyName)                                             \
617
  v8::Eternal<TypeName> PropertyName ## _;
618
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
619
  PER_ISOLATE_SYMBOL_PROPERTIES(VY)
620
  PER_ISOLATE_STRING_PROPERTIES(VS)
621
#undef V
622
#undef VY
623
#undef VS
624
#undef VP
625
  // Keep a list of all Persistent strings used for AsyncWrap Provider types.
626
  std::array<v8::Eternal<v8::String>, AsyncWrap::PROVIDERS_LENGTH>
627
      async_wrap_providers_;
628
629
  v8::Isolate* const isolate_;
630
  uv_loop_t* const event_loop_;
631
  NodeArrayBufferAllocator* const node_allocator_;
632
  MultiIsolatePlatform* platform_;
633
  std::shared_ptr<PerIsolateOptions> options_;
634
  worker::Worker* worker_context_ = nullptr;
635
};
636
637
10593
struct ContextInfo {
638
10593
  explicit ContextInfo(const std::string& name) : name(name) {}
639
  const std::string name;
640
  std::string origin;
641
  bool is_default = false;
642
};
643
644
class EnabledDebugList;
645
646
class KVStore {
647
 public:
648
5311
  KVStore() = default;
649
4840
  virtual ~KVStore() = default;
650
  KVStore(const KVStore&) = delete;
651
  KVStore& operator=(const KVStore&) = delete;
652
  KVStore(KVStore&&) = delete;
653
  KVStore& operator=(KVStore&&) = delete;
654
655
  virtual v8::MaybeLocal<v8::String> Get(v8::Isolate* isolate,
656
                                         v8::Local<v8::String> key) const = 0;
657
  virtual v8::Maybe<std::string> Get(const char* key) const = 0;
658
  virtual void Set(v8::Isolate* isolate,
659
                   v8::Local<v8::String> key,
660
                   v8::Local<v8::String> value) = 0;
661
  virtual int32_t Query(v8::Isolate* isolate,
662
                        v8::Local<v8::String> key) const = 0;
663
  virtual int32_t Query(const char* key) const = 0;
664
  virtual void Delete(v8::Isolate* isolate, v8::Local<v8::String> key) = 0;
665
  virtual v8::Local<v8::Array> Enumerate(v8::Isolate* isolate) const = 0;
666
667
  virtual std::shared_ptr<KVStore> Clone(v8::Isolate* isolate) const;
668
  virtual v8::Maybe<bool> AssignFromObject(v8::Local<v8::Context> context,
669
                                           v8::Local<v8::Object> entries);
670
671
  static std::shared_ptr<KVStore> CreateMapKVStore();
672
};
673
674
namespace per_process {
675
extern std::shared_ptr<KVStore> system_environment;
676
}
677
678
struct EnvSerializeInfo;
679
680
class AsyncHooks : public MemoryRetainer {
681
 public:
682
22
  SET_MEMORY_INFO_NAME(AsyncHooks)
683
22
  SET_SELF_SIZE(AsyncHooks)
684
  void MemoryInfo(MemoryTracker* tracker) const override;
685
686
  // Reason for both UidFields and Fields are that one is stored as a double*
687
  // and the other as a uint32_t*.
688
  enum Fields {
689
    kInit,
690
    kBefore,
691
    kAfter,
692
    kDestroy,
693
    kPromiseResolve,
694
    kTotals,
695
    kCheck,
696
    kStackLength,
697
    kUsesExecutionAsyncResource,
698
    kFieldsCount,
699
  };
700
701
  enum UidFields {
702
    kExecutionAsyncId,
703
    kTriggerAsyncId,
704
    kAsyncIdCounter,
705
    kDefaultTriggerAsyncId,
706
    kUidFieldsCount,
707
  };
708
709
  inline AliasedUint32Array& fields();
710
  inline AliasedFloat64Array& async_id_fields();
711
  inline AliasedFloat64Array& async_ids_stack();
712
  inline v8::Local<v8::Array> js_execution_async_resources();
713
  // Returns the native executionAsyncResource value at stack index `index`.
714
  // Resources provided on the JS side are not stored on the native stack,
715
  // in which case an empty `Local<>` is returned.
716
  // The `js_execution_async_resources` array contains the value in that case.
717
  inline v8::Local<v8::Object> native_execution_async_resource(size_t index);
718
719
  inline v8::Local<v8::String> provider_string(int idx);
720
721
  inline void no_force_checks();
722
  inline Environment* env();
723
724
  inline void push_async_context(double async_id, double trigger_async_id,
725
      v8::Local<v8::Object> execution_async_resource_);
726
  inline bool pop_async_context(double async_id);
727
  inline void clear_async_id_stack();  // Used in fatal exceptions.
728
729
  AsyncHooks(const AsyncHooks&) = delete;
730
  AsyncHooks& operator=(const AsyncHooks&) = delete;
731
  AsyncHooks(AsyncHooks&&) = delete;
732
  AsyncHooks& operator=(AsyncHooks&&) = delete;
733
9134
  ~AsyncHooks() = default;
734
735
  // Used to set the kDefaultTriggerAsyncId in a scope. This is instead of
736
  // passing the trigger_async_id along with other constructor arguments.
737
  class DefaultTriggerAsyncIdScope {
738
   public:
739
    DefaultTriggerAsyncIdScope() = delete;
740
    explicit DefaultTriggerAsyncIdScope(Environment* env,
741
                                        double init_trigger_async_id);
742
    explicit DefaultTriggerAsyncIdScope(AsyncWrap* async_wrap);
743
    ~DefaultTriggerAsyncIdScope();
744
745
    DefaultTriggerAsyncIdScope(const DefaultTriggerAsyncIdScope&) = delete;
746
    DefaultTriggerAsyncIdScope& operator=(const DefaultTriggerAsyncIdScope&) =
747
        delete;
748
    DefaultTriggerAsyncIdScope(DefaultTriggerAsyncIdScope&&) = delete;
749
    DefaultTriggerAsyncIdScope& operator=(DefaultTriggerAsyncIdScope&&) =
750
        delete;
751
752
   private:
753
    AsyncHooks* async_hooks_;
754
    double old_default_trigger_async_id_;
755
  };
756
757
4718
  struct SerializeInfo {
758
    AliasedBufferInfo async_ids_stack;
759
    AliasedBufferInfo fields;
760
    AliasedBufferInfo async_id_fields;
761
    SnapshotIndex js_execution_async_resources;
762
    std::vector<SnapshotIndex> native_execution_async_resources;
763
  };
764
765
  SerializeInfo Serialize(v8::Local<v8::Context> context,
766
                          v8::SnapshotCreator* creator);
767
  void Deserialize(v8::Local<v8::Context> context);
768
769
 private:
770
  friend class Environment;  // So we can call the constructor.
771
  explicit AsyncHooks(v8::Isolate* isolate, const SerializeInfo* info);
772
773
  // Stores the ids of the current execution context stack.
774
  AliasedFloat64Array async_ids_stack_;
775
  // Attached to a Uint32Array that tracks the number of active hooks for
776
  // each type.
777
  AliasedUint32Array fields_;
778
  // Attached to a Float64Array that tracks the state of async resources.
779
  AliasedFloat64Array async_id_fields_;
780
781
  void grow_async_ids_stack();
782
783
  v8::Global<v8::Array> js_execution_async_resources_;
784
  std::vector<v8::Global<v8::Object>> native_execution_async_resources_;
785
786
  // Non-empty during deserialization
787
  const SerializeInfo* info_ = nullptr;
788
};
789
790
class ImmediateInfo : public MemoryRetainer {
791
 public:
792
  inline AliasedUint32Array& fields();
793
  inline uint32_t count() const;
794
  inline uint32_t ref_count() const;
795
  inline bool has_outstanding() const;
796
  inline void ref_count_inc(uint32_t increment);
797
  inline void ref_count_dec(uint32_t decrement);
798
799
  ImmediateInfo(const ImmediateInfo&) = delete;
800
  ImmediateInfo& operator=(const ImmediateInfo&) = delete;
801
  ImmediateInfo(ImmediateInfo&&) = delete;
802
  ImmediateInfo& operator=(ImmediateInfo&&) = delete;
803
4567
  ~ImmediateInfo() = default;
804
805
22
  SET_MEMORY_INFO_NAME(ImmediateInfo)
806
22
  SET_SELF_SIZE(ImmediateInfo)
807
  void MemoryInfo(MemoryTracker* tracker) const override;
808
809
  struct SerializeInfo {
810
    AliasedBufferInfo fields;
811
  };
812
  SerializeInfo Serialize(v8::Local<v8::Context> context,
813
                          v8::SnapshotCreator* creator);
814
  void Deserialize(v8::Local<v8::Context> context);
815
816
 private:
817
  friend class Environment;  // So we can call the constructor.
818
  explicit ImmediateInfo(v8::Isolate* isolate, const SerializeInfo* info);
819
820
  enum Fields { kCount, kRefCount, kHasOutstanding, kFieldsCount };
821
822
  AliasedUint32Array fields_;
823
};
824
825
class TickInfo : public MemoryRetainer {
826
 public:
827
  inline AliasedUint8Array& fields();
828
  inline bool has_tick_scheduled() const;
829
  inline bool has_rejection_to_warn() const;
830
831
22
  SET_MEMORY_INFO_NAME(TickInfo)
832
22
  SET_SELF_SIZE(TickInfo)
833
  void MemoryInfo(MemoryTracker* tracker) const override;
834
835
  TickInfo(const TickInfo&) = delete;
836
  TickInfo& operator=(const TickInfo&) = delete;
837
  TickInfo(TickInfo&&) = delete;
838
  TickInfo& operator=(TickInfo&&) = delete;
839
4567
  ~TickInfo() = default;
840
841
  struct SerializeInfo {
842
    AliasedBufferInfo fields;
843
  };
844
  SerializeInfo Serialize(v8::Local<v8::Context> context,
845
                          v8::SnapshotCreator* creator);
846
  void Deserialize(v8::Local<v8::Context> context);
847
848
 private:
849
  friend class Environment;  // So we can call the constructor.
850
  explicit TickInfo(v8::Isolate* isolate, const SerializeInfo* info);
851
852
  enum Fields { kHasTickScheduled = 0, kHasRejectionToWarn, kFieldsCount };
853
854
  AliasedUint8Array fields_;
855
};
856
857
9134
class TrackingTraceStateObserver :
858
    public v8::TracingController::TraceStateObserver {
859
 public:
860
5038
  explicit TrackingTraceStateObserver(Environment* env) : env_(env) {}
861
862
87
  void OnTraceEnabled() override {
863
87
    UpdateTraceCategoryState();
864
87
  }
865
866
32
  void OnTraceDisabled() override {
867
32
    UpdateTraceCategoryState();
868
32
  }
869
870
 private:
871
  void UpdateTraceCategoryState();
872
873
  Environment* env_;
874
};
875
876
class ShouldNotAbortOnUncaughtScope {
877
 public:
878
  explicit inline ShouldNotAbortOnUncaughtScope(Environment* env);
879
  inline void Close();
880
  inline ~ShouldNotAbortOnUncaughtScope();
881
  ShouldNotAbortOnUncaughtScope(const ShouldNotAbortOnUncaughtScope&) = delete;
882
  ShouldNotAbortOnUncaughtScope& operator=(
883
      const ShouldNotAbortOnUncaughtScope&) = delete;
884
  ShouldNotAbortOnUncaughtScope(ShouldNotAbortOnUncaughtScope&&) = delete;
885
  ShouldNotAbortOnUncaughtScope& operator=(ShouldNotAbortOnUncaughtScope&&) =
886
      delete;
887
888
 private:
889
  Environment* env_;
890
};
891
892
class CleanupHookCallback {
893
 public:
894
628194
  CleanupHookCallback(void (*fn)(void*),
895
                      void* arg,
896
                      uint64_t insertion_order_counter)
897
628194
      : fn_(fn), arg_(arg), insertion_order_counter_(insertion_order_counter) {}
898
899
  // Only hashes `arg_`, since that is usually enough to identify the hook.
900
5038
  struct Hash {
901
    inline size_t operator()(const CleanupHookCallback& cb) const;
902
  };
903
904
  // Compares by `fn_` and `arg_` being equal.
905
5038
  struct Equal {
906
    inline bool operator()(const CleanupHookCallback& a,
907
                           const CleanupHookCallback& b) const;
908
  };
909
910
  inline BaseObject* GetBaseObject() const;
911
912
 private:
913
  friend class Environment;
914
  void (*fn_)(void*);
915
  void* arg_;
916
917
  // We keep track of the insertion order for these objects, so that we can
918
  // call the callbacks in reverse order when we are cleaning up.
919
  uint64_t insertion_order_counter_;
920
};
921
922
431105
struct PropInfo {
923
  std::string name;     // name for debugging
924
  size_t id;            // In the list - in case there are any empty entires
925
  SnapshotIndex index;  // In the snapshot
926
};
927
928
4595
struct EnvSerializeInfo {
929
  std::vector<std::string> native_modules;
930
  AsyncHooks::SerializeInfo async_hooks;
931
  TickInfo::SerializeInfo tick_info;
932
  ImmediateInfo::SerializeInfo immediate_info;
933
  performance::PerformanceState::SerializeInfo performance_state;
934
  AliasedBufferInfo stream_base_state;
935
  AliasedBufferInfo should_abort_on_uncaught_toggle;
936
937
  std::vector<PropInfo> persistent_templates;
938
  std::vector<PropInfo> persistent_values;
939
940
  SnapshotIndex context;
941
  friend std::ostream& operator<<(std::ostream& o, const EnvSerializeInfo& i);
942
};
943
944
class Environment : public MemoryRetainer {
945
 public:
946
  Environment(const Environment&) = delete;
947
  Environment& operator=(const Environment&) = delete;
948
  Environment(Environment&&) = delete;
949
  Environment& operator=(Environment&&) = delete;
950
951
22
  SET_MEMORY_INFO_NAME(Environment)
952
953
  inline size_t SelfSize() const override;
954
44
  bool IsRootNode() const override { return true; }
955
  void MemoryInfo(MemoryTracker* tracker) const override;
956
957
  EnvSerializeInfo Serialize(v8::SnapshotCreator* creator);
958
  void CreateProperties();
959
  void DeserializeProperties(const EnvSerializeInfo* info);
960
961
  void PrintAllBaseObjects();
962
  void VerifyNoStrongBaseObjects();
963
  // Should be called before InitializeInspector()
964
  void InitializeDiagnostics();
965
966
  std::string GetCwd();
967
968
#if HAVE_INSPECTOR
969
  // If the environment is created for a worker, pass parent_handle and
970
  // the ownership if transferred into the Environment.
971
  int InitializeInspector(
972
      std::unique_ptr<inspector::ParentInspectorHandle> parent_handle);
973
#endif
974
975
  v8::MaybeLocal<v8::Value> BootstrapInternalLoaders();
976
  v8::MaybeLocal<v8::Value> BootstrapNode();
977
  v8::MaybeLocal<v8::Value> RunBootstrapping();
978
979
  inline size_t async_callback_scope_depth() const;
980
  inline void PushAsyncCallbackScope();
981
  inline void PopAsyncCallbackScope();
982
983
  static inline Environment* GetCurrent(v8::Isolate* isolate);
984
  static inline Environment* GetCurrent(v8::Local<v8::Context> context);
985
  static inline Environment* GetCurrent(
986
      const v8::FunctionCallbackInfo<v8::Value>& info);
987
988
  template <typename T>
989
  static inline Environment* GetCurrent(
990
      const v8::PropertyCallbackInfo<T>& info);
991
992
  // Methods created using SetMethod(), SetPrototypeMethod(), etc. inside
993
  // this scope can access the created T* object using
994
  // GetBindingData<T>(args) later.
995
  template <typename T>
996
  T* AddBindingData(v8::Local<v8::Context> context,
997
                    v8::Local<v8::Object> target);
998
  template <typename T, typename U>
999
  static inline T* GetBindingData(const v8::PropertyCallbackInfo<U>& info);
1000
  template <typename T>
1001
  static inline T* GetBindingData(
1002
      const v8::FunctionCallbackInfo<v8::Value>& info);
1003
  template <typename T>
1004
  static inline T* GetBindingData(v8::Local<v8::Context> context);
1005
1006
  typedef std::unordered_map<
1007
      FastStringKey,
1008
      BaseObjectPtr<BaseObject>,
1009
      FastStringKey::Hash> BindingDataStore;
1010
1011
  // Create an Environment without initializing a main Context. Use
1012
  // InitializeMainContext() to initialize a main context for it.
1013
  Environment(IsolateData* isolate_data,
1014
              v8::Isolate* isolate,
1015
              const std::vector<std::string>& args,
1016
              const std::vector<std::string>& exec_args,
1017
              const EnvSerializeInfo* env_info,
1018
              EnvironmentFlags::Flags flags,
1019
              ThreadId thread_id);
1020
  void InitializeMainContext(v8::Local<v8::Context> context,
1021
                             const EnvSerializeInfo* env_info);
1022
  // Create an Environment and initialize the provided main context for it.
1023
  Environment(IsolateData* isolate_data,
1024
              v8::Local<v8::Context> context,
1025
              const std::vector<std::string>& args,
1026
              const std::vector<std::string>& exec_args,
1027
              const EnvSerializeInfo* env_info,
1028
              EnvironmentFlags::Flags flags,
1029
              ThreadId thread_id);
1030
  ~Environment() override;
1031
1032
  void InitializeLibuv();
1033
  inline const std::vector<std::string>& exec_argv();
1034
  inline const std::vector<std::string>& argv();
1035
  const std::string& exec_path() const;
1036
1037
  typedef void (*HandleCleanupCb)(Environment* env,
1038
                                  uv_handle_t* handle,
1039
                                  void* arg);
1040
  struct HandleCleanup {
1041
    uv_handle_t* handle_;
1042
    HandleCleanupCb cb_;
1043
    void* arg_;
1044
  };
1045
1046
  void RegisterHandleCleanups();
1047
  void CleanupHandles();
1048
  void Exit(int code);
1049
  void ExitEnv();
1050
1051
  // Register clean-up cb to be called on environment destruction.
1052
  inline void RegisterHandleCleanup(uv_handle_t* handle,
1053
                                    HandleCleanupCb cb,
1054
                                    void* arg);
1055
1056
  template <typename T, typename OnCloseCallback>
1057
  inline void CloseHandle(T* handle, OnCloseCallback callback);
1058
1059
  inline void AssignToContext(v8::Local<v8::Context> context,
1060
                              const ContextInfo& info);
1061
1062
  inline v8::Isolate* isolate() const;
1063
  inline uv_loop_t* event_loop() const;
1064
  inline void TryLoadAddon(
1065
      const char* filename,
1066
      int flags,
1067
      const std::function<bool(binding::DLib*)>& was_loaded);
1068
1069
  static inline Environment* from_timer_handle(uv_timer_t* handle);
1070
  inline uv_timer_t* timer_handle();
1071
1072
  static inline Environment* from_immediate_check_handle(uv_check_t* handle);
1073
  inline uv_check_t* immediate_check_handle();
1074
  inline uv_idle_t* immediate_idle_handle();
1075
1076
  inline void IncreaseWaitingRequestCounter();
1077
  inline void DecreaseWaitingRequestCounter();
1078
1079
  inline AsyncHooks* async_hooks();
1080
  inline ImmediateInfo* immediate_info();
1081
  inline TickInfo* tick_info();
1082
  inline uint64_t timer_base() const;
1083
  inline std::shared_ptr<KVStore> env_vars();
1084
  inline void set_env_vars(std::shared_ptr<KVStore> env_vars);
1085
1086
  inline IsolateData* isolate_data() const;
1087
1088
  inline bool printed_error() const;
1089
  inline void set_printed_error(bool value);
1090
1091
  void PrintSyncTrace() const;
1092
  inline void set_trace_sync_io(bool value);
1093
1094
  inline void set_force_context_aware(bool value);
1095
  inline bool force_context_aware() const;
1096
1097
  // This stores whether the --abort-on-uncaught-exception flag was passed
1098
  // to Node.
1099
  inline bool abort_on_uncaught_exception() const;
1100
  inline void set_abort_on_uncaught_exception(bool value);
1101
  // This is a pseudo-boolean that keeps track of whether an uncaught exception
1102
  // should abort the process or not if --abort-on-uncaught-exception was
1103
  // passed to Node. If the flag was not passed, it is ignored.
1104
  inline AliasedUint32Array& should_abort_on_uncaught_toggle();
1105
1106
  inline AliasedInt32Array& stream_base_state();
1107
1108
  // The necessary API for async_hooks.
1109
  inline double new_async_id();
1110
  inline double execution_async_id();
1111
  inline double trigger_async_id();
1112
  inline double get_default_trigger_async_id();
1113
1114
  // List of id's that have been destroyed and need the destroy() cb called.
1115
  inline std::vector<double>* destroy_async_id_list();
1116
1117
  std::set<std::string> native_modules_with_cache;
1118
  std::set<std::string> native_modules_without_cache;
1119
  // This is only filled during deserialization. We use a vector since
1120
  // it's only used for tests.
1121
  std::vector<std::string> native_modules_in_snapshot;
1122
1123
  std::unordered_multimap<int, loader::ModuleWrap*> hash_to_module_map;
1124
  std::unordered_map<uint32_t, loader::ModuleWrap*> id_to_module_map;
1125
  std::unordered_map<uint32_t, contextify::ContextifyScript*>
1126
      id_to_script_map;
1127
  std::unordered_map<uint32_t, contextify::CompiledFnEntry*> id_to_function_map;
1128
1129
  inline uint32_t get_next_module_id();
1130
  inline uint32_t get_next_script_id();
1131
  inline uint32_t get_next_function_id();
1132
1133
1250719
  EnabledDebugList* enabled_debug_list() { return &enabled_debug_list_; }
1134
1135
  inline performance::PerformanceState* performance_state();
1136
  inline std::unordered_map<std::string, uint64_t>* performance_marks();
1137
1138
  void CollectUVExceptionInfo(v8::Local<v8::Value> context,
1139
                              int errorno,
1140
                              const char* syscall = nullptr,
1141
                              const char* message = nullptr,
1142
                              const char* path = nullptr,
1143
                              const char* dest = nullptr);
1144
1145
  // If this flag is set, calls into JS (if they would be observable
1146
  // from userland) must be avoided.  This flag does not indicate whether
1147
  // calling into JS is allowed from a VM perspective at this point.
1148
  inline bool can_call_into_js() const;
1149
  inline void set_can_call_into_js(bool can_call_into_js);
1150
1151
  // Increase or decrease a counter that manages whether this Environment
1152
  // keeps the event loop alive on its own or not. The counter starts out at 0,
1153
  // meaning it does not, and any positive value will make it keep the event
1154
  // loop alive.
1155
  // This is used by Workers to manage their own .ref()/.unref() implementation,
1156
  // as Workers aren't directly associated with their own libuv handles.
1157
  inline void add_refs(int64_t diff);
1158
1159
  inline bool has_run_bootstrapping_code() const;
1160
  inline void set_has_run_bootstrapping_code(bool has_run_bootstrapping_code);
1161
1162
  inline bool has_serialized_options() const;
1163
  inline void set_has_serialized_options(bool has_serialized_options);
1164
1165
  inline bool is_main_thread() const;
1166
  inline bool should_not_register_esm_loader() const;
1167
  inline bool owns_process_state() const;
1168
  inline bool owns_inspector() const;
1169
  inline bool tracks_unmanaged_fds() const;
1170
  inline uint64_t thread_id() const;
1171
  inline worker::Worker* worker_context() const;
1172
  Environment* worker_parent_env() const;
1173
  inline void add_sub_worker_context(worker::Worker* context);
1174
  inline void remove_sub_worker_context(worker::Worker* context);
1175
  void stop_sub_worker_contexts();
1176
  template <typename Fn>
1177
  inline void ForEachWorker(Fn&& iterator);
1178
  inline bool is_stopping() const;
1179
  inline void set_stopping(bool value);
1180
  inline std::list<node_module>* extra_linked_bindings();
1181
  inline node_module* extra_linked_bindings_head();
1182
  inline const Mutex& extra_linked_bindings_mutex() const;
1183
1184
  inline bool filehandle_close_warning() const;
1185
  inline void set_filehandle_close_warning(bool on);
1186
1187
  inline void set_source_maps_enabled(bool on);
1188
  inline bool source_maps_enabled() const;
1189
1190
  inline void ThrowError(const char* errmsg);
1191
  inline void ThrowTypeError(const char* errmsg);
1192
  inline void ThrowRangeError(const char* errmsg);
1193
  inline void ThrowErrnoException(int errorno,
1194
                                  const char* syscall = nullptr,
1195
                                  const char* message = nullptr,
1196
                                  const char* path = nullptr);
1197
  inline void ThrowUVException(int errorno,
1198
                               const char* syscall = nullptr,
1199
                               const char* message = nullptr,
1200
                               const char* path = nullptr,
1201
                               const char* dest = nullptr);
1202
1203
  inline v8::Local<v8::FunctionTemplate>
1204
      NewFunctionTemplate(v8::FunctionCallback callback,
1205
                          v8::Local<v8::Signature> signature =
1206
                              v8::Local<v8::Signature>(),
1207
                          v8::ConstructorBehavior behavior =
1208
                              v8::ConstructorBehavior::kAllow,
1209
                          v8::SideEffectType side_effect =
1210
                              v8::SideEffectType::kHasSideEffect);
1211
1212
  // Convenience methods for NewFunctionTemplate().
1213
  inline void SetMethod(v8::Local<v8::Object> that,
1214
                        const char* name,
1215
                        v8::FunctionCallback callback);
1216
1217
  inline void SetProtoMethod(v8::Local<v8::FunctionTemplate> that,
1218
                             const char* name,
1219
                             v8::FunctionCallback callback);
1220
1221
  inline void SetInstanceMethod(v8::Local<v8::FunctionTemplate> that,
1222
                                const char* name,
1223
                                v8::FunctionCallback callback);
1224
1225
1226
  // Safe variants denote the function has no side effects.
1227
  inline void SetMethodNoSideEffect(v8::Local<v8::Object> that,
1228
                                    const char* name,
1229
                                    v8::FunctionCallback callback);
1230
  inline void SetProtoMethodNoSideEffect(v8::Local<v8::FunctionTemplate> that,
1231
                                         const char* name,
1232
                                         v8::FunctionCallback callback);
1233
1234
  void AtExit(void (*cb)(void* arg), void* arg);
1235
  void RunAtExitCallbacks();
1236
1237
  void RunWeakRefCleanup();
1238
1239
  // Strings and private symbols are shared across shared contexts
1240
  // The getters simply proxy to the per-isolate primitive.
1241
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
1242
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
1243
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
1244
#define V(TypeName, PropertyName)                                             \
1245
  inline v8::Local<TypeName> PropertyName() const;
1246
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
1247
  PER_ISOLATE_SYMBOL_PROPERTIES(VY)
1248
  PER_ISOLATE_STRING_PROPERTIES(VS)
1249
#undef V
1250
#undef VS
1251
#undef VY
1252
#undef VP
1253
1254
#define V(PropertyName, TypeName)                                             \
1255
  inline v8::Local<TypeName> PropertyName() const;                            \
1256
  inline void set_ ## PropertyName(v8::Local<TypeName> value);
1257
  ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1258
  ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
1259
#undef V
1260
1261
  inline v8::Local<v8::Context> context() const;
1262
1263
#if HAVE_INSPECTOR
1264
44794
  inline inspector::Agent* inspector_agent() const {
1265
44794
    return inspector_agent_.get();
1266
  }
1267
1268
  inline bool is_in_inspector_console_call() const;
1269
  inline void set_is_in_inspector_console_call(bool value);
1270
#endif
1271
1272
  typedef ListHead<HandleWrap, &HandleWrap::handle_wrap_queue_> HandleWrapQueue;
1273
  typedef ListHead<ReqWrapBase, &ReqWrapBase::req_wrap_queue_> ReqWrapQueue;
1274
1275
59072
  inline HandleWrapQueue* handle_wrap_queue() { return &handle_wrap_queue_; }
1276
76495
  inline ReqWrapQueue* req_wrap_queue() { return &req_wrap_queue_; }
1277
1278
1
  inline bool EmitProcessEnvWarning() {
1279
1
    bool current_value = emit_env_nonstring_warning_;
1280
1
    emit_env_nonstring_warning_ = false;
1281
1
    return current_value;
1282
  }
1283
1284
1
  inline bool EmitErrNameWarning() {
1285
1
    bool current_value = emit_err_name_warning_;
1286
1
    emit_err_name_warning_ = false;
1287
1
    return current_value;
1288
  }
1289
1290
  // cb will be called as cb(env) on the next event loop iteration.
1291
  // Unlike the JS setImmediate() function, nested SetImmediate() calls will
1292
  // be run without returning control to the event loop, similar to nextTick().
1293
  template <typename Fn>
1294
  inline void SetImmediate(
1295
      Fn&& cb, CallbackFlags::Flags flags = CallbackFlags::kRefed);
1296
  template <typename Fn>
1297
  // This behaves like SetImmediate() but can be called from any thread.
1298
  inline void SetImmediateThreadsafe(
1299
      Fn&& cb, CallbackFlags::Flags flags = CallbackFlags::kRefed);
1300
  // This behaves like V8's Isolate::RequestInterrupt(), but also accounts for
1301
  // the event loop (i.e. combines the V8 function with SetImmediate()).
1302
  // The passed callback may not throw exceptions.
1303
  // This function can be called from any thread.
1304
  template <typename Fn>
1305
  inline void RequestInterrupt(Fn&& cb);
1306
  // This needs to be available for the JS-land setImmediate().
1307
  void ToggleImmediateRef(bool ref);
1308
1309
  inline void PushShouldNotAbortOnUncaughtScope();
1310
  inline void PopShouldNotAbortOnUncaughtScope();
1311
  inline bool inside_should_not_abort_on_uncaught_scope() const;
1312
1313
  static inline Environment* ForAsyncHooks(AsyncHooks* hooks);
1314
1315
  v8::Local<v8::Value> GetNow();
1316
  void ScheduleTimer(int64_t duration);
1317
  void ToggleTimerRef(bool ref);
1318
1319
  inline void AddCleanupHook(void (*fn)(void*), void* arg);
1320
  inline void RemoveCleanupHook(void (*fn)(void*), void* arg);
1321
  void RunCleanup();
1322
1323
  static size_t NearHeapLimitCallback(void* data,
1324
                                      size_t current_heap_limit,
1325
                                      size_t initial_heap_limit);
1326
  static void BuildEmbedderGraph(v8::Isolate* isolate,
1327
                                 v8::EmbedderGraph* graph,
1328
                                 void* data);
1329
1330
  inline std::shared_ptr<EnvironmentOptions> options();
1331
  inline std::shared_ptr<ExclusiveAccess<HostPort>> inspector_host_port();
1332
1333
  // The BaseObject count is a debugging helper that makes sure that there are
1334
  // no memory leaks caused by BaseObjects staying alive longer than expected
1335
  // (in particular, no circular BaseObjectPtr references).
1336
  inline void modify_base_object_count(int64_t delta);
1337
  inline int64_t base_object_count() const;
1338
1339
3
  inline int32_t stack_trace_limit() const { return 10; }
1340
1341
#if HAVE_INSPECTOR
1342
  void set_coverage_connection(
1343
      std::unique_ptr<profiler::V8CoverageConnection> connection);
1344
  profiler::V8CoverageConnection* coverage_connection();
1345
1346
  inline void set_coverage_directory(const char* directory);
1347
  inline const std::string& coverage_directory() const;
1348
1349
  void set_cpu_profiler_connection(
1350
      std::unique_ptr<profiler::V8CpuProfilerConnection> connection);
1351
  profiler::V8CpuProfilerConnection* cpu_profiler_connection();
1352
1353
  inline void set_cpu_prof_name(const std::string& name);
1354
  inline const std::string& cpu_prof_name() const;
1355
1356
  inline void set_cpu_prof_interval(uint64_t interval);
1357
  inline uint64_t cpu_prof_interval() const;
1358
1359
  inline void set_cpu_prof_dir(const std::string& dir);
1360
  inline const std::string& cpu_prof_dir() const;
1361
1362
  void set_heap_profiler_connection(
1363
      std::unique_ptr<profiler::V8HeapProfilerConnection> connection);
1364
  profiler::V8HeapProfilerConnection* heap_profiler_connection();
1365
1366
  inline void set_heap_prof_name(const std::string& name);
1367
  inline const std::string& heap_prof_name() const;
1368
1369
  inline void set_heap_prof_dir(const std::string& dir);
1370
  inline const std::string& heap_prof_dir() const;
1371
1372
  inline void set_heap_prof_interval(uint64_t interval);
1373
  inline uint64_t heap_prof_interval() const;
1374
1375
#endif  // HAVE_INSPECTOR
1376
1377
  inline void set_main_utf16(std::unique_ptr<v8::String::Value>);
1378
  inline void set_process_exit_handler(
1379
      std::function<void(Environment*, int)>&& handler);
1380
1381
  void RunAndClearNativeImmediates(bool only_refed = false);
1382
  void RunAndClearInterrupts();
1383
1384
  inline std::unordered_map<char*, std::unique_ptr<v8::BackingStore>>*
1385
      released_allocated_buffers();
1386
1387
  void AddUnmanagedFd(int fd);
1388
  void RemoveUnmanagedFd(int fd);
1389
1390
 private:
1391
  inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
1392
                         const char* errmsg);
1393
1394
  std::list<binding::DLib> loaded_addons_;
1395
  v8::Isolate* const isolate_;
1396
  IsolateData* const isolate_data_;
1397
  uv_timer_t timer_handle_;
1398
  uv_check_t immediate_check_handle_;
1399
  uv_idle_t immediate_idle_handle_;
1400
  uv_async_t task_queues_async_;
1401
  int64_t task_queues_async_refs_ = 0;
1402
1403
  AsyncHooks async_hooks_;
1404
  ImmediateInfo immediate_info_;
1405
  TickInfo tick_info_;
1406
  const uint64_t timer_base_;
1407
  std::shared_ptr<KVStore> env_vars_;
1408
  bool printed_error_ = false;
1409
  bool trace_sync_io_ = false;
1410
  bool emit_env_nonstring_warning_ = true;
1411
  bool emit_err_name_warning_ = true;
1412
  bool emit_filehandle_warning_ = true;
1413
  bool source_maps_enabled_ = false;
1414
1415
  size_t async_callback_scope_depth_ = 0;
1416
  std::vector<double> destroy_async_id_list_;
1417
1418
#if HAVE_INSPECTOR
1419
  std::unique_ptr<profiler::V8CoverageConnection> coverage_connection_;
1420
  std::unique_ptr<profiler::V8CpuProfilerConnection> cpu_profiler_connection_;
1421
  std::string coverage_directory_;
1422
  std::string cpu_prof_dir_;
1423
  std::string cpu_prof_name_;
1424
  uint64_t cpu_prof_interval_;
1425
  std::unique_ptr<profiler::V8HeapProfilerConnection> heap_profiler_connection_;
1426
  std::string heap_prof_dir_;
1427
  std::string heap_prof_name_;
1428
  uint64_t heap_prof_interval_;
1429
#endif  // HAVE_INSPECTOR
1430
1431
  std::shared_ptr<EnvironmentOptions> options_;
1432
  // options_ contains debug options parsed from CLI arguments,
1433
  // while inspector_host_port_ stores the actual inspector host
1434
  // and port being used. For example the port is -1 by default
1435
  // and can be specified as 0 (meaning any port allocated when the
1436
  // server starts listening), but when the inspector server starts
1437
  // the inspector_host_port_->port() will be the actual port being
1438
  // used.
1439
  std::shared_ptr<ExclusiveAccess<HostPort>> inspector_host_port_;
1440
  std::vector<std::string> exec_argv_;
1441
  std::vector<std::string> argv_;
1442
  std::string exec_path_;
1443
1444
  bool is_processing_heap_limit_callback_ = false;
1445
  int64_t heap_limit_snapshot_taken_ = 0;
1446
1447
  uint32_t module_id_counter_ = 0;
1448
  uint32_t script_id_counter_ = 0;
1449
  uint32_t function_id_counter_ = 0;
1450
1451
  AliasedUint32Array should_abort_on_uncaught_toggle_;
1452
  int should_not_abort_scope_counter_ = 0;
1453
1454
  std::unique_ptr<TrackingTraceStateObserver> trace_state_observer_;
1455
1456
  AliasedInt32Array stream_base_state_;
1457
1458
  uint64_t environment_start_time_;
1459
  std::unique_ptr<performance::PerformanceState> performance_state_;
1460
  std::unordered_map<std::string, uint64_t> performance_marks_;
1461
1462
  bool has_run_bootstrapping_code_ = false;
1463
  bool has_serialized_options_ = false;
1464
1465
  std::atomic_bool can_call_into_js_ { true };
1466
  uint64_t flags_;
1467
  uint64_t thread_id_;
1468
  std::unordered_set<worker::Worker*> sub_worker_contexts_;
1469
1470
  static void* const kNodeContextTagPtr;
1471
  static int const kNodeContextTag;
1472
1473
#if HAVE_INSPECTOR
1474
  std::unique_ptr<inspector::Agent> inspector_agent_;
1475
  bool is_in_inspector_console_call_ = false;
1476
#endif
1477
1478
  // handle_wrap_queue_ and req_wrap_queue_ needs to be at a fixed offset from
1479
  // the start of the class because it is used by
1480
  // src/node_postmortem_metadata.cc to calculate offsets and generate debug
1481
  // symbols for Environment, which assumes that the position of members in
1482
  // memory are predictable. For more information please refer to
1483
  // `doc/guides/node-postmortem-support.md`
1484
  friend int GenDebugSymbols();
1485
  HandleWrapQueue handle_wrap_queue_;
1486
  ReqWrapQueue req_wrap_queue_;
1487
  std::list<HandleCleanup> handle_cleanup_queue_;
1488
  int handle_cleanup_waiting_ = 0;
1489
  int request_waiting_ = 0;
1490
1491
  EnabledDebugList enabled_debug_list_;
1492
1493
  std::list<node_module> extra_linked_bindings_;
1494
  Mutex extra_linked_bindings_mutex_;
1495
1496
  static void RunTimers(uv_timer_t* handle);
1497
1498
  struct ExitCallback {
1499
    void (*cb_)(void* arg);
1500
    void* arg_;
1501
  };
1502
1503
  std::list<ExitCallback> at_exit_functions_;
1504
1505
  typedef CallbackQueue<void, Environment*> NativeImmediateQueue;
1506
  NativeImmediateQueue native_immediates_;
1507
  Mutex native_immediates_threadsafe_mutex_;
1508
  NativeImmediateQueue native_immediates_threadsafe_;
1509
  NativeImmediateQueue native_immediates_interrupts_;
1510
  // Also guarded by native_immediates_threadsafe_mutex_. This can be used when
1511
  // trying to post tasks from other threads to an Environment, as the libuv
1512
  // handle for the immediate queues (task_queues_async_) may not be initialized
1513
  // yet or already have been destroyed.
1514
  bool task_queues_async_initialized_ = false;
1515
1516
  std::atomic<Environment**> interrupt_data_ {nullptr};
1517
  void RequestInterruptFromV8();
1518
  static void CheckImmediate(uv_check_t* handle);
1519
1520
  BindingDataStore bindings_;
1521
1522
  // Use an unordered_set, so that we have efficient insertion and removal.
1523
  std::unordered_set<CleanupHookCallback,
1524
                     CleanupHookCallback::Hash,
1525
                     CleanupHookCallback::Equal> cleanup_hooks_;
1526
  uint64_t cleanup_hook_counter_ = 0;
1527
  bool started_cleanup_ = false;
1528
1529
  int64_t base_object_count_ = 0;
1530
  int64_t initial_base_object_count_ = 0;
1531
  std::atomic_bool is_stopping_ { false };
1532
1533
  std::unordered_set<int> unmanaged_fds_;
1534
1535
  std::function<void(Environment*, int)> process_exit_handler_ {
1536
      DefaultProcessExitHandler };
1537
1538
  template <typename T>
1539
  void ForEachBaseObject(T&& iterator);
1540
1541
#define V(PropertyName, TypeName) v8::Global<TypeName> PropertyName ## _;
1542
  ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1543
  ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
1544
#undef V
1545
1546
  v8::Global<v8::Context> context_;
1547
1548
  // Keeps the main script source alive is one was passed to LoadEnvironment().
1549
  // We should probably find a way to just use plain `v8::String`s created from
1550
  // the source passed to LoadEnvironment() directly instead.
1551
  std::unique_ptr<v8::String::Value> main_utf16_;
1552
1553
  // Used by AllocatedBuffer::release() to keep track of the BackingStore for
1554
  // a given pointer.
1555
  std::unordered_map<char*, std::unique_ptr<v8::BackingStore>>
1556
      released_allocated_buffers_;
1557
};
1558
1559
}  // namespace node
1560
1561
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
1562
1563
#endif  // SRC_ENV_H_