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-12-12 04:11:07 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
9186
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
10609
struct ContextInfo {
638
10609
  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
5327
  KVStore() = default;
649
4855
  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
9156
  ~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
4731
  struct SerializeInfo {
758
    AliasedBufferIndex async_ids_stack;
759
    AliasedBufferIndex fields;
760
    AliasedBufferIndex 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
4578
  ~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
    AliasedBufferIndex 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
4578
  ~TickInfo() = default;
840
841
  struct SerializeInfo {
842
    AliasedBufferIndex 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
9156
class TrackingTraceStateObserver :
858
    public v8::TracingController::TraceStateObserver {
859
 public:
860
5050
  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
  typedef void (*Callback)(void*);
895
896
637725
  CleanupHookCallback(Callback fn,
897
                      void* arg,
898
                      uint64_t insertion_order_counter)
899
637725
      : fn_(fn), arg_(arg), insertion_order_counter_(insertion_order_counter) {}
900
901
  // Only hashes `arg_`, since that is usually enough to identify the hook.
902
5050
  struct Hash {
903
    inline size_t operator()(const CleanupHookCallback& cb) const;
904
  };
905
906
  // Compares by `fn_` and `arg_` being equal.
907
5050
  struct Equal {
908
    inline bool operator()(const CleanupHookCallback& a,
909
                           const CleanupHookCallback& b) const;
910
  };
911
912
  inline BaseObject* GetBaseObject() const;
913
914
 private:
915
  friend class Environment;
916
  Callback fn_;
917
  void* arg_;
918
919
  // We keep track of the insertion order for these objects, so that we can
920
  // call the callbacks in reverse order when we are cleaning up.
921
  uint64_t insertion_order_counter_;
922
};
923
924
432314
struct PropInfo {
925
  std::string name;     // name for debugging
926
  size_t id;            // In the list - in case there are any empty entires
927
  SnapshotIndex index;  // In the snapshot
928
};
929
930
4608
struct EnvSerializeInfo {
931
  std::vector<std::string> native_modules;
932
  AsyncHooks::SerializeInfo async_hooks;
933
  TickInfo::SerializeInfo tick_info;
934
  ImmediateInfo::SerializeInfo immediate_info;
935
  performance::PerformanceState::SerializeInfo performance_state;
936
  AliasedBufferIndex stream_base_state;
937
  AliasedBufferIndex should_abort_on_uncaught_toggle;
938
939
  std::vector<PropInfo> persistent_templates;
940
  std::vector<PropInfo> persistent_values;
941
942
  SnapshotIndex context;
943
  friend std::ostream& operator<<(std::ostream& o, const EnvSerializeInfo& i);
944
};
945
946
class Environment : public MemoryRetainer {
947
 public:
948
  Environment(const Environment&) = delete;
949
  Environment& operator=(const Environment&) = delete;
950
  Environment(Environment&&) = delete;
951
  Environment& operator=(Environment&&) = delete;
952
953
22
  SET_MEMORY_INFO_NAME(Environment)
954
955
  inline size_t SelfSize() const override;
956
44
  bool IsRootNode() const override { return true; }
957
  void MemoryInfo(MemoryTracker* tracker) const override;
958
959
  EnvSerializeInfo Serialize(v8::SnapshotCreator* creator);
960
  void CreateProperties();
961
  void DeserializeProperties(const EnvSerializeInfo* info);
962
963
  void PrintAllBaseObjects();
964
  void VerifyNoStrongBaseObjects();
965
  // Should be called before InitializeInspector()
966
  void InitializeDiagnostics();
967
968
  std::string GetCwd();
969
970
#if HAVE_INSPECTOR
971
  // If the environment is created for a worker, pass parent_handle and
972
  // the ownership if transferred into the Environment.
973
  int InitializeInspector(
974
      std::unique_ptr<inspector::ParentInspectorHandle> parent_handle);
975
#endif
976
977
  v8::MaybeLocal<v8::Value> BootstrapInternalLoaders();
978
  v8::MaybeLocal<v8::Value> BootstrapNode();
979
  v8::MaybeLocal<v8::Value> RunBootstrapping();
980
981
  inline size_t async_callback_scope_depth() const;
982
  inline void PushAsyncCallbackScope();
983
  inline void PopAsyncCallbackScope();
984
985
  static inline Environment* GetCurrent(v8::Isolate* isolate);
986
  static inline Environment* GetCurrent(v8::Local<v8::Context> context);
987
  static inline Environment* GetCurrent(
988
      const v8::FunctionCallbackInfo<v8::Value>& info);
989
990
  template <typename T>
991
  static inline Environment* GetCurrent(
992
      const v8::PropertyCallbackInfo<T>& info);
993
994
  // Methods created using SetMethod(), SetPrototypeMethod(), etc. inside
995
  // this scope can access the created T* object using
996
  // GetBindingData<T>(args) later.
997
  template <typename T>
998
  T* AddBindingData(v8::Local<v8::Context> context,
999
                    v8::Local<v8::Object> target);
1000
  template <typename T, typename U>
1001
  static inline T* GetBindingData(const v8::PropertyCallbackInfo<U>& info);
1002
  template <typename T>
1003
  static inline T* GetBindingData(
1004
      const v8::FunctionCallbackInfo<v8::Value>& info);
1005
  template <typename T>
1006
  static inline T* GetBindingData(v8::Local<v8::Context> context);
1007
1008
  typedef std::unordered_map<
1009
      FastStringKey,
1010
      BaseObjectPtr<BaseObject>,
1011
      FastStringKey::Hash> BindingDataStore;
1012
1013
  // Create an Environment without initializing a main Context. Use
1014
  // InitializeMainContext() to initialize a main context for it.
1015
  Environment(IsolateData* isolate_data,
1016
              v8::Isolate* isolate,
1017
              const std::vector<std::string>& args,
1018
              const std::vector<std::string>& exec_args,
1019
              const EnvSerializeInfo* env_info,
1020
              EnvironmentFlags::Flags flags,
1021
              ThreadId thread_id);
1022
  void InitializeMainContext(v8::Local<v8::Context> context,
1023
                             const EnvSerializeInfo* env_info);
1024
  // Create an Environment and initialize the provided main context for it.
1025
  Environment(IsolateData* isolate_data,
1026
              v8::Local<v8::Context> context,
1027
              const std::vector<std::string>& args,
1028
              const std::vector<std::string>& exec_args,
1029
              const EnvSerializeInfo* env_info,
1030
              EnvironmentFlags::Flags flags,
1031
              ThreadId thread_id);
1032
  ~Environment() override;
1033
1034
  void InitializeLibuv();
1035
  inline const std::vector<std::string>& exec_argv();
1036
  inline const std::vector<std::string>& argv();
1037
  const std::string& exec_path() const;
1038
1039
  typedef void (*HandleCleanupCb)(Environment* env,
1040
                                  uv_handle_t* handle,
1041
                                  void* arg);
1042
  struct HandleCleanup {
1043
    uv_handle_t* handle_;
1044
    HandleCleanupCb cb_;
1045
    void* arg_;
1046
  };
1047
1048
  void RegisterHandleCleanups();
1049
  void CleanupHandles();
1050
  void Exit(int code);
1051
  void ExitEnv();
1052
1053
  // Register clean-up cb to be called on environment destruction.
1054
  inline void RegisterHandleCleanup(uv_handle_t* handle,
1055
                                    HandleCleanupCb cb,
1056
                                    void* arg);
1057
1058
  template <typename T, typename OnCloseCallback>
1059
  inline void CloseHandle(T* handle, OnCloseCallback callback);
1060
1061
  inline void AssignToContext(v8::Local<v8::Context> context,
1062
                              const ContextInfo& info);
1063
1064
  inline v8::Isolate* isolate() const;
1065
  inline uv_loop_t* event_loop() const;
1066
  inline void TryLoadAddon(
1067
      const char* filename,
1068
      int flags,
1069
      const std::function<bool(binding::DLib*)>& was_loaded);
1070
1071
  static inline Environment* from_timer_handle(uv_timer_t* handle);
1072
  inline uv_timer_t* timer_handle();
1073
1074
  static inline Environment* from_immediate_check_handle(uv_check_t* handle);
1075
  inline uv_check_t* immediate_check_handle();
1076
  inline uv_idle_t* immediate_idle_handle();
1077
1078
  inline void IncreaseWaitingRequestCounter();
1079
  inline void DecreaseWaitingRequestCounter();
1080
1081
  inline AsyncHooks* async_hooks();
1082
  inline ImmediateInfo* immediate_info();
1083
  inline TickInfo* tick_info();
1084
  inline uint64_t timer_base() const;
1085
  inline std::shared_ptr<KVStore> env_vars();
1086
  inline void set_env_vars(std::shared_ptr<KVStore> env_vars);
1087
1088
  inline IsolateData* isolate_data() const;
1089
1090
  inline bool printed_error() const;
1091
  inline void set_printed_error(bool value);
1092
1093
  void PrintSyncTrace() const;
1094
  inline void set_trace_sync_io(bool value);
1095
1096
  inline void set_force_context_aware(bool value);
1097
  inline bool force_context_aware() const;
1098
1099
  // This stores whether the --abort-on-uncaught-exception flag was passed
1100
  // to Node.
1101
  inline bool abort_on_uncaught_exception() const;
1102
  inline void set_abort_on_uncaught_exception(bool value);
1103
  // This is a pseudo-boolean that keeps track of whether an uncaught exception
1104
  // should abort the process or not if --abort-on-uncaught-exception was
1105
  // passed to Node. If the flag was not passed, it is ignored.
1106
  inline AliasedUint32Array& should_abort_on_uncaught_toggle();
1107
1108
  inline AliasedInt32Array& stream_base_state();
1109
1110
  // The necessary API for async_hooks.
1111
  inline double new_async_id();
1112
  inline double execution_async_id();
1113
  inline double trigger_async_id();
1114
  inline double get_default_trigger_async_id();
1115
1116
  // List of id's that have been destroyed and need the destroy() cb called.
1117
  inline std::vector<double>* destroy_async_id_list();
1118
1119
  std::set<std::string> native_modules_with_cache;
1120
  std::set<std::string> native_modules_without_cache;
1121
  // This is only filled during deserialization. We use a vector since
1122
  // it's only used for tests.
1123
  std::vector<std::string> native_modules_in_snapshot;
1124
1125
  std::unordered_multimap<int, loader::ModuleWrap*> hash_to_module_map;
1126
  std::unordered_map<uint32_t, loader::ModuleWrap*> id_to_module_map;
1127
  std::unordered_map<uint32_t, contextify::ContextifyScript*>
1128
      id_to_script_map;
1129
  std::unordered_map<uint32_t, contextify::CompiledFnEntry*> id_to_function_map;
1130
1131
  inline uint32_t get_next_module_id();
1132
  inline uint32_t get_next_script_id();
1133
  inline uint32_t get_next_function_id();
1134
1135
1256531
  EnabledDebugList* enabled_debug_list() { return &enabled_debug_list_; }
1136
1137
  inline performance::PerformanceState* performance_state();
1138
  inline std::unordered_map<std::string, uint64_t>* performance_marks();
1139
1140
  void CollectUVExceptionInfo(v8::Local<v8::Value> context,
1141
                              int errorno,
1142
                              const char* syscall = nullptr,
1143
                              const char* message = nullptr,
1144
                              const char* path = nullptr,
1145
                              const char* dest = nullptr);
1146
1147
  // If this flag is set, calls into JS (if they would be observable
1148
  // from userland) must be avoided.  This flag does not indicate whether
1149
  // calling into JS is allowed from a VM perspective at this point.
1150
  inline bool can_call_into_js() const;
1151
  inline void set_can_call_into_js(bool can_call_into_js);
1152
1153
  // Increase or decrease a counter that manages whether this Environment
1154
  // keeps the event loop alive on its own or not. The counter starts out at 0,
1155
  // meaning it does not, and any positive value will make it keep the event
1156
  // loop alive.
1157
  // This is used by Workers to manage their own .ref()/.unref() implementation,
1158
  // as Workers aren't directly associated with their own libuv handles.
1159
  inline void add_refs(int64_t diff);
1160
1161
  inline bool has_run_bootstrapping_code() const;
1162
  inline void set_has_run_bootstrapping_code(bool has_run_bootstrapping_code);
1163
1164
  inline bool has_serialized_options() const;
1165
  inline void set_has_serialized_options(bool has_serialized_options);
1166
1167
  inline bool is_main_thread() const;
1168
  inline bool should_not_register_esm_loader() const;
1169
  inline bool owns_process_state() const;
1170
  inline bool owns_inspector() const;
1171
  inline bool tracks_unmanaged_fds() const;
1172
  inline uint64_t thread_id() const;
1173
  inline worker::Worker* worker_context() const;
1174
  Environment* worker_parent_env() const;
1175
  inline void add_sub_worker_context(worker::Worker* context);
1176
  inline void remove_sub_worker_context(worker::Worker* context);
1177
  void stop_sub_worker_contexts();
1178
  template <typename Fn>
1179
  inline void ForEachWorker(Fn&& iterator);
1180
  inline bool is_stopping() const;
1181
  inline void set_stopping(bool value);
1182
  inline std::list<node_module>* extra_linked_bindings();
1183
  inline node_module* extra_linked_bindings_head();
1184
  inline const Mutex& extra_linked_bindings_mutex() const;
1185
1186
  inline bool filehandle_close_warning() const;
1187
  inline void set_filehandle_close_warning(bool on);
1188
1189
  inline void set_source_maps_enabled(bool on);
1190
  inline bool source_maps_enabled() const;
1191
1192
  inline void ThrowError(const char* errmsg);
1193
  inline void ThrowTypeError(const char* errmsg);
1194
  inline void ThrowRangeError(const char* errmsg);
1195
  inline void ThrowErrnoException(int errorno,
1196
                                  const char* syscall = nullptr,
1197
                                  const char* message = nullptr,
1198
                                  const char* path = nullptr);
1199
  inline void ThrowUVException(int errorno,
1200
                               const char* syscall = nullptr,
1201
                               const char* message = nullptr,
1202
                               const char* path = nullptr,
1203
                               const char* dest = nullptr);
1204
1205
  inline v8::Local<v8::FunctionTemplate>
1206
      NewFunctionTemplate(v8::FunctionCallback callback,
1207
                          v8::Local<v8::Signature> signature =
1208
                              v8::Local<v8::Signature>(),
1209
                          v8::ConstructorBehavior behavior =
1210
                              v8::ConstructorBehavior::kAllow,
1211
                          v8::SideEffectType side_effect =
1212
                              v8::SideEffectType::kHasSideEffect);
1213
1214
  // Convenience methods for NewFunctionTemplate().
1215
  inline void SetMethod(v8::Local<v8::Object> that,
1216
                        const char* name,
1217
                        v8::FunctionCallback callback);
1218
1219
  inline void SetProtoMethod(v8::Local<v8::FunctionTemplate> that,
1220
                             const char* name,
1221
                             v8::FunctionCallback callback);
1222
1223
  inline void SetInstanceMethod(v8::Local<v8::FunctionTemplate> that,
1224
                                const char* name,
1225
                                v8::FunctionCallback callback);
1226
1227
1228
  // Safe variants denote the function has no side effects.
1229
  inline void SetMethodNoSideEffect(v8::Local<v8::Object> that,
1230
                                    const char* name,
1231
                                    v8::FunctionCallback callback);
1232
  inline void SetProtoMethodNoSideEffect(v8::Local<v8::FunctionTemplate> that,
1233
                                         const char* name,
1234
                                         v8::FunctionCallback callback);
1235
1236
  void AtExit(void (*cb)(void* arg), void* arg);
1237
  void RunAtExitCallbacks();
1238
1239
  void RunWeakRefCleanup();
1240
1241
  // Strings and private symbols are shared across shared contexts
1242
  // The getters simply proxy to the per-isolate primitive.
1243
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
1244
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
1245
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
1246
#define V(TypeName, PropertyName)                                             \
1247
  inline v8::Local<TypeName> PropertyName() const;
1248
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
1249
  PER_ISOLATE_SYMBOL_PROPERTIES(VY)
1250
  PER_ISOLATE_STRING_PROPERTIES(VS)
1251
#undef V
1252
#undef VS
1253
#undef VY
1254
#undef VP
1255
1256
#define V(PropertyName, TypeName)                                             \
1257
  inline v8::Local<TypeName> PropertyName() const;                            \
1258
  inline void set_ ## PropertyName(v8::Local<TypeName> value);
1259
  ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1260
  ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
1261
#undef V
1262
1263
  inline v8::Local<v8::Context> context() const;
1264
1265
#if HAVE_INSPECTOR
1266
44837
  inline inspector::Agent* inspector_agent() const {
1267
44837
    return inspector_agent_.get();
1268
  }
1269
1270
  inline bool is_in_inspector_console_call() const;
1271
  inline void set_is_in_inspector_console_call(bool value);
1272
#endif
1273
1274
  typedef ListHead<HandleWrap, &HandleWrap::handle_wrap_queue_> HandleWrapQueue;
1275
  typedef ListHead<ReqWrapBase, &ReqWrapBase::req_wrap_queue_> ReqWrapQueue;
1276
1277
59159
  inline HandleWrapQueue* handle_wrap_queue() { return &handle_wrap_queue_; }
1278
76994
  inline ReqWrapQueue* req_wrap_queue() { return &req_wrap_queue_; }
1279
1280
1
  inline bool EmitProcessEnvWarning() {
1281
1
    bool current_value = emit_env_nonstring_warning_;
1282
1
    emit_env_nonstring_warning_ = false;
1283
1
    return current_value;
1284
  }
1285
1286
1
  inline bool EmitErrNameWarning() {
1287
1
    bool current_value = emit_err_name_warning_;
1288
1
    emit_err_name_warning_ = false;
1289
1
    return current_value;
1290
  }
1291
1292
  // cb will be called as cb(env) on the next event loop iteration.
1293
  // Unlike the JS setImmediate() function, nested SetImmediate() calls will
1294
  // be run without returning control to the event loop, similar to nextTick().
1295
  template <typename Fn>
1296
  inline void SetImmediate(
1297
      Fn&& cb, CallbackFlags::Flags flags = CallbackFlags::kRefed);
1298
  template <typename Fn>
1299
  // This behaves like SetImmediate() but can be called from any thread.
1300
  inline void SetImmediateThreadsafe(
1301
      Fn&& cb, CallbackFlags::Flags flags = CallbackFlags::kRefed);
1302
  // This behaves like V8's Isolate::RequestInterrupt(), but also accounts for
1303
  // the event loop (i.e. combines the V8 function with SetImmediate()).
1304
  // The passed callback may not throw exceptions.
1305
  // This function can be called from any thread.
1306
  template <typename Fn>
1307
  inline void RequestInterrupt(Fn&& cb);
1308
  // This needs to be available for the JS-land setImmediate().
1309
  void ToggleImmediateRef(bool ref);
1310
1311
  inline void PushShouldNotAbortOnUncaughtScope();
1312
  inline void PopShouldNotAbortOnUncaughtScope();
1313
  inline bool inside_should_not_abort_on_uncaught_scope() const;
1314
1315
  static inline Environment* ForAsyncHooks(AsyncHooks* hooks);
1316
1317
  v8::Local<v8::Value> GetNow();
1318
  void ScheduleTimer(int64_t duration);
1319
  void ToggleTimerRef(bool ref);
1320
1321
  using CleanupCallback = CleanupHookCallback::Callback;
1322
  inline void AddCleanupHook(CleanupCallback cb, void* arg);
1323
  inline void RemoveCleanupHook(CleanupCallback cb, void* arg);
1324
  void RunCleanup();
1325
1326
  static size_t NearHeapLimitCallback(void* data,
1327
                                      size_t current_heap_limit,
1328
                                      size_t initial_heap_limit);
1329
  static void BuildEmbedderGraph(v8::Isolate* isolate,
1330
                                 v8::EmbedderGraph* graph,
1331
                                 void* data);
1332
1333
  inline std::shared_ptr<EnvironmentOptions> options();
1334
  inline std::shared_ptr<ExclusiveAccess<HostPort>> inspector_host_port();
1335
1336
  // The BaseObject count is a debugging helper that makes sure that there are
1337
  // no memory leaks caused by BaseObjects staying alive longer than expected
1338
  // (in particular, no circular BaseObjectPtr references).
1339
  inline void modify_base_object_count(int64_t delta);
1340
  inline int64_t base_object_count() const;
1341
1342
3
  inline int32_t stack_trace_limit() const { return 10; }
1343
1344
#if HAVE_INSPECTOR
1345
  void set_coverage_connection(
1346
      std::unique_ptr<profiler::V8CoverageConnection> connection);
1347
  profiler::V8CoverageConnection* coverage_connection();
1348
1349
  inline void set_coverage_directory(const char* directory);
1350
  inline const std::string& coverage_directory() const;
1351
1352
  void set_cpu_profiler_connection(
1353
      std::unique_ptr<profiler::V8CpuProfilerConnection> connection);
1354
  profiler::V8CpuProfilerConnection* cpu_profiler_connection();
1355
1356
  inline void set_cpu_prof_name(const std::string& name);
1357
  inline const std::string& cpu_prof_name() const;
1358
1359
  inline void set_cpu_prof_interval(uint64_t interval);
1360
  inline uint64_t cpu_prof_interval() const;
1361
1362
  inline void set_cpu_prof_dir(const std::string& dir);
1363
  inline const std::string& cpu_prof_dir() const;
1364
1365
  void set_heap_profiler_connection(
1366
      std::unique_ptr<profiler::V8HeapProfilerConnection> connection);
1367
  profiler::V8HeapProfilerConnection* heap_profiler_connection();
1368
1369
  inline void set_heap_prof_name(const std::string& name);
1370
  inline const std::string& heap_prof_name() const;
1371
1372
  inline void set_heap_prof_dir(const std::string& dir);
1373
  inline const std::string& heap_prof_dir() const;
1374
1375
  inline void set_heap_prof_interval(uint64_t interval);
1376
  inline uint64_t heap_prof_interval() const;
1377
1378
#endif  // HAVE_INSPECTOR
1379
1380
  inline void set_main_utf16(std::unique_ptr<v8::String::Value>);
1381
  inline void set_process_exit_handler(
1382
      std::function<void(Environment*, int)>&& handler);
1383
1384
  void RunAndClearNativeImmediates(bool only_refed = false);
1385
  void RunAndClearInterrupts();
1386
1387
  inline std::unordered_map<char*, std::unique_ptr<v8::BackingStore>>*
1388
      released_allocated_buffers();
1389
1390
  void AddUnmanagedFd(int fd);
1391
  void RemoveUnmanagedFd(int fd);
1392
1393
 private:
1394
  inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
1395
                         const char* errmsg);
1396
1397
  std::list<binding::DLib> loaded_addons_;
1398
  v8::Isolate* const isolate_;
1399
  IsolateData* const isolate_data_;
1400
  uv_timer_t timer_handle_;
1401
  uv_check_t immediate_check_handle_;
1402
  uv_idle_t immediate_idle_handle_;
1403
  uv_async_t task_queues_async_;
1404
  int64_t task_queues_async_refs_ = 0;
1405
1406
  AsyncHooks async_hooks_;
1407
  ImmediateInfo immediate_info_;
1408
  TickInfo tick_info_;
1409
  const uint64_t timer_base_;
1410
  std::shared_ptr<KVStore> env_vars_;
1411
  bool printed_error_ = false;
1412
  bool trace_sync_io_ = false;
1413
  bool emit_env_nonstring_warning_ = true;
1414
  bool emit_err_name_warning_ = true;
1415
  bool emit_filehandle_warning_ = true;
1416
  bool source_maps_enabled_ = false;
1417
1418
  size_t async_callback_scope_depth_ = 0;
1419
  std::vector<double> destroy_async_id_list_;
1420
1421
#if HAVE_INSPECTOR
1422
  std::unique_ptr<profiler::V8CoverageConnection> coverage_connection_;
1423
  std::unique_ptr<profiler::V8CpuProfilerConnection> cpu_profiler_connection_;
1424
  std::string coverage_directory_;
1425
  std::string cpu_prof_dir_;
1426
  std::string cpu_prof_name_;
1427
  uint64_t cpu_prof_interval_;
1428
  std::unique_ptr<profiler::V8HeapProfilerConnection> heap_profiler_connection_;
1429
  std::string heap_prof_dir_;
1430
  std::string heap_prof_name_;
1431
  uint64_t heap_prof_interval_;
1432
#endif  // HAVE_INSPECTOR
1433
1434
  std::shared_ptr<EnvironmentOptions> options_;
1435
  // options_ contains debug options parsed from CLI arguments,
1436
  // while inspector_host_port_ stores the actual inspector host
1437
  // and port being used. For example the port is -1 by default
1438
  // and can be specified as 0 (meaning any port allocated when the
1439
  // server starts listening), but when the inspector server starts
1440
  // the inspector_host_port_->port() will be the actual port being
1441
  // used.
1442
  std::shared_ptr<ExclusiveAccess<HostPort>> inspector_host_port_;
1443
  std::vector<std::string> exec_argv_;
1444
  std::vector<std::string> argv_;
1445
  std::string exec_path_;
1446
1447
  bool is_processing_heap_limit_callback_ = false;
1448
  int64_t heap_limit_snapshot_taken_ = 0;
1449
1450
  uint32_t module_id_counter_ = 0;
1451
  uint32_t script_id_counter_ = 0;
1452
  uint32_t function_id_counter_ = 0;
1453
1454
  AliasedUint32Array should_abort_on_uncaught_toggle_;
1455
  int should_not_abort_scope_counter_ = 0;
1456
1457
  std::unique_ptr<TrackingTraceStateObserver> trace_state_observer_;
1458
1459
  AliasedInt32Array stream_base_state_;
1460
1461
  uint64_t environment_start_time_;
1462
  std::unique_ptr<performance::PerformanceState> performance_state_;
1463
  std::unordered_map<std::string, uint64_t> performance_marks_;
1464
1465
  bool has_run_bootstrapping_code_ = false;
1466
  bool has_serialized_options_ = false;
1467
1468
  std::atomic_bool can_call_into_js_ { true };
1469
  uint64_t flags_;
1470
  uint64_t thread_id_;
1471
  std::unordered_set<worker::Worker*> sub_worker_contexts_;
1472
1473
  static void* const kNodeContextTagPtr;
1474
  static int const kNodeContextTag;
1475
1476
#if HAVE_INSPECTOR
1477
  std::unique_ptr<inspector::Agent> inspector_agent_;
1478
  bool is_in_inspector_console_call_ = false;
1479
#endif
1480
1481
  // handle_wrap_queue_ and req_wrap_queue_ needs to be at a fixed offset from
1482
  // the start of the class because it is used by
1483
  // src/node_postmortem_metadata.cc to calculate offsets and generate debug
1484
  // symbols for Environment, which assumes that the position of members in
1485
  // memory are predictable. For more information please refer to
1486
  // `doc/guides/node-postmortem-support.md`
1487
  friend int GenDebugSymbols();
1488
  HandleWrapQueue handle_wrap_queue_;
1489
  ReqWrapQueue req_wrap_queue_;
1490
  std::list<HandleCleanup> handle_cleanup_queue_;
1491
  int handle_cleanup_waiting_ = 0;
1492
  int request_waiting_ = 0;
1493
1494
  EnabledDebugList enabled_debug_list_;
1495
1496
  std::list<node_module> extra_linked_bindings_;
1497
  Mutex extra_linked_bindings_mutex_;
1498
1499
  static void RunTimers(uv_timer_t* handle);
1500
1501
  struct ExitCallback {
1502
    void (*cb_)(void* arg);
1503
    void* arg_;
1504
  };
1505
1506
  std::list<ExitCallback> at_exit_functions_;
1507
1508
  typedef CallbackQueue<void, Environment*> NativeImmediateQueue;
1509
  NativeImmediateQueue native_immediates_;
1510
  Mutex native_immediates_threadsafe_mutex_;
1511
  NativeImmediateQueue native_immediates_threadsafe_;
1512
  NativeImmediateQueue native_immediates_interrupts_;
1513
  // Also guarded by native_immediates_threadsafe_mutex_. This can be used when
1514
  // trying to post tasks from other threads to an Environment, as the libuv
1515
  // handle for the immediate queues (task_queues_async_) may not be initialized
1516
  // yet or already have been destroyed.
1517
  bool task_queues_async_initialized_ = false;
1518
1519
  std::atomic<Environment**> interrupt_data_ {nullptr};
1520
  void RequestInterruptFromV8();
1521
  static void CheckImmediate(uv_check_t* handle);
1522
1523
  BindingDataStore bindings_;
1524
1525
  // Use an unordered_set, so that we have efficient insertion and removal.
1526
  std::unordered_set<CleanupHookCallback,
1527
                     CleanupHookCallback::Hash,
1528
                     CleanupHookCallback::Equal> cleanup_hooks_;
1529
  uint64_t cleanup_hook_counter_ = 0;
1530
  bool started_cleanup_ = false;
1531
1532
  int64_t base_object_count_ = 0;
1533
  int64_t initial_base_object_count_ = 0;
1534
  std::atomic_bool is_stopping_ { false };
1535
1536
  std::unordered_set<int> unmanaged_fds_;
1537
1538
  std::function<void(Environment*, int)> process_exit_handler_ {
1539
      DefaultProcessExitHandler };
1540
1541
  template <typename T>
1542
  void ForEachBaseObject(T&& iterator);
1543
1544
#define V(PropertyName, TypeName) v8::Global<TypeName> PropertyName ## _;
1545
  ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1546
  ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
1547
#undef V
1548
1549
  v8::Global<v8::Context> context_;
1550
1551
  // Keeps the main script source alive is one was passed to LoadEnvironment().
1552
  // We should probably find a way to just use plain `v8::String`s created from
1553
  // the source passed to LoadEnvironment() directly instead.
1554
  std::unique_ptr<v8::String::Value> main_utf16_;
1555
1556
  // Used by AllocatedBuffer::release() to keep track of the BackingStore for
1557
  // a given pointer.
1558
  std::unordered_map<char*, std::unique_ptr<v8::BackingStore>>
1559
      released_allocated_buffers_;
1560
};
1561
1562
}  // namespace node
1563
1564
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
1565
1566
#endif  // SRC_ENV_H_