@scriptc/compiler 0.4.7 → 0.4.8

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 (776) hide show
  1. package/ambient/node-fallback/child_process.d.ts +71 -22
  2. package/ambient/node-fallback/crypto.d.ts +15 -7
  3. package/ambient/node-fallback/events.d.ts +23 -5
  4. package/ambient/node-fallback/fs.d.ts +3 -2
  5. package/ambient/node-fallback/http.d.ts +23 -17
  6. package/ambient/node-fallback/https.d.ts +5 -2
  7. package/ambient/node-fallback/net.d.ts +6 -0
  8. package/ambient/node-fallback/os.d.ts +11 -1
  9. package/ambient/node-fallback/path-posix.d.ts +6 -0
  10. package/ambient/node-fallback/path-win32.d.ts +5 -0
  11. package/ambient/node-fallback/path.d.ts +2 -0
  12. package/ambient/node-fallback/zlib.d.ts +31 -2
  13. package/ambient/scriptc-node-fallback.d.ts +37 -7
  14. package/ambient/scriptc.d.ts +7 -2
  15. package/dist/backend/executable-features.js +11 -3
  16. package/dist/backend/executable-features.js.map +1 -1
  17. package/dist/backend/library-pack.d.ts +6 -0
  18. package/dist/backend/library-pack.js +17 -6
  19. package/dist/backend/library-pack.js.map +1 -1
  20. package/dist/backend/library-pack.test.d.ts +1 -0
  21. package/dist/backend/library-pack.test.js +28 -0
  22. package/dist/backend/library-pack.test.js.map +1 -0
  23. package/dist/backend/linker.d.ts +9 -2
  24. package/dist/backend/linker.js +190 -32
  25. package/dist/backend/linker.js.map +1 -1
  26. package/dist/backend/lld.d.ts +8 -4
  27. package/dist/backend/lld.js +19 -13
  28. package/dist/backend/lld.js.map +1 -1
  29. package/dist/backend/lld.test.js +3 -1
  30. package/dist/backend/lld.test.js.map +1 -1
  31. package/dist/backend/llvm/alloc.d.ts +15 -2
  32. package/dist/backend/llvm/alloc.js +172 -36
  33. package/dist/backend/llvm/alloc.js.map +1 -1
  34. package/dist/backend/llvm/alloc.test.js +69 -1
  35. package/dist/backend/llvm/alloc.test.js.map +1 -1
  36. package/dist/backend/llvm/arenas.d.ts +17 -4
  37. package/dist/backend/llvm/arenas.js +105 -10
  38. package/dist/backend/llvm/arenas.js.map +1 -1
  39. package/dist/backend/llvm/arenas.test.js +229 -0
  40. package/dist/backend/llvm/arenas.test.js.map +1 -1
  41. package/dist/backend/llvm/bytes-alias.js +10 -1
  42. package/dist/backend/llvm/bytes-alias.js.map +1 -1
  43. package/dist/backend/llvm/bytes-headers.js +6 -0
  44. package/dist/backend/llvm/bytes-headers.js.map +1 -1
  45. package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
  46. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  47. package/dist/backend/llvm/call-lifetimes.js +10 -0
  48. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  49. package/dist/backend/llvm/classes.d.ts +16 -9
  50. package/dist/backend/llvm/classes.js +142 -37
  51. package/dist/backend/llvm/classes.js.map +1 -1
  52. package/dist/backend/llvm/classes.test.js +42 -0
  53. package/dist/backend/llvm/classes.test.js.map +1 -1
  54. package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
  55. package/dist/backend/llvm/cpu-dispatch.js +31 -7
  56. package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
  57. package/dist/backend/llvm/dyn.d.ts +12 -3
  58. package/dist/backend/llvm/dyn.js +31 -7
  59. package/dist/backend/llvm/dyn.js.map +1 -1
  60. package/dist/backend/llvm/emit-function.js +67 -4
  61. package/dist/backend/llvm/emit-function.js.map +1 -1
  62. package/dist/backend/llvm/emit-module.js +90 -39
  63. package/dist/backend/llvm/emit-module.js.map +1 -1
  64. package/dist/backend/llvm/emit-module.test.d.ts +1 -0
  65. package/dist/backend/llvm/emit-module.test.js +52 -0
  66. package/dist/backend/llvm/emit-module.test.js.map +1 -0
  67. package/dist/backend/llvm/emit-statements.js +99 -15
  68. package/dist/backend/llvm/emit-statements.js.map +1 -1
  69. package/dist/backend/llvm/emitter.d.ts +113 -8
  70. package/dist/backend/llvm/emitter.js +438 -67
  71. package/dist/backend/llvm/emitter.js.map +1 -1
  72. package/dist/backend/llvm/emitter.test.js +31 -3
  73. package/dist/backend/llvm/emitter.test.js.map +1 -1
  74. package/dist/backend/llvm/expr-async.js +19 -1
  75. package/dist/backend/llvm/expr-async.js.map +1 -1
  76. package/dist/backend/llvm/expr-bytes.js +16 -1
  77. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  78. package/dist/backend/llvm/expr-calls.js +18 -2
  79. package/dist/backend/llvm/expr-calls.js.map +1 -1
  80. package/dist/backend/llvm/expr-dynamic.js +31 -10
  81. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  82. package/dist/backend/llvm/expr-primitives.js +31 -3
  83. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  84. package/dist/backend/llvm/expr-records.d.ts +1 -1
  85. package/dist/backend/llvm/expr-records.js +124 -56
  86. package/dist/backend/llvm/expr-records.js.map +1 -1
  87. package/dist/backend/llvm/expr-stream-bridges.js +17 -0
  88. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  89. package/dist/backend/llvm/js-groups.d.ts +21 -0
  90. package/dist/backend/llvm/js-groups.js +277 -0
  91. package/dist/backend/llvm/js-groups.js.map +1 -0
  92. package/dist/backend/llvm/js-ic.d.ts +19 -1
  93. package/dist/backend/llvm/js-ic.js +96 -23
  94. package/dist/backend/llvm/js-ic.js.map +1 -1
  95. package/dist/backend/llvm/lib-dispatch.js +132 -1
  96. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  97. package/dist/backend/llvm/lib-network.js +33 -6
  98. package/dist/backend/llvm/lib-network.js.map +1 -1
  99. package/dist/backend/llvm/lib-process.js +44 -3
  100. package/dist/backend/llvm/lib-process.js.map +1 -1
  101. package/dist/backend/llvm/lib-shared.js +69 -2
  102. package/dist/backend/llvm/lib-shared.js.map +1 -1
  103. package/dist/backend/llvm/local-union-storage.test.js +32 -0
  104. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  105. package/dist/backend/llvm/loop-state.js +7 -2
  106. package/dist/backend/llvm/loop-state.js.map +1 -1
  107. package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
  108. package/dist/backend/llvm/map-entry-fusion.js +3 -3
  109. package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
  110. package/dist/backend/llvm/map-number-lookup.test.js +6 -6
  111. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  112. package/dist/backend/llvm/nullable-unions.js +7 -6
  113. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  114. package/dist/backend/llvm/nullable-unions.test.js +4 -1
  115. package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
  116. package/dist/backend/llvm/receivers.js +3 -0
  117. package/dist/backend/llvm/receivers.js.map +1 -1
  118. package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
  119. package/dist/backend/llvm/record-entry-fusion.js +217 -0
  120. package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
  121. package/dist/backend/llvm/record-results.d.ts +5 -2
  122. package/dist/backend/llvm/record-results.js +13 -12
  123. package/dist/backend/llvm/record-results.js.map +1 -1
  124. package/dist/backend/llvm/record-views.js +12 -6
  125. package/dist/backend/llvm/record-views.js.map +1 -1
  126. package/dist/backend/llvm/reference-effects.js +1 -0
  127. package/dist/backend/llvm/reference-effects.js.map +1 -1
  128. package/dist/backend/llvm/reference-writes.js +3 -0
  129. package/dist/backend/llvm/reference-writes.js.map +1 -1
  130. package/dist/backend/llvm/region-ir.js +1 -0
  131. package/dist/backend/llvm/region-ir.js.map +1 -1
  132. package/dist/backend/llvm/region-sites.d.ts +18 -0
  133. package/dist/backend/llvm/region-sites.js +79 -1
  134. package/dist/backend/llvm/region-sites.js.map +1 -1
  135. package/dist/backend/llvm/runtime-registries.test.js +53 -6
  136. package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
  137. package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
  138. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
  139. package/dist/backend/llvm/shapes.d.ts +33 -3
  140. package/dist/backend/llvm/shapes.js +183 -13
  141. package/dist/backend/llvm/shapes.js.map +1 -1
  142. package/dist/backend/llvm/stack-objects.d.ts +1 -2
  143. package/dist/backend/llvm/stack-objects.js +8 -5
  144. package/dist/backend/llvm/stack-objects.js.map +1 -1
  145. package/dist/backend/llvm/walkers.d.ts +12 -0
  146. package/dist/backend/llvm/walkers.js +46 -2
  147. package/dist/backend/llvm/walkers.js.map +1 -1
  148. package/dist/backend/may-throw.js +12 -2
  149. package/dist/backend/may-throw.js.map +1 -1
  150. package/dist/backend/may-throw.test.js +13 -0
  151. package/dist/backend/may-throw.test.js.map +1 -1
  152. package/dist/backend/native/contracts.d.ts +48 -8
  153. package/dist/backend/native/executable.js +55 -13
  154. package/dist/backend/native/executable.js.map +1 -1
  155. package/dist/backend/native/helper-identity-record.d.ts +11 -0
  156. package/dist/backend/native/helper-identity-record.js +76 -0
  157. package/dist/backend/native/helper-identity-record.js.map +1 -0
  158. package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
  159. package/dist/backend/native/helper-identity-record.test.js +101 -0
  160. package/dist/backend/native/helper-identity-record.test.js.map +1 -0
  161. package/dist/backend/native/library.js +9 -1
  162. package/dist/backend/native/library.js.map +1 -1
  163. package/dist/backend/native/runtime-inputs.js +4 -1
  164. package/dist/backend/native/runtime-inputs.js.map +1 -1
  165. package/dist/backend/native/vendor.d.ts +1 -1
  166. package/dist/backend/native/vendor.js +1 -1
  167. package/dist/backend/native/vendor.js.map +1 -1
  168. package/dist/backend/native-codegen-core.d.ts +13 -10
  169. package/dist/backend/native-codegen-core.js +26 -13
  170. package/dist/backend/native-codegen-core.js.map +1 -1
  171. package/dist/backend/native-codegen.js +27 -8
  172. package/dist/backend/native-codegen.js.map +1 -1
  173. package/dist/backend/native-codegen.test.js +110 -14
  174. package/dist/backend/native-codegen.test.js.map +1 -1
  175. package/dist/backend/native-link-info-core.d.ts +37 -8
  176. package/dist/backend/native-link-info-core.js.map +1 -1
  177. package/dist/backend/runtime-pack-core.d.ts +17 -2
  178. package/dist/backend/runtime-pack-core.js +18 -3
  179. package/dist/backend/runtime-pack-core.js.map +1 -1
  180. package/dist/backend/runtime-pack-targets.test.js +1 -1
  181. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  182. package/dist/backend/runtime-pack.test.js +211 -2
  183. package/dist/backend/runtime-pack.test.js.map +1 -1
  184. package/dist/backend/tree-classes.d.ts +42 -0
  185. package/dist/backend/tree-classes.js +723 -0
  186. package/dist/backend/tree-classes.js.map +1 -0
  187. package/dist/backend/tree-classes.test.d.ts +1 -0
  188. package/dist/backend/tree-classes.test.js +338 -0
  189. package/dist/backend/tree-classes.test.js.map +1 -0
  190. package/dist/backend/vendor-archives.d.ts +5 -1
  191. package/dist/backend/vendor-archives.js +51 -7
  192. package/dist/backend/vendor-archives.js.map +1 -1
  193. package/dist/backend/vendor-inputs.d.ts +25 -4
  194. package/dist/backend/vendor-inputs.js +68 -4
  195. package/dist/backend/vendor-inputs.js.map +1 -1
  196. package/dist/backend/vendor-inputs.test.js +35 -1
  197. package/dist/backend/vendor-inputs.test.js.map +1 -1
  198. package/dist/backend/warm-cache.js +1 -1
  199. package/dist/backend/warm-cache.js.map +1 -1
  200. package/dist/compat/fetch-profile.js +2 -2
  201. package/dist/coverage/report.js +47 -0
  202. package/dist/coverage/report.js.map +1 -1
  203. package/dist/coverage/surface-manifest.js +1 -1
  204. package/dist/diagnostics/codes.d.ts +8 -0
  205. package/dist/diagnostics/codes.js +8 -0
  206. package/dist/diagnostics/codes.js.map +1 -1
  207. package/dist/diagnostics/diagnostic.d.ts +27 -9
  208. package/dist/diagnostics/diagnostic.js +60 -19
  209. package/dist/diagnostics/diagnostic.js.map +1 -1
  210. package/dist/diagnostics/envelope.d.ts +18 -0
  211. package/dist/diagnostics/envelope.js.map +1 -1
  212. package/dist/executable/executable-cache.d.ts +21 -2
  213. package/dist/executable/executable-cache.js +21 -1
  214. package/dist/executable/executable-cache.js.map +1 -1
  215. package/dist/executable/executable-cache.test.js +123 -1
  216. package/dist/executable/executable-cache.test.js.map +1 -1
  217. package/dist/executable/prepare.js +199 -248
  218. package/dist/executable/prepare.js.map +1 -1
  219. package/dist/frontend/analysis.js +200 -18
  220. package/dist/frontend/analysis.js.map +1 -1
  221. package/dist/frontend/builtin-modules.d.ts +4 -0
  222. package/dist/frontend/builtin-modules.js +10 -0
  223. package/dist/frontend/builtin-modules.js.map +1 -1
  224. package/dist/frontend/early-errors.d.ts +12 -2
  225. package/dist/frontend/early-errors.js +535 -4
  226. package/dist/frontend/early-errors.js.map +1 -1
  227. package/dist/frontend/early-errors.test.js +165 -0
  228. package/dist/frontend/early-errors.test.js.map +1 -1
  229. package/dist/frontend/inferred-js-diagnostics.test.js +65 -0
  230. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  231. package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
  232. package/dist/frontend/jsx-opinion-sites.test.js +86 -0
  233. package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
  234. package/dist/frontend/lib-exports.d.ts +23 -4
  235. package/dist/frontend/lib-exports.js +98 -26
  236. package/dist/frontend/lib-exports.js.map +1 -1
  237. package/dist/frontend/lowering/binding-analysis.js +21 -3
  238. package/dist/frontend/lowering/binding-analysis.js.map +1 -1
  239. package/dist/frontend/lowering/buffers.d.ts +8 -0
  240. package/dist/frontend/lowering/buffers.js +43 -0
  241. package/dist/frontend/lowering/buffers.js.map +1 -0
  242. package/dist/frontend/lowering/builtin-calls.js +4 -0
  243. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  244. package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
  245. package/dist/frontend/lowering/builtin-namespaces.js +24 -3
  246. package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
  247. package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
  248. package/dist/frontend/lowering/builtin-statics.js +407 -0
  249. package/dist/frontend/lowering/builtin-statics.js.map +1 -0
  250. package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
  251. package/dist/frontend/lowering/builtins/arguments.js +12 -0
  252. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  253. package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
  254. package/dist/frontend/lowering/builtins/atomics.js +87 -1
  255. package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
  256. package/dist/frontend/lowering/builtins/child-process-methods.js +2 -2
  257. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  258. package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
  259. package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
  260. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  261. package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
  262. package/dist/frontend/lowering/builtins/child-process.js +560 -27
  263. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  264. package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
  265. package/dist/frontend/lowering/builtins/compression.js +41 -21
  266. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  267. package/dist/frontend/lowering/builtins/constants.js +7 -2
  268. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  269. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
  270. package/dist/frontend/lowering/builtins/filesystem-calls.js +28 -2
  271. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  272. package/dist/frontend/lowering/builtins/json.js +4 -0
  273. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  274. package/dist/frontend/lowering/builtins/module-calls.js +3 -1
  275. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  276. package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
  277. package/dist/frontend/lowering/builtins/numbers.js +10 -2
  278. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  279. package/dist/frontend/lowering/builtins/operating-system.d.ts +6 -3
  280. package/dist/frontend/lowering/builtins/operating-system.js +96 -16
  281. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  282. package/dist/frontend/lowering/builtins/process.d.ts +2 -2
  283. package/dist/frontend/lowering/builtins/process.js +103 -8
  284. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  285. package/dist/frontend/lowering/builtins/promises.js +169 -8
  286. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  287. package/dist/frontend/lowering/builtins/properties.js +6 -2
  288. package/dist/frontend/lowering/builtins/properties.js.map +1 -1
  289. package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
  290. package/dist/frontend/lowering/builtins/readline.js +180 -36
  291. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  292. package/dist/frontend/lowering/builtins/url.js +35 -12
  293. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  294. package/dist/frontend/lowering/builtins/webassembly.js +2 -0
  295. package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
  296. package/dist/frontend/lowering/call-arguments.d.ts +10 -0
  297. package/dist/frontend/lowering/call-arguments.js +37 -2
  298. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  299. package/dist/frontend/lowering/call-signatures.d.ts +10 -0
  300. package/dist/frontend/lowering/call-signatures.js +103 -0
  301. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  302. package/dist/frontend/lowering/class-construction.d.ts +14 -2
  303. package/dist/frontend/lowering/class-construction.js +99 -5
  304. package/dist/frontend/lowering/class-construction.js.map +1 -1
  305. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +9 -0
  306. package/dist/frontend/lowering/class-dynamic-dispatch.js +1283 -1030
  307. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  308. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
  309. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  310. package/dist/frontend/lowering/class-prototypes.js +20 -15
  311. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  312. package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
  313. package/dist/frontend/lowering/class-runtime-statics.js +20 -1
  314. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  315. package/dist/frontend/lowering/class-unions.js +21 -4
  316. package/dist/frontend/lowering/class-unions.js.map +1 -1
  317. package/dist/frontend/lowering/coercions/function-adapters.js +9 -0
  318. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  319. package/dist/frontend/lowering/coercions/state.d.ts +8 -0
  320. package/dist/frontend/lowering/coercions/state.js +17 -0
  321. package/dist/frontend/lowering/coercions/state.js.map +1 -1
  322. package/dist/frontend/lowering/coercions/structural-plans.js +20 -5
  323. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  324. package/dist/frontend/lowering/coercions/structural.js +10 -1
  325. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  326. package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
  327. package/dist/frontend/lowering/coercions/unions.js +54 -10
  328. package/dist/frontend/lowering/coercions/unions.js.map +1 -1
  329. package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
  330. package/dist/frontend/lowering/constructor-returns.js +284 -58
  331. package/dist/frontend/lowering/constructor-returns.js.map +1 -1
  332. package/dist/frontend/lowering/containers/array-callbacks.js +156 -62
  333. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  334. package/dist/frontend/lowering/containers/array-construction.js +21 -3
  335. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  336. package/dist/frontend/lowering/containers/array-from-async.js +139 -3
  337. package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
  338. package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
  339. package/dist/frontend/lowering/containers/array-iteration.js +24 -7
  340. package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
  341. package/dist/frontend/lowering/containers/array-methods.js +14 -11
  342. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  343. package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
  344. package/dist/frontend/lowering/containers/bytes.js +446 -86
  345. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  346. package/dist/frontend/lowering/containers/callback-arguments.d.ts +5 -0
  347. package/dist/frontend/lowering/containers/callback-arguments.js +21 -12
  348. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  349. package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
  350. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
  351. package/dist/frontend/lowering/containers/collection-methods.js +52 -17
  352. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  353. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
  354. package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
  355. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
  356. package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
  357. package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
  358. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  359. package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
  360. package/dist/frontend/lowering/crypto-tables.js +5 -5
  361. package/dist/frontend/lowering/dispatch-sites.js +3 -0
  362. package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
  363. package/dist/frontend/lowering/divergences.d.ts +40 -0
  364. package/dist/frontend/lowering/divergences.js +239 -20
  365. package/dist/frontend/lowering/divergences.js.map +1 -1
  366. package/dist/frontend/lowering/effect-free.d.ts +12 -0
  367. package/dist/frontend/lowering/effect-free.js +44 -0
  368. package/dist/frontend/lowering/effect-free.js.map +1 -0
  369. package/dist/frontend/lowering/expressions/array-literals.d.ts +10 -0
  370. package/dist/frontend/lowering/expressions/array-literals.js +62 -0
  371. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  372. package/dist/frontend/lowering/expressions/binary.js +115 -5
  373. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  374. package/dist/frontend/lowering/expressions/element-access.js +151 -7
  375. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  376. package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
  377. package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
  378. package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
  379. package/dist/frontend/lowering/expressions/identifiers.js +31 -2
  380. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  381. package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
  382. package/dist/frontend/lowering/expressions/narrowing.js +175 -22
  383. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  384. package/dist/frontend/lowering/expressions/object-literals.js +173 -11
  385. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  386. package/dist/frontend/lowering/expressions/optional-chains.js +5 -1
  387. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  388. package/dist/frontend/lowering/expressions/property-access.d.ts +8 -0
  389. package/dist/frontend/lowering/expressions/property-access.js +379 -109
  390. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  391. package/dist/frontend/lowering/expressions/relational.js +237 -7
  392. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  393. package/dist/frontend/lowering/expressions/typeof.js +8 -0
  394. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  395. package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
  396. package/dist/frontend/lowering/expressions/union-fields.js +103 -13
  397. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  398. package/dist/frontend/lowering/expressions/updates.js +74 -55
  399. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  400. package/dist/frontend/lowering/function-returns.js +37 -10
  401. package/dist/frontend/lowering/function-returns.js.map +1 -1
  402. package/dist/frontend/lowering/general-streams.js +5 -0
  403. package/dist/frontend/lowering/general-streams.js.map +1 -1
  404. package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
  405. package/dist/frontend/lowering/generator-delegation.js +301 -118
  406. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  407. package/dist/frontend/lowering/generic-functions.d.ts +27 -1
  408. package/dist/frontend/lowering/generic-functions.js +432 -18
  409. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  410. package/dist/frontend/lowering/global-function-values.d.ts +25 -0
  411. package/dist/frontend/lowering/global-function-values.js +193 -0
  412. package/dist/frontend/lowering/global-function-values.js.map +1 -0
  413. package/dist/frontend/lowering/global-values.d.ts +6 -4
  414. package/dist/frontend/lowering/global-values.js +24 -10
  415. package/dist/frontend/lowering/global-values.js.map +1 -1
  416. package/dist/frontend/lowering/host-global-values.d.ts +31 -0
  417. package/dist/frontend/lowering/host-global-values.js +121 -0
  418. package/dist/frontend/lowering/host-global-values.js.map +1 -0
  419. package/dist/frontend/lowering/host-globals.d.ts +74 -0
  420. package/dist/frontend/lowering/host-globals.js +344 -0
  421. package/dist/frontend/lowering/host-globals.js.map +1 -0
  422. package/dist/frontend/lowering/http2-constants.js +1 -1
  423. package/dist/frontend/lowering/iterator-adapters.js +46 -17
  424. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  425. package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
  426. package/dist/frontend/lowering/iterator-prototype.js +160 -0
  427. package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
  428. package/dist/frontend/lowering/key-order-witness.js +43 -22
  429. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  430. package/dist/frontend/lowering/key-order-witness.test.js +1 -0
  431. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  432. package/dist/frontend/lowering/lib-boundary.js +11 -3
  433. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  434. package/dist/frontend/lowering/lower-assert.js +30 -15
  435. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  436. package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
  437. package/dist/frontend/lowering/lower-async-iteration.js +15 -0
  438. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  439. package/dist/frontend/lowering/lower-builtin-values.js +11 -1
  440. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  441. package/dist/frontend/lowering/lower-calls.d.ts +25 -0
  442. package/dist/frontend/lowering/lower-calls.js +929 -227
  443. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  444. package/dist/frontend/lowering/lower-calls.test.js +59 -16
  445. package/dist/frontend/lowering/lower-calls.test.js.map +1 -1
  446. package/dist/frontend/lowering/lower-classes.d.ts +20 -0
  447. package/dist/frontend/lowering/lower-classes.js +468 -44
  448. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  449. package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -2
  450. package/dist/frontend/lowering/lower-event-emitter.js +253 -83
  451. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  452. package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
  453. package/dist/frontend/lowering/lower-exprs.js +71 -20
  454. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  455. package/dist/frontend/lowering/lower-functions.js +25 -6
  456. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  457. package/dist/frontend/lowering/lower-generators.js +57 -10
  458. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  459. package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
  460. package/dist/frontend/lowering/lower-global-value.js +14 -5
  461. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  462. package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
  463. package/dist/frontend/lowering/lower-inspect.js +638 -64
  464. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  465. package/dist/frontend/lowering/lower-modules.js +48 -2
  466. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  467. package/dist/frontend/lowering/lower-namespaces.js +18 -0
  468. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  469. package/dist/frontend/lowering/lower-node-island.js +16 -6
  470. package/dist/frontend/lowering/lower-node-island.js.map +1 -1
  471. package/dist/frontend/lowering/lower-server.js +303 -87
  472. package/dist/frontend/lowering/lower-server.js.map +1 -1
  473. package/dist/frontend/lowering/lower-stdlib.js +45 -0
  474. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  475. package/dist/frontend/lowering/lower-stmts.d.ts +14 -11
  476. package/dist/frontend/lowering/lower-stmts.js +270 -52
  477. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  478. package/dist/frontend/lowering/lower-timers.js +110 -27
  479. package/dist/frontend/lowering/lower-timers.js.map +1 -1
  480. package/dist/frontend/lowering/lower-url.js +6 -3
  481. package/dist/frontend/lowering/lower-url.js.map +1 -1
  482. package/dist/frontend/lowering/lowerer.d.ts +227 -21
  483. package/dist/frontend/lowering/lowerer.js +651 -92
  484. package/dist/frontend/lowering/lowerer.js.map +1 -1
  485. package/dist/frontend/lowering/lowerer.test.js +18 -0
  486. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  487. package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
  488. package/dist/frontend/lowering/lowering-facts.js +323 -0
  489. package/dist/frontend/lowering/lowering-facts.js.map +1 -0
  490. package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
  491. package/dist/frontend/lowering/lowering-facts.test.js +100 -0
  492. package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
  493. package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
  494. package/dist/frontend/lowering/nan-coded-reads.js +112 -9
  495. package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
  496. package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
  497. package/dist/frontend/lowering/optional-arguments.js +26 -2
  498. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  499. package/dist/frontend/lowering/partial-assertions.d.ts +0 -3
  500. package/dist/frontend/lowering/partial-assertions.js +9 -15
  501. package/dist/frontend/lowering/partial-assertions.js.map +1 -1
  502. package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
  503. package/dist/frontend/lowering/primitive-throws.js +241 -0
  504. package/dist/frontend/lowering/primitive-throws.js.map +1 -0
  505. package/dist/frontend/lowering/primitive-wrappers.js +1 -0
  506. package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
  507. package/dist/frontend/lowering/record-inherited.d.ts +17 -1
  508. package/dist/frontend/lowering/record-inherited.js +16 -2
  509. package/dist/frontend/lowering/record-inherited.js.map +1 -1
  510. package/dist/frontend/lowering/record-links.d.ts +73 -0
  511. package/dist/frontend/lowering/record-links.js +797 -0
  512. package/dist/frontend/lowering/record-links.js.map +1 -0
  513. package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
  514. package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
  515. package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
  516. package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
  517. package/dist/frontend/lowering/runtime-optional-report.js +300 -0
  518. package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
  519. package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
  520. package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
  521. package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
  522. package/dist/frontend/lowering/static-typeof.d.ts +3 -1
  523. package/dist/frontend/lowering/static-typeof.js +6 -1
  524. package/dist/frontend/lowering/static-typeof.js.map +1 -1
  525. package/dist/frontend/lowering/strict-mode.d.ts +1 -5
  526. package/dist/frontend/lowering/strict-mode.js +4 -30
  527. package/dist/frontend/lowering/strict-mode.js.map +1 -1
  528. package/dist/frontend/lowering/structural-instances.d.ts +7 -0
  529. package/dist/frontend/lowering/structural-instances.js +23 -0
  530. package/dist/frontend/lowering/structural-instances.js.map +1 -1
  531. package/dist/frontend/lowering/surfaces.d.ts +15 -1
  532. package/dist/frontend/lowering/surfaces.js +78 -10
  533. package/dist/frontend/lowering/surfaces.js.map +1 -1
  534. package/dist/frontend/lowering/union-retag.d.ts +13 -1
  535. package/dist/frontend/lowering/union-retag.js +55 -1
  536. package/dist/frontend/lowering/union-retag.js.map +1 -1
  537. package/dist/frontend/lowering/union-retag.test.js +51 -0
  538. package/dist/frontend/lowering/union-retag.test.js.map +1 -1
  539. package/dist/frontend/lowering/unit-journal.d.ts +8 -0
  540. package/dist/frontend/lowering/unit-journal.js +14 -0
  541. package/dist/frontend/lowering/unit-journal.js.map +1 -1
  542. package/dist/frontend/lowering/unit-journal.test.js +36 -1
  543. package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
  544. package/dist/frontend/lowering/zlib-constants.js +3 -2
  545. package/dist/frontend/lowering/zlib-constants.js.map +1 -1
  546. package/dist/frontend/npm-static.js +78 -9
  547. package/dist/frontend/npm-static.js.map +1 -1
  548. package/dist/frontend/npm-static.test.js +95 -2
  549. package/dist/frontend/npm-static.test.js.map +1 -1
  550. package/dist/frontend/pipeline.d.ts +5 -4
  551. package/dist/frontend/pipeline.js +94 -31
  552. package/dist/frontend/pipeline.js.map +1 -1
  553. package/dist/frontend/pipeline.test.js +68 -11
  554. package/dist/frontend/pipeline.test.js.map +1 -1
  555. package/dist/frontend/program.d.ts +62 -2
  556. package/dist/frontend/program.js +695 -422
  557. package/dist/frontend/program.js.map +1 -1
  558. package/dist/frontend/program.test.js +37 -1
  559. package/dist/frontend/program.test.js.map +1 -1
  560. package/dist/frontend/services-node.d.ts +7 -0
  561. package/dist/frontend/services-node.js +32 -1
  562. package/dist/frontend/services-node.js.map +1 -1
  563. package/dist/frontend/services-node.test.js +51 -0
  564. package/dist/frontend/services-node.test.js.map +1 -1
  565. package/dist/frontend/shape-inference/overlay.js +68 -2
  566. package/dist/frontend/shape-inference/overlay.js.map +1 -1
  567. package/dist/frontend/tier-analysis.d.ts +9 -0
  568. package/dist/frontend/tier-analysis.js +1 -0
  569. package/dist/frontend/tier-analysis.js.map +1 -1
  570. package/dist/frontend/tsc-codes.d.ts +57 -3
  571. package/dist/frontend/tsc-codes.js +935 -150
  572. package/dist/frontend/tsc-codes.js.map +1 -1
  573. package/dist/frontend/tsc-codes.test.js +221 -12
  574. package/dist/frontend/tsc-codes.test.js.map +1 -1
  575. package/dist/frontend/type-mapper.d.ts +91 -9
  576. package/dist/frontend/type-mapper.js +622 -181
  577. package/dist/frontend/type-mapper.js.map +1 -1
  578. package/dist/index.d.ts +1 -1
  579. package/dist/index.js +80 -15
  580. package/dist/index.js.map +1 -1
  581. package/dist/index.test.d.ts +1 -0
  582. package/dist/index.test.js +60 -0
  583. package/dist/index.test.js.map +1 -0
  584. package/dist/ir/builtin-effects.js +43 -0
  585. package/dist/ir/builtin-effects.js.map +1 -1
  586. package/dist/ir/builtin-signatures.d.ts +1 -1
  587. package/dist/ir/builtin-signatures.js +242 -16
  588. package/dist/ir/builtin-signatures.js.map +1 -1
  589. package/dist/ir/callback-specialization.d.ts +3 -2
  590. package/dist/ir/callback-specialization.js +35 -25
  591. package/dist/ir/callback-specialization.js.map +1 -1
  592. package/dist/ir/capture-values.d.ts +8 -4
  593. package/dist/ir/capture-values.js +9 -6
  594. package/dist/ir/capture-values.js.map +1 -1
  595. package/dist/ir/char-unit-locals.d.ts +6 -2
  596. package/dist/ir/char-unit-locals.js +11 -2
  597. package/dist/ir/char-unit-locals.js.map +1 -1
  598. package/dist/ir/class-key-index.d.ts +18 -0
  599. package/dist/ir/class-key-index.js +29 -0
  600. package/dist/ir/class-key-index.js.map +1 -0
  601. package/dist/ir/class-key-index.test.d.ts +1 -0
  602. package/dist/ir/class-key-index.test.js +25 -0
  603. package/dist/ir/class-key-index.test.js.map +1 -0
  604. package/dist/ir/codec.generated.d.ts +1 -1
  605. package/dist/ir/codec.generated.js +724 -648
  606. package/dist/ir/codec.generated.js.map +1 -1
  607. package/dist/ir/constant-globals.d.ts +5 -2
  608. package/dist/ir/constant-globals.js +25 -27
  609. package/dist/ir/constant-globals.js.map +1 -1
  610. package/dist/ir/expression-inlining.d.ts +4 -2
  611. package/dist/ir/expression-inlining.js +8 -2
  612. package/dist/ir/expression-inlining.js.map +1 -1
  613. package/dist/ir/field-values.d.ts +5 -2
  614. package/dist/ir/field-values.js +32 -21
  615. package/dist/ir/field-values.js.map +1 -1
  616. package/dist/ir/fields.generated.d.ts +11 -2
  617. package/dist/ir/fields.generated.js +8 -0
  618. package/dist/ir/fields.generated.js.map +1 -1
  619. package/dist/ir/final-fields.js +1 -1
  620. package/dist/ir/final-fields.js.map +1 -1
  621. package/dist/ir/function-references.d.ts +5 -4
  622. package/dist/ir/function-references.js +7 -4
  623. package/dist/ir/function-references.js.map +1 -1
  624. package/dist/ir/function-references.test.js +7 -0
  625. package/dist/ir/function-references.test.js.map +1 -1
  626. package/dist/ir/init-only-globals.d.ts +4 -2
  627. package/dist/ir/init-only-globals.js +17 -18
  628. package/dist/ir/init-only-globals.js.map +1 -1
  629. package/dist/ir/inline-array-views.js +1 -0
  630. package/dist/ir/inline-array-views.js.map +1 -1
  631. package/dist/ir/int32-slots.js +7 -0
  632. package/dist/ir/int32-slots.js.map +1 -1
  633. package/dist/ir/ir.d.ts +59 -4
  634. package/dist/ir/ir.js +7 -0
  635. package/dist/ir/ir.js.map +1 -1
  636. package/dist/ir/js-groups.d.ts +51 -0
  637. package/dist/ir/js-groups.js +394 -0
  638. package/dist/ir/js-groups.js.map +1 -0
  639. package/dist/ir/js-groups.test.d.ts +1 -0
  640. package/dist/ir/js-groups.test.js +555 -0
  641. package/dist/ir/js-groups.test.js.map +1 -0
  642. package/dist/ir/js-ic.js +30 -5
  643. package/dist/ir/js-ic.js.map +1 -1
  644. package/dist/ir/js-ic.test.js +27 -1
  645. package/dist/ir/js-ic.test.js.map +1 -1
  646. package/dist/ir/node-index.d.ts +23 -6
  647. package/dist/ir/node-index.js +126 -49
  648. package/dist/ir/node-index.js.map +1 -1
  649. package/dist/ir/numeric-call-specialization.d.ts +4 -2
  650. package/dist/ir/numeric-call-specialization.js +40 -26
  651. package/dist/ir/numeric-call-specialization.js.map +1 -1
  652. package/dist/ir/paired-while-loops.d.ts +4 -2
  653. package/dist/ir/paired-while-loops.js +8 -2
  654. package/dist/ir/paired-while-loops.js.map +1 -1
  655. package/dist/ir/parameter-versions.d.ts +13 -4
  656. package/dist/ir/parameter-versions.js +63 -42
  657. package/dist/ir/parameter-versions.js.map +1 -1
  658. package/dist/ir/property-bags.d.ts +4 -2
  659. package/dist/ir/property-bags.js +22 -17
  660. package/dist/ir/property-bags.js.map +1 -1
  661. package/dist/ir/row-pairs.d.ts +4 -2
  662. package/dist/ir/row-pairs.js +12 -11
  663. package/dist/ir/row-pairs.js.map +1 -1
  664. package/dist/ir/runtime-features.d.ts +87 -12
  665. package/dist/ir/runtime-features.js +263 -160
  666. package/dist/ir/runtime-features.js.map +1 -1
  667. package/dist/ir/runtime-features.test.js +109 -139
  668. package/dist/ir/runtime-features.test.js.map +1 -1
  669. package/dist/ir/runtime-jam-loops.d.ts +35 -0
  670. package/dist/ir/runtime-jam-loops.js +604 -0
  671. package/dist/ir/runtime-jam-loops.js.map +1 -0
  672. package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
  673. package/dist/ir/runtime-jam-loops.test.js +565 -0
  674. package/dist/ir/runtime-jam-loops.test.js.map +1 -0
  675. package/dist/ir/saturating-loop-jams.d.ts +4 -2
  676. package/dist/ir/saturating-loop-jams.js +11 -10
  677. package/dist/ir/saturating-loop-jams.js.map +1 -1
  678. package/dist/ir/scalar-records.d.ts +5 -2
  679. package/dist/ir/scalar-records.js +12 -2
  680. package/dist/ir/scalar-records.js.map +1 -1
  681. package/dist/ir/self-captures.d.ts +4 -2
  682. package/dist/ir/self-captures.js +32 -27
  683. package/dist/ir/self-captures.js.map +1 -1
  684. package/dist/ir/serialize.d.ts +6 -1
  685. package/dist/ir/serialize.js +87 -23
  686. package/dist/ir/serialize.js.map +1 -1
  687. package/dist/ir/serialize.test.js +26 -0
  688. package/dist/ir/serialize.test.js.map +1 -1
  689. package/dist/ir/tiers.js +1 -0
  690. package/dist/ir/tiers.js.map +1 -1
  691. package/dist/ir/traverse.js +4 -0
  692. package/dist/ir/traverse.js.map +1 -1
  693. package/dist/ir/typed-argument-clones.d.ts +30 -0
  694. package/dist/ir/typed-argument-clones.js +789 -0
  695. package/dist/ir/typed-argument-clones.js.map +1 -0
  696. package/dist/ir/union-arm-loops.d.ts +3 -0
  697. package/dist/ir/union-arm-loops.js +373 -0
  698. package/dist/ir/union-arm-loops.js.map +1 -0
  699. package/dist/ir/union-arm-loops.test.d.ts +1 -0
  700. package/dist/ir/union-arm-loops.test.js +230 -0
  701. package/dist/ir/union-arm-loops.test.js.map +1 -0
  702. package/dist/ir/validate.js +88 -18
  703. package/dist/ir/validate.js.map +1 -1
  704. package/dist/library/compiler-self-identity.d.ts +8 -2
  705. package/dist/library/compiler-self-identity.js +92 -18
  706. package/dist/library/compiler-self-identity.js.map +1 -1
  707. package/dist/library/compiler-self-identity.test.js +150 -3
  708. package/dist/library/compiler-self-identity.test.js.map +1 -1
  709. package/dist/library/int-infer.d.ts +5 -0
  710. package/dist/library/int-infer.js +15 -3
  711. package/dist/library/int-infer.js.map +1 -1
  712. package/dist/library/ir-policy.js +1 -0
  713. package/dist/library/ir-policy.js.map +1 -1
  714. package/dist/library/library-cache.d.ts +4 -0
  715. package/dist/library/library-cache.js +2 -0
  716. package/dist/library/library-cache.js.map +1 -1
  717. package/dist/library/library-cache.test.js +26 -0
  718. package/dist/library/library-cache.test.js.map +1 -1
  719. package/dist/library/prepare.js +99 -31
  720. package/dist/library/prepare.js.map +1 -1
  721. package/dist/native/cache.d.ts +7 -0
  722. package/dist/native/cache.js +47 -0
  723. package/dist/native/cache.js.map +1 -1
  724. package/dist/native/cache.test.js +13 -1
  725. package/dist/native/cache.test.js.map +1 -1
  726. package/dist/native/cli.js +1 -1
  727. package/dist/native/cli.js.map +1 -1
  728. package/dist/native/compiler.js +18 -3
  729. package/dist/native/compiler.js.map +1 -1
  730. package/dist/native/executable-cache-open.test.js +31 -5
  731. package/dist/native/executable-cache-open.test.js.map +1 -1
  732. package/dist/native/executable-cache.d.ts +6 -1
  733. package/dist/native/executable-cache.js +7 -1
  734. package/dist/native/executable-cache.js.map +1 -1
  735. package/dist/native/prepare.d.ts +3 -0
  736. package/dist/native/prepare.js +43 -26
  737. package/dist/native/prepare.js.map +1 -1
  738. package/dist/native/prepare.test.js +25 -3
  739. package/dist/native/prepare.test.js.map +1 -1
  740. package/dist/native/sanitizer.js +10 -1
  741. package/dist/native/sanitizer.js.map +1 -1
  742. package/dist/native/sanitizer.test.js +7 -2
  743. package/dist/native/sanitizer.test.js.map +1 -1
  744. package/dist/node-islands/boundary.d.ts +12 -0
  745. package/dist/node-islands/boundary.js +38 -6
  746. package/dist/node-islands/boundary.js.map +1 -1
  747. package/dist/node-islands/boundary.test.d.ts +1 -0
  748. package/dist/node-islands/boundary.test.js +76 -0
  749. package/dist/node-islands/boundary.test.js.map +1 -0
  750. package/dist/node-islands/detect.d.ts +9 -0
  751. package/dist/node-islands/detect.js +110 -0
  752. package/dist/node-islands/detect.js.map +1 -1
  753. package/dist/node-islands/detect.test.js +24 -0
  754. package/dist/node-islands/detect.test.js.map +1 -1
  755. package/dist/node-islands/graph-islands.d.ts +40 -0
  756. package/dist/node-islands/graph-islands.js +128 -0
  757. package/dist/node-islands/graph-islands.js.map +1 -0
  758. package/dist/node-islands/growth.d.ts +57 -0
  759. package/dist/node-islands/growth.js +205 -0
  760. package/dist/node-islands/growth.js.map +1 -0
  761. package/dist/node-islands/report.d.ts +12 -0
  762. package/dist/node-islands/report.js +28 -0
  763. package/dist/node-islands/report.js.map +1 -1
  764. package/dist/node-islands/report.test.js +2 -0
  765. package/dist/node-islands/report.test.js.map +1 -1
  766. package/dist/node-islands/rules.js +5 -0
  767. package/dist/node-islands/rules.js.map +1 -1
  768. package/dist/node-islands/scan.d.ts +11 -2
  769. package/dist/node-islands/scan.js +61 -9
  770. package/dist/node-islands/scan.js.map +1 -1
  771. package/dist/wasm/translate.js +11 -5
  772. package/dist/wasm/translate.js.map +1 -1
  773. package/dist/wasm/translate.test.js +35 -0
  774. package/dist/wasm/translate.test.js.map +1 -1
  775. package/package.json +20 -20
  776. package/surface-manifest.json +184 -117
