@kungfu-tech/libnode-win32-x64 0.0.0-bootstrap.0 → 22.22.3-kf.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/dist/node/include/acorn_version.h +6 -0
  4. package/dist/node/include/aliased_buffer-inl.h +244 -0
  5. package/dist/node/include/aliased_buffer.h +206 -0
  6. package/dist/node/include/aliased_struct-inl.h +54 -0
  7. package/dist/node/include/aliased_struct.h +63 -0
  8. package/dist/node/include/amaro_version.h +6 -0
  9. package/dist/node/include/async_context_frame.h +33 -0
  10. package/dist/node/include/async_wrap-inl.h +96 -0
  11. package/dist/node/include/async_wrap.h +243 -0
  12. package/dist/node/include/base_object-inl.h +335 -0
  13. package/dist/node/include/base_object.h +342 -0
  14. package/dist/node/include/base_object_types.h +74 -0
  15. package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
  16. package/dist/node/include/blob_serializer_deserializer.h +132 -0
  17. package/dist/node/include/callback_queue-inl.h +97 -0
  18. package/dist/node/include/callback_queue.h +79 -0
  19. package/dist/node/include/cares_wrap.h +447 -0
  20. package/dist/node/include/cjs_module_lexer_version.h +6 -0
  21. package/dist/node/include/cleanup_queue-inl.h +36 -0
  22. package/dist/node/include/cleanup_queue.h +79 -0
  23. package/dist/node/include/compile_cache.h +104 -0
  24. package/dist/node/include/connect_wrap.h +26 -0
  25. package/dist/node/include/connection_wrap.h +30 -0
  26. package/dist/node/include/cppgc/allocation.h +310 -0
  27. package/dist/node/include/cppgc/common.h +28 -0
  28. package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
  29. package/dist/node/include/cppgc/custom-space.h +97 -0
  30. package/dist/node/include/cppgc/default-platform.h +67 -0
  31. package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
  32. package/dist/node/include/cppgc/explicit-management.h +100 -0
  33. package/dist/node/include/cppgc/garbage-collected.h +106 -0
  34. package/dist/node/include/cppgc/heap-consistency.h +309 -0
  35. package/dist/node/include/cppgc/heap-handle.h +48 -0
  36. package/dist/node/include/cppgc/heap-state.h +82 -0
  37. package/dist/node/include/cppgc/heap-statistics.h +120 -0
  38. package/dist/node/include/cppgc/heap.h +202 -0
  39. package/dist/node/include/cppgc/internal/api-constants.h +87 -0
  40. package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
  41. package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
  42. package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
  43. package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
  44. package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
  45. package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
  46. package/dist/node/include/cppgc/internal/gc-info.h +148 -0
  47. package/dist/node/include/cppgc/internal/logging.h +50 -0
  48. package/dist/node/include/cppgc/internal/member-storage.h +256 -0
  49. package/dist/node/include/cppgc/internal/name-trait.h +137 -0
  50. package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
  51. package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
  52. package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
  53. package/dist/node/include/cppgc/liveness-broker.h +78 -0
  54. package/dist/node/include/cppgc/macros.h +35 -0
  55. package/dist/node/include/cppgc/member.h +629 -0
  56. package/dist/node/include/cppgc/name-provider.h +65 -0
  57. package/dist/node/include/cppgc/object-size-trait.h +58 -0
  58. package/dist/node/include/cppgc/persistent.h +377 -0
  59. package/dist/node/include/cppgc/platform.h +163 -0
  60. package/dist/node/include/cppgc/prefinalizer.h +75 -0
  61. package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
  62. package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
  63. package/dist/node/include/cppgc/source-location.h +16 -0
  64. package/dist/node/include/cppgc/testing.h +106 -0
  65. package/dist/node/include/cppgc/trace-trait.h +128 -0
  66. package/dist/node/include/cppgc/type-traits.h +271 -0
  67. package/dist/node/include/cppgc/visitor.h +504 -0
  68. package/dist/node/include/crypto/crypto_aes.h +88 -0
  69. package/dist/node/include/crypto/crypto_bio.h +193 -0
  70. package/dist/node/include/crypto/crypto_cipher.h +293 -0
  71. package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
  72. package/dist/node/include/crypto/crypto_clienthello.h +131 -0
  73. package/dist/node/include/crypto/crypto_common.h +64 -0
  74. package/dist/node/include/crypto/crypto_context.h +171 -0
  75. package/dist/node/include/crypto/crypto_dh.h +126 -0
  76. package/dist/node/include/crypto/crypto_dsa.h +52 -0
  77. package/dist/node/include/crypto/crypto_ec.h +164 -0
  78. package/dist/node/include/crypto/crypto_hash.h +91 -0
  79. package/dist/node/include/crypto/crypto_hkdf.h +61 -0
  80. package/dist/node/include/crypto/crypto_hmac.h +92 -0
  81. package/dist/node/include/crypto/crypto_keygen.h +299 -0
  82. package/dist/node/include/crypto/crypto_keys.h +392 -0
  83. package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
  84. package/dist/node/include/crypto/crypto_random.h +124 -0
  85. package/dist/node/include/crypto/crypto_rsa.h +136 -0
  86. package/dist/node/include/crypto/crypto_scrypt.h +85 -0
  87. package/dist/node/include/crypto/crypto_sig.h +165 -0
  88. package/dist/node/include/crypto/crypto_spkac.h +21 -0
  89. package/dist/node/include/crypto/crypto_timing.h +20 -0
  90. package/dist/node/include/crypto/crypto_tls.h +305 -0
  91. package/dist/node/include/crypto/crypto_util.h +725 -0
  92. package/dist/node/include/crypto/crypto_x509.h +140 -0
  93. package/dist/node/include/dataqueue/queue.h +306 -0
  94. package/dist/node/include/debug_utils-inl.h +278 -0
  95. package/dist/node/include/debug_utils.h +196 -0
  96. package/dist/node/include/diagnosticfilename-inl.h +33 -0
  97. package/dist/node/include/embedded_data.h +17 -0
  98. package/dist/node/include/encoding_binding.h +61 -0
  99. package/dist/node/include/env-inl.h +984 -0
  100. package/dist/node/include/env.h +1287 -0
  101. package/dist/node/include/env_properties.h +540 -0
  102. package/dist/node/include/handle_wrap.h +123 -0
  103. package/dist/node/include/histogram-inl.h +107 -0
  104. package/dist/node/include/histogram.h +279 -0
  105. package/dist/node/include/inspector/io_agent.h +30 -0
  106. package/dist/node/include/inspector/main_thread_interface.h +116 -0
  107. package/dist/node/include/inspector/network_agent.h +94 -0
  108. package/dist/node/include/inspector/network_inspector.h +45 -0
  109. package/dist/node/include/inspector/network_requests_buffer.h +195 -0
  110. package/dist/node/include/inspector/network_resource_manager.h +29 -0
  111. package/dist/node/include/inspector/node_json.h +24 -0
  112. package/dist/node/include/inspector/node_string.h +101 -0
  113. package/dist/node/include/inspector/protocol_helper.h +27 -0
  114. package/dist/node/include/inspector/runtime_agent.h +41 -0
  115. package/dist/node/include/inspector/target_agent.h +75 -0
  116. package/dist/node/include/inspector/tracing_agent.h +43 -0
  117. package/dist/node/include/inspector/worker_agent.h +40 -0
  118. package/dist/node/include/inspector/worker_inspector.h +124 -0
  119. package/dist/node/include/inspector_agent.h +165 -0
  120. package/dist/node/include/inspector_io.h +78 -0
  121. package/dist/node/include/inspector_profiler.h +149 -0
  122. package/dist/node/include/inspector_socket.h +60 -0
  123. package/dist/node/include/inspector_socket_server.h +110 -0
  124. package/dist/node/include/js_native_api.h +607 -0
  125. package/dist/node/include/js_native_api_types.h +226 -0
  126. package/dist/node/include/js_native_api_v8.h +485 -0
  127. package/dist/node/include/js_native_api_v8_internals.h +45 -0
  128. package/dist/node/include/js_stream.h +52 -0
  129. package/dist/node/include/json_utils.h +172 -0
  130. package/dist/node/include/large_pages/node_large_page.h +34 -0
  131. package/dist/node/include/libplatform/libplatform-export.h +29 -0
  132. package/dist/node/include/libplatform/libplatform.h +112 -0
  133. package/dist/node/include/libplatform/v8-tracing.h +333 -0
  134. package/dist/node/include/memory_tracker-inl.h +359 -0
  135. package/dist/node/include/memory_tracker.h +289 -0
  136. package/dist/node/include/module_wrap.h +216 -0
  137. package/dist/node/include/node.h +1593 -0
  138. package/dist/node/include/node_api.h +265 -0
  139. package/dist/node/include/node_api_internals.h +48 -0
  140. package/dist/node/include/node_api_types.h +56 -0
  141. package/dist/node/include/node_binding.h +161 -0
  142. package/dist/node/include/node_blob.h +159 -0
  143. package/dist/node/include/node_bob-inl.h +36 -0
  144. package/dist/node/include/node_bob.h +107 -0
  145. package/dist/node/include/node_buffer.h +92 -0
  146. package/dist/node/include/node_builtins.h +220 -0
  147. package/dist/node/include/node_config_file.h +46 -0
  148. package/dist/node/include/node_constants.h +82 -0
  149. package/dist/node/include/node_context_data.h +168 -0
  150. package/dist/node/include/node_contextify.h +204 -0
  151. package/dist/node/include/node_crypto.h +56 -0
  152. package/dist/node/include/node_debug.h +30 -0
  153. package/dist/node/include/node_dir.h +52 -0
  154. package/dist/node/include/node_dotenv.h +45 -0
  155. package/dist/node/include/node_errors.h +380 -0
  156. package/dist/node/include/node_exit_code.h +54 -0
  157. package/dist/node/include/node_external_reference.h +165 -0
  158. package/dist/node/include/node_file-inl.h +406 -0
  159. package/dist/node/include/node_file.h +537 -0
  160. package/dist/node/include/node_http2.h +1177 -0
  161. package/dist/node/include/node_http2_state.h +159 -0
  162. package/dist/node/include/node_http_common-inl.h +202 -0
  163. package/dist/node/include/node_http_common.h +535 -0
  164. package/dist/node/include/node_i18n.h +132 -0
  165. package/dist/node/include/node_internals.h +483 -0
  166. package/dist/node/include/node_main_instance.h +67 -0
  167. package/dist/node/include/node_mem-inl.h +113 -0
  168. package/dist/node/include/node_mem.h +45 -0
  169. package/dist/node/include/node_messaging.h +389 -0
  170. package/dist/node/include/node_metadata.h +164 -0
  171. package/dist/node/include/node_modules.h +91 -0
  172. package/dist/node/include/node_mutex.h +323 -0
  173. package/dist/node/include/node_object_wrap.h +132 -0
  174. package/dist/node/include/node_options-inl.h +490 -0
  175. package/dist/node/include/node_options.h +615 -0
  176. package/dist/node/include/node_perf.h +166 -0
  177. package/dist/node/include/node_perf_common.h +102 -0
  178. package/dist/node/include/node_platform.h +238 -0
  179. package/dist/node/include/node_process-inl.h +26 -0
  180. package/dist/node/include/node_process.h +112 -0
  181. package/dist/node/include/node_realm-inl.h +151 -0
  182. package/dist/node/include/node_realm.h +183 -0
  183. package/dist/node/include/node_report.h +43 -0
  184. package/dist/node/include/node_revert.h +82 -0
  185. package/dist/node/include/node_root_certs.h +3520 -0
  186. package/dist/node/include/node_sea.h +74 -0
  187. package/dist/node/include/node_shadow_realm.h +46 -0
  188. package/dist/node/include/node_snapshot_builder.h +57 -0
  189. package/dist/node/include/node_snapshotable.h +174 -0
  190. package/dist/node/include/node_sockaddr-inl.h +257 -0
  191. package/dist/node/include/node_sockaddr.h +394 -0
  192. package/dist/node/include/node_sqlite.h +270 -0
  193. package/dist/node/include/node_stat_watcher.h +73 -0
  194. package/dist/node/include/node_task_runner.h +92 -0
  195. package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
  196. package/dist/node/include/node_threadsafe_cow.h +105 -0
  197. package/dist/node/include/node_union_bytes.h +81 -0
  198. package/dist/node/include/node_url.h +96 -0
  199. package/dist/node/include/node_v8.h +77 -0
  200. package/dist/node/include/node_v8_platform-inl.h +185 -0
  201. package/dist/node/include/node_version.h +110 -0
  202. package/dist/node/include/node_wasi.h +184 -0
  203. package/dist/node/include/node_wasm_web_api.h +55 -0
  204. package/dist/node/include/node_watchdog.h +154 -0
  205. package/dist/node/include/node_webstorage.h +60 -0
  206. package/dist/node/include/node_worker.h +158 -0
  207. package/dist/node/include/path.h +33 -0
  208. package/dist/node/include/permission/addon_permission.h +31 -0
  209. package/dist/node/include/permission/child_process_permission.h +31 -0
  210. package/dist/node/include/permission/fs_permission.h +167 -0
  211. package/dist/node/include/permission/inspector_permission.h +31 -0
  212. package/dist/node/include/permission/permission.h +138 -0
  213. package/dist/node/include/permission/permission_base.h +65 -0
  214. package/dist/node/include/permission/wasi_permission.h +31 -0
  215. package/dist/node/include/permission/worker_permission.h +31 -0
  216. package/dist/node/include/pipe_wrap.h +80 -0
  217. package/dist/node/include/quic/application.h +159 -0
  218. package/dist/node/include/quic/bindingdata.h +272 -0
  219. package/dist/node/include/quic/cid.h +127 -0
  220. package/dist/node/include/quic/data.h +148 -0
  221. package/dist/node/include/quic/defs.h +245 -0
  222. package/dist/node/include/quic/endpoint.h +458 -0
  223. package/dist/node/include/quic/http3.h +15 -0
  224. package/dist/node/include/quic/logstream.h +81 -0
  225. package/dist/node/include/quic/packet.h +152 -0
  226. package/dist/node/include/quic/preferredaddress.h +72 -0
  227. package/dist/node/include/quic/session.h +443 -0
  228. package/dist/node/include/quic/sessionticket.h +108 -0
  229. package/dist/node/include/quic/streams.h +232 -0
  230. package/dist/node/include/quic/tlscontext.h +227 -0
  231. package/dist/node/include/quic/tokens.h +256 -0
  232. package/dist/node/include/quic/transportparams.h +165 -0
  233. package/dist/node/include/req_wrap-inl.h +171 -0
  234. package/dist/node/include/req_wrap.h +77 -0
  235. package/dist/node/include/spawn_sync.h +243 -0
  236. package/dist/node/include/stream_base-inl.h +173 -0
  237. package/dist/node/include/stream_base.h +478 -0
  238. package/dist/node/include/stream_pipe.h +76 -0
  239. package/dist/node/include/stream_wrap.h +132 -0
  240. package/dist/node/include/string_bytes.h +113 -0
  241. package/dist/node/include/string_decoder-inl.h +31 -0
  242. package/dist/node/include/string_decoder.h +49 -0
  243. package/dist/node/include/tcp_wrap.h +105 -0
  244. package/dist/node/include/threadpoolwork-inl.h +70 -0
  245. package/dist/node/include/timer_wrap-inl.h +32 -0
  246. package/dist/node/include/timer_wrap.h +85 -0
  247. package/dist/node/include/timers.h +70 -0
  248. package/dist/node/include/tracing/agent.h +195 -0
  249. package/dist/node/include/tracing/node_trace_buffer.h +83 -0
  250. package/dist/node/include/tracing/node_trace_writer.h +75 -0
  251. package/dist/node/include/tracing/trace_event.h +722 -0
  252. package/dist/node/include/tracing/trace_event_common.h +1109 -0
  253. package/dist/node/include/tracing/traced_value.h +129 -0
  254. package/dist/node/include/tty_wrap.h +65 -0
  255. package/dist/node/include/udp_wrap.h +230 -0
  256. package/dist/node/include/undici_version.h +6 -0
  257. package/dist/node/include/util-inl.h +700 -0
  258. package/dist/node/include/util.h +1021 -0
  259. package/dist/node/include/uv/aix.h +32 -0
  260. package/dist/node/include/uv/bsd.h +34 -0
  261. package/dist/node/include/uv/darwin.h +61 -0
  262. package/dist/node/include/uv/errno.h +483 -0
  263. package/dist/node/include/uv/linux.h +34 -0
  264. package/dist/node/include/uv/os390.h +33 -0
  265. package/dist/node/include/uv/posix.h +31 -0
  266. package/dist/node/include/uv/sunos.h +44 -0
  267. package/dist/node/include/uv/threadpool.h +37 -0
  268. package/dist/node/include/uv/tree.h +521 -0
  269. package/dist/node/include/uv/unix.h +512 -0
  270. package/dist/node/include/uv/version.h +43 -0
  271. package/dist/node/include/uv/win.h +698 -0
  272. package/dist/node/include/uv.h +1990 -0
  273. package/dist/node/include/v8-array-buffer.h +525 -0
  274. package/dist/node/include/v8-callbacks.h +462 -0
  275. package/dist/node/include/v8-container.h +183 -0
  276. package/dist/node/include/v8-context.h +485 -0
  277. package/dist/node/include/v8-cppgc.h +245 -0
  278. package/dist/node/include/v8-data.h +80 -0
  279. package/dist/node/include/v8-date.h +48 -0
  280. package/dist/node/include/v8-debug.h +168 -0
  281. package/dist/node/include/v8-embedder-heap.h +82 -0
  282. package/dist/node/include/v8-embedder-state-scope.h +52 -0
  283. package/dist/node/include/v8-exception.h +223 -0
  284. package/dist/node/include/v8-extension.h +62 -0
  285. package/dist/node/include/v8-external.h +37 -0
  286. package/dist/node/include/v8-fast-api-calls.h +984 -0
  287. package/dist/node/include/v8-forward.h +82 -0
  288. package/dist/node/include/v8-function-callback.h +607 -0
  289. package/dist/node/include/v8-function.h +140 -0
  290. package/dist/node/include/v8-handle-base.h +137 -0
  291. package/dist/node/include/v8-initialization.h +289 -0
  292. package/dist/node/include/v8-inspector-protocol.h +13 -0
  293. package/dist/node/include/v8-inspector.h +419 -0
  294. package/dist/node/include/v8-internal.h +1397 -0
  295. package/dist/node/include/v8-isolate.h +1767 -0
  296. package/dist/node/include/v8-json.h +47 -0
  297. package/dist/node/include/v8-local-handle.h +758 -0
  298. package/dist/node/include/v8-locker.h +138 -0
  299. package/dist/node/include/v8-maybe.h +160 -0
  300. package/dist/node/include/v8-memory-span.h +198 -0
  301. package/dist/node/include/v8-message.h +233 -0
  302. package/dist/node/include/v8-metrics.h +264 -0
  303. package/dist/node/include/v8-microtask-queue.h +157 -0
  304. package/dist/node/include/v8-microtask.h +28 -0
  305. package/dist/node/include/v8-object.h +824 -0
  306. package/dist/node/include/v8-persistent-handle.h +582 -0
  307. package/dist/node/include/v8-platform.h +1358 -0
  308. package/dist/node/include/v8-primitive-object.h +118 -0
  309. package/dist/node/include/v8-primitive.h +877 -0
  310. package/dist/node/include/v8-profiler.h +1302 -0
  311. package/dist/node/include/v8-promise.h +174 -0
  312. package/dist/node/include/v8-proxy.h +50 -0
  313. package/dist/node/include/v8-regexp.h +106 -0
  314. package/dist/node/include/v8-script.h +904 -0
  315. package/dist/node/include/v8-snapshot.h +266 -0
  316. package/dist/node/include/v8-source-location.h +92 -0
  317. package/dist/node/include/v8-statistics.h +238 -0
  318. package/dist/node/include/v8-template.h +1297 -0
  319. package/dist/node/include/v8-traced-handle.h +432 -0
  320. package/dist/node/include/v8-typed-array.h +390 -0
  321. package/dist/node/include/v8-unwinder-state.h +31 -0
  322. package/dist/node/include/v8-unwinder.h +132 -0
  323. package/dist/node/include/v8-util.h +665 -0
  324. package/dist/node/include/v8-value-serializer-version.h +24 -0
  325. package/dist/node/include/v8-value-serializer.h +316 -0
  326. package/dist/node/include/v8-value.h +655 -0
  327. package/dist/node/include/v8-version-string.h +38 -0
  328. package/dist/node/include/v8-version.h +20 -0
  329. package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
  330. package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
  331. package/dist/node/include/v8-wasm.h +201 -0
  332. package/dist/node/include/v8-weak-callback-info.h +80 -0
  333. package/dist/node/include/v8.h +88 -0
  334. package/dist/node/include/v8config.h +981 -0
  335. package/dist/node/include/zlib_version.h +6 -0
  336. package/dist/node/libnode.dll +0 -0
  337. package/dist/node/libnode.lib +0 -0
  338. package/dist/node/libnodebuildinfo.json +10 -0
  339. package/dist/node/link_node.lib +0 -0
  340. package/dist/node/link_node.node +0 -0
  341. package/index.js +5 -0
  342. package/libnode.release.json +8 -0
  343. package/package.json +29 -1
