@encharm/cws 4.1.0 → 4.2.0

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 (370) hide show
  1. package/dist/bindings/cws_linux_108.node +0 -0
  2. package/dist/bindings/cws_linux_64.node +0 -0
  3. package/dist/bindings/cws_linux_72.node +0 -0
  4. package/dist/bindings/cws_linux_79.node +0 -0
  5. package/dist/bindings/cws_linux_83.node +0 -0
  6. package/dist/bindings/cws_linux_93.node +0 -0
  7. package/dist/bindings/cws_win32_64.node +0 -0
  8. package/dist/bindings/cws_win32_72.node +0 -0
  9. package/dist/bindings/cws_win32_79.node +0 -0
  10. package/dist/bindings/cws_win32_83.node +0 -0
  11. package/dist/bindings/cws_win32_93.node +0 -0
  12. package/package.json +1 -1
  13. package/src/Addon.h +24 -2
  14. package/src/HTTPSocket.cpp +1 -1
  15. package/src/headers/{13 → 18}/aliased_buffer.h +61 -9
  16. package/src/headers/18/aliased_struct-inl.h +54 -0
  17. package/src/headers/18/aliased_struct.h +63 -0
  18. package/src/headers/{12 → 18}/async_wrap-inl.h +0 -0
  19. package/src/headers/{12 → 18}/async_wrap.h +26 -2
  20. package/src/headers/{12/base64.h → 18/base64-inl.h} +78 -86
  21. package/src/headers/18/base64.h +69 -0
  22. package/src/headers/{12 → 18}/base_object-inl.h +46 -25
  23. package/src/headers/{12 → 18}/base_object.h +82 -17
  24. package/src/headers/{12 → 18}/callback_queue-inl.h +9 -9
  25. package/src/headers/{12 → 18}/callback_queue.h +13 -5
  26. package/src/headers/18/cares_wrap.h +523 -0
  27. package/src/headers/{12 → 18}/connect_wrap.h +0 -0
  28. package/src/headers/{12 → 18}/connection_wrap.h +0 -0
  29. package/src/headers/18/crypto/crypto_aes.h +89 -0
  30. package/src/headers/{13/node_crypto_bio.h → 18/crypto/crypto_bio.h} +3 -4
  31. package/src/headers/18/crypto/crypto_cipher.h +291 -0
  32. package/src/headers/{13/node_crypto_clienthello-inl.h → 18/crypto/crypto_clienthello-inl.h} +4 -5
  33. package/src/headers/{13/node_crypto_clienthello.h → 18/crypto/crypto_clienthello.h} +3 -4
  34. package/src/headers/{12/node_crypto_common.h → 18/crypto/crypto_common.h} +49 -36
  35. package/src/headers/18/crypto/crypto_context.h +147 -0
  36. package/src/headers/18/crypto/crypto_dh.h +156 -0
  37. package/src/headers/18/crypto/crypto_dsa.h +77 -0
  38. package/src/headers/18/crypto/crypto_ec.h +170 -0
  39. package/src/headers/{12/node_crypto_groups.h → 18/crypto/crypto_groups.h} +3 -3
  40. package/src/headers/18/crypto/crypto_hash.h +89 -0
  41. package/src/headers/18/crypto/crypto_hkdf.h +65 -0
  42. package/src/headers/18/crypto/crypto_hmac.h +94 -0
  43. package/src/headers/18/crypto/crypto_keygen.h +305 -0
  44. package/src/headers/18/crypto/crypto_keys.h +420 -0
  45. package/src/headers/18/crypto/crypto_pbkdf2.h +76 -0
  46. package/src/headers/18/crypto/crypto_random.h +130 -0
  47. package/src/headers/18/crypto/crypto_rsa.h +141 -0
  48. package/src/headers/18/crypto/crypto_scrypt.h +87 -0
  49. package/src/headers/18/crypto/crypto_sig.h +168 -0
  50. package/src/headers/18/crypto/crypto_spkac.h +21 -0
  51. package/src/headers/18/crypto/crypto_timing.h +20 -0
  52. package/src/headers/{13/tls_wrap.h → 18/crypto/crypto_tls.h} +137 -66
  53. package/src/headers/18/crypto/crypto_util.h +791 -0
  54. package/src/headers/18/crypto/crypto_x509.h +143 -0
  55. package/src/headers/{12 → 18}/debug_utils-inl.h +0 -0
  56. package/src/headers/{13 → 18}/debug_utils.h +7 -4
  57. package/src/headers/{12 → 18}/diagnosticfilename-inl.h +0 -0
  58. package/src/headers/{12 → 18}/env-inl.h +397 -304
  59. package/src/headers/{12 → 18}/env.h +397 -172
  60. package/src/headers/{12 → 18}/handle_wrap.h +7 -3
  61. package/src/headers/18/histogram-inl.h +107 -0
  62. package/src/headers/18/histogram.h +239 -0
  63. package/src/headers/{13 → 18}/inspector_agent.h +4 -7
  64. package/src/headers/{12 → 18}/inspector_io.h +0 -0
  65. package/src/headers/{13 → 18}/inspector_profiler.h +17 -5
  66. package/src/headers/{12 → 18}/inspector_socket.h +0 -0
  67. package/src/headers/{12 → 18}/inspector_socket_server.h +0 -0
  68. package/src/headers/18/js_native_api.h +571 -0
  69. package/src/headers/{13 → 18}/js_native_api_types.h +30 -7
  70. package/src/headers/{12 → 18}/js_native_api_v8.h +220 -83
  71. package/src/headers/{12 → 18}/js_native_api_v8_internals.h +6 -5
  72. package/src/headers/{12 → 18}/js_stream.h +0 -0
  73. package/src/headers/{12 → 18}/json_utils.h +0 -0
  74. package/src/headers/{13 → 18}/memory_tracker-inl.h +6 -5
  75. package/src/headers/{13 → 18}/memory_tracker.h +0 -7
  76. package/src/headers/{13 → 18}/module_wrap.h +24 -7
  77. package/src/headers/{13 → 18}/node.h +329 -68
  78. package/src/headers/18/node_api.h +288 -0
  79. package/src/headers/18/node_api_internals.h +38 -0
  80. package/src/headers/{12 → 18}/node_api_types.h +12 -9
  81. package/src/headers/{12 → 18}/node_binding.h +0 -0
  82. package/src/headers/18/node_blob.h +191 -0
  83. package/src/headers/18/node_bob-inl.h +37 -0
  84. package/src/headers/18/node_bob.h +111 -0
  85. package/src/headers/{13 → 18}/node_buffer.h +0 -0
  86. package/src/headers/{13 → 18}/node_constants.h +5 -1
  87. package/src/headers/{12 → 18}/node_context_data.h +5 -0
  88. package/src/headers/{12 → 18}/node_contextify.h +37 -2
  89. package/src/headers/{10/node_win32_perfctr_provider.h → 18/node_crypto.h} +30 -31
  90. package/src/headers/{12 → 18}/node_dir.h +0 -0
  91. package/src/headers/{12 → 18}/node_dtrace.h +0 -0
  92. package/src/headers/{12 → 18}/node_errors.h +90 -24
  93. package/src/headers/18/node_external_reference.h +145 -0
  94. package/src/headers/{13 → 18}/node_file-inl.h +38 -21
  95. package/src/headers/{12 → 18}/node_file.h +74 -13
  96. package/src/headers/{13 → 18}/node_http2.h +365 -269
  97. package/src/headers/{12 → 18}/node_http2_state.h +40 -50
  98. package/src/headers/{13 → 18}/node_http_common-inl.h +25 -5
  99. package/src/headers/{13 → 18}/node_http_common.h +24 -20
  100. package/src/headers/{13 → 18}/node_i18n.h +2 -1
  101. package/src/headers/{12 → 18}/node_internals.h +39 -41
  102. package/src/headers/{13 → 18}/node_main_instance.h +15 -18
  103. package/src/headers/{12 → 18}/node_mem-inl.h +0 -0
  104. package/src/headers/{12 → 18}/node_mem.h +1 -1
  105. package/src/headers/{13 → 18}/node_messaging.h +170 -23
  106. package/src/headers/{12 → 18}/node_metadata.h +17 -4
  107. package/src/headers/{12 → 18}/node_mutex.h +77 -1
  108. package/src/headers/{12 → 18}/node_native_module.h +11 -1
  109. package/src/headers/{13 → 18}/node_native_module_env.h +14 -8
  110. package/src/headers/{12 → 18}/node_object_wrap.h +0 -0
  111. package/src/headers/{13 → 18}/node_options-inl.h +51 -21
  112. package/src/headers/{13 → 18}/node_options.h +46 -14
  113. package/src/headers/18/node_perf.h +168 -0
  114. package/src/headers/{12 → 18}/node_perf_common.h +16 -22
  115. package/src/headers/{12 → 18}/node_platform.h +21 -16
  116. package/src/headers/18/node_process-inl.h +26 -0
  117. package/src/headers/18/node_process.h +97 -0
  118. package/src/headers/{13 → 18}/node_report.h +2 -2
  119. package/src/headers/{13 → 18}/node_revert.h +10 -0
  120. package/src/headers/{12 → 18}/node_root_certs.h +439 -651
  121. package/src/headers/18/node_snapshot_builder.h +43 -0
  122. package/src/headers/18/node_snapshotable.h +130 -0
  123. package/src/headers/{12 → 18}/node_sockaddr-inl.h +100 -4
  124. package/src/headers/18/node_sockaddr.h +405 -0
  125. package/src/headers/{12 → 18}/node_stat_watcher.h +7 -1
  126. package/src/headers/{12 → 18}/node_union_bytes.h +0 -0
  127. package/src/headers/{13 → 18}/node_url.h +18 -1
  128. package/src/headers/18/node_v8.h +41 -0
  129. package/src/headers/{12 → 18}/node_v8_platform-inl.h +10 -0
  130. package/src/headers/{13 → 18}/node_version.h +7 -7
  131. package/src/headers/{12 → 18}/node_wasi.h +0 -0
  132. package/src/headers/18/node_wasm_web_api.h +55 -0
  133. package/src/headers/{13 → 18}/node_watchdog.h +0 -0
  134. package/src/headers/{10 → 18}/node_win32_etw_provider-inl.h +7 -6
  135. package/src/headers/{10 → 18}/node_win32_etw_provider.h +0 -0
  136. package/src/headers/{13 → 18}/node_worker.h +24 -17
  137. package/src/headers/{12 → 18}/pipe_wrap.h +2 -0
  138. package/src/headers/{12 → 18}/req_wrap-inl.h +0 -0
  139. package/src/headers/{12 → 18}/req_wrap.h +1 -1
  140. package/src/headers/{12 → 18}/spawn_sync.h +0 -0
  141. package/src/headers/{13 → 18}/stream_base-inl.h +58 -22
  142. package/src/headers/{13 → 18}/stream_base.h +29 -3
  143. package/src/headers/{13 → 18}/stream_pipe.h +8 -3
  144. package/src/headers/{12 → 18}/stream_wrap.h +4 -1
  145. package/src/headers/{13 → 18}/string_bytes.h +0 -7
  146. package/src/headers/{12 → 18}/string_decoder-inl.h +0 -0
  147. package/src/headers/{10 → 18}/string_decoder.h +0 -0
  148. package/src/headers/{13 → 18}/string_search.h +2 -2
  149. package/src/headers/{12 → 18}/tcp_wrap.h +4 -0
  150. package/src/headers/{12 → 18}/threadpoolwork-inl.h +0 -0
  151. package/src/headers/18/timer_wrap-inl.h +32 -0
  152. package/src/headers/18/timer_wrap.h +85 -0
  153. package/src/headers/{13 → 18}/tracing/agent.h +1 -1
  154. package/src/headers/{12 → 18}/tracing/node_trace_buffer.h +0 -0
  155. package/src/headers/{12 → 18}/tracing/node_trace_writer.h +0 -0
  156. package/src/headers/{13 → 18}/tracing/trace_event.h +23 -13
  157. package/src/headers/{12 → 18}/tracing/trace_event_common.h +0 -0
  158. package/src/headers/{12 → 18}/tracing/traced_value.h +0 -0
  159. package/src/headers/{13 → 18}/tty_wrap.h +2 -1
  160. package/src/headers/{13 → 18}/udp_wrap.h +5 -0
  161. package/src/headers/{13 → 18}/util-inl.h +69 -15
  162. package/src/headers/{13 → 18}/util.h +93 -31
  163. package/src/headers/18/v8-fast-api-calls.h +939 -0
  164. package/src/headers/{12 → 18}/v8abbr.h +2 -2
  165. package/src/headers/10/aliased_buffer.h +0 -241
  166. package/src/headers/10/async_wrap-inl.h +0 -106
  167. package/src/headers/10/async_wrap.h +0 -218
  168. package/src/headers/10/base64.h +0 -197
  169. package/src/headers/10/base_object-inl.h +0 -132
  170. package/src/headers/10/base_object.h +0 -115
  171. package/src/headers/10/connect_wrap.h +0 -28
  172. package/src/headers/10/connection_wrap.h +0 -30
  173. package/src/headers/10/debug_utils.h +0 -128
  174. package/src/headers/10/env-inl.h +0 -906
  175. package/src/headers/10/env.h +0 -1046
  176. package/src/headers/10/handle_wrap.h +0 -114
  177. package/src/headers/10/inspector_agent.h +0 -137
  178. package/src/headers/10/inspector_io.h +0 -97
  179. package/src/headers/10/inspector_socket.h +0 -59
  180. package/src/headers/10/inspector_socket_server.h +0 -104
  181. package/src/headers/10/js_stream.h +0 -57
  182. package/src/headers/10/memory_tracker-inl.h +0 -318
  183. package/src/headers/10/memory_tracker.h +0 -246
  184. package/src/headers/10/module_wrap.h +0 -100
  185. package/src/headers/10/node.h +0 -863
  186. package/src/headers/10/node_api.h +0 -752
  187. package/src/headers/10/node_api_types.h +0 -171
  188. package/src/headers/10/node_buffer.h +0 -90
  189. package/src/headers/10/node_code_cache.h +0 -17
  190. package/src/headers/10/node_constants.h +0 -74
  191. package/src/headers/10/node_context_data.h +0 -39
  192. package/src/headers/10/node_contextify.h +0 -141
  193. package/src/headers/10/node_counters.h +0 -59
  194. package/src/headers/10/node_crypto.h +0 -699
  195. package/src/headers/10/node_crypto_bio.h +0 -177
  196. package/src/headers/10/node_crypto_clienthello-inl.h +0 -92
  197. package/src/headers/10/node_crypto_clienthello.h +0 -131
  198. package/src/headers/10/node_crypto_groups.h +0 -416
  199. package/src/headers/10/node_dtrace.h +0 -84
  200. package/src/headers/10/node_errors.h +0 -118
  201. package/src/headers/10/node_file.h +0 -373
  202. package/src/headers/10/node_http2.h +0 -1304
  203. package/src/headers/10/node_http2_state.h +0 -158
  204. package/src/headers/10/node_i18n.h +0 -69
  205. package/src/headers/10/node_internals.h +0 -952
  206. package/src/headers/10/node_javascript.h +0 -41
  207. package/src/headers/10/node_messaging.h +0 -219
  208. package/src/headers/10/node_mutex.h +0 -191
  209. package/src/headers/10/node_object_wrap.h +0 -130
  210. package/src/headers/10/node_options-inl.h +0 -444
  211. package/src/headers/10/node_options.h +0 -397
  212. package/src/headers/10/node_perf.h +0 -134
  213. package/src/headers/10/node_perf_common.h +0 -96
  214. package/src/headers/10/node_persistent.h +0 -30
  215. package/src/headers/10/node_platform.h +0 -170
  216. package/src/headers/10/node_revert.h +0 -75
  217. package/src/headers/10/node_root_certs.h +0 -3393
  218. package/src/headers/10/node_stat_watcher.h +0 -65
  219. package/src/headers/10/node_url.h +0 -193
  220. package/src/headers/10/node_version.h +0 -120
  221. package/src/headers/10/node_watchdog.h +0 -114
  222. package/src/headers/10/node_worker.h +0 -94
  223. package/src/headers/10/pipe_wrap.h +0 -76
  224. package/src/headers/10/req_wrap-inl.h +0 -166
  225. package/src/headers/10/req_wrap.h +0 -61
  226. package/src/headers/10/sharedarraybuffer_metadata.h +0 -67
  227. package/src/headers/10/spawn_sync.h +0 -240
  228. package/src/headers/10/stream_base-inl.h +0 -458
  229. package/src/headers/10/stream_base.h +0 -378
  230. package/src/headers/10/stream_pipe.h +0 -72
  231. package/src/headers/10/stream_wrap.h +0 -130
  232. package/src/headers/10/string_bytes.h +0 -126
  233. package/src/headers/10/string_decoder-inl.h +0 -38
  234. package/src/headers/10/string_search.h +0 -620
  235. package/src/headers/10/tcp_wrap.h +0 -99
  236. package/src/headers/10/tls_wrap.h +0 -195
  237. package/src/headers/10/tracing/agent.h +0 -178
  238. package/src/headers/10/tracing/node_trace_buffer.h +0 -83
  239. package/src/headers/10/tracing/node_trace_writer.h +0 -75
  240. package/src/headers/10/tracing/trace_event.h +0 -706
  241. package/src/headers/10/tracing/trace_event_common.h +0 -1102
  242. package/src/headers/10/tracing/traced_value.h +0 -68
  243. package/src/headers/10/tty_wrap.h +0 -63
  244. package/src/headers/10/udp_wrap.h +0 -102
  245. package/src/headers/10/util-inl.h +0 -459
  246. package/src/headers/10/util.h +0 -508
  247. package/src/headers/10/v8abbr.h +0 -121
  248. package/src/headers/12/aliased_buffer.h +0 -263
  249. package/src/headers/12/debug_utils.h +0 -181
  250. package/src/headers/12/histogram-inl.h +0 -83
  251. package/src/headers/12/histogram.h +0 -98
  252. package/src/headers/12/http_parser_adaptor.h +0 -24
  253. package/src/headers/12/inspector_agent.h +0 -147
  254. package/src/headers/12/inspector_profiler.h +0 -137
  255. package/src/headers/12/js_native_api.h +0 -541
  256. package/src/headers/12/js_native_api_types.h +0 -139
  257. package/src/headers/12/memory_tracker-inl.h +0 -339
  258. package/src/headers/12/memory_tracker.h +0 -283
  259. package/src/headers/12/module_wrap.h +0 -99
  260. package/src/headers/12/node.h +0 -887
  261. package/src/headers/12/node_api.h +0 -239
  262. package/src/headers/12/node_buffer.h +0 -92
  263. package/src/headers/12/node_constants.h +0 -80
  264. package/src/headers/12/node_crypto.h +0 -800
  265. package/src/headers/12/node_crypto_bio.h +0 -195
  266. package/src/headers/12/node_crypto_clienthello-inl.h +0 -91
  267. package/src/headers/12/node_crypto_clienthello.h +0 -132
  268. package/src/headers/12/node_file-inl.h +0 -289
  269. package/src/headers/12/node_http2.h +0 -1311
  270. package/src/headers/12/node_http_parser_impl.h +0 -994
  271. package/src/headers/12/node_i18n.h +0 -144
  272. package/src/headers/12/node_main_instance.h +0 -97
  273. package/src/headers/12/node_messaging.h +0 -227
  274. package/src/headers/12/node_native_module_env.h +0 -65
  275. package/src/headers/12/node_options-inl.h +0 -447
  276. package/src/headers/12/node_options.h +0 -479
  277. package/src/headers/12/node_perf.h +0 -181
  278. package/src/headers/12/node_process.h +0 -41
  279. package/src/headers/12/node_report.h +0 -47
  280. package/src/headers/12/node_revert.h +0 -78
  281. package/src/headers/12/node_sockaddr.h +0 -123
  282. package/src/headers/12/node_url.h +0 -188
  283. package/src/headers/12/node_version.h +0 -98
  284. package/src/headers/12/node_watchdog.h +0 -152
  285. package/src/headers/12/node_win32_etw_provider-inl.h +0 -287
  286. package/src/headers/12/node_win32_etw_provider.h +0 -99
  287. package/src/headers/12/node_worker.h +0 -142
  288. package/src/headers/12/sharedarraybuffer_metadata.h +0 -72
  289. package/src/headers/12/stream_base-inl.h +0 -323
  290. package/src/headers/12/stream_base.h +0 -431
  291. package/src/headers/12/stream_pipe.h +0 -72
  292. package/src/headers/12/string_bytes.h +0 -142
  293. package/src/headers/12/string_decoder.h +0 -50
  294. package/src/headers/12/string_search.h +0 -638
  295. package/src/headers/12/tls_wrap.h +0 -221
  296. package/src/headers/12/tracing/agent.h +0 -195
  297. package/src/headers/12/tracing/trace_event.h +0 -710
  298. package/src/headers/12/tty_wrap.h +0 -64
  299. package/src/headers/12/udp_wrap.h +0 -222
  300. package/src/headers/12/util-inl.h +0 -529
  301. package/src/headers/12/util.h +0 -765
  302. package/src/headers/13/async_wrap-inl.h +0 -94
  303. package/src/headers/13/async_wrap.h +0 -224
  304. package/src/headers/13/base64.h +0 -197
  305. package/src/headers/13/base_object-inl.h +0 -353
  306. package/src/headers/13/base_object.h +0 -229
  307. package/src/headers/13/connect_wrap.h +0 -26
  308. package/src/headers/13/connection_wrap.h +0 -30
  309. package/src/headers/13/debug_utils-inl.h +0 -223
  310. package/src/headers/13/diagnosticfilename-inl.h +0 -33
  311. package/src/headers/13/env-inl.h +0 -1293
  312. package/src/headers/13/env.h +0 -1469
  313. package/src/headers/13/handle_wrap.h +0 -117
  314. package/src/headers/13/histogram-inl.h +0 -83
  315. package/src/headers/13/histogram.h +0 -98
  316. package/src/headers/13/inspector_io.h +0 -78
  317. package/src/headers/13/inspector_socket.h +0 -60
  318. package/src/headers/13/inspector_socket_server.h +0 -110
  319. package/src/headers/13/js_native_api.h +0 -541
  320. package/src/headers/13/js_native_api_v8.h +0 -303
  321. package/src/headers/13/js_native_api_v8_internals.h +0 -38
  322. package/src/headers/13/js_stream.h +0 -52
  323. package/src/headers/13/json_utils.h +0 -160
  324. package/src/headers/13/node_api.h +0 -239
  325. package/src/headers/13/node_api_types.h +0 -44
  326. package/src/headers/13/node_binding.h +0 -99
  327. package/src/headers/13/node_context_data.h +0 -39
  328. package/src/headers/13/node_contextify.h +0 -161
  329. package/src/headers/13/node_crypto.h +0 -800
  330. package/src/headers/13/node_crypto_common.h +0 -138
  331. package/src/headers/13/node_crypto_groups.h +0 -415
  332. package/src/headers/13/node_dir.h +0 -52
  333. package/src/headers/13/node_dtrace.h +0 -86
  334. package/src/headers/13/node_errors.h +0 -210
  335. package/src/headers/13/node_file.h +0 -364
  336. package/src/headers/13/node_http2_state.h +0 -144
  337. package/src/headers/13/node_internals.h +0 -405
  338. package/src/headers/13/node_mem-inl.h +0 -112
  339. package/src/headers/13/node_mem.h +0 -41
  340. package/src/headers/13/node_metadata.h +0 -109
  341. package/src/headers/13/node_mutex.h +0 -247
  342. package/src/headers/13/node_native_module.h +0 -99
  343. package/src/headers/13/node_object_wrap.h +0 -132
  344. package/src/headers/13/node_perf.h +0 -181
  345. package/src/headers/13/node_perf_common.h +0 -97
  346. package/src/headers/13/node_platform.h +0 -190
  347. package/src/headers/13/node_process.h +0 -41
  348. package/src/headers/13/node_root_certs.h +0 -3424
  349. package/src/headers/13/node_sockaddr-inl.h +0 -170
  350. package/src/headers/13/node_sockaddr.h +0 -123
  351. package/src/headers/13/node_stat_watcher.h +0 -66
  352. package/src/headers/13/node_union_bytes.h +0 -103
  353. package/src/headers/13/node_v8_platform-inl.h +0 -184
  354. package/src/headers/13/node_wasi.h +0 -108
  355. package/src/headers/13/node_win32_etw_provider-inl.h +0 -287
  356. package/src/headers/13/node_win32_etw_provider.h +0 -99
  357. package/src/headers/13/pipe_wrap.h +0 -78
  358. package/src/headers/13/req_wrap-inl.h +0 -170
  359. package/src/headers/13/req_wrap.h +0 -77
  360. package/src/headers/13/spawn_sync.h +0 -242
  361. package/src/headers/13/stream_wrap.h +0 -130
  362. package/src/headers/13/string_decoder-inl.h +0 -37
  363. package/src/headers/13/string_decoder.h +0 -50
  364. package/src/headers/13/tcp_wrap.h +0 -101
  365. package/src/headers/13/threadpoolwork-inl.h +0 -57
  366. package/src/headers/13/tracing/node_trace_buffer.h +0 -83
  367. package/src/headers/13/tracing/node_trace_writer.h +0 -75
  368. package/src/headers/13/tracing/trace_event_common.h +0 -1109
  369. package/src/headers/13/tracing/traced_value.h +0 -70
  370. package/src/headers/13/v8abbr.h +0 -124