@@ -7,7 +7,7 @@ import { JsIcSites } from "../../ir/js-ic.js";
7
7
  import {} from "./array-search.js";
8
8
  import { emitStringInputs } from "./string-lifetimes.js";
9
9
  import { emitThreadSlotsIntrinsic } from "./thread-slots.js";
10
- import { CYC_BUF, CYC_HDR, FIRST_EMITTED_CYC_KIND, inlineAllocSupported, RECORD_SOURCES_GATE, WEAK_KEYS_GATE, } from "./alloc.js";
10
+ import { CYC_BUF, CYC_HDR, FIRST_EMITTED_CYC_KIND, inlineAllocSupported, RECORD_KEPT_GATE, RECORD_SOURCES_GATE, WEAK_KEYS_GATE, } from "./alloc.js";
11
11
  import { youngNurseryRequested } from "../young-nursery.js";
12
12
  import { llvmBytes as llBytes, wtf8Bytes } from "../literals.js";
13
13
  import { InternalCompilerError } from "../../errors.js";
@@ -27,12 +27,14 @@ import { addRecordResultEntries, resultEntryName } from "./record-results.js";
27
27
  import { specializeCallbackCalls } from "../../ir/callback-specialization.js";
28
28
  import { EmitJournal, registerReplay, renameChunk, replayJournal, } from "./emit-journal.js";