@@ -0,0 +1,984 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_ENV_INL_H_
23
+ #define SRC_ENV_INL_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #include "aliased_buffer-inl.h"
28
+ #include "callback_queue-inl.h"
29
+ #include "env.h"
30
+ #include "node.h"
31
+ #include "node_context_data.h"
32
+ #include "node_internals.h"
33
+ #include "node_perf_common.h"
34
+ #include "node_realm-inl.h"
35
+ #include "util-inl.h"
36
+ #include "uv.h"
37
+ #include "v8-cppgc.h"
38
+ #include "v8.h"
39
+
40
+ #include <cstddef>
41
+ #include <cstdint>
42
+
43
+ #include <utility>
44
+
45
+ namespace node {
46
+
47
+ NoArrayBufferZeroFillScope::NoArrayBufferZeroFillScope(
48
+ IsolateData* isolate_data)
49
+ : node_allocator_(isolate_data->node_allocator()) {
50
+ if (node_allocator_ != nullptr) node_allocator_->zero_fill_field()[0] = 0;
51
+ }
52
+
53
+ NoArrayBufferZeroFillScope::~NoArrayBufferZeroFillScope() {
54
+ if (node_allocator_ != nullptr) node_allocator_->zero_fill_field()[0] = 1;
55
+ }
56
+
57
+ inline v8::Isolate* IsolateData::isolate() const {
58
+ return isolate_;
59
+ }
60
+
61
+ inline uv_loop_t* IsolateData::event_loop() const {
62
+ return event_loop_;
63
+ }
64
+
65
+ inline void IsolateData::SetCppgcReference(v8::Isolate* isolate,
66
+ v8::Local<v8::Object> object,
67
+ void* wrappable) {
68
+ v8::CppHeap* heap = isolate->GetCppHeap();
69
+ CHECK_NOT_NULL(heap);
70
+ v8::WrapperDescriptor descriptor = heap->wrapper_descriptor();
71
+ uint16_t required_size = std::max(descriptor.wrappable_instance_index,
72
+ descriptor.wrappable_type_index);
73
+ CHECK_GT(object->InternalFieldCount(), required_size);
74
+
75
+ uint16_t* id_ptr = nullptr;
76
+ {
77
+ Mutex::ScopedLock lock(isolate_data_mutex_);
78
+ auto it =
79
+ wrapper_data_map_.find(descriptor.embedder_id_for_garbage_collected);
80
+ CHECK_NE(it, wrapper_data_map_.end());
81
+ id_ptr = &(it->second->cppgc_id);
82
+ }
83
+
84
+ object->SetAlignedPointerInInternalField(descriptor.wrappable_type_index,
85
+ id_ptr);
86
+ object->SetAlignedPointerInInternalField(descriptor.wrappable_instance_index,
87
+ wrappable);
88
+ }
89
+
90
+ inline uint16_t* IsolateData::embedder_id_for_cppgc() const {
91
+ return &(wrapper_data_->cppgc_id);
92
+ }
93
+
94
+ inline uint16_t* IsolateData::embedder_id_for_non_cppgc() const {
95
+ return &(wrapper_data_->non_cppgc_id);
96
+ }
97
+
98
+ inline NodeArrayBufferAllocator* IsolateData::node_allocator() const {
99
+ return node_allocator_;
100
+ }
101
+
102
+ inline MultiIsolatePlatform* IsolateData::platform() const {
103
+ return platform_;
104
+ }
105
+
106
+ inline const SnapshotData* IsolateData::snapshot_data() const {
107
+ return snapshot_data_;
108
+ }
109
+
110
+ inline void IsolateData::set_worker_context(worker::Worker* context) {
111
+ CHECK_NULL(worker_context_); // Should be set only once.
112
+ worker_context_ = context;
113
+ }
114
+
115
+ inline worker::Worker* IsolateData::worker_context() const {
116
+ return worker_context_;
117
+ }
118
+
119
+ inline v8::Local<v8::String> IsolateData::async_wrap_provider(int index) const {
120
+ return async_wrap_providers_[index].Get(isolate_);
121
+ }
122
+
123
+ inline AliasedUint32Array& AsyncHooks::fields() {
124
+ return fields_;
125
+ }
126
+
127
+ inline AliasedFloat64Array& AsyncHooks::async_id_fields() {
128
+ return async_id_fields_;
129
+ }
130
+
131
+ inline AliasedFloat64Array& AsyncHooks::async_ids_stack() {
132
+ return async_ids_stack_;
133
+ }
134
+
135
+ v8::Local<v8::Array> AsyncHooks::js_execution_async_resources() {
136
+ if (js_execution_async_resources_.IsEmpty()) [[unlikely]] {
137
+ js_execution_async_resources_.Reset(
138
+ env()->isolate(), v8::Array::New(env()->isolate()));
139
+ }
140
+ return PersistentToLocal::Strong(js_execution_async_resources_);
141
+ }
142
+
143
+ v8::Local<v8::Object> AsyncHooks::native_execution_async_resource(size_t i) {
144
+ if (i >= native_execution_async_resources_.size() ||
145
+ native_execution_async_resources_[i] == nullptr)
146
+ return {};
147
+ return *native_execution_async_resources_[i];
148
+ }
149
+
150
+ inline v8::Local<v8::String> AsyncHooks::provider_string(int idx) {
151
+ return env()->isolate_data()->async_wrap_provider(idx);
152
+ }
153
+
154
+ inline void AsyncHooks::no_force_checks() {
155
+ fields_[kCheck] -= 1;
156
+ }
157
+
158
+ inline Environment* AsyncHooks::env() {
159
+ return Environment::ForAsyncHooks(this);
160
+ }
161
+
162
+ Environment* Environment::ForAsyncHooks(AsyncHooks* hooks) {
163
+ return ContainerOf(&Environment::async_hooks_, hooks);
164
+ }
165
+
166
+ inline size_t Environment::async_callback_scope_depth() const {
167
+ return async_callback_scope_depth_;
168
+ }
169
+
170
+ inline void Environment::PushAsyncCallbackScope() {
171
+ async_callback_scope_depth_++;
172
+ }
173
+
174
+ inline void Environment::PopAsyncCallbackScope() {
175
+ async_callback_scope_depth_--;
176
+ }
177
+
178
+ inline AliasedUint32Array& ImmediateInfo::fields() {
179
+ return fields_;
180
+ }
181
+
182
+ inline uint32_t ImmediateInfo::count() const {
183
+ return fields_[kCount];
184
+ }
185
+
186
+ inline uint32_t ImmediateInfo::ref_count() const {
187
+ return fields_[kRefCount];
188
+ }
189
+
190
+ inline bool ImmediateInfo::has_outstanding() const {
191
+ return fields_[kHasOutstanding] == 1;
192
+ }
193
+
194
+ inline void ImmediateInfo::ref_count_inc(uint32_t increment) {
195
+ fields_[kRefCount] += increment;
196
+ }
197
+
198
+ inline void ImmediateInfo::ref_count_dec(uint32_t decrement) {
199
+ fields_[kRefCount] -= decrement;
200
+ }
201
+
202
+ inline AliasedUint8Array& TickInfo::fields() {
203
+ return fields_;
204
+ }
205
+
206
+ inline bool TickInfo::has_tick_scheduled() const {
207
+ return fields_[kHasTickScheduled] == 1;
208
+ }
209
+
210
+ inline bool TickInfo::has_rejection_to_warn() const {
211
+ return fields_[kHasRejectionToWarn] == 1;
212
+ }
213
+
214
+ inline Environment* Environment::GetCurrent(v8::Isolate* isolate) {
215
+ if (!isolate->InContext()) [[unlikely]]
216
+ return nullptr;
217
+ v8::HandleScope handle_scope(isolate);
218
+ return GetCurrent(isolate->GetCurrentContext());
219
+ }
220
+
221
+ inline Environment* Environment::GetCurrent(v8::Local<v8::Context> context) {
222
+ if (!ContextEmbedderTag::IsNodeContext(context)) [[unlikely]] {
223
+ return nullptr;
224
+ }
225
+ return static_cast<Environment*>(
226
+ context->GetAlignedPointerFromEmbedderData(
227
+ ContextEmbedderIndex::kEnvironment));
228
+ }
229
+
230
+ inline Environment* Environment::GetCurrent(
231
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
232
+ return GetCurrent(info.GetIsolate()->GetCurrentContext());
233
+ }
234
+
235
+ template <typename T>
236
+ inline Environment* Environment::GetCurrent(
237
+ const v8::PropertyCallbackInfo<T>& info) {
238
+ return GetCurrent(info.GetIsolate()->GetCurrentContext());
239
+ }
240
+
241
+ inline v8::Isolate* Environment::isolate() const {
242
+ return isolate_;
243
+ }
244
+
245
+ inline Environment* Environment::from_timer_handle(uv_timer_t* handle) {
246
+ return ContainerOf(&Environment::timer_handle_, handle);
247
+ }
248
+
249
+ inline uv_timer_t* Environment::timer_handle() {
250
+ return &timer_handle_;
251
+ }
252
+
253
+ inline Environment* Environment::from_immediate_check_handle(
254
+ uv_check_t* handle) {
255
+ return ContainerOf(&Environment::immediate_check_handle_, handle);
256
+ }
257
+
258
+ inline uv_check_t* Environment::immediate_check_handle() {
259
+ return &immediate_check_handle_;
260
+ }
261
+
262
+ inline uv_idle_t* Environment::immediate_idle_handle() {
263
+ return &immediate_idle_handle_;
264
+ }
265
+
266
+ template <typename T, typename OnCloseCallback>
267
+ inline void Environment::CloseHandle(T* handle, OnCloseCallback callback) {
268
+ handle_cleanup_waiting_++;
269
+ static_assert(sizeof(T) >= sizeof(uv_handle_t), "T is a libuv handle");
270
+ static_assert(offsetof(T, data) == offsetof(uv_handle_t, data),
271
+ "T is a libuv handle");
272
+ static_assert(offsetof(T, close_cb) == offsetof(uv_handle_t, close_cb),
273
+ "T is a libuv handle");
274
+ struct CloseData {
275
+ Environment* env;
276
+ OnCloseCallback callback;
277
+ void* original_data;
278
+ };
279
+ handle->data = new CloseData { this, callback, handle->data };
280
+ uv_close(reinterpret_cast<uv_handle_t*>(handle), [](uv_handle_t* handle) {
281
+ std::unique_ptr<CloseData> data { static_cast<CloseData*>(handle->data) };
282
+ data->env->handle_cleanup_waiting_--;
283
+ handle->data = data->original_data;
284
+ data->callback(reinterpret_cast<T*>(handle));
285
+ });
286
+ }
287
+
288
+ void Environment::IncreaseWaitingRequestCounter() {
289
+ request_waiting_++;
290
+ }
291
+
292
+ void Environment::DecreaseWaitingRequestCounter() {
293
+ request_waiting_--;
294
+ CHECK_GE(request_waiting_, 0);
295
+ }
296
+
297
+ inline uv_loop_t* Environment::event_loop() const {
298
+ return isolate_data()->event_loop();
299
+ }
300
+
301
+ #if HAVE_INSPECTOR
302
+ inline bool Environment::is_in_inspector_console_call() const {
303
+ return is_in_inspector_console_call_;
304
+ }
305
+
306
+ inline void Environment::set_is_in_inspector_console_call(bool value) {
307
+ is_in_inspector_console_call_ = value;
308
+ }
309
+ #endif
310
+
311
+ inline AsyncHooks* Environment::async_hooks() {
312
+ return &async_hooks_;
313
+ }
314
+
315
+ inline ImmediateInfo* Environment::immediate_info() {
316
+ return &immediate_info_;
317
+ }
318
+
319
+ inline AliasedInt32Array& Environment::timeout_info() {
320
+ return timeout_info_;
321
+ }
322
+
323
+ inline TickInfo* Environment::tick_info() {
324
+ return &tick_info_;
325
+ }
326
+
327
+ inline permission::Permission* Environment::permission() {
328
+ return &permission_;
329
+ }
330
+
331
+ inline uint64_t Environment::timer_base() const {
332
+ return timer_base_;
333
+ }
334
+
335
+ inline std::shared_ptr<KVStore> Environment::env_vars() {
336
+ return env_vars_;
337
+ }
338
+
339
+ inline void Environment::set_env_vars(std::shared_ptr<KVStore> env_vars) {
340
+ env_vars_ = env_vars;
341
+ }
342
+
343
+ inline bool Environment::printed_error() const {
344
+ return printed_error_;
345
+ }
346
+
347
+ inline void Environment::set_printed_error(bool value) {
348
+ printed_error_ = value;
349
+ }
350
+
351
+ inline void Environment::set_trace_sync_io(bool value) {
352
+ trace_sync_io_ = value;
353
+ }
354
+
355
+ inline bool Environment::abort_on_uncaught_exception() const {
356
+ return options_->abort_on_uncaught_exception;
357
+ }
358
+
359
+ inline void Environment::set_force_context_aware(bool value) {
360
+ options_->force_context_aware = value;
361
+ }
362
+
363
+ inline bool Environment::force_context_aware() const {
364
+ return options_->force_context_aware;
365
+ }
366
+
367
+ inline void Environment::set_exiting(bool value) {
368
+ exit_info_[kExiting] = value ? 1 : 0;
369
+ }
370
+
371
+ inline bool Environment::exiting() const {
372
+ return exit_info_[kExiting] == 1;
373
+ }
374
+
375
+ inline ExitCode Environment::exit_code(const ExitCode default_code) const {
376
+ return exit_info_[kHasExitCode] == 0
377
+ ? default_code
378
+ : static_cast<ExitCode>(exit_info_[kExitCode]);
379
+ }
380
+
381
+ inline void Environment::set_exit_code(const ExitCode code) {
382
+ exit_info_[kExitCode] = static_cast<int>(code);
383
+ exit_info_[kHasExitCode] = 1;
384
+ }
385
+
386
+ inline AliasedInt32Array& Environment::exit_info() {
387
+ return exit_info_;
388
+ }
389
+
390
+ inline void Environment::set_abort_on_uncaught_exception(bool value) {
391
+ options_->abort_on_uncaught_exception = value;
392
+ }
393
+
394
+ inline AliasedUint32Array& Environment::should_abort_on_uncaught_toggle() {
395
+ return should_abort_on_uncaught_toggle_;
396
+ }
397
+
398
+ inline AliasedInt32Array& Environment::stream_base_state() {
399
+ return stream_base_state_;
400
+ }
401
+
402
+ ShouldNotAbortOnUncaughtScope::ShouldNotAbortOnUncaughtScope(
403
+ Environment* env)
404
+ : env_(env) {
405
+ env_->PushShouldNotAbortOnUncaughtScope();
406
+ }
407
+
408
+ ShouldNotAbortOnUncaughtScope::~ShouldNotAbortOnUncaughtScope() {
409
+ Close();
410
+ }
411
+
412
+ void ShouldNotAbortOnUncaughtScope::Close() {
413
+ if (env_ != nullptr) {
414
+ env_->PopShouldNotAbortOnUncaughtScope();
415
+ env_ = nullptr;
416
+ }
417
+ }
418
+
419
+ inline void Environment::PushShouldNotAbortOnUncaughtScope() {
420
+ should_not_abort_scope_counter_++;
421
+ }
422
+
423
+ inline void Environment::PopShouldNotAbortOnUncaughtScope() {
424
+ should_not_abort_scope_counter_--;
425
+ }
426
+
427
+ inline bool Environment::inside_should_not_abort_on_uncaught_scope() const {
428
+ return should_not_abort_scope_counter_ > 0;
429
+ }
430
+
431
+ inline std::vector<double>* Environment::destroy_async_id_list() {
432
+ return &destroy_async_id_list_;
433
+ }
434
+
435
+ inline builtins::BuiltinLoader* Environment::builtin_loader() {
436
+ return &builtin_loader_;
437
+ }
438
+
439
+ inline const EmbedderPreloadCallback& Environment::embedder_preload() const {
440
+ return embedder_preload_;
441
+ }
442
+
443
+ inline void Environment::set_embedder_preload(EmbedderPreloadCallback fn) {
444
+ embedder_preload_ = std::move(fn);
445
+ }
446
+
447
+ inline double Environment::new_async_id() {
448
+ async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter] += 1;
449
+ return async_hooks()->async_id_fields()[AsyncHooks::kAsyncIdCounter];
450
+ }
451
+
452
+ inline double Environment::execution_async_id() {
453
+ return async_hooks()->async_id_fields()[AsyncHooks::kExecutionAsyncId];
454
+ }
455
+
456
+ inline double Environment::trigger_async_id() {
457
+ return async_hooks()->async_id_fields()[AsyncHooks::kTriggerAsyncId];
458
+ }
459
+
460
+ inline double Environment::get_default_trigger_async_id() {
461
+ double default_trigger_async_id =
462
+ async_hooks()->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId];
463
+ // If defaultTriggerAsyncId isn't set, use the executionAsyncId
464
+ if (default_trigger_async_id < 0)
465
+ default_trigger_async_id = execution_async_id();
466
+ return default_trigger_async_id;
467
+ }
468
+
469
+ inline int64_t Environment::stack_trace_limit() const {
470
+ return isolate_data_->options()->stack_trace_limit;
471
+ }
472
+
473
+ inline std::shared_ptr<EnvironmentOptions> Environment::options() {
474
+ return options_;
475
+ }
476
+
477
+ inline const std::vector<std::string>& Environment::argv() {
478
+ return argv_;
479
+ }
480
+
481
+ inline const std::vector<std::string>& Environment::exec_argv() {
482
+ return exec_argv_;
483
+ }
484
+
485
+ inline const std::string& Environment::exec_path() const {
486
+ return exec_path_;
487
+ }
488
+
489
+ inline CompileCacheHandler* Environment::compile_cache_handler() {
490
+ auto* result = compile_cache_handler_.get();
491
+ DCHECK_NOT_NULL(result);
492
+ return result;
493
+ }
494
+
495
+ inline bool Environment::use_compile_cache() const {
496
+ return compile_cache_handler_.get() != nullptr;
497
+ }
498
+
499
+ #if HAVE_INSPECTOR
500
+ inline void Environment::set_coverage_directory(const char* dir) {
501
+ coverage_directory_ = std::string(dir);
502
+ }
503
+
504
+ inline void Environment::set_coverage_connection(
505
+ std::unique_ptr<profiler::V8CoverageConnection> connection) {
506
+ CHECK_NULL(coverage_connection_);
507
+ std::swap(coverage_connection_, connection);
508
+ }
509
+
510
+ inline profiler::V8CoverageConnection* Environment::coverage_connection() {
511
+ return coverage_connection_.get();
512
+ }
513
+
514
+ inline const std::string& Environment::coverage_directory() const {
515
+ return coverage_directory_;
516
+ }
517
+
518
+ inline void Environment::set_cpu_profiler_connection(
519
+ std::unique_ptr<profiler::V8CpuProfilerConnection> connection) {
520
+ CHECK_NULL(cpu_profiler_connection_);
521
+ std::swap(cpu_profiler_connection_, connection);
522
+ }
523
+
524
+ inline profiler::V8CpuProfilerConnection*
525
+ Environment::cpu_profiler_connection() {
526
+ return cpu_profiler_connection_.get();
527
+ }
528
+
529
+ inline void Environment::set_cpu_prof_interval(uint64_t interval) {
530
+ cpu_prof_interval_ = interval;
531
+ }
532
+
533
+ inline uint64_t Environment::cpu_prof_interval() const {
534
+ return cpu_prof_interval_;
535
+ }
536
+
537
+ inline void Environment::set_cpu_prof_name(const std::string& name) {
538
+ cpu_prof_name_ = name;
539
+ }
540
+
541
+ inline const std::string& Environment::cpu_prof_name() const {
542
+ return cpu_prof_name_;
543
+ }
544
+
545
+ inline void Environment::set_cpu_prof_dir(const std::string& dir) {
546
+ cpu_prof_dir_ = dir;
547
+ }
548
+
549
+ inline const std::string& Environment::cpu_prof_dir() const {
550
+ return cpu_prof_dir_;
551
+ }
552
+
553
+ inline void Environment::set_heap_profiler_connection(
554
+ std::unique_ptr<profiler::V8HeapProfilerConnection> connection) {
555
+ CHECK_NULL(heap_profiler_connection_);
556
+ std::swap(heap_profiler_connection_, connection);
557
+ }
558
+
559
+ inline profiler::V8HeapProfilerConnection*
560
+ Environment::heap_profiler_connection() {
561
+ return heap_profiler_connection_.get();
562
+ }
563
+
564
+ inline void Environment::set_heap_prof_name(const std::string& name) {
565
+ heap_prof_name_ = name;
566
+ }
567
+
568
+ inline const std::string& Environment::heap_prof_name() const {
569
+ return heap_prof_name_;
570
+ }
571
+
572
+ inline void Environment::set_heap_prof_dir(const std::string& dir) {
573
+ heap_prof_dir_ = dir;
574
+ }
575
+
576
+ inline const std::string& Environment::heap_prof_dir() const {
577
+ return heap_prof_dir_;
578
+ }
579
+
580
+ inline void Environment::set_heap_prof_interval(uint64_t interval) {
581
+ heap_prof_interval_ = interval;
582
+ }
583
+
584
+ inline uint64_t Environment::heap_prof_interval() const {
585
+ return heap_prof_interval_;
586
+ }
587
+
588
+ #endif // HAVE_INSPECTOR
589
+
590
+ inline
591
+ std::shared_ptr<ExclusiveAccess<HostPort>> Environment::inspector_host_port() {
592
+ return inspector_host_port_;
593
+ }
594
+
595
+ inline std::shared_ptr<PerIsolateOptions> IsolateData::options() {
596
+ return options_;
597
+ }
598
+
599
+ template <typename Fn>
600
+ void Environment::SetImmediate(Fn&& cb, CallbackFlags::Flags flags) {
601
+ auto callback = native_immediates_.CreateCallback(std::move(cb), flags);
602
+ native_immediates_.Push(std::move(callback));
603
+
604
+ if (flags & CallbackFlags::kRefed) {
605
+ if (immediate_info()->ref_count() == 0)
606
+ ToggleImmediateRef(true);
607
+ immediate_info()->ref_count_inc(1);
608
+ }
609
+ }
610
+
611
+ template <typename Fn>
612
+ void Environment::SetImmediateThreadsafe(Fn&& cb, CallbackFlags::Flags flags) {
613
+ auto callback = native_immediates_threadsafe_.CreateCallback(
614
+ std::move(cb), flags);
615
+ {
616
+ Mutex::ScopedLock lock(native_immediates_threadsafe_mutex_);
617
+ native_immediates_threadsafe_.Push(std::move(callback));
618
+ if (task_queues_async_initialized_)
619
+ uv_async_send(&task_queues_async_);
620
+ }
621
+ }
622
+
623
+ template <typename Fn>
624
+ void Environment::RequestInterrupt(Fn&& cb) {
625
+ auto callback = native_immediates_interrupts_.CreateCallback(
626
+ std::move(cb), CallbackFlags::kRefed);
627
+ {
628
+ Mutex::ScopedLock lock(native_immediates_threadsafe_mutex_);
629
+ native_immediates_interrupts_.Push(std::move(callback));
630
+ if (task_queues_async_initialized_)
631
+ uv_async_send(&task_queues_async_);
632
+ }
633
+ RequestInterruptFromV8();
634
+ }
635
+
636
+ inline bool Environment::can_call_into_js() const {
637
+ return can_call_into_js_ && !is_stopping();
638
+ }
639
+
640
+ inline void Environment::set_can_call_into_js(bool can_call_into_js) {
641
+ can_call_into_js_ = can_call_into_js;
642
+ }
643
+
644
+ inline bool Environment::has_run_bootstrapping_code() const {
645
+ return principal_realm_->has_run_bootstrapping_code();
646
+ }
647
+
648
+ inline bool Environment::has_serialized_options() const {
649
+ return has_serialized_options_;
650
+ }
651
+
652
+ inline void Environment::set_has_serialized_options(bool value) {
653
+ has_serialized_options_ = value;
654
+ }
655
+
656
+ inline bool Environment::is_main_thread() const {
657
+ return worker_context() == nullptr;
658
+ }
659
+
660
+ inline bool Environment::no_native_addons() const {
661
+ return (flags_ & EnvironmentFlags::kNoNativeAddons) ||
662
+ !options_->allow_native_addons;
663
+ }
664
+
665
+ inline bool Environment::should_not_register_esm_loader() const {
666
+ return flags_ & EnvironmentFlags::kNoRegisterESMLoader;
667
+ }
668
+
669
+ inline bool Environment::owns_process_state() const {
670
+ return flags_ & EnvironmentFlags::kOwnsProcessState;
671
+ }
672
+
673
+ inline bool Environment::owns_inspector() const {
674
+ return flags_ & EnvironmentFlags::kOwnsInspector;
675
+ }
676
+
677
+ inline bool Environment::should_create_inspector() const {
678
+ return (flags_ & EnvironmentFlags::kNoCreateInspector) == 0 &&
679
+ !(options_->test_runner && options_->test_isolation == "process") &&
680
+ !options_->watch_mode;
681
+ }
682
+
683
+ inline bool Environment::should_wait_for_inspector_frontend() const {
684
+ return (flags_ & EnvironmentFlags::kNoWaitForInspectorFrontend) == 0;
685
+ }
686
+
687
+ inline bool Environment::tracks_unmanaged_fds() const {
688
+ return flags_ & EnvironmentFlags::kTrackUnmanagedFds;
689
+ }
690
+
691
+ inline bool Environment::hide_console_windows() const {
692
+ return flags_ & EnvironmentFlags::kHideConsoleWindows;
693
+ }
694
+
695
+ inline bool Environment::no_global_search_paths() const {
696
+ return (flags_ & EnvironmentFlags::kNoGlobalSearchPaths) ||
697
+ !options_->global_search_paths;
698
+ }
699
+
700
+ inline bool Environment::should_start_debug_signal_handler() const {
701
+ return ((flags_ & EnvironmentFlags::kNoStartDebugSignalHandler) == 0) &&
702
+ !options_->disable_sigusr1;
703
+ }
704
+
705
+ inline bool Environment::no_browser_globals() const {
706
+ // configure --no-browser-globals
707
+ #ifdef NODE_NO_BROWSER_GLOBALS
708
+ return true;
709
+ #else
710
+ return flags_ & EnvironmentFlags::kNoBrowserGlobals;
711
+ #endif
712
+ }
713
+
714
+ bool Environment::filehandle_close_warning() const {
715
+ return emit_filehandle_warning_;
716
+ }
717
+
718
+ void Environment::set_filehandle_close_warning(bool on) {
719
+ emit_filehandle_warning_ = on;
720
+ }
721
+
722
+ void Environment::set_source_maps_enabled(bool on) {
723
+ source_maps_enabled_ = on;
724
+ }
725
+
726
+ bool Environment::source_maps_enabled() const {
727
+ return source_maps_enabled_;
728
+ }
729
+
730
+ inline uint64_t Environment::thread_id() const {
731
+ return thread_id_;
732
+ }
733
+
734
+ inline std::string_view Environment::thread_name() const {
735
+ return thread_name_;
736
+ }
737
+
738
+ inline worker::Worker* Environment::worker_context() const {
739
+ return isolate_data()->worker_context();
740
+ }
741
+
742
+ inline void Environment::add_sub_worker_context(worker::Worker* context) {
743
+ sub_worker_contexts_.insert(context);
744
+ }
745
+
746
+ inline void Environment::remove_sub_worker_context(worker::Worker* context) {
747
+ sub_worker_contexts_.erase(context);
748
+ }
749
+
750
+ template <typename Fn>
751
+ inline void Environment::ForEachWorker(Fn&& iterator) {
752
+ for (worker::Worker* w : sub_worker_contexts_) iterator(w);
753
+ }
754
+
755
+ inline bool Environment::is_stopping() const {
756
+ return is_stopping_.load();
757
+ }
758
+
759
+ inline void Environment::set_stopping(bool value) {
760
+ is_stopping_.store(value);
761
+ }
762
+
763
+ inline std::list<node_module>* Environment::extra_linked_bindings() {
764
+ return &extra_linked_bindings_;
765
+ }
766
+
767
+ inline node_module* Environment::extra_linked_bindings_head() {
768
+ return extra_linked_bindings_.size() > 0 ?
769
+ &extra_linked_bindings_.front() : nullptr;
770
+ }
771
+
772
+ inline node_module* Environment::extra_linked_bindings_tail() {
773
+ return extra_linked_bindings_.size() > 0 ?
774
+ &extra_linked_bindings_.back() : nullptr;
775
+ }
776
+
777
+ inline const Mutex& Environment::extra_linked_bindings_mutex() const {
778
+ return extra_linked_bindings_mutex_;
779
+ }
780
+
781
+ inline performance::PerformanceState* Environment::performance_state() {
782
+ return performance_state_.get();
783
+ }
784
+
785
+ inline IsolateData* Environment::isolate_data() const {
786
+ return isolate_data_;
787
+ }
788
+
789
+ template <typename T>
790
+ inline void Environment::ForEachRealm(T&& iterator) const {
791
+ // TODO(legendecas): iterate over more realms bound to the environment.
792
+ iterator(principal_realm());
793
+ }
794
+
795
+ inline void Environment::ThrowError(const char* errmsg) {
796
+ ThrowError(v8::Exception::Error, errmsg);
797
+ }
798
+
799
+ inline void Environment::ThrowTypeError(const char* errmsg) {
800
+ ThrowError(v8::Exception::TypeError, errmsg);
801
+ }
802
+
803
+ inline void Environment::ThrowRangeError(const char* errmsg) {
804
+ ThrowError(v8::Exception::RangeError, errmsg);
805
+ }
806
+
807
+ inline void Environment::ThrowError(
808
+ v8::Local<v8::Value> (*fun)(v8::Local<v8::String>, v8::Local<v8::Value>),
809
+ const char* errmsg) {
810
+ v8::HandleScope handle_scope(isolate());
811
+ isolate()->ThrowException(fun(OneByteString(isolate(), errmsg), {}));
812
+ }
813
+
814
+ inline void Environment::ThrowStdErrException(std::error_code error_code,
815
+ const char* syscall,
816
+ const char* path) {
817
+ ThrowErrnoException(
818
+ error_code.value(), syscall, error_code.message().c_str(), path);
819
+ }
820
+
821
+ inline void Environment::ThrowErrnoException(int errorno,
822
+ const char* syscall,
823
+ const char* message,
824
+ const char* path) {
825
+ isolate()->ThrowException(
826
+ ErrnoException(isolate(), errorno, syscall, message, path));
827
+ }
828
+
829
+ inline void Environment::ThrowUVException(int errorno,
830
+ const char* syscall,
831
+ const char* message,
832
+ const char* path,
833
+ const char* dest) {
834
+ isolate()->ThrowException(
835
+ UVException(isolate(), errorno, syscall, message, path, dest));
836
+ }
837
+
838
+ void Environment::AddCleanupHook(CleanupQueue::Callback fn, void* arg) {
839
+ cleanup_queue_.Add(fn, arg);
840
+ }
841
+
842
+ void Environment::RemoveCleanupHook(CleanupQueue::Callback fn, void* arg) {
843
+ cleanup_queue_.Remove(fn, arg);
844
+ }
845
+
846
+ void Environment::set_process_exit_handler(
847
+ std::function<void(Environment*, ExitCode)>&& handler) {
848
+ process_exit_handler_ = std::move(handler);
849
+ }
850
+
851
+ #define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
852
+ #define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
853
+ #define VS(PropertyName, StringValue) V(v8::String, PropertyName)
854
+ #define VR(PropertyName, TypeName) V(v8::Private, per_realm_##PropertyName)
855
+ #define V(TypeName, PropertyName) \
856
+ inline \
857
+ v8::Local<TypeName> IsolateData::PropertyName() const { \
858
+ return PropertyName ## _ .Get(isolate_); \
859
+ }
860
+ PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
861
+ PER_ISOLATE_SYMBOL_PROPERTIES(VY)
862
+ PER_ISOLATE_STRING_PROPERTIES(VS)
863
+ PER_REALM_STRONG_PERSISTENT_VALUES(VR)
864
+ #undef V
865
+ #undef VR
866
+ #undef VS
867
+ #undef VY
868
+ #undef VP
869
+
870
+ #define VM(PropertyName) V(PropertyName##_binding_template, v8::ObjectTemplate)
871
+ #define V(PropertyName, TypeName) \
872
+ inline v8::Local<TypeName> IsolateData::PropertyName() const { \
873
+ return PropertyName##_.Get(isolate_); \
874
+ } \
875
+ inline void IsolateData::set_##PropertyName(v8::Local<TypeName> value) { \
876
+ CHECK(PropertyName##_.IsEmpty()); \
877
+ PropertyName##_.Set(isolate_, value); \
878
+ }
879
+ PER_ISOLATE_TEMPLATE_PROPERTIES(V)
880
+ NODE_BINDINGS_WITH_PER_ISOLATE_INIT(VM)
881
+ #undef V
882
+ #undef VM
883
+
884
+ #define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
885
+ #define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
886
+ #define VS(PropertyName, StringValue) V(v8::String, PropertyName)
887
+ #define V(TypeName, PropertyName) \
888
+ inline v8::Local<TypeName> Environment::PropertyName() const { \
889
+ return isolate_data()->PropertyName(); \
890
+ }
891
+ PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
892
+ PER_ISOLATE_SYMBOL_PROPERTIES(VY)
893
+ PER_ISOLATE_STRING_PROPERTIES(VS)
894
+ #undef V
895
+ #undef VS
896
+ #undef VY
897
+ #undef VP
898
+
899
+ #define V(PropertyName, TypeName) \
900
+ inline v8::Local<TypeName> Environment::PropertyName() const { \
901
+ return isolate_data()->PropertyName(); \
902
+ } \
903
+ inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \
904
+ DCHECK(isolate_data()->PropertyName().IsEmpty()); \
905
+ isolate_data()->set_##PropertyName(value); \
906
+ }
907
+ PER_ISOLATE_TEMPLATE_PROPERTIES(V)
908
+ #undef V
909
+
910
+ #define V(PropertyName, TypeName) \
911
+ inline v8::Local<TypeName> Environment::PropertyName() const { \
912
+ DCHECK_NOT_NULL(principal_realm_); \
913
+ return principal_realm_->PropertyName(); \
914
+ } \
915
+ inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \
916
+ DCHECK_NOT_NULL(principal_realm_); \
917
+ principal_realm_->set_##PropertyName(value); \
918
+ }
919
+ PER_REALM_STRONG_PERSISTENT_VALUES(V)
920
+ #undef V
921
+
922
+ v8::Local<v8::Context> Environment::context() const {
923
+ return principal_realm()->context();
924
+ }
925
+
926
+ PrincipalRealm* Environment::principal_realm() const {
927
+ return principal_realm_.get();
928
+ }
929
+
930
+ inline void Environment::set_heap_snapshot_near_heap_limit(uint32_t limit) {
931
+ heap_snapshot_near_heap_limit_ = limit;
932
+ }
933
+
934
+ inline bool Environment::is_in_heapsnapshot_heap_limit_callback() const {
935
+ return is_in_heapsnapshot_heap_limit_callback_;
936
+ }
937
+
938
+ inline bool Environment::report_exclude_env() const {
939
+ return options_->report_exclude_env;
940
+ }
941
+
942
+ inline void Environment::AddHeapSnapshotNearHeapLimitCallback() {
943
+ DCHECK(!heapsnapshot_near_heap_limit_callback_added_);
944
+ heapsnapshot_near_heap_limit_callback_added_ = true;
945
+ isolate_->AddNearHeapLimitCallback(Environment::NearHeapLimitCallback, this);
946
+ }
947
+
948
+ inline void Environment::RemoveHeapSnapshotNearHeapLimitCallback(
949
+ size_t heap_limit) {
950
+ DCHECK(heapsnapshot_near_heap_limit_callback_added_);
951
+ heapsnapshot_near_heap_limit_callback_added_ = false;
952
+ isolate_->RemoveNearHeapLimitCallback(Environment::NearHeapLimitCallback,
953
+ heap_limit);
954
+ }
955
+
956
+ inline void Environment::SetAsyncResourceContextFrame(
957
+ std::uintptr_t async_resource_handle,
958
+ v8::Global<v8::Value>&& context_frame) {
959
+ async_resource_context_frames_.emplace(
960
+ std::make_pair(async_resource_handle, std::move(context_frame)));
961
+ }
962
+
963
+ inline const v8::Global<v8::Value>& Environment::GetAsyncResourceContextFrame(
964
+ std::uintptr_t async_resource_handle) {
965
+ auto&& async_resource_context_frame =
966
+ async_resource_context_frames_.find(async_resource_handle);
967
+ CHECK_NE(async_resource_context_frame, async_resource_context_frames_.end());
968
+
969
+ return async_resource_context_frame->second;
970
+ }
971
+
972
+ inline void Environment::RemoveAsyncResourceContextFrame(
973
+ std::uintptr_t async_resource_handle) {
974
+ async_resource_context_frames_.erase(async_resource_handle);
975
+ }
976
+ } // namespace node
977
+
978
+ // These two files depend on each other. Including base_object-inl.h after this
979
+ // file is the easiest way to avoid issues with that circular dependency.
980
+ #include "base_object-inl.h"
981
+
982
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
983
+
984
+ #endif // SRC_ENV_INL_H_