@@ -34,9 +34,11 @@
34
34
  #include "handle_wrap.h"
35
35
  #include "node.h"
36
36
  #include "node_binding.h"
37
- #include "node_http2_state.h"
38
37
  #include "node_main_instance.h"
38
+ #include "node_native_module.h"
39
39
  #include "node_options.h"
40
+ #include "node_perf_common.h"
41
+ #include "node_snapshotable.h"
40
42
  #include "req_wrap.h"
41
43
  #include "util.h"
42
44
  #include "uv.h"
@@ -47,12 +49,14 @@
47
49
  #include <cstdint>
48
50
  #include <functional>
49
51
  #include <list>
52
+ #include <memory>
53
+ #include <ostream>
54
+ #include <set>
55
+ #include <string>
50
56
  #include <unordered_map>
51
57
  #include <unordered_set>
52
58
  #include <vector>
53
59
 
54
- struct nghttp2_rcbuf;
55
-
56
60
  namespace node {
57
61
 
58
62
  namespace contextify {
@@ -60,10 +64,6 @@ class ContextifyScript;
60
64
  class CompiledFnEntry;
61
65
  }
62
66
 
63
- namespace fs {
64
- class FileHandleReadWrap;
65
- }
66
-
67
67
  namespace performance {
68
68
  class PerformanceState;
69
69
  }
@@ -137,6 +137,19 @@ enum class FsStatsOffset {
137
137
  constexpr size_t kFsStatsBufferLength =
138
138
  static_cast<size_t>(FsStatsOffset::kFsStatsFieldsNumber) * 2;
139
139
 
140
+ // Disables zero-filling for ArrayBuffer allocations in this scope. This is
141
+ // similar to how we implement Buffer.allocUnsafe() in JS land.
142
+ class NoArrayBufferZeroFillScope {
143
+ public:
144
+ inline explicit NoArrayBufferZeroFillScope(IsolateData* isolate_data);
145
+ inline ~NoArrayBufferZeroFillScope();
146
+
147
+ private:
148
+ NodeArrayBufferAllocator* node_allocator_;
149
+
150
+ friend class Environment;
151
+ };
152
+
140
153
  // PER_ISOLATE_* macros: We have a lot of per-isolate properties
141
154
  // and adding and maintaining their getters and setters by hand would be
142
155
  // difficult so let's make the preprocessor generate them for us.
@@ -153,19 +166,24 @@ constexpr size_t kFsStatsBufferLength =
153
166
  // "node:" prefix to avoid name clashes with third-party code.
154
167
  #define PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(V) \
155
168
  V(alpn_buffer_private_symbol, "node:alpnBuffer") \
156
- V(arraybuffer_untransferable_private_symbol, "node:untransferableBuffer") \
157
169
  V(arrow_message_private_symbol, "node:arrowMessage") \
158
170
  V(contextify_context_private_symbol, "node:contextify:context") \
159
171
  V(contextify_global_private_symbol, "node:contextify:global") \
160
172
  V(decorated_private_symbol, "node:decorated") \
173
+ V(napi_type_tag, "node:napi:type_tag") \
161
174
  V(napi_wrapper, "node:napi:wrapper") \
162
- V(sab_lifetimepartner_symbol, "node:sharedArrayBufferLifetimePartner") \
175
+ V(untransferable_object_private_symbol, "node:untransferableObject") \
163
176
 
164
177
  // Symbols are per-isolate primitives but Environment proxies them
165
178
  // for the sake of convenience.
166
179
  #define PER_ISOLATE_SYMBOL_PROPERTIES(V) \
180
+ V(async_id_symbol, "async_id_symbol") \
167
181
  V(handle_onclose_symbol, "handle_onclose") \
168
182
  V(no_message_symbol, "no_message_symbol") \
183
+ V(messaging_deserialize_symbol, "messaging_deserialize_symbol") \
184
+ V(messaging_transfer_symbol, "messaging_transfer_symbol") \
185
+ V(messaging_clone_symbol, "messaging_clone_symbol") \
186
+ V(messaging_transfer_list_symbol, "messaging_transfer_list_symbol") \
169
187
  V(oninit_symbol, "oninit") \
170
188
  V(owner_symbol, "owner_symbol") \
171
189
  V(onpskexchange_symbol, "onpskexchange") \
@@ -175,12 +193,14 @@ constexpr size_t kFsStatsBufferLength =
175
193
  // Strings are per-isolate primitives but Environment proxies them
176
194
  // for the sake of convenience. Strings should be ASCII-only.
177
195
  #define PER_ISOLATE_STRING_PROPERTIES(V) \
196
+ V(ack_string, "ack") \
178
197
  V(address_string, "address") \
179
198
  V(aliases_string, "aliases") \
180
199
  V(args_string, "args") \
181
200
  V(asn1curve_string, "asn1Curve") \
182
201
  V(async_ids_stack_string, "async_ids_stack") \
183
202
  V(bits_string, "bits") \
203
+ V(block_list_string, "blockList") \
184
204
  V(buffer_string, "buffer") \
185
205
  V(bytes_parsed_string, "bytesParsed") \
186
206
  V(bytes_read_string, "bytesRead") \
@@ -208,12 +228,17 @@ constexpr size_t kFsStatsBufferLength =
208
228
  V(crypto_rsa_pss_string, "rsa-pss") \
209
229
  V(cwd_string, "cwd") \
210
230
  V(data_string, "data") \
231
+ V(default_is_true_string, "defaultIsTrue") \
232
+ V(deserialize_info_string, "deserializeInfo") \
211
233
  V(dest_string, "dest") \
212
234
  V(destroyed_string, "destroyed") \
213
235
  V(detached_string, "detached") \
214
236
  V(dh_string, "DH") \
237
+ V(divisor_length_string, "divisorLength") \
215
238
  V(dns_a_string, "A") \
216
239
  V(dns_aaaa_string, "AAAA") \
240
+ V(dns_caa_string, "CAA") \
241
+ V(dns_critical_string, "critical") \
217
242
  V(dns_cname_string, "CNAME") \
218
243
  V(dns_mx_string, "MX") \
219
244
  V(dns_naptr_string, "NAPTR") \
@@ -225,6 +250,7 @@ constexpr size_t kFsStatsBufferLength =
225
250
  V(done_string, "done") \
226
251
  V(duration_string, "duration") \
227
252
  V(ecdh_string, "ECDH") \
253
+ V(emit_string, "emit") \
228
254
  V(emit_warning_string, "emitWarning") \
229
255
  V(empty_object_string, "{}") \
230
256
  V(encoding_string, "encoding") \
@@ -246,21 +272,28 @@ constexpr size_t kFsStatsBufferLength =
246
272
  V(fd_string, "fd") \
247
273
  V(fields_string, "fields") \
248
274
  V(file_string, "file") \
275
+ V(filename_string, "filename") \
249
276
  V(fingerprint256_string, "fingerprint256") \
277
+ V(fingerprint512_string, "fingerprint512") \
250
278
  V(fingerprint_string, "fingerprint") \
251
279
  V(flags_string, "flags") \
280
+ V(flowlabel_string, "flowlabel") \
252
281
  V(fragment_string, "fragment") \
282
+ V(frames_received_string, "framesReceived") \
283
+ V(frames_sent_string, "framesSent") \
253
284
  V(function_string, "function") \
254
285
  V(get_data_clone_error_string, "_getDataCloneError") \
255
286
  V(get_shared_array_buffer_id_string, "_getSharedArrayBufferId") \
256
287
  V(gid_string, "gid") \
257
288
  V(h2_string, "h2") \
258
289
  V(handle_string, "handle") \
290
+ V(hash_algorithm_string, "hashAlgorithm") \
259
291
  V(help_text_string, "helpText") \
260
292
  V(homedir_string, "homedir") \
261
293
  V(host_string, "host") \
262
294
  V(hostmaster_string, "hostmaster") \
263
295
  V(http_1_1_string, "http/1.1") \
296
+ V(id_string, "id") \
264
297
  V(identity_string, "identity") \
265
298
  V(ignore_string, "ignore") \
266
299
  V(infoaccess_string, "infoAccess") \
@@ -268,23 +301,46 @@ constexpr size_t kFsStatsBufferLength =
268
301
  V(input_string, "input") \
269
302
  V(internal_binding_string, "internalBinding") \
270
303
  V(internal_string, "internal") \
271
- V(ipv4_string, "IPv4") \
272
- V(ipv6_string, "IPv6") \
273
304
  V(isclosing_string, "isClosing") \
274
305
  V(issuer_string, "issuer") \
275
306
  V(issuercert_string, "issuerCertificate") \
307
+ V(jwk_crv_string, "crv") \
308
+ V(jwk_d_string, "d") \
309
+ V(jwk_dp_string, "dp") \
310
+ V(jwk_dq_string, "dq") \
311
+ V(jwk_dsa_string, "DSA") \
312
+ V(jwk_e_string, "e") \
313
+ V(jwk_ec_string, "EC") \
314
+ V(jwk_g_string, "g") \
315
+ V(jwk_k_string, "k") \
316
+ V(jwk_p_string, "p") \
317
+ V(jwk_q_string, "q") \
318
+ V(jwk_qi_string, "qi") \
319
+ V(jwk_kty_string, "kty") \
320
+ V(jwk_n_string, "n") \
321
+ V(jwk_oct_string, "oct") \
322
+ V(jwk_okp_string, "OKP") \
323
+ V(jwk_rsa_string, "RSA") \
324
+ V(jwk_x_string, "x") \
325
+ V(jwk_y_string, "y") \
276
326
  V(kill_signal_string, "killSignal") \
277
327
  V(kind_string, "kind") \
328
+ V(length_string, "length") \
278
329
  V(library_string, "library") \
279
330
  V(mac_string, "mac") \
280
331
  V(max_buffer_string, "maxBuffer") \
332
+ V(max_concurrent_streams_string, "maxConcurrentStreams") \
281
333
  V(message_port_constructor_string, "MessagePort") \
282
334
  V(message_port_string, "messagePort") \
283
335
  V(message_string, "message") \
336
+ V(messageerror_string, "messageerror") \
337
+ V(mgf1_hash_algorithm_string, "mgf1HashAlgorithm") \
284
338
  V(minttl_string, "minttl") \
285
339
  V(module_string, "module") \
286
340
  V(modulus_string, "modulus") \
341
+ V(modulus_length_string, "modulusLength") \
287
342
  V(name_string, "name") \
343
+ V(named_curve_string, "namedCurve") \
288
344
  V(netmask_string, "netmask") \
289
345
  V(next_string, "next") \
290
346
  V(nistcurve_string, "nistCurve") \
@@ -315,11 +371,13 @@ constexpr size_t kFsStatsBufferLength =
315
371
  V(options_string, "options") \
316
372
  V(order_string, "order") \
317
373
  V(output_string, "output") \
374
+ V(overlapped_string, "overlapped") \
318
375
  V(parse_error_string, "Parse Error") \
319
376
  V(password_string, "password") \
320
377
  V(path_string, "path") \
321
378
  V(pending_handle_string, "pendingHandle") \
322
379
  V(pid_string, "pid") \
380
+ V(ping_rtt_string, "pingRTT") \
323
381
  V(pipe_source_string, "pipeSource") \
324
382
  V(pipe_string, "pipe") \
325
383
  V(pipe_target_string, "pipeTarget") \
@@ -333,7 +391,9 @@ constexpr size_t kFsStatsBufferLength =
333
391
  V(promise_string, "promise") \
334
392
  V(psk_string, "psk") \
335
393
  V(pubkey_string, "pubkey") \
394
+ V(public_exponent_string, "publicExponent") \
336
395
  V(query_string, "query") \
396
+ V(rate_string, "rate") \
337
397
  V(raw_string, "raw") \
338
398
  V(read_host_object_string, "_readHostObject") \
339
399
  V(readable_string, "readable") \
@@ -344,6 +404,7 @@ constexpr size_t kFsStatsBufferLength =
344
404
  V(replacement_string, "replacement") \
345
405
  V(require_string, "require") \
346
406
  V(retry_string, "retry") \
407
+ V(salt_length_string, "saltLength") \
347
408
  V(scheme_string, "scheme") \
348
409
  V(scopeid_string, "scopeid") \
349
410
  V(serial_number_string, "serialNumber") \
@@ -361,8 +422,12 @@ constexpr size_t kFsStatsBufferLength =
361
422
  V(stack_string, "stack") \
362
423
  V(standard_name_string, "standardName") \
363
424
  V(start_time_string, "startTime") \
425
+ V(state_string, "state") \
426
+ V(stats_string, "stats") \
364
427
  V(status_string, "status") \
365
428
  V(stdio_string, "stdio") \
429
+ V(stream_average_duration_string, "streamAverageDuration") \
430
+ V(stream_count_string, "streamCount") \
366
431
  V(subject_string, "subject") \
367
432
  V(subjectaltname_string, "subjectaltname") \
368
433
  V(syscall_string, "syscall") \
@@ -370,6 +435,9 @@ constexpr size_t kFsStatsBufferLength =
370
435
  V(thread_id_string, "threadId") \
371
436
  V(ticketkeycallback_string, "onticketkeycallback") \
372
437
  V(timeout_string, "timeout") \
438
+ V(time_to_first_byte_string, "timeToFirstByte") \
439
+ V(time_to_first_byte_sent_string, "timeToFirstByteSent") \
440
+ V(time_to_first_header_string, "timeToFirstHeader") \
373
441
  V(tls_ticket_string, "tlsTicket") \
374
442
  V(transfer_string, "transfer") \
375
443
  V(ttl_string, "ttl") \
@@ -378,7 +446,6 @@ constexpr size_t kFsStatsBufferLength =
378
446
  V(unknown_string, "<unknown>") \
379
447
  V(url_special_ftp_string, "ftp:") \
380
448
  V(url_special_file_string, "file:") \
381
- V(url_special_gopher_string, "gopher:") \
382
449
  V(url_special_http_string, "http:") \
383
450
  V(url_special_https_string, "https:") \
384
451
  V(url_special_ws_string, "ws:") \
@@ -401,9 +468,12 @@ constexpr size_t kFsStatsBufferLength =
401
468
  V(zero_return_string, "ZERO_RETURN")
402
469
 
403
470
  #define ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) \
404
- V(as_callback_data_template, v8::FunctionTemplate) \
405
471
  V(async_wrap_ctor_template, v8::FunctionTemplate) \
406
472
  V(async_wrap_object_ctor_template, v8::FunctionTemplate) \
473
+ V(base_object_ctor_template, v8::FunctionTemplate) \
474
+ V(binding_data_ctor_template, v8::FunctionTemplate) \
475
+ V(blob_constructor_template, v8::FunctionTemplate) \
476
+ V(blocklist_constructor_template, v8::FunctionTemplate) \
407
477
  V(compiled_fn_entry_template, v8::ObjectTemplate) \
408
478
  V(dir_instance_template, v8::ObjectTemplate) \
409
479
  V(fd_constructor_template, v8::ObjectTemplate) \
@@ -411,36 +481,44 @@ constexpr size_t kFsStatsBufferLength =
411
481
  V(filehandlereadwrap_template, v8::ObjectTemplate) \
412
482
  V(fsreqpromise_constructor_template, v8::ObjectTemplate) \
413
483
  V(handle_wrap_ctor_template, v8::FunctionTemplate) \
414
- V(histogram_instance_template, v8::ObjectTemplate) \
484
+ V(histogram_ctor_template, v8::FunctionTemplate) \
415
485
  V(http2settings_constructor_template, v8::ObjectTemplate) \
416
486
  V(http2stream_constructor_template, v8::ObjectTemplate) \
417
487
  V(http2ping_constructor_template, v8::ObjectTemplate) \
418
488
  V(i18n_converter_template, v8::ObjectTemplate) \
489
+ V(intervalhistogram_constructor_template, v8::FunctionTemplate) \
419
490
  V(libuv_stream_wrap_ctor_template, v8::FunctionTemplate) \
420
491
  V(message_port_constructor_template, v8::FunctionTemplate) \
492
+ V(microtask_queue_ctor_template, v8::FunctionTemplate) \
421
493
  V(pipe_constructor_template, v8::FunctionTemplate) \
422
494
  V(promise_wrap_template, v8::ObjectTemplate) \
423
495
  V(sab_lifetimepartner_constructor_template, v8::FunctionTemplate) \
424
496
  V(script_context_constructor_template, v8::FunctionTemplate) \
425
497
  V(secure_context_constructor_template, v8::FunctionTemplate) \
426
498
  V(shutdown_wrap_template, v8::ObjectTemplate) \
499
+ V(socketaddress_constructor_template, v8::FunctionTemplate) \
427
500
  V(streambaseoutputstream_constructor_template, v8::ObjectTemplate) \
501
+ V(qlogoutputstream_constructor_template, v8::ObjectTemplate) \
428
502
  V(tcp_constructor_template, v8::FunctionTemplate) \
429
503
  V(tty_constructor_template, v8::FunctionTemplate) \
430
504
  V(write_wrap_template, v8::ObjectTemplate) \
431
- V(worker_heap_snapshot_taker_template, v8::ObjectTemplate)
505
+ V(worker_heap_snapshot_taker_template, v8::ObjectTemplate) \
506
+ V(x509_constructor_template, v8::FunctionTemplate)
432
507
 
433
508
  #define ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) \
434
- V(as_callback_data, v8::Object) \
435
509
  V(async_hooks_after_function, v8::Function) \
436
510
  V(async_hooks_before_function, v8::Function) \
511
+ V(async_hooks_callback_trampoline, v8::Function) \
437
512
  V(async_hooks_binding, v8::Object) \
438
513
  V(async_hooks_destroy_function, v8::Function) \
439
514
  V(async_hooks_init_function, v8::Function) \
440
515
  V(async_hooks_promise_resolve_function, v8::Function) \
441
516
  V(buffer_prototype_object, v8::Object) \
442
517
  V(crypto_key_object_constructor, v8::Function) \
443
- V(domain_callback, v8::Function) \
518
+ V(crypto_key_object_handle_constructor, v8::Function) \
519
+ V(crypto_key_object_private_constructor, v8::Function) \
520
+ V(crypto_key_object_public_constructor, v8::Function) \
521
+ V(crypto_key_object_secret_constructor, v8::Function) \
444
522
  V(domexception_function, v8::Function) \
445
523
  V(enhance_fatal_stack_after_inspector, v8::Function) \
446
524
  V(enhance_fatal_stack_before_inspector, v8::Function) \
@@ -455,13 +533,15 @@ constexpr size_t kFsStatsBufferLength =
455
533
  V(http2session_on_origin_function, v8::Function) \
456
534
  V(http2session_on_ping_function, v8::Function) \
457
535
  V(http2session_on_priority_function, v8::Function) \
458
- V(http2session_on_select_padding_function, v8::Function) \
459
536
  V(http2session_on_settings_function, v8::Function) \
460
537
  V(http2session_on_stream_close_function, v8::Function) \
461
538
  V(http2session_on_stream_trailers_function, v8::Function) \
462
539
  V(internal_binding_loader, v8::Function) \
463
540
  V(immediate_callback_function, v8::Function) \
464
541
  V(inspector_console_extension_installer, v8::Function) \
542
+ V(inspector_disable_async_hooks, v8::Function) \
543
+ V(inspector_enable_async_hooks, v8::Function) \
544
+ V(messaging_deserialize_create_object, v8::Function) \
465
545
  V(message_port, v8::Object) \
466
546
  V(native_module_require, v8::Function) \
467
547
  V(performance_entry_callback, v8::Function) \
@@ -469,6 +549,11 @@ constexpr size_t kFsStatsBufferLength =
469
549
  V(prepare_stack_trace_callback, v8::Function) \
470
550
  V(process_object, v8::Object) \
471
551
  V(primordials, v8::Object) \
552
+ V(primordials_safe_map_prototype_object, v8::Object) \
553
+ V(primordials_safe_set_prototype_object, v8::Object) \
554
+ V(primordials_safe_weak_map_prototype_object, v8::Object) \
555
+ V(primordials_safe_weak_set_prototype_object, v8::Object) \
556
+ V(promise_hook_handler, v8::Function) \
472
557
  V(promise_reject_callback, v8::Function) \
473
558
  V(script_data_constructor_function, v8::Function) \
474
559
  V(source_map_cache_getter, v8::Function) \
@@ -477,11 +562,14 @@ constexpr size_t kFsStatsBufferLength =
477
562
  V(tls_wrap_constructor_function, v8::Function) \
478
563
  V(trace_category_state_function, v8::Function) \
479
564
  V(udp_constructor_function, v8::Function) \
480
- V(url_constructor_function, v8::Function)
565
+ V(url_constructor_function, v8::Function) \
566
+ V(wasm_streaming_compilation_impl, v8::Function) \
567
+ V(wasm_streaming_object_constructor, v8::Function)
481
568
 
482
569
  class Environment;
483
570
 
484
- class IsolateData : public MemoryRetainer {
571
+ typedef size_t SnapshotIndex;
572
+ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer {
485
573
  public:
486
574
  IsolateData(v8::Isolate* isolate,
487
575
  uv_loop_t* event_loop,
@@ -498,10 +586,11 @@ class IsolateData : public MemoryRetainer {
498
586
  inline std::shared_ptr<PerIsolateOptions> options();
499
587
  inline void set_options(std::shared_ptr<PerIsolateOptions> options);
500
588
 
501
- inline bool uses_node_allocator() const;
502
- inline v8::ArrayBuffer::Allocator* allocator() const;
503
589
  inline NodeArrayBufferAllocator* node_allocator() const;
504
590
 
591
+ inline worker::Worker* worker_context() const;
592
+ inline void set_worker_context(worker::Worker* context);
593
+
505
594
  #define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
506
595
  #define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
507
596
  #define VS(PropertyName, StringValue) V(v8::String, PropertyName)
@@ -516,7 +605,9 @@ class IsolateData : public MemoryRetainer {
516
605
  #undef VP
517
606
  inline v8::Local<v8::String> async_wrap_provider(int index) const;
518
607
 
519
- std::unordered_map<nghttp2_rcbuf*, v8::Eternal<v8::String>> http2_static_strs;
608
+ size_t max_young_gen_size = 1;
609
+ std::unordered_map<const char*, v8::Eternal<v8::String>> static_str_map;
610
+
520
611
  inline v8::Isolate* isolate() const;
521
612
  IsolateData(const IsolateData&) = delete;
522
613
  IsolateData& operator=(const IsolateData&) = delete;
@@ -545,11 +636,10 @@ class IsolateData : public MemoryRetainer {
545
636
 
546
637
  v8::Isolate* const isolate_;
547
638
  uv_loop_t* const event_loop_;
548
- v8::ArrayBuffer::Allocator* const allocator_;
549
639
  NodeArrayBufferAllocator* const node_allocator_;
550
- const bool uses_node_allocator_;
551
640
  MultiIsolatePlatform* platform_;
552
641
  std::shared_ptr<PerIsolateOptions> options_;
642
+ worker::Worker* worker_context_ = nullptr;
553
643
  };
554
644
 
555
645
  struct ContextInfo {
@@ -561,38 +651,6 @@ struct ContextInfo {
561
651
 
562
652
  class EnabledDebugList;
563
653
 
564
- // A unique-pointer-ish object that is compatible with the JS engine's
565
- // ArrayBuffer::Allocator.
566
- struct AllocatedBuffer {
567
- public:
568
- explicit inline AllocatedBuffer(Environment* env = nullptr);
569
- inline AllocatedBuffer(Environment* env, uv_buf_t buf);
570
- inline ~AllocatedBuffer();
571
- inline void Resize(size_t len);
572
-
573
- inline uv_buf_t release();
574
- inline char* data();
575
- inline const char* data() const;
576
- inline size_t size() const;
577
- inline void clear();
578
-
579
- inline v8::MaybeLocal<v8::Object> ToBuffer();
580
- inline v8::Local<v8::ArrayBuffer> ToArrayBuffer();
581
-
582
- inline AllocatedBuffer(AllocatedBuffer&& other);
583
- inline AllocatedBuffer& operator=(AllocatedBuffer&& other);
584
- AllocatedBuffer(const AllocatedBuffer& other) = delete;
585
- AllocatedBuffer& operator=(const AllocatedBuffer& other) = delete;
586
-
587
- private:
588
- Environment* env_;
589
- // We do not pass this to libuv directly, but uv_buf_t is a convenient way
590
- // to represent a chunk of memory, and plays nicely with other parts of core.
591
- uv_buf_t buffer_;
592
-
593
- friend class Environment;
594
- };
595
-
596
654
  class KVStore {
597
655
  public:
598
656
  KVStore() = default;
@@ -625,6 +683,8 @@ namespace per_process {
625
683
  extern std::shared_ptr<KVStore> system_environment;
626
684
  }
627
685
 
686
+ struct EnvSerializeInfo;
687
+
628
688
  class AsyncHooks : public MemoryRetainer {
629
689
  public:
630
690
  SET_MEMORY_INFO_NAME(AsyncHooks)
@@ -642,6 +702,7 @@ class AsyncHooks : public MemoryRetainer {
642
702
  kTotals,
643
703
  kCheck,
644
704
  kStackLength,
705
+ kUsesExecutionAsyncResource,
645
706
  kFieldsCount,
646
707
  };
647
708
 
@@ -656,18 +717,34 @@ class AsyncHooks : public MemoryRetainer {
656
717
  inline AliasedUint32Array& fields();
657
718
  inline AliasedFloat64Array& async_id_fields();
658
719
  inline AliasedFloat64Array& async_ids_stack();
659
- inline v8::Local<v8::Array> execution_async_resources();
720
+ inline v8::Local<v8::Array> js_execution_async_resources();
721
+ // Returns the native executionAsyncResource value at stack index `index`.
722
+ // Resources provided on the JS side are not stored on the native stack,
723
+ // in which case an empty `Local<>` is returned.
724
+ // The `js_execution_async_resources` array contains the value in that case.
725
+ inline v8::Local<v8::Object> native_execution_async_resource(size_t index);
726
+
727
+ inline void SetJSPromiseHooks(v8::Local<v8::Function> init,
728
+ v8::Local<v8::Function> before,
729
+ v8::Local<v8::Function> after,
730
+ v8::Local<v8::Function> resolve);
660
731
 
661
732
  inline v8::Local<v8::String> provider_string(int idx);
662
733
 
663
734
  inline void no_force_checks();
664
735
  inline Environment* env();
665
736
 
737
+ // NB: This call does not take (co-)ownership of `execution_async_resource`.
738
+ // The lifetime of the `v8::Local<>` pointee must last until
739
+ // `pop_async_context()` or `clear_async_id_stack()` are called.
666
740
  inline void push_async_context(double async_id, double trigger_async_id,
667
- v8::Local<v8::Value> execution_async_resource_);
741
+ v8::Local<v8::Object> execution_async_resource);
668
742
  inline bool pop_async_context(double async_id);
669
743
  inline void clear_async_id_stack(); // Used in fatal exceptions.
670
744
 
745
+ inline void AddContext(v8::Local<v8::Context> ctx);
746
+ inline void RemoveContext(v8::Local<v8::Context> ctx);
747
+
671
748
  AsyncHooks(const AsyncHooks&) = delete;
672
749
  AsyncHooks& operator=(const AsyncHooks&) = delete;
673
750
  AsyncHooks(AsyncHooks&&) = delete;
@@ -696,9 +773,24 @@ class AsyncHooks : public MemoryRetainer {
696
773
  double old_default_trigger_async_id_;
697
774
  };
698
775
 
776
+ struct SerializeInfo {
777
+ AliasedBufferIndex async_ids_stack;
778
+ AliasedBufferIndex fields;
779
+ AliasedBufferIndex async_id_fields;
780
+ SnapshotIndex js_execution_async_resources;
781
+ std::vector<SnapshotIndex> native_execution_async_resources;
782
+ };
783
+
784
+ SerializeInfo Serialize(v8::Local<v8::Context> context,
785
+ v8::SnapshotCreator* creator);
786
+ void Deserialize(v8::Local<v8::Context> context);
787
+
699
788
  private:
700
789
  friend class Environment; // So we can call the constructor.
701
- inline AsyncHooks();
790
+ explicit AsyncHooks(v8::Isolate* isolate, const SerializeInfo* info);
791
+
792
+ [[noreturn]] void FailWithCorruptedAsyncStack(double expected_async_id);
793
+
702
794
  // Stores the ids of the current execution context stack.
703
795
  AliasedFloat64Array async_ids_stack_;
704
796
  // Attached to a Uint32Array that tracks the number of active hooks for
@@ -709,7 +801,15 @@ class AsyncHooks : public MemoryRetainer {
709
801
 
710
802
  void grow_async_ids_stack();
711
803
 
712
- v8::Global<v8::Array> execution_async_resources_;
804
+ v8::Global<v8::Array> js_execution_async_resources_;
805
+ std::vector<v8::Local<v8::Object>> native_execution_async_resources_;
806
+
807
+ // Non-empty during deserialization
808
+ const SerializeInfo* info_ = nullptr;
809
+
810
+ std::vector<v8::Global<v8::Context>> contexts_;
811
+
812
+ std::array<v8::Global<v8::Function>, 4> js_promise_hooks_;
713
813
  };
714
814
 
715
815
  class ImmediateInfo : public MemoryRetainer {
@@ -731,9 +831,16 @@ class ImmediateInfo : public MemoryRetainer {
731
831
  SET_SELF_SIZE(ImmediateInfo)
732
832
  void MemoryInfo(MemoryTracker* tracker) const override;
733
833
 
834
+ struct SerializeInfo {
835
+ AliasedBufferIndex fields;
836
+ };
837
+ SerializeInfo Serialize(v8::Local<v8::Context> context,
838
+ v8::SnapshotCreator* creator);
839
+ void Deserialize(v8::Local<v8::Context> context);
840
+
734
841
  private:
735
842
  friend class Environment; // So we can call the constructor.
736
- inline explicit ImmediateInfo(v8::Isolate* isolate);
843
+ explicit ImmediateInfo(v8::Isolate* isolate, const SerializeInfo* info);
737
844
 
738
845
  enum Fields { kCount, kRefCount, kHasOutstanding, kFieldsCount };
739
846
 
@@ -756,9 +863,16 @@ class TickInfo : public MemoryRetainer {
756
863
  TickInfo& operator=(TickInfo&&) = delete;
757
864
  ~TickInfo() = default;
758
865
 
866
+ struct SerializeInfo {
867
+ AliasedBufferIndex fields;
868
+ };
869
+ SerializeInfo Serialize(v8::Local<v8::Context> context,
870
+ v8::SnapshotCreator* creator);
871
+ void Deserialize(v8::Local<v8::Context> context);
872
+
759
873
  private:
760
874
  friend class Environment; // So we can call the constructor.
761
- inline explicit TickInfo(v8::Isolate* isolate);
875
+ explicit TickInfo(v8::Isolate* isolate, const SerializeInfo* info);
762
876
 
763
877
  enum Fields { kHasTickScheduled = 0, kHasRejectionToWarn, kFieldsCount };
764
878
 
@@ -802,7 +916,9 @@ class ShouldNotAbortOnUncaughtScope {
802
916
 
803
917
  class CleanupHookCallback {
804
918
  public:
805
- CleanupHookCallback(void (*fn)(void*),
919
+ typedef void (*Callback)(void*);
920
+
921
+ CleanupHookCallback(Callback fn,
806
922
  void* arg,
807
923
  uint64_t insertion_order_counter)
808
924
  : fn_(fn), arg_(arg), insertion_order_counter_(insertion_order_counter) {}
@@ -822,7 +938,7 @@ class CleanupHookCallback {
822
938
 
823
939
  private:
824
940
  friend class Environment;
825
- void (*fn_)(void*);
941
+ Callback fn_;
826
942
  void* arg_;
827
943
 
828
944
  // We keep track of the insertion order for these objects, so that we can
@@ -830,6 +946,62 @@ class CleanupHookCallback {
830
946
  uint64_t insertion_order_counter_;
831
947
  };
832
948
 
949
+ struct PropInfo {
950
+ std::string name; // name for debugging
951
+ size_t id; // In the list - in case there are any empty entries
952
+ SnapshotIndex index; // In the snapshot
953
+ };
954
+
955
+ typedef void (*DeserializeRequestCallback)(v8::Local<v8::Context> context,
956
+ v8::Local<v8::Object> holder,
957
+ int index,
958
+ InternalFieldInfo* info);
959
+ struct DeserializeRequest {
960
+ DeserializeRequestCallback cb;
961
+ v8::Global<v8::Object> holder;
962
+ int index;
963
+ InternalFieldInfo* info = nullptr; // Owned by the request
964
+
965
+ // Move constructor
966
+ DeserializeRequest(DeserializeRequest&& other) = default;
967
+ };
968
+
969
+ struct EnvSerializeInfo {
970
+ std::vector<PropInfo> bindings;
971
+ std::vector<std::string> native_modules;
972
+ AsyncHooks::SerializeInfo async_hooks;
973
+ TickInfo::SerializeInfo tick_info;
974
+ ImmediateInfo::SerializeInfo immediate_info;
975
+ performance::PerformanceState::SerializeInfo performance_state;
976
+ AliasedBufferIndex stream_base_state;
977
+ AliasedBufferIndex should_abort_on_uncaught_toggle;
978
+
979
+ std::vector<PropInfo> persistent_templates;
980
+ std::vector<PropInfo> persistent_values;
981
+
982
+ SnapshotIndex context;
983
+ friend std::ostream& operator<<(std::ostream& o, const EnvSerializeInfo& i);
984
+ };
985
+
986
+ struct SnapshotData {
987
+ // The result of v8::SnapshotCreator::CreateBlob() during the snapshot
988
+ // building process.
989
+ v8::StartupData v8_snapshot_blob_data;
990
+
991
+ static const size_t kNodeBaseContextIndex = 0;
992
+ static const size_t kNodeMainContextIndex = kNodeBaseContextIndex + 1;
993
+
994
+ std::vector<size_t> isolate_data_indices;
995
+ // TODO(joyeecheung): there should be a vector of env_info once we snapshot
996
+ // the worker environments.
997
+ EnvSerializeInfo env_info;
998
+ // A vector of built-in ids and v8::ScriptCompiler::CachedData, this can be
999
+ // shared across Node.js instances because they are supposed to share the
1000
+ // read only space. We use native_module::CodeCacheInfo because
1001
+ // v8::ScriptCompiler::CachedData is not copyable.
1002
+ std::vector<native_module::CodeCacheInfo> code_cache;
1003
+ };
1004
+
833
1005
  class Environment : public MemoryRetainer {
834
1006
  public:
835
1007
  Environment(const Environment&) = delete;
@@ -843,9 +1015,23 @@ class Environment : public MemoryRetainer {
843
1015
  bool IsRootNode() const override { return true; }
844
1016
  void MemoryInfo(MemoryTracker* tracker) const override;
845
1017
 
1018
+ EnvSerializeInfo Serialize(v8::SnapshotCreator* creator);
846
1019
  void CreateProperties();
1020
+ void DeserializeProperties(const EnvSerializeInfo* info);
1021
+
1022
+ void PrintInfoForSnapshotIfDebug();
1023
+ void PrintAllBaseObjects();
1024
+ void VerifyNoStrongBaseObjects();
1025
+ void EnqueueDeserializeRequest(DeserializeRequestCallback cb,
1026
+ v8::Local<v8::Object> holder,
1027
+ int index,
1028
+ InternalFieldInfo* info);
1029
+ void RunDeserializeRequests();
847
1030
  // Should be called before InitializeInspector()
848
1031
  void InitializeDiagnostics();
1032
+
1033
+ std::string GetCwd();
1034
+
849
1035
  #if HAVE_INSPECTOR
850
1036
  // If the environment is created for a worker, pass parent_handle and
851
1037
  // the ownership if transferred into the Environment.
@@ -861,13 +1047,6 @@ class Environment : public MemoryRetainer {
861
1047
  inline void PushAsyncCallbackScope();
862
1048
  inline void PopAsyncCallbackScope();
863
1049
 
864
- enum Flags {
865
- kNoFlags = 0,
866
- kIsMainThread = 1 << 0,
867
- kOwnsProcessState = 1 << 1,
868
- kOwnsInspector = 1 << 2,
869
- };
870
-
871
1050
  static inline Environment* GetCurrent(v8::Isolate* isolate);
872
1051
  static inline Environment* GetCurrent(v8::Local<v8::Context> context);
873
1052
  static inline Environment* GetCurrent(
@@ -877,20 +1056,47 @@ class Environment : public MemoryRetainer {
877
1056
  static inline Environment* GetCurrent(
878
1057
  const v8::PropertyCallbackInfo<T>& info);
879
1058
 
880
- static inline Environment* GetFromCallbackData(v8::Local<v8::Value> val);
1059
+ // Methods created using SetMethod(), SetPrototypeMethod(), etc. inside
1060
+ // this scope can access the created T* object using
1061
+ // GetBindingData<T>(args) later.
1062
+ template <typename T>
1063
+ T* AddBindingData(v8::Local<v8::Context> context,
1064
+ v8::Local<v8::Object> target);
1065
+ template <typename T, typename U>
1066
+ static inline T* GetBindingData(const v8::PropertyCallbackInfo<U>& info);
1067
+ template <typename T>
1068
+ static inline T* GetBindingData(
1069
+ const v8::FunctionCallbackInfo<v8::Value>& info);
1070
+ template <typename T>
1071
+ static inline T* GetBindingData(v8::Local<v8::Context> context);
881
1072
 
882
- static uv_key_t thread_local_env;
883
- static inline Environment* GetThreadLocalEnv();
1073
+ typedef std::unordered_map<
1074
+ FastStringKey,
1075
+ BaseObjectPtr<BaseObject>,
1076
+ FastStringKey::Hash> BindingDataStore;
884
1077
 
1078
+ // Create an Environment without initializing a main Context. Use
1079
+ // InitializeMainContext() to initialize a main context for it.
1080
+ Environment(IsolateData* isolate_data,
1081
+ v8::Isolate* isolate,
1082
+ const std::vector<std::string>& args,
1083
+ const std::vector<std::string>& exec_args,
1084
+ const EnvSerializeInfo* env_info,
1085
+ EnvironmentFlags::Flags flags,
1086
+ ThreadId thread_id);
1087
+ void InitializeMainContext(v8::Local<v8::Context> context,
1088
+ const EnvSerializeInfo* env_info);
1089
+ // Create an Environment and initialize the provided main context for it.
885
1090
  Environment(IsolateData* isolate_data,
886
1091
  v8::Local<v8::Context> context,
887
1092
  const std::vector<std::string>& args,
888
1093
  const std::vector<std::string>& exec_args,
889
- Flags flags = Flags(),
890
- uint64_t thread_id = kNoThreadId);
1094
+ const EnvSerializeInfo* env_info,
1095
+ EnvironmentFlags::Flags flags,
1096
+ ThreadId thread_id);
891
1097
  ~Environment() override;
892
1098
 
893
- void InitializeLibuv(bool start_profiler_idle_notifier);
1099
+ void InitializeLibuv();
894
1100
  inline const std::vector<std::string>& exec_argv();
895
1101
  inline const std::vector<std::string>& argv();
896
1102
  const std::string& exec_path() const;
@@ -921,8 +1127,6 @@ class Environment : public MemoryRetainer {
921
1127
  const ContextInfo& info);
922
1128
 
923
1129
  void StartProfilerIdleNotifier();
924
- void StopProfilerIdleNotifier();
925
- inline bool profiler_idle_notifier_started() const;
926
1130
 
927
1131
  inline v8::Isolate* isolate() const;
928
1132
  inline uv_loop_t* event_loop() const;
@@ -950,21 +1154,15 @@ class Environment : public MemoryRetainer {
950
1154
 
951
1155
  inline IsolateData* isolate_data() const;
952
1156
 
953
- // Utilities that allocate memory using the Isolate's ArrayBuffer::Allocator.
954
- // In particular, using AllocateManaged() will provide a RAII-style object
955
- // with easy conversion to `Buffer` and `ArrayBuffer` objects.
956
- inline AllocatedBuffer AllocateManaged(size_t size, bool checked = true);
957
- inline char* Allocate(size_t size);
958
- inline char* AllocateUnchecked(size_t size);
959
- char* Reallocate(char* data, size_t old_size, size_t size);
960
- inline void Free(char* data, size_t size);
961
-
962
1157
  inline bool printed_error() const;
963
1158
  inline void set_printed_error(bool value);
964
1159
 
965
1160
  void PrintSyncTrace() const;
966
1161
  inline void set_trace_sync_io(bool value);
967
1162
 
1163
+ inline void set_force_context_aware(bool value);
1164
+ inline bool force_context_aware() const;
1165
+
968
1166
  // This stores whether the --abort-on-uncaught-exception flag was passed
969
1167
  // to Node.
970
1168
  inline bool abort_on_uncaught_exception() const;
@@ -985,8 +1183,12 @@ class Environment : public MemoryRetainer {
985
1183
  // List of id's that have been destroyed and need the destroy() cb called.
986
1184
  inline std::vector<double>* destroy_async_id_list();
987
1185
 
1186
+ std::set<struct node_module*> internal_bindings;
988
1187
  std::set<std::string> native_modules_with_cache;
989
1188
  std::set<std::string> native_modules_without_cache;
1189
+ // This is only filled during deserialization. We use a vector since
1190
+ // it's only used for tests.
1191
+ std::vector<std::string> native_modules_in_snapshot;
990
1192
 
991
1193
  std::unordered_multimap<int, loader::ModuleWrap*> hash_to_module_map;
992
1194
  std::unordered_map<uint32_t, loader::ModuleWrap*> id_to_module_map;
@@ -998,33 +1200,9 @@ class Environment : public MemoryRetainer {
998
1200
  inline uint32_t get_next_script_id();
999
1201
  inline uint32_t get_next_function_id();
1000
1202
 
1001
- inline double* heap_statistics_buffer() const;
1002
- inline void set_heap_statistics_buffer(double* pointer);
1003
-
1004
- inline double* heap_space_statistics_buffer() const;
1005
- inline void set_heap_space_statistics_buffer(double* pointer);
1006
-
1007
- inline double* heap_code_statistics_buffer() const;
1008
- inline void set_heap_code_statistics_buffer(double* pointer);
1009
-
1010
- inline char* http_parser_buffer() const;
1011
- inline void set_http_parser_buffer(char* buffer);
1012
- inline bool http_parser_buffer_in_use() const;
1013
- inline void set_http_parser_buffer_in_use(bool in_use);
1014
-
1015
- inline http2::Http2State* http2_state() const;
1016
- inline void set_http2_state(std::unique_ptr<http2::Http2State> state);
1017
-
1018
1203
  EnabledDebugList* enabled_debug_list() { return &enabled_debug_list_; }
1019
1204
 
1020
- inline AliasedFloat64Array* fs_stats_field_array();
1021
- inline AliasedBigUint64Array* fs_stats_field_bigint_array();
1022
-
1023
- inline std::vector<std::unique_ptr<fs::FileHandleReadWrap>>&
1024
- file_handle_read_wrap_freelist();
1025
-
1026
1205
  inline performance::PerformanceState* performance_state();
1027
- inline std::unordered_map<std::string, uint64_t>* performance_marks();
1028
1206
 
1029
1207
  void CollectUVExceptionInfo(v8::Local<v8::Value> context,
1030
1208
  int errorno,
@@ -1048,21 +1226,24 @@ class Environment : public MemoryRetainer {
1048
1226
  inline void add_refs(int64_t diff);
1049
1227
 
1050
1228
  inline bool has_run_bootstrapping_code() const;
1051
- inline void set_has_run_bootstrapping_code(bool has_run_bootstrapping_code);
1229
+ inline void DoneBootstrapping();
1052
1230
 
1053
1231
  inline bool has_serialized_options() const;
1054
1232
  inline void set_has_serialized_options(bool has_serialized_options);
1055
1233
 
1056
- static uint64_t AllocateThreadId();
1057
- static constexpr uint64_t kNoThreadId = -1;
1058
-
1059
1234
  inline bool is_main_thread() const;
1235
+ inline bool no_native_addons() const;
1236
+ inline bool should_not_register_esm_loader() const;
1237
+ inline bool should_create_inspector() const;
1060
1238
  inline bool owns_process_state() const;
1061
1239
  inline bool owns_inspector() const;
1240
+ inline bool tracks_unmanaged_fds() const;
1241
+ inline bool hide_console_windows() const;
1242
+ inline bool no_global_search_paths() const;
1243
+ inline bool no_browser_globals() const;
1062
1244
  inline uint64_t thread_id() const;
1063
1245
  inline worker::Worker* worker_context() const;
1064
1246
  Environment* worker_parent_env() const;
1065
- inline void set_worker_context(worker::Worker* context);
1066
1247
  inline void add_sub_worker_context(worker::Worker* context);
1067
1248
  inline void remove_sub_worker_context(worker::Worker* context);
1068
1249
  void stop_sub_worker_contexts();
@@ -1072,8 +1253,15 @@ class Environment : public MemoryRetainer {
1072
1253
  inline void set_stopping(bool value);
1073
1254
  inline std::list<node_module>* extra_linked_bindings();
1074
1255
  inline node_module* extra_linked_bindings_head();
1256
+ inline node_module* extra_linked_bindings_tail();
1075
1257
  inline const Mutex& extra_linked_bindings_mutex() const;
1076
1258
 
1259
+ inline bool filehandle_close_warning() const;
1260
+ inline void set_filehandle_close_warning(bool on);
1261
+
1262
+ inline void set_source_maps_enabled(bool on);
1263
+ inline bool source_maps_enabled() const;
1264
+
1077
1265
  inline void ThrowError(const char* errmsg);
1078
1266
  inline void ThrowTypeError(const char* errmsg);
1079
1267
  inline void ThrowRangeError(const char* errmsg);
@@ -1087,20 +1275,23 @@ class Environment : public MemoryRetainer {
1087
1275
  const char* path = nullptr,
1088
1276
  const char* dest = nullptr);
1089
1277
 
1090
- inline v8::Local<v8::FunctionTemplate>
1091
- NewFunctionTemplate(v8::FunctionCallback callback,
1092
- v8::Local<v8::Signature> signature =
1093
- v8::Local<v8::Signature>(),
1094
- v8::ConstructorBehavior behavior =
1095
- v8::ConstructorBehavior::kAllow,
1096
- v8::SideEffectType side_effect =
1097
- v8::SideEffectType::kHasSideEffect);
1278
+ inline v8::Local<v8::FunctionTemplate> NewFunctionTemplate(
1279
+ v8::FunctionCallback callback,
1280
+ v8::Local<v8::Signature> signature = v8::Local<v8::Signature>(),
1281
+ v8::ConstructorBehavior behavior = v8::ConstructorBehavior::kAllow,
1282
+ v8::SideEffectType side_effect = v8::SideEffectType::kHasSideEffect,
1283
+ const v8::CFunction* c_function = nullptr);
1098
1284
 
1099
1285
  // Convenience methods for NewFunctionTemplate().
1100
1286
  inline void SetMethod(v8::Local<v8::Object> that,
1101
1287
  const char* name,
1102
1288
  v8::FunctionCallback callback);
1103
1289
 
1290
+ inline void SetFastMethod(v8::Local<v8::Object> that,
1291
+ const char* name,
1292
+ v8::FunctionCallback slow_callback,
1293
+ const v8::CFunction* c_function);
1294
+
1104
1295
  inline void SetProtoMethod(v8::Local<v8::FunctionTemplate> that,
1105
1296
  const char* name,
1106
1297
  v8::FunctionCallback callback);
@@ -1118,14 +1309,27 @@ class Environment : public MemoryRetainer {
1118
1309
  const char* name,
1119
1310
  v8::FunctionCallback callback);
1120
1311
 
1121
- void BeforeExit(void (*cb)(void* arg), void* arg);
1122
- void RunBeforeExitCallbacks();
1312
+ enum class SetConstructorFunctionFlag {
1313
+ NONE,
1314
+ SET_CLASS_NAME,
1315
+ };
1316
+
1317
+ inline void SetConstructorFunction(v8::Local<v8::Object> that,
1318
+ const char* name,
1319
+ v8::Local<v8::FunctionTemplate> tmpl,
1320
+ SetConstructorFunctionFlag flag =
1321
+ SetConstructorFunctionFlag::SET_CLASS_NAME);
1322
+
1323
+ inline void SetConstructorFunction(v8::Local<v8::Object> that,
1324
+ v8::Local<v8::String> name,
1325
+ v8::Local<v8::FunctionTemplate> tmpl,
1326
+ SetConstructorFunctionFlag flag =
1327
+ SetConstructorFunctionFlag::SET_CLASS_NAME);
1328
+
1123
1329
  void AtExit(void (*cb)(void* arg), void* arg);
1124
1330
  void RunAtExitCallbacks();
1125
1331
 
1126
- void RegisterFinalizationGroupForCleanup(v8::Local<v8::FinalizationGroup> fg);
1127
1332
  void RunWeakRefCleanup();
1128
- void CleanupFinalizationGroups();
1129
1333
 
1130
1334
  // Strings and private symbols are shared across shared contexts
1131
1335
  // The getters simply proxy to the per-isolate primitive.
@@ -1182,12 +1386,12 @@ class Environment : public MemoryRetainer {
1182
1386
  // Unlike the JS setImmediate() function, nested SetImmediate() calls will
1183
1387
  // be run without returning control to the event loop, similar to nextTick().
1184
1388
  template <typename Fn>
1185
- inline void SetImmediate(Fn&& cb);
1186
- template <typename Fn>
1187
- inline void SetUnrefImmediate(Fn&& cb);
1389
+ inline void SetImmediate(
1390
+ Fn&& cb, CallbackFlags::Flags flags = CallbackFlags::kRefed);
1188
1391
  template <typename Fn>
1189
1392
  // This behaves like SetImmediate() but can be called from any thread.
1190
- inline void SetImmediateThreadsafe(Fn&& cb, bool refed = true);
1393
+ inline void SetImmediateThreadsafe(
1394
+ Fn&& cb, CallbackFlags::Flags flags = CallbackFlags::kRefed);
1191
1395
  // This behaves like V8's Isolate::RequestInterrupt(), but also accounts for
1192
1396
  // the event loop (i.e. combines the V8 function with SetImmediate()).
1193
1397
  // The passed callback may not throw exceptions.
@@ -1207,10 +1411,14 @@ class Environment : public MemoryRetainer {
1207
1411
  void ScheduleTimer(int64_t duration);
1208
1412
  void ToggleTimerRef(bool ref);
1209
1413
 
1210
- inline void AddCleanupHook(void (*fn)(void*), void* arg);
1211
- inline void RemoveCleanupHook(void (*fn)(void*), void* arg);
1414
+ using CleanupCallback = CleanupHookCallback::Callback;
1415
+ inline void AddCleanupHook(CleanupCallback cb, void* arg);
1416
+ inline void RemoveCleanupHook(CleanupCallback cb, void* arg);
1212
1417
  void RunCleanup();
1213
1418
 
1419
+ static size_t NearHeapLimitCallback(void* data,
1420
+ size_t current_heap_limit,
1421
+ size_t initial_heap_limit);
1214
1422
  static void BuildEmbedderGraph(v8::Isolate* isolate,
1215
1423
  v8::EmbedderGraph* graph,
1216
1424
  void* data);
@@ -1218,14 +1426,15 @@ class Environment : public MemoryRetainer {
1218
1426
  inline std::shared_ptr<EnvironmentOptions> options();
1219
1427
  inline std::shared_ptr<ExclusiveAccess<HostPort>> inspector_host_port();
1220
1428
 
1221
- inline int32_t stack_trace_limit() const { return 10; }
1222
-
1223
1429
  // The BaseObject count is a debugging helper that makes sure that there are
1224
1430
  // no memory leaks caused by BaseObjects staying alive longer than expected
1225
1431
  // (in particular, no circular BaseObjectPtr references).
1226
1432
  inline void modify_base_object_count(int64_t delta);
1433
+ inline int64_t base_object_created_after_bootstrap() const;
1227
1434
  inline int64_t base_object_count() const;
1228
1435
 
1436
+ inline int32_t stack_trace_limit() const { return 10; }
1437
+
1229
1438
  #if HAVE_INSPECTOR
1230
1439
  void set_coverage_connection(
1231
1440
  std::unique_ptr<profiler::V8CoverageConnection> connection);
@@ -1262,14 +1471,24 @@ class Environment : public MemoryRetainer {
1262
1471
 
1263
1472
  #endif // HAVE_INSPECTOR
1264
1473
 
1265
- // Only available if a MultiIsolatePlatform is in use.
1266
- void AddArrayBufferAllocatorToKeepAliveUntilIsolateDispose(
1267
- std::shared_ptr<v8::ArrayBuffer::Allocator>);
1474
+ inline void set_main_utf16(std::unique_ptr<v8::String::Value>);
1475
+ inline void set_process_exit_handler(
1476
+ std::function<void(Environment*, int)>&& handler);
1268
1477
 
1269
- private:
1270
- template <typename Fn>
1271
- inline void CreateImmediate(Fn&& cb, bool ref);
1478
+ void RunAndClearNativeImmediates(bool only_refed = false);
1479
+ void RunAndClearInterrupts();
1480
+
1481
+ inline uv_buf_t allocate_managed_buffer(const size_t suggested_size);
1482
+ inline std::unique_ptr<v8::BackingStore> release_managed_buffer(
1483
+ const uv_buf_t& buf);
1272
1484
 
1485
+ void AddUnmanagedFd(int fd);
1486
+ void RemoveUnmanagedFd(int fd);
1487
+
1488
+ template <typename T>
1489
+ void ForEachBindingData(T&& iterator);
1490
+
1491
+ private:
1273
1492
  inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
1274
1493
  const char* errmsg);
1275
1494
 
@@ -1283,7 +1502,6 @@ class Environment : public MemoryRetainer {
1283
1502
  uv_check_t idle_check_handle_;
1284
1503
  uv_async_t task_queues_async_;
1285
1504
  int64_t task_queues_async_refs_ = 0;
1286
- bool profiler_idle_notifier_started_ = false;
1287
1505
 
1288
1506
  AsyncHooks async_hooks_;
1289
1507
  ImmediateInfo immediate_info_;
@@ -1294,6 +1512,9 @@ class Environment : public MemoryRetainer {
1294
1512
  bool trace_sync_io_ = false;
1295
1513
  bool emit_env_nonstring_warning_ = true;
1296
1514
  bool emit_err_name_warning_ = true;
1515
+ bool emit_filehandle_warning_ = true;
1516
+ bool source_maps_enabled_ = false;
1517
+
1297
1518
  size_t async_callback_scope_depth_ = 0;
1298
1519
  std::vector<double> destroy_async_id_list_;
1299
1520
 
@@ -1323,6 +1544,9 @@ class Environment : public MemoryRetainer {
1323
1544
  std::vector<std::string> argv_;
1324
1545
  std::string exec_path_;
1325
1546
 
1547
+ bool is_processing_heap_limit_callback_ = false;
1548
+ int64_t heap_limit_snapshot_taken_ = 0;
1549
+
1326
1550
  uint32_t module_id_counter_ = 0;
1327
1551
  uint32_t script_id_counter_ = 0;
1328
1552
  uint32_t function_id_counter_ = 0;
@@ -1334,19 +1558,17 @@ class Environment : public MemoryRetainer {
1334
1558
 
1335
1559
  AliasedInt32Array stream_base_state_;
1336
1560
 
1561
+ uint64_t environment_start_time_;
1337
1562
  std::unique_ptr<performance::PerformanceState> performance_state_;
1338
- std::unordered_map<std::string, uint64_t> performance_marks_;
1339
1563
 
1340
1564
  bool has_run_bootstrapping_code_ = false;
1341
1565
  bool has_serialized_options_ = false;
1342
1566
 
1343
1567
  std::atomic_bool can_call_into_js_ { true };
1344
- Flags flags_;
1568
+ uint64_t flags_;
1345
1569
  uint64_t thread_id_;
1346
1570
  std::unordered_set<worker::Worker*> sub_worker_contexts_;
1347
1571
 
1348
- std::deque<v8::Global<v8::FinalizationGroup>> cleanup_finalization_groups_;
1349
-
1350
1572
  static void* const kNodeContextTagPtr;
1351
1573
  static int const kNodeContextTag;
1352
1574
 
@@ -1355,12 +1577,14 @@ class Environment : public MemoryRetainer {
1355
1577
  bool is_in_inspector_console_call_ = false;
1356
1578
  #endif
1357
1579
 
1580
+ std::list<DeserializeRequest> deserialize_requests_;
1581
+
1358
1582
  // handle_wrap_queue_ and req_wrap_queue_ needs to be at a fixed offset from
1359
1583
  // the start of the class because it is used by
1360
1584
  // src/node_postmortem_metadata.cc to calculate offsets and generate debug
1361
1585
  // symbols for Environment, which assumes that the position of members in
1362
1586
  // memory are predictable. For more information please refer to
1363
- // `doc/guides/node-postmortem-support.md`
1587
+ // `doc/contributing/node-postmortem-support.md`
1364
1588
  friend int GenDebugSymbols();
1365
1589
  HandleWrapQueue handle_wrap_queue_;
1366
1590
  ReqWrapQueue req_wrap_queue_;
@@ -1368,22 +1592,7 @@ class Environment : public MemoryRetainer {
1368
1592
  int handle_cleanup_waiting_ = 0;
1369
1593
  int request_waiting_ = 0;
1370
1594
 
1371
- double* heap_statistics_buffer_ = nullptr;
1372
- double* heap_space_statistics_buffer_ = nullptr;
1373
- double* heap_code_statistics_buffer_ = nullptr;
1374
-
1375
- char* http_parser_buffer_ = nullptr;
1376
- bool http_parser_buffer_in_use_ = false;
1377
- std::unique_ptr<http2::Http2State> http2_state_;
1378
-
1379
1595
  EnabledDebugList enabled_debug_list_;
1380
- AliasedFloat64Array fs_stats_field_array_;
1381
- AliasedBigUint64Array fs_stats_field_bigint_array_;
1382
-
1383
- std::vector<std::unique_ptr<fs::FileHandleReadWrap>>
1384
- file_handle_read_wrap_freelist_;
1385
-
1386
- worker::Worker* worker_context_ = nullptr;
1387
1596
 
1388
1597
  std::list<node_module> extra_linked_bindings_;
1389
1598
  Mutex extra_linked_bindings_mutex_;
@@ -1394,7 +1603,6 @@ class Environment : public MemoryRetainer {
1394
1603
  void (*cb_)(void* arg);
1395
1604
  void* arg_;
1396
1605
  };
1397
- std::list<ExitCallback> before_exit_functions_;
1398
1606
 
1399
1607
  std::list<ExitCallback> at_exit_functions_;
1400
1608
 
@@ -1403,13 +1611,18 @@ class Environment : public MemoryRetainer {
1403
1611
  Mutex native_immediates_threadsafe_mutex_;
1404
1612
  NativeImmediateQueue native_immediates_threadsafe_;
1405
1613
  NativeImmediateQueue native_immediates_interrupts_;
1614
+ // Also guarded by native_immediates_threadsafe_mutex_. This can be used when
1615
+ // trying to post tasks from other threads to an Environment, as the libuv
1616
+ // handle for the immediate queues (task_queues_async_) may not be initialized
1617
+ // yet or already have been destroyed.
1618
+ bool task_queues_async_initialized_ = false;
1406
1619
 
1407
- void RunAndClearNativeImmediates(bool only_refed = false);
1408
- void RunAndClearInterrupts();
1409
- Environment** interrupt_data_ = nullptr;
1620
+ std::atomic<Environment**> interrupt_data_ {nullptr};
1410
1621
  void RequestInterruptFromV8();
1411
1622
  static void CheckImmediate(uv_check_t* handle);
1412
1623
 
1624
+ BindingDataStore bindings_;
1625
+
1413
1626
  // Use an unordered_set, so that we have efficient insertion and removal.
1414
1627
  std::unordered_set<CleanupHookCallback,
1415
1628
  CleanupHookCallback::Hash,
@@ -1418,11 +1631,13 @@ class Environment : public MemoryRetainer {
1418
1631
  bool started_cleanup_ = false;
1419
1632
 
1420
1633
  int64_t base_object_count_ = 0;
1634
+ int64_t base_object_created_by_bootstrap_ = 0;
1421
1635
  std::atomic_bool is_stopping_ { false };
1422
1636
 
1423
- typedef std::unordered_set<std::shared_ptr<v8::ArrayBuffer::Allocator>>
1424
- ArrayBufferAllocatorList;
1425
- ArrayBufferAllocatorList* keep_alive_allocators_ = nullptr;
1637
+ std::unordered_set<int> unmanaged_fds_;
1638
+
1639
+ std::function<void(Environment*, int)> process_exit_handler_ {
1640
+ DefaultProcessExitHandler };
1426
1641
 
1427
1642
  template <typename T>
1428
1643
  void ForEachBaseObject(T&& iterator);
@@ -1433,6 +1648,16 @@ class Environment : public MemoryRetainer {
1433
1648
  #undef V
1434
1649
 
1435
1650
  v8::Global<v8::Context> context_;
1651
+
1652
+ // Keeps the main script source alive is one was passed to LoadEnvironment().
1653
+ // We should probably find a way to just use plain `v8::String`s created from
1654
+ // the source passed to LoadEnvironment() directly instead.
1655
+ std::unique_ptr<v8::String::Value> main_utf16_;
1656
+
1657
+ // Used by allocate_managed_buffer() and release_managed_buffer() to keep
1658
+ // track of the BackingStore for a given pointer.
1659
+ std::unordered_map<char*, std::unique_ptr<v8::BackingStore>>
1660
+ released_allocated_buffers_;
1436
1661
  };
1437
1662
 
1438
1663
  } // namespace node