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