29
29
  import { specializeNumericCalls } from "../../ir/numeric-call-specialization.js";
30
+ import { specializeTypedArguments } from "../../ir/typed-argument-clones.js";
30
31
  import { versionLoopBoundParameters } from "../../ir/parameter-versions.js";
31
32
  import { inlineExpressionFunctions } from "../../ir/expression-inlining.js";
32
33
  import { inlineArrayReads, NO_INLINE_ARRAYS, planInlineArrays, } from "../../ir/inline-arrays.js";
33
34
  import { inlineArraysApply, programLifetimeClassOf } from "./inline-arrays.js";
34
35
  import { pairRowSums } from "../../ir/row-pairs.js";
35
36
  import { jamSaturatingLoops } from "../../ir/saturating-loop-jams.js";
37
+ import { jamRuntimeCountLoops } from "../../ir/runtime-jam-loops.js";
36
38
  import { allocatedLiteral, fillAllocationLength, int32ArrayKey, selectInt32Arrays, } from "../../ir/int32-arrays.js";
37
39
  import { everyExpr, everyExprChild, everyStmtChild, everyStmtList } from "../../ir/traverse.js";
38
40
  import { INT32_RANGE, withinInt32, } from "../../ir/integer-ranges.js";
@@ -47,6 +49,7 @@ import { dropUnwrittenPropertyBags } from "../../ir/property-bags.js";
47
49
  import { freezeInitOnlyGlobals } from "../../ir/init-only-globals.js";
48
50
  import { hoistFinalFieldReads } from "../../ir/field-values.js";
49
51
  import { holdCharLocalsAsUnits } from "../../ir/char-unit-locals.js";
52
+ import { versionUnionArmLoops } from "../../ir/union-arm-loops.js";
50
53
  import { unitSafeFunctions } from "./string-unit-versions.js";
51
54
  import { stringScanInline } from "./string-reads.js";
52
55
  import { findInt32Abis, INT32_ABI_SUFFIX, SCALAR_UNION_DUMMY, SCALAR_UNION_RESULT, } from "./int32-abi.js";
@@ -73,6 +76,7 @@ import { borrowsCheckedNarrow, CheckedNarrows } from "./checked-narrows.js";
73
76
  import { emitDenseArraySet, emitDenseSlotUnlink, SCR_ELEM_I32, } from "./dense-array-access.js";
74
77
  import { matchMapRead, pointerMapGet } from "./map-read-lifetimes.js";
75
78
  import {} from "./map-entry-fusion.js";
79
+ import {} from "./record-entry-fusion.js";
76
80
  import { emitBorrowedFieldSequence, guardedValue } from "./borrowed-receivers.js";
77
81
  import { emitBorrowedInputs } from "./borrowed-inputs.js";
78
82
  import { findWalkBorrows } from "./walk-borrows.js";
@@ -114,11 +118,12 @@ import { emitNetworkHttpLibCall } from "./lib-network.js";
114
118
  import { emitAssertInspectLibCall, emitIoLibCall, emitGenericLibCall, emitLibCall, } from "./lib-dispatch.js";
115
119
  import { assignCompactLayouts, buildClassGraph, classFieldTypes, classMembershipIntervals, classFieldIndex, compactRefLoadLines, compactRefStoreLines, classPreLines, classStructSym, programLifetimeClass, } from "./classes.js";
116
120
  import { LifetimeRegions, REGION_TYPES } from "./regions.js";
121
+ import { planTreeClasses } from "../tree-classes.js";
117
122
  import { arenaAware, arenaCurrentAddress, arenaNewSym, arenasRequested, planArenas, } from "./arenas.js";
118
123
  import { children } from "./region-ir.js";
119
124
  import { LlDyn, recordDynKeepsIdentity } from "./dyn.js";
120
125
  import { VirtualBorrows } from "./virtual-borrows.js";
121
- import { planRecordViews, recordViewFieldPtr } from "./record-views.js";
126
+ import { absentTrapLines, planRecordViews, recordViewFieldPtr, recordViewTestLines, } from "./record-views.js";
122
127
  import { LlvmUnsupportedError } from "./unsupported.js";
123
128
  import { LlWalkers } from "./walkers.js";
124
129
  import { isObjectArm, isPayloadTag, NULLABLE_ABSENT, NULLABLE_NULL, NullableUnions, pointerTagFn, } from "./nullable-unions.js";
@@ -171,16 +176,18 @@ export function lowRegionTarget(platform, sanitize) {
171
176
  /** Function versions on loop-bounding number parameters
172
177
  * (ir/parameter-versions.ts). Library builds have no int32 entries, and a
173
178
  * module that observes call stacks could see the version's frame. */
174
- function versionParameters(mod) {
175
- if (mod.lib !== undefined || observesStacks(mod))
179
+ function versionParameters(mod, nodes) {
180
+ if (mod.lib !== undefined || observesStacks(mod, nodes))
176
181
  return mod;
177
- return versionLoopBoundParameters(mod, mangleFunction);
182
+ return versionLoopBoundParameters(mod, mangleFunction, nodes);
178
183
  }
179
184
  /** The int32 slot analysis of `mod`, with the inputs LlEmitter gives it.
180
185
  * With `revise`, the analysis revises the functions of candidates that drop
181
- * (Int32SlotInputs.revise), and `mod` is the module it started from. */
182
- function analyzeModuleInt32Slots(mod, revise) {
183
- const nodeIndex = new IrNodeIndex(mod);
186
+ * (Int32SlotInputs.revise), and `mod` is the module it started from. The
187
+ * node index of `mod` takes the nodes `previous` recorded for the functions
188
+ * both hold. */
189
+ function analyzeModuleInt32Slots(mod, previous, revise) {
190
+ const nodeIndex = new IrNodeIndex(mod, previous);
184
191
  const initializerBindings = findInitializerBindings(mod, nodeIndex);
185
192
  const dynamicStores = dynamicFieldStores(mod, undefined, undefined, nodeIndex);
186
193
  const slots = analyzeInt32Slots(mod, {
@@ -200,7 +207,7 @@ function keptInt32Arrays(analysis) {
200
207
  * node index of `mod`, and its initializer bindings and dynamic stores,
201
208
  * which must be the ones the analysis read. Null when they differ. */
202
209
  function revisedAnalysis(analysis, mod) {
203
- const nodeIndex = new IrNodeIndex(mod);
210
+ const nodeIndex = new IrNodeIndex(mod, analysis.nodeIndex);
204
211
  const initializerBindings = findInitializerBindings(mod, nodeIndex);
205
212
  const dynamicStores = dynamicFieldStores(mod, undefined, undefined, nodeIndex);
206
213
  const read = analysis.initializerBindings;
@@ -249,16 +256,19 @@ function moduleEmitter(input, options) {
249
256
  // Each proof selectInt32Arrays asks for analyzes a marked module; the
250
257
  // emitter of the module it returns reuses the last one. A proof that
251
258
  // revised functions analyzed the module of the functions it ended with.
252
- const rounds = { last: null, functions: null, revising: true };
259
+ // Each round's node index takes the recorded nodes of the functions it
260
+ // shares with the latest index (`nodes`).
261
+ const rounds = { last: null, functions: null, revising: true, nodes: undefined };
253
262
  const proven = (marked, revise) => {
254
263
  rounds.functions = null;
255
264
  if (revise === null || !rounds.revising) {
256
- rounds.last = analyzeModuleInt32Slots(marked);
265
+ rounds.last = analyzeModuleInt32Slots(marked, rounds.nodes);
266
+ rounds.nodes = rounds.last.nodeIndex;
257
267
  return { kept: keptInt32Arrays(rounds.last), functions: null };
258
268
  }
259
269
  const latest = new Map();
260
270
  try {
261
- rounds.last = analyzeModuleInt32Slots(marked, (fnName, dropped) => {
271
+ rounds.last = analyzeModuleInt32Slots(marked, rounds.nodes, (fnName, dropped) => {
262
272
  const fn = revise(fnName, dropped);
263
273
  latest.set(fnName, fn);
264
274
  return fn;
@@ -270,6 +280,7 @@ function moduleEmitter(input, options) {
270
280
  rounds.last = null;
271
281
  return null;
272
282
  }
283
+ rounds.nodes = rounds.last.nodeIndex;
273
284
  if (latest.size === 0)
274
285
  return { kept: keptInt32Arrays(rounds.last), functions: null };
275
286
  rounds.functions = marked.functions.map((fn) => latest.get(fn.name) ?? fn);
@@ -279,7 +290,13 @@ function moduleEmitter(input, options) {
279
290
  if (options.debugSources !== undefined)
280
291
  return new LlEmitter(mod, options, null, null);
281
292
  const timing = options.timing ?? (() => { });
282
- const passed = versionParameters(addRecordResultEntries(scalarizeLiteralResults(scalarizeNumericRecords(specializeCallbackCalls(specializeNumericCalls(pairRowSums(jamSaturatingLoops(inlineArraysPass(options, inlineExpressionFunctions(foldConstantGlobals(copyStableCaptures(resolveSelfCaptures(hoistFinalFieldReads(freezeInitOnlyGlobals(holdCharLocalsAsUnits(dropUnwrittenPropertyBags(runPairedWhileLoopsAsFor(mod)))))))))))), mangleFunction), mangleFunction)))));
293
+ // One index of the module the passes start from. Each pass skips the
294
+ // functions the index records without the node kinds it rewrites, and
295
+ // reads its scans of whole bodies from the index; it walks the functions
296
+ // an earlier pass rewrote, which the index does not record.
297
+ const nodes = new IrNodeIndex(mod);
298
+ rounds.nodes = nodes;
299
+ const passed = versionUnionArmLoops(versionParameters(addRecordResultEntries(scalarizeLiteralResults(scalarizeNumericRecords(specializeCallbackCalls(specializeNumericCalls(specializeTypedArguments(pairRowSums(jamRuntimeCountLoops(jamSaturatingLoops(inlineArraysPass(options, inlineExpressionFunctions(foldConstantGlobals(copyStableCaptures(resolveSelfCaptures(hoistFinalFieldReads(freezeInitOnlyGlobals(holdCharLocalsAsUnits(dropUnwrittenPropertyBags(runPairedWhileLoopsAsFor(mod, nodes), nodes), nodes), nodes), nodes), nodes), nodes), nodes), nodes)), nodes), nodes), nodes), mangleFunction, nodes), mangleFunction, nodes), mangleFunction, nodes)), nodes), nodes), nodes), nodes);
283
300
  timing("llvm-emit-rewrites");
284
301
  let emitted = selectInt32Arrays(passed, proven, resultEntryTargets);
285
302
  let prepared = rounds.last;
@@ -303,7 +320,7 @@ function moduleEmitter(input, options) {
303
320
  if (process.env["SCRIPTC_INT32_VERIFY"] === "1")
304
321
  verifyInt32Selection(passed, emitted, prepared?.mod === emitted ? prepared : null);
305
322
  timing("llvm-emit-int32");
306
- const emitter = new LlEmitter(emitted, options, null, prepared?.mod === emitted ? prepared : null);
323
+ const emitter = new LlEmitter(emitted, options, null, prepared?.mod === emitted ? prepared : null, rounds.nodes);
307
324
  timing("llvm-emit-analyses");
308
325
  return emitter;
309
326
  }
@@ -313,13 +330,13 @@ function moduleEmitter(input, options) {
313
330
  function verifyInt32Selection(passed, emitted, analysis) {
314
331
  let last = null;
315
332
  const reference = selectInt32Arrays(passed, (marked) => {
316
- last = analyzeModuleInt32Slots(marked);
333
+ last = analyzeModuleInt32Slots(marked, undefined);
317
334
  return { kept: keptInt32Arrays(last), functions: null };
318
335
  }, resultEntryTargets);
319
336
  const text = (mod) => serializeModuleParts(mod).join("");
320
337
  if (text(reference) !== text(emitted))
321
338
  throw new InternalCompilerError("int32 selection: the revised module differs from the rounds'");
322
- const facts = (mod, prepared) => (prepared?.mod === mod ? prepared : analyzeModuleInt32Slots(mod)).slots.summary(mod);
339
+ const facts = (mod, prepared) => (prepared?.mod === mod ? prepared : analyzeModuleInt32Slots(mod, undefined)).slots.summary(mod);
323
340
  const expected = facts(reference, last);
324
341
  const actual = facts(emitted, analysis);
325
342
  if (expected !== actual) {
@@ -396,6 +413,25 @@ function isIdentifierByte(code) {
396
413
  * to its next suspension, which returns to the caller, and the body's own
397
414
  * bookkeeping calls do not suspend it. */
398
415
  export const SUSPENDS = /@(?:scr_(?:await_|module_await\b|promise_await_settled\b|test_sub\b|gen_yield_|async_gen_(?!new\b|next_|return_|throw\b|hop_done\b)|fiber_)|sc_a[wd]_)/;
416
+ /** The literal text each SUSPENDS alternative starts with. The `@scr_` prefix
417
+ * is joined to each suffix here so that a prefix is not read as an emitted
418
+ * symbol name by the runtime ABI scan. */
419
+ const SUSPEND_PREFIXES = [
420
+ "await_",
421
+ "module_await",
422
+ "promise_await_settled",
423
+ "test_sub",
424
+ "gen_yield_",
425
+ "async_gen_",
426
+ "fiber_",
427
+ ]
428
+ .map((suffix) => `@scr_${suffix}`)
429
+ .concat("@sc_aw_", "@sc_ad_");
430
+ /** Whether `text` mentions a SUSPENDS entry point. The regex runs only on
431
+ * text that holds one of its prefixes, which most function bodies do not. */
432
+ export function mentionsSuspension(text) {
433
+ return SUSPEND_PREFIXES.some((prefix) => text.includes(prefix)) && SUSPENDS.test(text);
434
+ }
399
435
  /** The suspensions of a fiber body's own awaits, which its stackless
400
436
  * coroutine form suspends itself at instead. */
401
437
  const AWAIT_SUSPENSIONS = /@(?:scr_await_(?:void|f64|bool|str|ref|hop|dyn_value)\b|sc_a[wd]_[A-Za-z0-9_]+)/g;
@@ -504,6 +540,10 @@ export class LlEmitter {
504
540
  mod;
505
541
  /** Per-feature state (emitter-state.ts), indexed by each key's slot. */
506
542
  moduleStates = [];
543
+ /** The names of the functions that `versionLoopBoundParameters` versions
544
+ * for int32 loop bounds: the ones that keep their name and call the copy
545
+ * and the fallback. Computed on first use. */
546
+ int32Versioned = null;
507
547
  localArrayReads = new Map();
508
548
  loopArrayBorrows = new Set();
509
549
  scalarStringSlices = new Map();
@@ -527,7 +567,7 @@ export class LlEmitter {
527
567
  fieldAliasTags = new Map();
528
568
  fieldPointerTags = new Map();
529
569
  /** The field pointers (classFieldPtr) of this function whose fields hold
530
- * 32-bit references to compact class instances (LlClassMeta.compressed):
570
+ * 32-bit references (LlClassMeta.compressed):
531
571
  * loadField/loadRef decode them and storeField/storeRef encode them. */
532
572
  compressedFieldPtrs = new Set();
533
573
  /** Compact class instances live in the program-lifetime region below
@@ -535,6 +575,12 @@ export class LlEmitter {
535
575
  * classes): main reserves it before compiled code runs (scr_plr_init), and
536
576
  * fields and arrays of compactRefType hold 32-bit references. */
537
577
  compactRegion = false;
578
+ /** A compact class has a field holding an array, a map, a set or a heap
579
+ * instance (windowRefType), so a reference to it is a 32-bit address of
580
+ * the allocator's window: main requires the window to serve every
581
+ * reference block (scr_sa_require_window), and ends the process when it
582
+ * cannot, rather than hand out an address a field would truncate. */
583
+ windowRefs = false;
538
584
  /** Native class fields with different property names cannot occupy the
539
585
  * same slot of one object. Inherited views of the same property share a
540
586
  * tag. Array storage has its own disjoint categories; untagged runtime
@@ -839,6 +885,9 @@ export class LlEmitter {
839
885
  sanitizeAttributes;
840
886
  /** LlvmTargetOptions.cpuDispatch, where it applies. */
841
887
  cpuDispatch;
888
+ /** How the program's functions are copied (cpu-dispatch.ts): for runtime
889
+ * dispatch, for an x86-64-v3 `targetCpu` ("target"), or not at all. */
890
+ cpuCopies;
842
891
  wasmBoundsChecks;
843
892
  /** Interned string literals: UTF-8 text → { symbol, byte length } —
844
893
  * first-use order, the runtime ABI’s determinism discipline. */
@@ -944,6 +993,8 @@ export class LlEmitter {
944
993
  numberMapKeyIntegers = new Map();
945
994
  /** The current function's fused string-key Map get-then-set pairs (map-entry-fusion.ts). */
946
995
  mapEntryFusion = null;
996
+ /** The current function's fused record get-then-set pairs (record-entry-fusion.ts). */
997
+ recordEntryFusion = null;
947
998
  callLifetimes;
948
999
  /** The locals whose value never leaves its frame (frame-escapes.ts), for
949
1000
  * class instances with reference fields in frame storage. */
@@ -1105,6 +1156,11 @@ export class LlEmitter {
1105
1156
  arraySearchKinds = new Set();
1106
1157
  /** Typed-ref recipe constants by type key (lazy receivers). */
1107
1158
  typedRefRecipes = new Map();
1159
+ /** The module links narrowed record copies to their sources
1160
+ * (IrModule.recordLinks). */
1161
+ hasRecordLinks() {
1162
+ return (this.mod.recordLinks?.length ?? 0) > 0;
1163
+ }
1108
1164
  /** ReadableStream.from adapters keep typed arrays by reference and box
1109
1165
  * one current element per pull. */
1110
1166
  streamFromArrayAdapters = new Map();
@@ -1140,6 +1196,18 @@ export class LlEmitter {
1140
1196
  * zero-initialized ScrJsIc per site (scr_js.h). */
1141
1197
  jsIcSiteCount = 0;
1142
1198
  jsIcSitesMemo;
1199
+ /** Guard-group records of dynamic-tier functions (js-groups.ts): one
1200
+ * zero-initialized ScrJsGroup per group, and the key arrays the probes
1201
+ * read (scr_js.h). */
1202
+ jsGroupCount = 0;
1203
+ jsGroupKeysCount = 0;
1204
+ jsGroupKeysByName = new Map();
1205
+ jsGroupKeysByText = new Map();
1206
+ /** The guard of each group the function being emitted has entered: the
1207
+ * entry value, and the position of the member that comes next. */
1208
+ groupRuns = new Map();
1209
+ /** The guard groups of the function being emitted (ir/js-groups.ts). */
1210
+ jsGroupPlan = null;
1143
1211
  /** The tier of the function being emitted. */
1144
1212
  currentTier = undefined;
1145
1213
  /** The class graph (buildClassGraph): preorder numbering, hierarchy
@@ -1413,7 +1481,7 @@ export class LlEmitter {
1413
1481
  journaled;
1414
1482
  /** Stack-trace mode: functions no capture can include (no frame push). */
1415
1483
  unframedFunctions;
1416
- constructor(mod, options, journal = null, int32Analysis = null) {
1484
+ constructor(mod, options, journal = null, int32Analysis = null, previousIndex) {
1417
1485
  this.mod = mod;
1418
1486
  this.targetOptions = options;
1419
1487
  this.journal = journal;
@@ -1421,8 +1489,9 @@ export class LlEmitter {
1421
1489
  journal !== null ||
1422
1490
  ((options.functionWorkers ?? 1) > 1 && options.forkPrimitives !== undefined);
1423
1491
  // One walk of every body, which the analyses below read instead of
1424
- // walking the bodies themselves.
1425
- this.nodeIndex = int32Analysis?.nodeIndex ?? new IrNodeIndex(mod);
1492
+ // walking the bodies themselves. The functions `previousIndex` (an index
1493
+ // of an earlier module) recorded are not walked again.
1494
+ this.nodeIndex = int32Analysis?.nodeIndex ?? new IrNodeIndex(mod, previousIndex);
1426
1495
  this.initializerBindings =
1427
1496
  int32Analysis?.initializerBindings ?? findInitializerBindings(mod, this.nodeIndex);
1428
1497
  // One walk finds the dynamic field stores every analysis below consults.
@@ -1490,13 +1559,16 @@ export class LlEmitter {
1490
1559
  this.nodeIslandModuleData = options.nodeIslandModuleData ?? null;
1491
1560
  this.targetCpu = options.targetCpu;
1492
1561
  this.sanitizeAttributes = options.sanitizeAttributes !== false;
1493
- this.cpuDispatch =
1494
- options.cpuDispatch === true &&
1495
- options.targetCpu === undefined &&
1496
- !this.wasi &&
1497
- mod.lib === undefined &&
1498
- this.debug === null &&
1499
- /^(x86_64|amd64|x64)\b/.test(options.targetTriple || process.arch);
1562
+ const copyable = !this.wasi &&
1563
+ mod.lib === undefined &&
1564
+ this.debug === null &&
1565
+ /^(x86_64|amd64|x64)\b/.test(options.targetTriple || process.arch);
1566
+ this.cpuDispatch = options.cpuDispatch === true && options.targetCpu === undefined && copyable;
1567
+ this.cpuCopies = this.cpuDispatch
1568
+ ? "dispatch"
1569
+ : options.targetCpu === "x86-64-v3" && copyable
1570
+ ? "target"
1571
+ : null;
1500
1572
  this.wasmBoundsChecks =
1501
1573
  options.wasmBoundsChecks === true ||
1502
1574
  wasmBoundsChecks({
@@ -1687,6 +1759,9 @@ export class LlEmitter {
1687
1759
  // The same holds for a class union's arms (class-unions.ts).
1688
1760
  classUnionHeaders(mod, this.nullableUnions.allClassUnions(), this.tracedShapes, this.tracedUnions);
1689
1761
  this.shapeHost = {
1762
+ ...((mod.recordLinks?.length ?? 0) > 0
1763
+ ? { recordSourcesGate: RECORD_KEPT_GATE, recordLinks: mod.recordLinks }
1764
+ : {}),
1690
1765
  // Journal hooks only on emitters that can emit ranges (chunk
1691
1766
  // emitters, and emitters whose workers take a journal after the
1692
1767
  // fork), so the host's optional calls cost nothing otherwise.
@@ -1723,6 +1798,8 @@ export class LlEmitter {
1723
1798
  // Worker programs keep one allocator per script thread: the inline
1724
1799
  // paths address its thread-local state.
1725
1800
  threadLocalAlloc: mod.workers === true,
1801
+ // Linux executables find a block's owner in the chunk map.
1802
+ windowMap: options.lowRegion === true,
1726
1803
  rcHelpers: this.rcHelpers,
1727
1804
  ...(this.rcMode !== undefined ? { rcMode: this.rcMode } : {}),
1728
1805
  ...(this.rcHelpersNoinline ? { rcHelpersNoinline: true } : {}),
@@ -1886,12 +1963,14 @@ export class LlEmitter {
1886
1963
  // except where regions count them or a slot word follows the header.
1887
1964
  if (this.sizeType === "i64" && mod.lifetimeRegions !== true)
1888
1965
  assignCompactLayouts(this.classMeta, (root) => programLifetimeClass(this.shapeHost, root) && !root.threadSlot, (cls) => classFieldTypes(this.shapeHost, cls, this.int32Slots),
1889
- // Executables whose region lies below 32 GiB hold compact class
1890
- // instances there (scr_plr_alloc), so fields referring to one store
1891
- // a 32-bit reference: the field's type, the class of a
1892
- // `C | undefined` or `C | null` pointer, or the reference arm of a
1893
- // nullable pointer field, is a compact class. `C | null | undefined`
1894
- // keeps the pointer: its null is a sentinel outside the region.
1966
+ // Executables whose window lies below 32 GiB hold compact class
1967
+ // instances there (scr_plr_alloc), and arrays, maps, sets and other
1968
+ // class instances too, so fields referring to one store a 32-bit
1969
+ // reference: the field's type, the class of a `C | undefined` or
1970
+ // `C | null` pointer, or the reference arm of a nullable pointer
1971
+ // field, is a compact class, or windowRefType holds. `C | null |
1972
+ // undefined` keeps the pointer: its null is a sentinel outside the
1973
+ // region.
1895
1974
  mod.lib === undefined && options.lowRegion === true
1896
1975
  ? (cls, i, isCompact) => {
1897
1976
  const f = cls.fields[i];
@@ -1899,6 +1978,10 @@ export class LlEmitter {
1899
1978
  return false;
1900
1979
  if (this.compactRefType(f.type, isCompact))
1901
1980
  return true;
1981
+ if (this.windowRefType(f.type, isCompact)) {
1982
+ this.windowRefs = true;
1983
+ return true;
1984
+ }
1902
1985
  const nullable = f.type.kind === "union" && this.nullableUnions.single(f.type.unionId) === null
1903
1986
  ? this.nullableFields.get(cls.name, f.name)
1904
1987
  : null;
@@ -1909,8 +1992,53 @@ export class LlEmitter {
1909
1992
  mod.lib === undefined &&
1910
1993
  options.lowRegion === true &&
1911
1994
  [...this.classMeta.values()].some((m) => m.compact);
1995
+ for (const [name, rec] of RUNTIME_ERROR_CLASSES) {
1996
+ const meta = this.classMeta.get(name);
1997
+ if (!meta)
1998
+ break; // hand-written IR without the builtin defs: no stamps
1999
+ this.errorIntervals.push({ kind: rec.kind, pre: meta.pre, post: meta.post, lib: rec.lib });
2000
+ }
2001
+ const emMeta = this.classMeta.get(RUNTIME_EMITTER_CLASS);
2002
+ if (emMeta)
2003
+ this.emitterInterval = { pre: emMeta.pre, post: emMeta.post };
2004
+ for (const [name, rec] of RUNTIME_STREAM_CLASSES) {
2005
+ const meta = this.classMeta.get(name);
2006
+ if (!meta)
2007
+ continue;
2008
+ this.streamIntervals.push({
2009
+ vt: `scr_${rec.lib.toLowerCase()}_vt`,
2010
+ pre: meta.pre,
2011
+ post: meta.post,
2012
+ lib: rec.lib,
2013
+ });
2014
+ }
2015
+ this.virtualBorrows = new VirtualBorrows(mod, this.classMeta, this.fnByName, this.callLifetimes.borrowed);
2016
+ // After the vtable slots: borrowing slots exclude their implementations.
2017
+ if (this.debug === null)
2018
+ this.analyzeBorrowedReturns();
2019
+ // Which classes drop their count word: a node of a graph the program
2020
+ // proves acyclic, singly owned and unobserved (backend/tree-classes.ts,
2021
+ // out/unique-ownership/DESIGN.md). The linear-use analysis agrees with
2022
+ // the emitter's own ownership discipline, so it reads the facts above
2023
+ // and nothing else. A debug build skips the borrowed-return analysis
2024
+ // this needs; it keeps every class counted.
2025
+ if (this.debug === null && mod.lib === undefined && mod.lifetimeRegions !== true) {
2026
+ const plan = planTreeClasses(mod, {
2027
+ borrowed: this.callLifetimes.borrowed,
2028
+ borrowedReturns: this.borrowedReturns,
2029
+ traced: { shapes: this.tracedShapes, unions: this.tracedUnions },
2030
+ immutable: this.immutableFields,
2031
+ published: this.publishedTypes,
2032
+ });
2033
+ for (const name of plan.classes)
2034
+ this.classMeta.get(name).tree = true;
2035
+ this.treeMoves = plan.classes.size > 0 ? new Set(plan.moves) : null;
2036
+ }
1912
2037
  // Group arenas: off with lifetime regions, which own their classes'
1913
2038
  // allocation, and in libraries, whose exports any host code calls.
2039
+ // Planned after the tree classes, which keep the general allocator:
2040
+ // their teardown is a plain free, and an arena block's disposal runs
2041
+ // the counted path.
1914
2042
  if (arenasRequested() && mod.lifetimeRegions !== true && mod.lib === undefined) {
1915
2043
  this.arenas = planArenas(mod, {
1916
2044
  shape: (id) => {
@@ -1924,6 +2052,7 @@ export class LlEmitter {
1924
2052
  const meta = this.classMeta.get(def.name);
1925
2053
  return (meta !== undefined &&
1926
2054
  !meta.compact &&
2055
+ !meta.tree &&
1927
2056
  !meta.threadSlot &&
1928
2057
  // An Array subclass's instance is an array (the runtime's header).
1929
2058
  def.arrayElem === undefined &&
@@ -1933,6 +2062,7 @@ export class LlEmitter {
1933
2062
  },
1934
2063
  nullableArm: (unionId) => this.nullableUnions.single(unionId)?.arm ?? null,
1935
2064
  traced: (t) => traceAdapter(this.shapeHost, t) !== null,
2065
+ tree: (def) => this.classMeta.get(def.name)?.tree === true,
1936
2066
  });
1937
2067
  if (this.arenas !== null) {
1938
2068
  this.shapeHost.arenaShapes = this.arenas.shapes;
@@ -1948,30 +2078,6 @@ export class LlEmitter {
1948
2078
  if (arenaShapes !== undefined && viewTargets !== null)
1949
2079
  for (const id of arenaShapes)
1950
2080
  viewTargets.delete(id);
1951
- for (const [name, rec] of RUNTIME_ERROR_CLASSES) {
1952
- const meta = this.classMeta.get(name);
1953
- if (!meta)
1954
- break; // hand-written IR without the builtin defs: no stamps
1955
- this.errorIntervals.push({ kind: rec.kind, pre: meta.pre, post: meta.post, lib: rec.lib });
1956
- }
1957
- const emMeta = this.classMeta.get(RUNTIME_EMITTER_CLASS);
1958
- if (emMeta)
1959
- this.emitterInterval = { pre: emMeta.pre, post: emMeta.post };
1960
- for (const [name, rec] of RUNTIME_STREAM_CLASSES) {
1961
- const meta = this.classMeta.get(name);
1962
- if (!meta)
1963
- continue;
1964
- this.streamIntervals.push({
1965
- vt: `scr_${rec.lib.toLowerCase()}_vt`,
1966
- pre: meta.pre,
1967
- post: meta.post,
1968
- lib: rec.lib,
1969
- });
1970
- }
1971
- this.virtualBorrows = new VirtualBorrows(mod, this.classMeta, this.fnByName, this.callLifetimes.borrowed);
1972
- // After the vtable slots: borrowing slots exclude their implementations.
1973
- if (this.debug === null)
1974
- this.analyzeBorrowedReturns();
1975
2081
  this.int32SlotsValue ??= this.joinInt32Slots();
1976
2082
  }
1977
2083
  /** Computes the int32 slot analysis, or starts it on a forked process.
@@ -2056,7 +2162,7 @@ export class LlEmitter {
2056
2162
  emitParts() {
2057
2163
  const parts = emitParts(this);
2058
2164
  const bridged = this.unwindAbi.size > 0 ? bridgePlainUnwindCalls(parts) : parts;
2059
- const out = this.cpuDispatch ? cloneForCpuDispatch(bridged) : bridged;
2165
+ const out = this.cpuCopies === null ? bridged : cloneForCpuDispatch(bridged, this.cpuCopies);
2060
2166
  return this.heapCensus === null ? out : [...out, this.heapCensus.definitions().join("\n")];
2061
2167
  }
2062
2168
  /** The entry point and JavaScript name of each named function the
@@ -2065,10 +2171,18 @@ export class LlEmitter {
2065
2171
  * displayName, else its sourceName. Function boxes without a static name
2066
2172
  * look the closure's entry up in this table. */
2067
2173
  closureNameEntries;
2174
+ closureNameByEntry;
2175
+ /** The declared functions `closureNames` lists by their wrapper. A scan
2176
+ * sees closures in statements the emitter never reaches (a statement
2177
+ * after a runtimeFence: the fence always jumps), so some of these names
2178
+ * never enter `fnValues`; emitFnValueDefs defines their wrapper anyway,
2179
+ * because the table's entry has to resolve. */
2180
+ closureWrapperNames = new Set();
2068
2181
  closureNames() {
2069
2182
  if (this.closureNameEntries !== undefined)
2070
2183
  return this.closureNameEntries;
2071
2184
  const entries = new Map();
2185
+ this.closureNameByEntry = entries;
2072
2186
  const scan = this.nodeIndex.scan(CLOSURE_KINDS);
2073
2187
  for (const fn of this.mod.functions) {
2074
2188
  eachNodeOfKinds(fn, scan, (node) => {
@@ -2079,7 +2193,9 @@ export class LlEmitter {
2079
2193
  (target?.sourceName !== "<anonymous>" ? target?.sourceName : undefined);
2080
2194
  if (target === undefined || name === undefined || name === "")
2081
2195
  return true;
2082
- const entry = target.captures === undefined ? mangleWrapper(node.fnName) : this.callTarget(node.fnName);
2196
+ const entry = this.closureEntry(node.fnName, target);
2197
+ if (target.captures === undefined)
2198
+ this.closureWrapperNames.add(node.fnName);
2083
2199
  if (!entries.has(entry))
2084
2200
  entries.set(entry, name);
2085
2201
  return true;
@@ -2087,6 +2203,21 @@ export class LlEmitter {
2087
2203
  }
2088
2204
  return (this.closureNameEntries = [...entries].map(([entry, name]) => ({ entry, name })));
2089
2205
  }
2206
+ /** The entry point of a closure of `fnName` (closureNames). */
2207
+ closureEntry(fnName, target) {
2208
+ return target.captures === undefined ? mangleWrapper(fnName) : this.callTarget(fnName);
2209
+ }
2210
+ /** The name the closure-name table gives a closure made of `fnName`
2211
+ * (null when it has none), which lets a box of a closure made at the site
2212
+ * skip the table lookup; undefined for a function the module does not
2213
+ * define. */
2214
+ closureNameOf(fnName) {
2215
+ const target = this.fnByName.get(fnName);
2216
+ if (target === undefined)
2217
+ return undefined;
2218
+ this.closureNames();
2219
+ return this.closureNameByEntry.get(this.closureEntry(fnName, target)) ?? null;
2220
+ }
2090
2221
  /** The dispose-observer gates the emitted frees and record writers test
2091
2222
  * (alloc.ts): defined after every helper is emitted, because dynCheck
2092
2223
  * builders, JSON schemas and weak collection constructors are requested
@@ -2095,7 +2226,10 @@ export class LlEmitter {
2095
2226
  const weak = [...this.decls].some((d) => d.includes("@scr_weak_map_new(") || d.includes("@scr_weak_set_new("));
2096
2227
  return [
2097
2228
  `${WEAK_KEYS_GATE} = internal constant i1 ${weak}`,
2098
- `${RECORD_SOURCES_GATE} = internal constant i1 ${this.dyn.keepsRecordSources}`,
2229
+ `${RECORD_SOURCES_GATE} = internal constant i1 ${this.dyn.keepsRecordSources || this.hasRecordLinks()}`,
2230
+ ...(this.hasRecordLinks()
2231
+ ? [`${RECORD_KEPT_GATE} = internal constant i1 ${this.dyn.keepsRecordSources}`]
2232
+ : []),
2099
2233
  ``,
2100
2234
  ];
2101
2235
  }
@@ -2131,10 +2265,15 @@ export class LlEmitter {
2131
2265
  }
2132
2266
  /** Env-signature wrappers + interned immortal closures for declared
2133
2267
  * functions used as values (the runtime ABI’s sc_w_/sc_fc_ pair): every
2134
- * mention of `f` yields the same pointer, so `f === f` holds. */
2268
+ * mention of `f` yields the same pointer, so `f === f` holds. The
2269
+ * closure-name table's wrapper entries are included even when their
2270
+ * closure was never emitted (see closureWrapperNames). */
2135
2271
  emitFnValueDefs() {
2136
2272
  const out = [];
2137
- for (const name of this.fnValues) {
2273
+ const names = new Set(this.fnValues);
2274
+ for (const name of this.closureWrapperNames)
2275
+ names.add(name);
2276
+ for (const name of names) {
2138
2277
  const fn = this.fnByName.get(name);
2139
2278
  const params = fn.params.map((p, i) => `${this.llType(p.type)} %a${i}`);
2140
2279
  const args = fn.params.map((p, i) => `${this.llType(p.type)} %a${i}`).join(", ");
@@ -3010,11 +3149,27 @@ export class LlEmitter {
3010
3149
  toFrame(v) {
3011
3150
  this.disownTemp(v);
3012
3151
  }
3152
+ /** Whether a value of `type` is an instance of a tree class, whose retain
3153
+ * is a no-op and whose release destroys the subtree: it has exactly one
3154
+ * owner, so it may only be moved. */
3155
+ isTreeValue(type) {
3156
+ if (this.treeMoves === null)
3157
+ return false;
3158
+ const nullable = this.shapeHost.nullableUnions.of(type);
3159
+ const arm = nullable === null ? type : nullable.repr === "single" ? nullable.arm : null;
3160
+ return (arm !== null && arm.kind === "object" && this.classMeta.get(arm.className)?.tree === true);
3161
+ }
3013
3162
  /** The retained (+1) read of a refcounted value — type-directed through
3014
3163
  * the `_v` table (immortals skip, exactly the C retain calls). */
3015
3164
  retainCall(name, type) {
3016
3165
  if (this.isImmortal(name))
3017
3166
  return name;
3167
+ // A copy of a tree value would be a second owner, and the two would
3168
+ // destroy the same nodes. Every accepted read of one is a move
3169
+ // (takeLastUseMove), so a retain means the plan and the emitter
3170
+ // disagree: fail here rather than corrupt the heap.
3171
+ if (this.isTreeValue(type))
3172
+ throw new InternalCompilerError(`llvm emitter bug: tree value ${name} is copied instead of moved`);
3018
3173
  const t = this.B.tmp();
3019
3174
  this.B.line(`${t} = call ptr ${retainSym(this.shapeHost, type)}(ptr ${name})`);
3020
3175
  return t;
@@ -4070,6 +4225,29 @@ export class LlEmitter {
4070
4225
  single.arm.kind === "object" &&
4071
4226
  isCompact(single.arm.className));
4072
4227
  }
4228
+ /** Whether values of `t` are NULL or a refcounted object that lies in the
4229
+ * allocator's window below 32 GiB, so that a compact class field of type
4230
+ * `t` can store it as a 32-bit reference: an array, map or set, or an
4231
+ * instance of a class that is not compact and that the program allocates
4232
+ * (not the runtime's Error hierarchy, whose instances the runtime
4233
+ * allocates), or one of these or `undefined`/`null` (NULL). Strings keep
4234
+ * 8-byte pointers: literals lie in the executable's image. */
4235
+ windowRefType(t, isCompact) {
4236
+ const target = (u) => {
4237
+ if (u.kind === "array" || u.kind === "map" || u.kind === "set")
4238
+ return true;
4239
+ if (u.kind !== "object" || isCompact(u.className))
4240
+ return false;
4241
+ const meta = this.classMeta.get(u.className);
4242
+ return meta !== undefined && meta.root.def.runtime !== true;
4243
+ };
4244
+ if (target(t))
4245
+ return true;
4246
+ if (t.kind !== "union")
4247
+ return false;
4248
+ const single = this.nullableUnions.single(t.unionId);
4249
+ return single !== null && single.nullTag < 0 && target(single.arm);
4250
+ }
4073
4251
  /** Whether arrays of `elem` hold 32-bit references (SCR_ELEM_CREF). */
4074
4252
  compactArrayElem(elem) {
4075
4253
  return this.compactRegion && this.compactRefType(elem);
@@ -4240,6 +4418,155 @@ export class LlEmitter {
4240
4418
  const type = shape.fields[idx].type;
4241
4419
  return { ptr: p, type, inline: this.inlineUnions.record(type) };
4242
4420
  }
4421
+ /** Whether a value of `shapeId` may lack field `field`: a PARTIAL record
4422
+ * view (record-views.ts) whose viewed record does not declare it. A field
4423
+ * with no value representation (a unit type) keeps its slot lookup. */
4424
+ partialFieldMissing(shapeId, field) {
4425
+ if (this.shapeHost.recordViews?.partialMissing(shapeId, field) !== true)
4426
+ return false;
4427
+ const type = this.recordShape(shapeId).fields.find((f) => f.name === field)?.type;
4428
+ return type !== undefined && !isUnitType(type);
4429
+ }
4430
+ /** The viewed record's slot for `field` of a partial view, or NULL when
4431
+ * that record does not declare the field. The caller has established that
4432
+ * `obj` is a view. */
4433
+ partialViewSlot(objName, shapeId, field) {
4434
+ const position = this.recordShape(shapeId).fields.findIndex((f) => f.name === field);
4435
+ this.declare(`declare ptr @scr_record_view_slot(ptr, ${this.sizeType})`);
4436
+ const slot = this.B.tmp();
4437
+ this.B.line(`${slot} = call ptr @scr_record_view_slot(ptr ${objName}, ${this.sizeType} ${position})`);
4438
+ return slot;
4439
+ }
4440
+ /** The boxed property a partial view keeps for a field its viewed record
4441
+ * does not declare (NULL until something writes it). */
4442
+ partialViewExtra(objName, field) {
4443
+ this.declare(`declare ptr @scr_record_view_extra(ptr, ptr, ${this.sizeType})`);
4444
+ const extra = this.B.tmp();
4445
+ this.B.line(`${extra} = call ptr @scr_record_view_extra(ptr ${objName}, ptr ${this.cstr(field)}, ${this.sizeType} ${Buffer.byteLength(field, "utf8")})`);
4446
+ return extra;
4447
+ }
4448
+ /** Reads field `field` of `obj` (shape `shapeId`) where a PARTIAL view may
4449
+ * lack it. A view's present field reads through the viewed record's slot;
4450
+ * a field that record does not declare reads the property a write left in
4451
+ * the view's extra store, converted back to the field type; a field
4452
+ * nothing wrote stops the program (the frontend's checked read throws its
4453
+ * TypeError first). The answer is owned, like a checked conversion's. */
4454
+ readPartialField(objName, shapeId, field, type) {
4455
+ const B = this.B;
4456
+ const idx = this.recordShape(shapeId).fields.findIndex((f) => f.name === field);
4457
+ const inline = this.inlineUnions.record(type);
4458
+ const isView = B.tmp();
4459
+ const view = B.newLabel("pf.view");
4460
+ const notView = B.newLabel("pf.slot");
4461
+ const slots = B.newLabel("pf.slots");
4462
+ const extra = B.newLabel("pf.extra");
4463
+ const answer = B.newLabel("pf.answer");
4464
+ for (const line of recordViewTestLines(this.sizeType, objName, isView))
4465
+ B.line(line.trimStart());
4466
+ B.condBr(isView, view, notView);
4467
+ // Not a view: the field's own slot.
4468
+ B.startBlock(notView);
4469
+ const own = B.tmp();
4470
+ B.line(`${own} = getelementptr inbounds %${mangleRecordStruct(shapeId)}, ptr ${objName}, i64 0, i32 ${idx + this.nullableUnions.fieldBase(shapeId)}`);
4471
+ const ownFrom = B.currentLabel();
4472
+ B.br(slots);
4473
+ B.startBlock(view);
4474
+ const slot = this.partialViewSlot(objName, shapeId, field);
4475
+ const present = B.tmp();
4476
+ B.line(`${present} = icmp ne ptr ${slot}, null`);
4477
+ const slotFrom = B.currentLabel();
4478
+ B.condBr(present, slots, extra);
4479
+ B.startBlock(slots);
4480
+ const addr = B.tmp();
4481
+ B.line(`${addr} = phi ptr [ ${own}, %${ownFrom} ], [ ${slot}, %${slotFrom} ]`);
4482
+ // An inline union field answers a private stack box, as a plain read does.
4483
+ const loaded = inline
4484
+ ? this.inlineFieldUnion(addr, type)
4485
+ : this.loadRecordField(addr, type, false);
4486
+ const hit = isRefCounted(type) ? this.retainFrame(loaded, type) : loaded;
4487
+ const hitFrom = B.currentLabel();
4488
+ B.br(answer);
4489
+ B.startBlock(extra);
4490
+ const stored = this.partialViewExtra(objName, field);
4491
+ const absent = B.tmp();
4492
+ B.line(`${absent} = icmp eq ptr ${stored}, null`);
4493
+ const trap = B.newLabel("pf.absent");
4494
+ const convert = B.newLabel("pf.convert");
4495
+ B.condBr(absent, trap, convert);
4496
+ B.startBlock(trap);
4497
+ absentTrapLines(B, (text) => this.cstr(text), (decl) => this.declare(decl));
4498
+ B.startBlock(convert);
4499
+ const path = B.slot();
4500
+ B.entryAllocas.push(`${path} = alloca %ScrDynPath`);
4501
+ const parentPtr = B.tmp();
4502
+ const keyPtr = B.tmp();
4503
+ const indexPtr = B.tmp();
4504
+ B.line(`${parentPtr} = getelementptr inbounds %ScrDynPath, ptr ${path}, i64 0, i32 0`);
4505
+ B.line(`store ptr null, ptr ${parentPtr}`);
4506
+ B.line(`${keyPtr} = getelementptr inbounds %ScrDynPath, ptr ${path}, i64 0, i32 1`);
4507
+ B.line(`store ptr ${this.cstr(field)}, ptr ${keyPtr}`);
4508
+ B.line(`${indexPtr} = getelementptr inbounds %ScrDynPath, ptr ${path}, i64 0, i32 2`);
4509
+ B.line(`store ${this.sizeType} 0, ptr ${indexPtr}`);
4510
+ const helper = this.dyn.dynCheckHelper(type);
4511
+ const ty = this.llType(type);
4512
+ const checked = B.tmp();
4513
+ B.line(`${checked} = call ${ty === "i1" ? "zeroext i1" : ty} @${helper}(ptr ${stored}, ptr ${path})`);
4514
+ const convertFrom = B.currentLabel();
4515
+ B.br(answer);
4516
+ B.startBlock(answer);
4517
+ const value = B.tmp();
4518
+ B.line(`${value} = phi ${ty} [ ${hit}, %${hitFrom} ], [ ${checked}, %${convertFrom} ]`);
4519
+ return { name: value, type };
4520
+ }
4521
+ /** Stores `value` into field `field` of `obj` (shape `shapeId`) where a
4522
+ * PARTIAL view may lack it, calling `storeAt` with the address to write.
4523
+ * A field the viewed record does not declare is kept as a boxed property
4524
+ * in the view's extra store, where reflection and a later read see it;
4525
+ * `released` gives up a caller reference the frame does not own. */
4526
+ storePartialField(objName, shapeId, field, type, value, storeAt, released) {
4527
+ const B = this.B;
4528
+ const idx = this.recordShape(shapeId).fields.findIndex((f) => f.name === field);
4529
+ const isView = B.tmp();
4530
+ const notView = B.newLabel("ps.slot");
4531
+ const view = B.newLabel("ps.view");
4532
+ const present = B.newLabel("ps.present");
4533
+ const store = B.newLabel("ps.store");
4534
+ const extra = B.newLabel("ps.extra");
4535
+ const done = B.newLabel("ps.done");
4536
+ for (const line of recordViewTestLines(this.sizeType, objName, isView))
4537
+ B.line(line.trimStart());
4538
+ B.condBr(isView, view, notView);
4539
+ B.startBlock(notView);
4540
+ const own = B.tmp();
4541
+ B.line(`${own} = getelementptr inbounds %${mangleRecordStruct(shapeId)}, ptr ${objName}, i64 0, i32 ${idx + this.nullableUnions.fieldBase(shapeId)}`);
4542
+ const ownFrom = B.currentLabel();
4543
+ B.br(store);
4544
+ B.startBlock(view);
4545
+ const slot = this.partialViewSlot(objName, shapeId, field);
4546
+ const hasSlot = B.tmp();
4547
+ B.line(`${hasSlot} = icmp ne ptr ${slot}, null`);
4548
+ B.condBr(hasSlot, present, extra);
4549
+ B.startBlock(present);
4550
+ const presentFrom = B.currentLabel();
4551
+ B.br(store);
4552
+ // One store site whichever slot answers: the value's frame ownership
4553
+ // ends in one place, whether the write runs on this program's path or
4554
+ // on the other branch of the test.
4555
+ B.startBlock(store);
4556
+ const addr = B.tmp();
4557
+ B.line(`${addr} = phi ptr [ ${own}, %${ownFrom} ], [ ${slot}, %${presentFrom} ]`);
4558
+ storeAt(addr);
4559
+ B.br(done);
4560
+ B.startBlock(extra);
4561
+ const boxed = B.tmp();
4562
+ const box = this.dyn.toDynHelper(type);
4563
+ B.line(`${boxed} = call ptr @${box}(${this.llType(type)} ${value.name})`);
4564
+ this.declare(`declare void @scr_record_view_extra_set(ptr, ptr, ${this.sizeType}, ptr)`);
4565
+ B.line(`call void @scr_record_view_extra_set(ptr ${objName}, ptr ${this.cstr(field)}, ${this.sizeType} ${Buffer.byteLength(field, "utf8")}, ptr ${boxed})`);
4566
+ released?.();
4567
+ B.br(done);
4568
+ B.startBlock(done);
4569
+ }
4243
4570
  /** The overflow map's slot pointer on an index-signature shape. */
4244
4571
  recordOvfPtr(objName, shapeId) {
4245
4572
  const shape = this.recordShape(shapeId);
@@ -5041,7 +5368,7 @@ export class LlEmitter {
5041
5368
  /** An emitter for a range of this module's functions: the same facts,
5042
5369
  * empty module-level tables, and a journal of what the range adds. */
5043
5370
  chunkEmitter() {
5044
- const chunk = new LlEmitter(this.mod, { ...this.targetOptions, functionChunks: 1 }, new EmitJournal());
5371
+ const chunk = new LlEmitter(this.mod, { ...this.targetOptions, functionChunks: 1 }, new EmitJournal(), null, this.nodeIndex);
5045
5372
  chunk.debug?.record();
5046
5373
  return chunk;
5047
5374
  }
@@ -5217,7 +5544,8 @@ export class LlEmitter {
5217
5544
  const exception = B.tmp();
5218
5545
  B.line(`${exception} = landingpad { ptr, i32 } cleanup`);
5219
5546
  for (const index of borrowed)
5220
- this.releaseFrame(`%p${index}`, fn.params[index].type);
5547
+ if (!this.isTreeValue(fn.params[index].type))
5548
+ this.releaseFrame(`%p${index}`, fn.params[index].type);
5221
5549
  this.declare(UNWIND_RESUME_DECLARATION);
5222
5550
  B.resumeUnwind(exception);
5223
5551
  B.startBlock(ok);
@@ -5244,8 +5572,10 @@ export class LlEmitter {
5244
5572
  result = B.tmp();
5245
5573
  B.line(`${result} = load ptr, ptr ${slot}`);
5246
5574
  }
5575
+ // A tree value is passed by reference to its owner and never counted,
5576
+ // so the wrapper has nothing to drop for it.
5247
5577
  for (const index of borrowed)
5248
- if (!kept.has(index))
5578
+ if (!kept.has(index) && !this.isTreeValue(fn.params[index].type))
5249
5579
  this.releaseFrame(`%p${index}`, fn.params[index].type);
5250
5580
  B.terminate(ret === "void" ? "ret void" : `ret ${ret} ${result}`);
5251
5581
  const symbol = kept.size > 0 ? `${mangleBorrowedFunction(fn.name)}.virtual` : mangleFunction(fn.name);
@@ -5486,6 +5816,17 @@ export class LlEmitter {
5486
5816
  /** Emits the move of a noted last read: the slot is cleared, so scope
5487
5817
  * exits release nothing and the read's owned temp carries the reference. */
5488
5818
  takeLastUseMove(e, slot, type) {
5819
+ if (this.isTreeValue(e.type)) {
5820
+ // A tree value has one owner and no count: every read of it that the
5821
+ // plan accepted IS its transfer (backend/tree-classes.ts records the
5822
+ // expression), so the read takes the reference exactly as a last-use
5823
+ // move does. A read the plan did not record would copy the node,
5824
+ // which retainCall refuses.
5825
+ if (this.treeMoves?.delete(e) !== true)
5826
+ return false;
5827
+ this.B.line(`store ptr null, ptr ${slot}`);
5828
+ return true;
5829
+ }
5489
5830
  if (this.lastUseMoves.get(e) !== slot || !typeEquals(type, e.type))
5490
5831
  return false;
5491
5832
  this.lastUseMoves.delete(e);
@@ -6771,6 +7112,11 @@ export class LlEmitter {
6771
7112
  /** Group arenas (arenas.ts): the plan, the list slot of each root and
6772
7113
  * call region, and which locals' scopes drop which roots' arenas. */
6773
7114
  arenas = null;
7115
+ /** The varRef reads the tree-class plan proved move a node out of its
7116
+ * local (backend/tree-classes.ts). Each one emits its own last-use move:
7117
+ * the source slot is nulled and the value taken without a retain, since
7118
+ * a tree instance has no count to raise. */
7119
+ treeMoves = null;
6774
7120
  arenaSlots = new Map();
6775
7121
  /** The frames emitStmtBody opens for whole statements (arenas only). */
6776
7122
  statementFrames = new Set();
@@ -6919,6 +7265,29 @@ export class LlEmitter {
6919
7265
  this.journal?.site(name, "jsIcSite");
6920
7266
  return name;
6921
7267
  }
7268
+ /** A fresh guard-group record (js-groups.ts). */
7269
+ jsGroup() {
7270
+ const name = `@sc_js_group_${this.jsGroupCount++}`;
7271
+ this.journal?.site(name, "jsGroup");
7272
+ return name;
7273
+ }
7274
+ /** The constant key array `keys` (string literal symbols) that a group's
7275
+ * probe reads, shared by every group with the same keys. */
7276
+ jsGroupKeys(keys) {
7277
+ const text = keys.join("\u0000");
7278
+ let name = this.jsGroupKeysByText.get(text);
7279
+ if (name !== undefined)
7280
+ return name;
7281
+ name = `@sc_gkeys_${this.jsGroupKeysCount++}`;
7282
+ this.jsGroupKeysByText.set(text, name);
7283
+ this.jsGroupKeysByName.set(name, keys);
7284
+ this.journal?.site(name, "jsGroupKeys", [keys]);
7285
+ return name;
7286
+ }
7287
+ /** The key array of each of this module's guard groups, by name. */
7288
+ get jsGroupKeysTable() {
7289
+ return this.jsGroupKeysByName;
7290
+ }
6922
7291
  /** A fresh read-site cache for one constant-key dyn read. */
6923
7292
  dynReadIcSite() {
6924
7293
  const name = `@sc_dyn_read_ic_${this.dynReadIcSites++}`;
@@ -7144,8 +7513,8 @@ export class LlEmitter {
7144
7513
  emitRecordKeyGet(e) {
7145
7514
  return emitRecordKeyGet(this, e);
7146
7515
  }
7147
- keyedRecordReadInto(slot, join, objName, keyName, shapeId, resultType, overflowOnly, loc, missNaN = false) {
7148
- return keyedRecordReadInto(this, slot, join, objName, keyName, shapeId, resultType, overflowOnly, loc, missNaN);
7516
+ keyedRecordReadInto(slot, join, objName, keyName, shapeId, resultType, overflowOnly, loc, missNaN = false, missInto = null, read = null) {
7517
+ return keyedRecordReadInto(this, slot, join, objName, keyName, shapeId, resultType, overflowOnly, loc, missNaN, missInto, read);
7149
7518
  }
7150
7519
  dynPromiseAdapter(inner) {
7151
7520
  return dynPromiseAdapter(this, inner);
@@ -7262,6 +7631,8 @@ function addNumberedSymbol(into, key, entry, prefix, names) {
7262
7631
  names.set(entry.sym, own.sym);
7263
7632
  }
7264
7633
  registerReplay("jsIcSite", (emitter) => emitter.jsIcSite());
7634
+ registerReplay("jsGroup", (emitter) => emitter.jsGroup());
7635
+ registerReplay("jsGroupKeys", (emitter, args) => emitter.jsGroupKeys(args[0]));
7265
7636
  registerReplay("dynReadIcSite", (emitter) => emitter.dynReadIcSite());
7266
7637
  registerReplay("speculativeLoopSite", (emitter) => emitter.speculativeLoopSite());
7267
7638
  for (const op of [