@scriptc/compiler 0.4.2 → 0.4.4

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 (726) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +470 -66
  2. package/dist/backend/cycle-analysis.d.ts +4 -1
  3. package/dist/backend/cycle-analysis.js +6 -4
  4. package/dist/backend/cycle-analysis.js.map +1 -1
  5. package/dist/backend/cycle-analysis.test.js +55 -0
  6. package/dist/backend/cycle-analysis.test.js.map +1 -1
  7. package/dist/backend/cycle-mutability.d.ts +7 -0
  8. package/dist/backend/cycle-mutability.js +19 -1
  9. package/dist/backend/cycle-mutability.js.map +1 -1
  10. package/dist/backend/executable-features.js +2 -0
  11. package/dist/backend/executable-features.js.map +1 -1
  12. package/dist/backend/immutability.d.ts +6 -3
  13. package/dist/backend/immutability.js +33 -29
  14. package/dist/backend/immutability.js.map +1 -1
  15. package/dist/backend/library-pack.js +1 -0
  16. package/dist/backend/library-pack.js.map +1 -1
  17. package/dist/backend/llvm/alloc.d.ts +16 -1
  18. package/dist/backend/llvm/alloc.js +54 -4
  19. package/dist/backend/llvm/alloc.js.map +1 -1
  20. package/dist/backend/llvm/appended-array-literals.d.ts +2 -1
  21. package/dist/backend/llvm/appended-array-literals.js +44 -36
  22. package/dist/backend/llvm/appended-array-literals.js.map +1 -1
  23. package/dist/backend/llvm/appended-array-literals.test.js +4 -3
  24. package/dist/backend/llvm/appended-array-literals.test.js.map +1 -1
  25. package/dist/backend/llvm/array-search.d.ts +4 -3
  26. package/dist/backend/llvm/array-search.js +21 -9
  27. package/dist/backend/llvm/array-search.js.map +1 -1
  28. package/dist/backend/llvm/blocks.d.ts +1 -1
  29. package/dist/backend/llvm/blocks.js +2 -2
  30. package/dist/backend/llvm/blocks.js.map +1 -1
  31. package/dist/backend/llvm/byte-windows.js +2 -0
  32. package/dist/backend/llvm/byte-windows.js.map +1 -1
  33. package/dist/backend/llvm/bytes-alias.d.ts +6 -1
  34. package/dist/backend/llvm/bytes-alias.js +8 -2
  35. package/dist/backend/llvm/bytes-alias.js.map +1 -1
  36. package/dist/backend/llvm/bytes-loop-versions.d.ts +47 -5
  37. package/dist/backend/llvm/bytes-loop-versions.js +479 -32
  38. package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
  39. package/dist/backend/llvm/bytes-loop-versions.test.js +263 -2
  40. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  41. package/dist/backend/llvm/checked-value-lifetimes.js +2 -0
  42. package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
  43. package/dist/backend/llvm/classes.d.ts +7 -5
  44. package/dist/backend/llvm/classes.js +44 -20
  45. package/dist/backend/llvm/classes.js.map +1 -1
  46. package/dist/backend/llvm/classes.test.js +167 -7
  47. package/dist/backend/llvm/classes.test.js.map +1 -1
  48. package/dist/backend/llvm/common.d.ts +9 -3
  49. package/dist/backend/llvm/common.js +9 -3
  50. package/dist/backend/llvm/common.js.map +1 -1
  51. package/dist/backend/llvm/constant-callbacks.d.ts +2 -1
  52. package/dist/backend/llvm/constant-callbacks.js +83 -52
  53. package/dist/backend/llvm/constant-callbacks.js.map +1 -1
  54. package/dist/backend/llvm/counted-loops.d.ts +7 -0
  55. package/dist/backend/llvm/counted-loops.js +18 -0
  56. package/dist/backend/llvm/counted-loops.js.map +1 -1
  57. package/dist/backend/llvm/debug-info.js +2 -5
  58. package/dist/backend/llvm/debug-info.js.map +1 -1
  59. package/dist/backend/llvm/dense-array-access.d.ts +39 -8
  60. package/dist/backend/llvm/dense-array-access.js +222 -52
  61. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  62. package/dist/backend/llvm/dense-array-access.test.js +36 -0
  63. package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
  64. package/dist/backend/llvm/dense-array-loops.d.ts +17 -1
  65. package/dist/backend/llvm/dense-array-loops.js +194 -5
  66. package/dist/backend/llvm/dense-array-loops.js.map +1 -1
  67. package/dist/backend/llvm/dense-array-loops.test.js +90 -1
  68. package/dist/backend/llvm/dense-array-loops.test.js.map +1 -1
  69. package/dist/backend/llvm/dyn-handle-tags.test.js +6 -1
  70. package/dist/backend/llvm/dyn-handle-tags.test.js.map +1 -1
  71. package/dist/backend/llvm/dyn.d.ts +30 -0
  72. package/dist/backend/llvm/dyn.js +373 -70
  73. package/dist/backend/llvm/dyn.js.map +1 -1
  74. package/dist/backend/llvm/emit-function.js +13 -28
  75. package/dist/backend/llvm/emit-function.js.map +1 -1
  76. package/dist/backend/llvm/emit-journal.d.ts +93 -0
  77. package/dist/backend/llvm/emit-journal.js +170 -0
  78. package/dist/backend/llvm/emit-journal.js.map +1 -0
  79. package/dist/backend/llvm/emit-module.js +211 -33
  80. package/dist/backend/llvm/emit-module.js.map +1 -1
  81. package/dist/backend/llvm/emit-statements.d.ts +0 -4
  82. package/dist/backend/llvm/emit-statements.js +268 -84
  83. package/dist/backend/llvm/emit-statements.js.map +1 -1
  84. package/dist/backend/llvm/emitter-state.d.ts +7 -0
  85. package/dist/backend/llvm/emitter-state.js +14 -0
  86. package/dist/backend/llvm/emitter-state.js.map +1 -0
  87. package/dist/backend/llvm/emitter.d.ts +186 -37
  88. package/dist/backend/llvm/emitter.js +733 -90
  89. package/dist/backend/llvm/emitter.js.map +1 -1
  90. package/dist/backend/llvm/emitter.test.js +65 -7
  91. package/dist/backend/llvm/emitter.test.js.map +1 -1
  92. package/dist/backend/llvm/expr-async.js +11 -13
  93. package/dist/backend/llvm/expr-async.js.map +1 -1
  94. package/dist/backend/llvm/expr-bytes.js +48 -20
  95. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  96. package/dist/backend/llvm/expr-callbacks.js +47 -0
  97. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  98. package/dist/backend/llvm/expr-calls.js +28 -14
  99. package/dist/backend/llvm/expr-calls.js.map +1 -1
  100. package/dist/backend/llvm/expr-containers.d.ts +14 -2
  101. package/dist/backend/llvm/expr-containers.js +143 -37
  102. package/dist/backend/llvm/expr-containers.js.map +1 -1
  103. package/dist/backend/llvm/expr-context.d.ts +14 -0
  104. package/dist/backend/llvm/expr-dynamic.js +18 -11
  105. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  106. package/dist/backend/llvm/expr-primitives.js +119 -38
  107. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  108. package/dist/backend/llvm/expr-primitives.test.js +11 -6
  109. package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
  110. package/dist/backend/llvm/expr-records.d.ts +12 -0
  111. package/dist/backend/llvm/expr-records.js +106 -0
  112. package/dist/backend/llvm/expr-records.js.map +1 -1
  113. package/dist/backend/llvm/expr-stream-bridges.d.ts +2 -2
  114. package/dist/backend/llvm/expr-stream-bridges.js +210 -69
  115. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  116. package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
  117. package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
  118. package/dist/backend/llvm/expr-stream-callbacks.d.ts +2 -2
  119. package/dist/backend/llvm/expr-stream-callbacks.js +74 -20
  120. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  121. package/dist/backend/llvm/int32-kind-loops.d.ts +39 -0
  122. package/dist/backend/llvm/int32-kind-loops.js +106 -0
  123. package/dist/backend/llvm/int32-kind-loops.js.map +1 -0
  124. package/dist/backend/llvm/integer-or-nan-indexes.test.d.ts +1 -0
  125. package/dist/backend/llvm/integer-or-nan-indexes.test.js +118 -0
  126. package/dist/backend/llvm/integer-or-nan-indexes.test.js.map +1 -0
  127. package/dist/backend/llvm/integer-values.d.ts +25 -1
  128. package/dist/backend/llvm/integer-values.js +95 -0
  129. package/dist/backend/llvm/integer-values.js.map +1 -1
  130. package/dist/backend/llvm/js-ic.d.ts +1 -1
  131. package/dist/backend/llvm/js-ic.js +1 -1
  132. package/dist/backend/llvm/js-ic.js.map +1 -1
  133. package/dist/backend/llvm/key-orders.d.ts +7 -0
  134. package/dist/backend/llvm/key-orders.js +33 -0
  135. package/dist/backend/llvm/key-orders.js.map +1 -0
  136. package/dist/backend/llvm/lib-connect.js +4 -0
  137. package/dist/backend/llvm/lib-connect.js.map +1 -1
  138. package/dist/backend/llvm/lib-datagram.js +11 -0
  139. package/dist/backend/llvm/lib-datagram.js.map +1 -1
  140. package/dist/backend/llvm/lib-dispatch.js +213 -5
  141. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  142. package/dist/backend/llvm/lib-filesystem.js +4 -4
  143. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  144. package/dist/backend/llvm/lib-http2.js +4 -0
  145. package/dist/backend/llvm/lib-http2.js.map +1 -1
  146. package/dist/backend/llvm/lib-lookup.js +16 -6
  147. package/dist/backend/llvm/lib-lookup.js.map +1 -1
  148. package/dist/backend/llvm/lib-process.js +37 -1
  149. package/dist/backend/llvm/lib-process.js.map +1 -1
  150. package/dist/backend/llvm/lib-shared.js +94 -2
  151. package/dist/backend/llvm/lib-shared.js.map +1 -1
  152. package/dist/backend/llvm/lib-stream.js +35 -5
  153. package/dist/backend/llvm/lib-stream.js.map +1 -1
  154. package/dist/backend/llvm/local-array-reads.js +115 -19
  155. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  156. package/dist/backend/llvm/local-array-reads.test.js +14 -0
  157. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  158. package/dist/backend/llvm/loop-state.d.ts +33 -0
  159. package/dist/backend/llvm/loop-state.js +42 -0
  160. package/dist/backend/llvm/loop-state.js.map +1 -0
  161. package/dist/backend/llvm/map-number-lookup.d.ts +26 -8
  162. package/dist/backend/llvm/map-number-lookup.js +91 -31
  163. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  164. package/dist/backend/llvm/map-number-lookup.test.js +55 -0
  165. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  166. package/dist/backend/llvm/map-read-lifetimes.js +4 -2
  167. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  168. package/dist/backend/llvm/nullable-unions.d.ts +2 -1
  169. package/dist/backend/llvm/nullable-unions.js +15 -3
  170. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  171. package/dist/backend/llvm/publish.d.ts +10 -0
  172. package/dist/backend/llvm/publish.js +15 -3
  173. package/dist/backend/llvm/publish.js.map +1 -1
  174. package/dist/backend/llvm/receivers.js +6 -1
  175. package/dist/backend/llvm/receivers.js.map +1 -1
  176. package/dist/backend/llvm/record-results.d.ts +1 -9
  177. package/dist/backend/llvm/record-results.js +2 -11
  178. package/dist/backend/llvm/record-results.js.map +1 -1
  179. package/dist/backend/llvm/reference-effects.js +3 -0
  180. package/dist/backend/llvm/reference-effects.js.map +1 -1
  181. package/dist/backend/llvm/reference-writes.d.ts +7 -2
  182. package/dist/backend/llvm/reference-writes.js +89 -72
  183. package/dist/backend/llvm/reference-writes.js.map +1 -1
  184. package/dist/backend/llvm/running-extrema.d.ts +11 -0
  185. package/dist/backend/llvm/running-extrema.js +115 -0
  186. package/dist/backend/llvm/running-extrema.js.map +1 -0
  187. package/dist/backend/llvm/running-extrema.test.d.ts +1 -0
  188. package/dist/backend/llvm/running-extrema.test.js +89 -0
  189. package/dist/backend/llvm/running-extrema.test.js.map +1 -0
  190. package/dist/backend/llvm/shapes.d.ts +71 -15
  191. package/dist/backend/llvm/shapes.js +224 -40
  192. package/dist/backend/llvm/shapes.js.map +1 -1
  193. package/dist/backend/llvm/shapes.test.js +53 -7
  194. package/dist/backend/llvm/shapes.test.js.map +1 -1
  195. package/dist/backend/llvm/speculative-integers.d.ts +6 -0
  196. package/dist/backend/llvm/speculative-integers.js +2 -2
  197. package/dist/backend/llvm/speculative-integers.js.map +1 -1
  198. package/dist/backend/llvm/stack-captures.js +1 -5
  199. package/dist/backend/llvm/stack-captures.js.map +1 -1
  200. package/dist/backend/llvm/stack-objects.d.ts +3 -2
  201. package/dist/backend/llvm/stack-objects.js +5 -2
  202. package/dist/backend/llvm/stack-objects.js.map +1 -1
  203. package/dist/backend/llvm/string-reads.d.ts +12 -0
  204. package/dist/backend/llvm/string-reads.js +44 -0
  205. package/dist/backend/llvm/string-reads.js.map +1 -1
  206. package/dist/backend/llvm/union-repr.d.ts +4 -3
  207. package/dist/backend/llvm/union-repr.js +6 -5
  208. package/dist/backend/llvm/union-repr.js.map +1 -1
  209. package/dist/backend/llvm/walk-borrows.d.ts +3 -0
  210. package/dist/backend/llvm/walk-borrows.js +46 -41
  211. package/dist/backend/llvm/walk-borrows.js.map +1 -1
  212. package/dist/backend/llvm/walkers.d.ts +3 -0
  213. package/dist/backend/llvm/walkers.js +101 -65
  214. package/dist/backend/llvm/walkers.js.map +1 -1
  215. package/dist/backend/llvm/wrapping-sums.d.ts +16 -1
  216. package/dist/backend/llvm/wrapping-sums.js +126 -0
  217. package/dist/backend/llvm/wrapping-sums.js.map +1 -1
  218. package/dist/backend/may-throw.d.ts +8 -10
  219. package/dist/backend/may-throw.js +14 -10
  220. package/dist/backend/may-throw.js.map +1 -1
  221. package/dist/backend/native/contracts.d.ts +5 -0
  222. package/dist/backend/native/executable.js +7 -0
  223. package/dist/backend/native/executable.js.map +1 -1
  224. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  225. package/dist/backend/native/runtime-inputs.js +1 -0
  226. package/dist/backend/native/runtime-inputs.js.map +1 -1
  227. package/dist/backend/native-codegen-core.d.ts +5 -3
  228. package/dist/backend/native-codegen-core.js +13 -6
  229. package/dist/backend/native-codegen-core.js.map +1 -1
  230. package/dist/backend/native-codegen.test.js +6 -4
  231. package/dist/backend/native-codegen.test.js.map +1 -1
  232. package/dist/backend/native-link-info-core.d.ts +4 -0
  233. package/dist/backend/native-link-info-core.js.map +1 -1
  234. package/dist/backend/publication.d.ts +12 -1
  235. package/dist/backend/publication.js +37 -14
  236. package/dist/backend/publication.js.map +1 -1
  237. package/dist/backend/publication.test.js +30 -0
  238. package/dist/backend/publication.test.js.map +1 -1
  239. package/dist/backend/result-slots.d.ts +16 -0
  240. package/dist/backend/result-slots.js +23 -0
  241. package/dist/backend/result-slots.js.map +1 -0
  242. package/dist/backend/runtime-abi.d.ts +2 -2
  243. package/dist/backend/runtime-abi.js +2 -2
  244. package/dist/backend/runtime-pack-core.d.ts +1 -0
  245. package/dist/backend/runtime-pack-core.js +1 -0
  246. package/dist/backend/runtime-pack-core.js.map +1 -1
  247. package/dist/backend/runtime-pack-targets.test.js +2 -1
  248. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  249. package/dist/backend/runtime-pack.test.js +2 -1
  250. package/dist/backend/runtime-pack.test.js.map +1 -1
  251. package/dist/backend/stack-observations.d.ts +2 -1
  252. package/dist/backend/stack-observations.js +67 -42
  253. package/dist/backend/stack-observations.js.map +1 -1
  254. package/dist/backend/target-cpu.d.ts +26 -0
  255. package/dist/backend/target-cpu.js +98 -0
  256. package/dist/backend/target-cpu.js.map +1 -0
  257. package/dist/backend/target-cpu.test.d.ts +1 -0
  258. package/dist/backend/target-cpu.test.js +38 -0
  259. package/dist/backend/target-cpu.test.js.map +1 -0
  260. package/dist/backend/target-diagnostics.js +5 -3
  261. package/dist/backend/target-diagnostics.js.map +1 -1
  262. package/dist/backend/warm-cache.js +1 -0
  263. package/dist/backend/warm-cache.js.map +1 -1
  264. package/dist/cli/command.js +20 -1
  265. package/dist/cli/command.js.map +1 -1
  266. package/dist/cli/usage.d.ts +4 -1
  267. package/dist/cli/usage.js +10 -3
  268. package/dist/cli/usage.js.map +1 -1
  269. package/dist/compat/fetch-profile.js +1 -1
  270. package/dist/compat/fetch-profile.js.map +1 -1
  271. package/dist/compile-types.d.ts +7 -0
  272. package/dist/contracts/check.js +4 -3
  273. package/dist/contracts/check.js.map +1 -1
  274. package/dist/contracts/int32-elements.js +10 -2
  275. package/dist/contracts/int32-elements.js.map +1 -1
  276. package/dist/coverage/report.js +12 -3
  277. package/dist/coverage/report.js.map +1 -1
  278. package/dist/diagnostics/diagnostic.d.ts +4 -0
  279. package/dist/diagnostics/diagnostic.js +1 -1
  280. package/dist/diagnostics/diagnostic.js.map +1 -1
  281. package/dist/diagnostics/envelope.d.ts +3 -0
  282. package/dist/diagnostics/envelope.js +1 -0
  283. package/dist/diagnostics/envelope.js.map +1 -1
  284. package/dist/executable/executable-cache.d.ts +5 -0
  285. package/dist/executable/executable-cache.js +5 -0
  286. package/dist/executable/executable-cache.js.map +1 -1
  287. package/dist/executable/executable-cache.test.js +3 -0
  288. package/dist/executable/executable-cache.test.js.map +1 -1
  289. package/dist/frontend/decl-projection.d.ts +41 -0
  290. package/dist/frontend/decl-projection.js +949 -0
  291. package/dist/frontend/decl-projection.js.map +1 -0
  292. package/dist/frontend/decl-projection.test.d.ts +1 -0
  293. package/dist/frontend/decl-projection.test.js +30 -0
  294. package/dist/frontend/decl-projection.test.js.map +1 -0
  295. package/dist/frontend/dts-paths.d.ts +15 -0
  296. package/dist/frontend/dts-paths.js +25 -0
  297. package/dist/frontend/dts-paths.js.map +1 -1
  298. package/dist/frontend/input-tracker.d.ts +6 -0
  299. package/dist/frontend/input-tracker.js +51 -28
  300. package/dist/frontend/input-tracker.js.map +1 -1
  301. package/dist/frontend/input-tracker.test.js +19 -0
  302. package/dist/frontend/input-tracker.test.js.map +1 -1
  303. package/dist/frontend/lowering/array-values.js +100 -2
  304. package/dist/frontend/lowering/array-values.js.map +1 -1
  305. package/dist/frontend/lowering/builtins/async-context.d.ts +8 -2
  306. package/dist/frontend/lowering/builtins/async-context.js +62 -3
  307. package/dist/frontend/lowering/builtins/async-context.js.map +1 -1
  308. package/dist/frontend/lowering/builtins/child-process-methods.js +46 -15
  309. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  310. package/dist/frontend/lowering/builtins/child-process.js +13 -2
  311. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  312. package/dist/frontend/lowering/builtins/crypto.js +87 -10
  313. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  314. package/dist/frontend/lowering/builtins/dates.js +4 -1
  315. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  316. package/dist/frontend/lowering/builtins/filesystem-calls.js +3 -3
  317. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  318. package/dist/frontend/lowering/builtins/fs-glob.js +6 -3
  319. package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -1
  320. package/dist/frontend/lowering/builtins/fs-paths.d.ts +43 -5
  321. package/dist/frontend/lowering/builtins/fs-paths.js +245 -93
  322. package/dist/frontend/lowering/builtins/fs-paths.js.map +1 -1
  323. package/dist/frontend/lowering/builtins/global-namespace-keys.d.ts +3 -0
  324. package/dist/frontend/lowering/builtins/global-namespace-keys.js +122 -0
  325. package/dist/frontend/lowering/builtins/global-namespace-keys.js.map +1 -0
  326. package/dist/frontend/lowering/builtins/module-calls.js +6 -3
  327. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  328. package/dist/frontend/lowering/builtins/numbers.js +9 -1
  329. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  330. package/dist/frontend/lowering/builtins/promises.d.ts +7 -1
  331. package/dist/frontend/lowering/builtins/promises.js +236 -139
  332. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  333. package/dist/frontend/lowering/builtins/readline.d.ts +5 -1
  334. package/dist/frontend/lowering/builtins/readline.js +35 -3
  335. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  336. package/dist/frontend/lowering/builtins/url.js +24 -1
  337. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  338. package/dist/frontend/lowering/builtins/webassembly.js +6 -3
  339. package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
  340. package/dist/frontend/lowering/call-signatures.js +0 -1
  341. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  342. package/dist/frontend/lowering/cjs-exports-object.js +1 -1
  343. package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
  344. package/dist/frontend/lowering/cjs-inline-require.d.ts +32 -0
  345. package/dist/frontend/lowering/cjs-inline-require.js +307 -4
  346. package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
  347. package/dist/frontend/lowering/class-callbacks.d.ts +5 -2
  348. package/dist/frontend/lowering/class-callbacks.js +82 -12
  349. package/dist/frontend/lowering/class-callbacks.js.map +1 -1
  350. package/dist/frontend/lowering/class-construction.d.ts +4 -1
  351. package/dist/frontend/lowering/class-construction.js +17 -3
  352. package/dist/frontend/lowering/class-construction.js.map +1 -1
  353. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +49 -2
  354. package/dist/frontend/lowering/class-dynamic-dispatch.js +880 -108
  355. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  356. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +47 -0
  357. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  358. package/dist/frontend/lowering/class-iterables.d.ts +2 -1
  359. package/dist/frontend/lowering/class-iterables.js +9 -1
  360. package/dist/frontend/lowering/class-iterables.js.map +1 -1
  361. package/dist/frontend/lowering/class-method-mutations.js +83 -24
  362. package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
  363. package/dist/frontend/lowering/class-protocols.d.ts +25 -0
  364. package/dist/frontend/lowering/class-protocols.js +183 -1
  365. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  366. package/dist/frontend/lowering/class-prototypes.js +31 -2
  367. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  368. package/dist/frontend/lowering/class-runtime-statics.d.ts +9 -3
  369. package/dist/frontend/lowering/class-runtime-statics.js +29 -4
  370. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  371. package/dist/frontend/lowering/coercions/structural-plans.js +48 -1
  372. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  373. package/dist/frontend/lowering/coercions/structural.js +91 -1
  374. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  375. package/dist/frontend/lowering/completion-callbacks.d.ts +4 -0
  376. package/dist/frontend/lowering/completion-callbacks.js +146 -0
  377. package/dist/frontend/lowering/completion-callbacks.js.map +1 -0
  378. package/dist/frontend/lowering/containers/array-callback-call.js +2 -2
  379. package/dist/frontend/lowering/containers/array-callback-call.js.map +1 -1
  380. package/dist/frontend/lowering/containers/array-callbacks.d.ts +5 -4
  381. package/dist/frontend/lowering/containers/array-callbacks.js +345 -24
  382. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  383. package/dist/frontend/lowering/containers/array-concat.js +10 -0
  384. package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
  385. package/dist/frontend/lowering/containers/array-construction.js +5 -0
  386. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  387. package/dist/frontend/lowering/containers/array-methods.js +26 -3
  388. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  389. package/dist/frontend/lowering/containers/array-pipelines.js +19 -8
  390. package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
  391. package/dist/frontend/lowering/containers/bytes.d.ts +25 -17
  392. package/dist/frontend/lowering/containers/bytes.js +455 -46
  393. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  394. package/dist/frontend/lowering/containers/callback-arguments.js +3 -0
  395. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  396. package/dist/frontend/lowering/containers/collection-methods.js +7 -2
  397. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  398. package/dist/frontend/lowering/containers/filter-predicates.d.ts +6 -0
  399. package/dist/frontend/lowering/containers/filter-predicates.js +205 -0
  400. package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -0
  401. package/dist/frontend/lowering/containers/indexed-objects.d.ts +0 -12
  402. package/dist/frontend/lowering/containers/indexed-objects.js +46 -7
  403. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  404. package/dist/frontend/lowering/containers/string-and-regexp.js +55 -9
  405. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  406. package/dist/frontend/lowering/containers/string-replacement.js +43 -19
  407. package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
  408. package/dist/frontend/lowering/date-values.d.ts +11 -0
  409. package/dist/frontend/lowering/date-values.js +207 -0
  410. package/dist/frontend/lowering/date-values.js.map +1 -0
  411. package/dist/frontend/lowering/dispatch-sites.js +15 -1
  412. package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
  413. package/dist/frontend/lowering/divergences.js +9 -1
  414. package/dist/frontend/lowering/divergences.js.map +1 -1
  415. package/dist/frontend/lowering/error-methods.js +47 -2
  416. package/dist/frontend/lowering/error-methods.js.map +1 -1
  417. package/dist/frontend/lowering/expressions/array-literals.js +53 -0
  418. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  419. package/dist/frontend/lowering/expressions/binary.js +100 -28
  420. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  421. package/dist/frontend/lowering/expressions/element-access.js +169 -13
  422. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  423. package/dist/frontend/lowering/expressions/identifiers.js +64 -5
  424. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  425. package/dist/frontend/lowering/expressions/narrowing.js +95 -1
  426. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  427. package/dist/frontend/lowering/expressions/nullish-assignment.js +3 -1
  428. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
  429. package/dist/frontend/lowering/expressions/object-literals.d.ts +10 -0
  430. package/dist/frontend/lowering/expressions/object-literals.js +138 -51
  431. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  432. package/dist/frontend/lowering/expressions/optional-chains.js +12 -0
  433. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  434. package/dist/frontend/lowering/expressions/property-access.js +168 -10
  435. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  436. package/dist/frontend/lowering/expressions/relational.js +212 -33
  437. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  438. package/dist/frontend/lowering/expressions/typeof.js +6 -0
  439. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  440. package/dist/frontend/lowering/expressions/union-fields.js +4 -0
  441. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  442. package/dist/frontend/lowering/expressions/updates.js +39 -3
  443. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  444. package/dist/frontend/lowering/frozen-records.d.ts +28 -0
  445. package/dist/frontend/lowering/frozen-records.js +322 -0
  446. package/dist/frontend/lowering/frozen-records.js.map +1 -0
  447. package/dist/frontend/lowering/function-returns.js +64 -0
  448. package/dist/frontend/lowering/function-returns.js.map +1 -1
  449. package/dist/frontend/lowering/generic-functions.js +7 -2
  450. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  451. package/dist/frontend/lowering/indexed-unions.d.ts +54 -0
  452. package/dist/frontend/lowering/indexed-unions.js +401 -0
  453. package/dist/frontend/lowering/indexed-unions.js.map +1 -0
  454. package/dist/frontend/lowering/iterable-values.d.ts +49 -0
  455. package/dist/frontend/lowering/iterable-values.js +297 -0
  456. package/dist/frontend/lowering/iterable-values.js.map +1 -0
  457. package/dist/frontend/lowering/iterator-adapters.js +186 -1
  458. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  459. package/dist/frontend/lowering/js-class-fields.d.ts +8 -0
  460. package/dist/frontend/lowering/js-class-fields.js +45 -10
  461. package/dist/frontend/lowering/js-class-fields.js.map +1 -1
  462. package/dist/frontend/lowering/key-order-witness.d.ts +18 -3
  463. package/dist/frontend/lowering/key-order-witness.js +974 -48
  464. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  465. package/dist/frontend/lowering/key-order-witness.test.js +530 -10
  466. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  467. package/dist/frontend/lowering/lower-assert.js +15 -3
  468. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  469. package/dist/frontend/lowering/lower-async-iteration.js +4 -1
  470. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  471. package/dist/frontend/lowering/lower-calls.d.ts +7 -0
  472. package/dist/frontend/lowering/lower-calls.js +462 -44
  473. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  474. package/dist/frontend/lowering/lower-classes.d.ts +11 -2
  475. package/dist/frontend/lowering/lower-classes.js +324 -69
  476. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  477. package/dist/frontend/lowering/lower-dgram.js +3 -1
  478. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  479. package/dist/frontend/lowering/lower-exprs.js +215 -3
  480. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  481. package/dist/frontend/lowering/lower-functions.d.ts +11 -0
  482. package/dist/frontend/lowering/lower-functions.js +83 -0
  483. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  484. package/dist/frontend/lowering/lower-generators.js +42 -32
  485. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  486. package/dist/frontend/lowering/lower-global-value.js +6 -3
  487. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  488. package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
  489. package/dist/frontend/lowering/lower-inspect.js +53 -17
  490. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  491. package/dist/frontend/lowering/lower-modules.js +53 -5
  492. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  493. package/dist/frontend/lowering/lower-namespaces.js +5 -1
  494. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  495. package/dist/frontend/lowering/lower-server.js +2 -2
  496. package/dist/frontend/lowering/lower-server.js.map +1 -1
  497. package/dist/frontend/lowering/lower-stdlib.d.ts +5 -0
  498. package/dist/frontend/lowering/lower-stdlib.js +30 -0
  499. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  500. package/dist/frontend/lowering/lower-stmts.d.ts +23 -0
  501. package/dist/frontend/lowering/lower-stmts.js +553 -81
  502. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  503. package/dist/frontend/lowering/lower-stream.d.ts +20 -2
  504. package/dist/frontend/lowering/lower-stream.js +1483 -156
  505. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  506. package/dist/frontend/lowering/lowerer.d.ts +107 -8
  507. package/dist/frontend/lowering/lowerer.js +381 -36
  508. package/dist/frontend/lowering/lowerer.js.map +1 -1
  509. package/dist/frontend/lowering/module-namespace-elements.d.ts +11 -1
  510. package/dist/frontend/lowering/module-namespace-elements.js +82 -5
  511. package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
  512. package/dist/frontend/lowering/new-target.d.ts +12 -0
  513. package/dist/frontend/lowering/new-target.js +280 -0
  514. package/dist/frontend/lowering/new-target.js.map +1 -0
  515. package/dist/frontend/lowering/object-factory-new.d.ts +5 -0
  516. package/dist/frontend/lowering/object-factory-new.js +20 -6
  517. package/dist/frontend/lowering/object-factory-new.js.map +1 -1
  518. package/dist/frontend/lowering/overload-choice.d.ts +33 -0
  519. package/dist/frontend/lowering/overload-choice.js +190 -0
  520. package/dist/frontend/lowering/overload-choice.js.map +1 -0
  521. package/dist/frontend/lowering/surfaces.d.ts +3 -0
  522. package/dist/frontend/lowering/surfaces.js +73 -8
  523. package/dist/frontend/lowering/surfaces.js.map +1 -1
  524. package/dist/frontend/lowering/undefined-index.d.ts +27 -0
  525. package/dist/frontend/lowering/undefined-index.js +82 -0
  526. package/dist/frontend/lowering/undefined-index.js.map +1 -0
  527. package/dist/frontend/lowering/var-hoisting.js +29 -13
  528. package/dist/frontend/lowering/var-hoisting.js.map +1 -1
  529. package/dist/frontend/lowering/width-lift.d.ts +18 -0
  530. package/dist/frontend/npm-static-bundled-chunks.js +9 -11
  531. package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
  532. package/dist/frontend/npm-static-bundled-chunks.test.js +6 -5
  533. package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
  534. package/dist/frontend/npm-static-rewrite-syntax.js +9 -1
  535. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
  536. package/dist/frontend/npm-static.js +4 -20
  537. package/dist/frontend/npm-static.js.map +1 -1
  538. package/dist/frontend/package-shims.d.ts +3 -0
  539. package/dist/frontend/package-shims.js +71 -8
  540. package/dist/frontend/package-shims.js.map +1 -1
  541. package/dist/frontend/pipeline.js +19 -11
  542. package/dist/frontend/pipeline.js.map +1 -1
  543. package/dist/frontend/process-fork.d.ts +25 -0
  544. package/dist/frontend/process-fork.js +2 -0
  545. package/dist/frontend/process-fork.js.map +1 -0
  546. package/dist/frontend/program-analysis.d.ts +5 -1
  547. package/dist/frontend/program-analysis.js +5 -0
  548. package/dist/frontend/program-analysis.js.map +1 -1
  549. package/dist/frontend/program.d.ts +21 -6
  550. package/dist/frontend/program.js +681 -83
  551. package/dist/frontend/program.js.map +1 -1
  552. package/dist/frontend/program.test.js +43 -3
  553. package/dist/frontend/program.test.js.map +1 -1
  554. package/dist/frontend/token-equivalence.d.ts +3 -0
  555. package/dist/frontend/token-equivalence.js +409 -0
  556. package/dist/frontend/token-equivalence.js.map +1 -0
  557. package/dist/frontend/token-equivalence.test.d.ts +1 -0
  558. package/dist/frontend/token-equivalence.test.js +67 -0
  559. package/dist/frontend/token-equivalence.test.js.map +1 -0
  560. package/dist/frontend/ts7/ast-node.d.ts +22 -0
  561. package/dist/frontend/ts7/ast-node.js +1048 -103
  562. package/dist/frontend/ts7/ast-node.js.map +1 -1
  563. package/dist/frontend/ts7/ast-node.test.js +24 -0
  564. package/dist/frontend/ts7/ast-node.test.js.map +1 -1
  565. package/dist/frontend/ts7/ast-wire.d.ts +4 -3
  566. package/dist/frontend/ts7/ast-wire.js +34 -24
  567. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  568. package/dist/frontend/ts7/ast-wire.test.js +23 -0
  569. package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
  570. package/dist/frontend/ts7/checker-backend.d.ts +3 -4
  571. package/dist/frontend/ts7/checker-backend.js +2 -2
  572. package/dist/frontend/ts7/checker-backend.js.map +1 -1
  573. package/dist/frontend/ts7/checker-backend.test.js +5 -9
  574. package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
  575. package/dist/frontend/ts7/checker.d.ts +4 -0
  576. package/dist/frontend/ts7/checker.js +7 -0
  577. package/dist/frontend/ts7/checker.js.map +1 -1
  578. package/dist/frontend/ts7/lib-diagnostics.d.ts +24 -0
  579. package/dist/frontend/ts7/lib-diagnostics.js +307 -0
  580. package/dist/frontend/ts7/lib-diagnostics.js.map +1 -0
  581. package/dist/frontend/ts7/lib-diagnostics.test.d.ts +1 -0
  582. package/dist/frontend/ts7/lib-diagnostics.test.js +199 -0
  583. package/dist/frontend/ts7/lib-diagnostics.test.js.map +1 -0
  584. package/dist/frontend/ts7/program-host.d.ts +7 -0
  585. package/dist/frontend/ts7/program-host.js +25 -2
  586. package/dist/frontend/ts7/program-host.js.map +1 -1
  587. package/dist/frontend/ts7/semantic-model.d.ts +3 -0
  588. package/dist/frontend/ts7/semantic-model.js +5 -0
  589. package/dist/frontend/ts7/semantic-model.js.map +1 -1
  590. package/dist/frontend/ts7/semantic-model.test.js +6 -1
  591. package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
  592. package/dist/frontend/ts7/semantic-types.d.ts +1 -1
  593. package/dist/frontend/ts7/semantic-types.js +1 -1
  594. package/dist/frontend/ts7/semantic-types.js.map +1 -1
  595. package/dist/frontend/ts7/session.d.ts +14 -1
  596. package/dist/frontend/ts7/session.js +22 -0
  597. package/dist/frontend/ts7/session.js.map +1 -1
  598. package/dist/frontend/type-mapper.d.ts +13 -1
  599. package/dist/frontend/type-mapper.js +229 -20
  600. package/dist/frontend/type-mapper.js.map +1 -1
  601. package/dist/index.d.ts +0 -5
  602. package/dist/index.js +46 -4
  603. package/dist/index.js.map +1 -1
  604. package/dist/ir/analysis.js +5 -3
  605. package/dist/ir/analysis.js.map +1 -1
  606. package/dist/ir/array-length-stability.d.ts +4 -0
  607. package/dist/ir/array-length-stability.js +19 -6
  608. package/dist/ir/array-length-stability.js.map +1 -1
  609. package/dist/ir/array-length-stability.test.js +24 -0
  610. package/dist/ir/array-length-stability.test.js.map +1 -1
  611. package/dist/ir/builtin-effects.d.ts +7 -0
  612. package/dist/ir/builtin-effects.js +60 -0
  613. package/dist/ir/builtin-effects.js.map +1 -1
  614. package/dist/ir/builtin-signatures.d.ts +6 -4
  615. package/dist/ir/builtin-signatures.js +222 -13
  616. package/dist/ir/builtin-signatures.js.map +1 -1
  617. package/dist/ir/callback-specialization.d.ts +2 -1
  618. package/dist/ir/callback-specialization.js +23 -18
  619. package/dist/ir/callback-specialization.js.map +1 -1
  620. package/dist/ir/char-unit-locals.d.ts +19 -0
  621. package/dist/ir/char-unit-locals.js +185 -0
  622. package/dist/ir/char-unit-locals.js.map +1 -0
  623. package/dist/ir/char-unit-locals.test.d.ts +1 -0
  624. package/dist/ir/char-unit-locals.test.js +94 -0
  625. package/dist/ir/char-unit-locals.test.js.map +1 -0
  626. package/dist/ir/final-fields.d.ts +2 -1
  627. package/dist/ir/final-fields.js +14 -16
  628. package/dist/ir/final-fields.js.map +1 -1
  629. package/dist/ir/function-references.d.ts +2 -0
  630. package/dist/ir/function-references.js +2 -0
  631. package/dist/ir/function-references.js.map +1 -1
  632. package/dist/ir/function-references.test.js +3 -0
  633. package/dist/ir/function-references.test.js.map +1 -1
  634. package/dist/ir/initializer-bindings.d.ts +2 -1
  635. package/dist/ir/initializer-bindings.js +27 -20
  636. package/dist/ir/initializer-bindings.js.map +1 -1
  637. package/dist/ir/int32-arrays.d.ts +108 -0
  638. package/dist/ir/int32-arrays.js +831 -0
  639. package/dist/ir/int32-arrays.js.map +1 -0
  640. package/dist/ir/int32-slots.d.ts +24 -2
  641. package/dist/ir/int32-slots.js +266 -57
  642. package/dist/ir/int32-slots.js.map +1 -1
  643. package/dist/ir/int32-slots.test.js +33 -0
  644. package/dist/ir/int32-slots.test.js.map +1 -1
  645. package/dist/ir/integer-loops.d.ts +3 -3
  646. package/dist/ir/integer-loops.js +28 -10
  647. package/dist/ir/integer-loops.js.map +1 -1
  648. package/dist/ir/integer-loops.test.js +10 -0
  649. package/dist/ir/integer-loops.test.js.map +1 -1
  650. package/dist/ir/integer-ranges.d.ts +5 -0
  651. package/dist/ir/integer-ranges.js +125 -12
  652. package/dist/ir/integer-ranges.js.map +1 -1
  653. package/dist/ir/integer-ranges.test.js +30 -0
  654. package/dist/ir/integer-ranges.test.js.map +1 -1
  655. package/dist/ir/ir.d.ts +83 -10
  656. package/dist/ir/ir.js +77 -6
  657. package/dist/ir/ir.js.map +1 -1
  658. package/dist/ir/ir.test.js +23 -2
  659. package/dist/ir/ir.test.js.map +1 -1
  660. package/dist/ir/js-ic.d.ts +4 -0
  661. package/dist/ir/js-ic.js +17 -1
  662. package/dist/ir/js-ic.js.map +1 -1
  663. package/dist/ir/js-ic.test.js +46 -0
  664. package/dist/ir/js-ic.test.js.map +1 -1
  665. package/dist/ir/node-index.d.ts +57 -0
  666. package/dist/ir/node-index.js +215 -0
  667. package/dist/ir/node-index.js.map +1 -0
  668. package/dist/ir/paired-while-loops.d.ts +25 -0
  669. package/dist/ir/paired-while-loops.js +335 -0
  670. package/dist/ir/paired-while-loops.js.map +1 -0
  671. package/dist/ir/paired-while-loops.test.d.ts +1 -0
  672. package/dist/ir/paired-while-loops.test.js +163 -0
  673. package/dist/ir/paired-while-loops.test.js.map +1 -0
  674. package/dist/ir/parameter-versions.d.ts +25 -0
  675. package/dist/ir/parameter-versions.js +300 -0
  676. package/dist/ir/parameter-versions.js.map +1 -0
  677. package/dist/ir/runtime-features.d.ts +34 -13
  678. package/dist/ir/runtime-features.js +177 -39
  679. package/dist/ir/runtime-features.js.map +1 -1
  680. package/dist/ir/serialize.d.ts +12 -2
  681. package/dist/ir/serialize.js +16 -3
  682. package/dist/ir/serialize.js.map +1 -1
  683. package/dist/ir/serialize.test.js +17 -0
  684. package/dist/ir/serialize.test.js.map +1 -1
  685. package/dist/ir/traverse.js +18 -6
  686. package/dist/ir/traverse.js.map +1 -1
  687. package/dist/ir/validate.js +167 -40
  688. package/dist/ir/validate.js.map +1 -1
  689. package/dist/library/ir-policy.js +3 -0
  690. package/dist/library/ir-policy.js.map +1 -1
  691. package/dist/native/cache.d.ts +6 -1
  692. package/dist/native/cache.js +28 -5
  693. package/dist/native/cache.js.map +1 -1
  694. package/dist/native/cache.test.js +16 -2
  695. package/dist/native/cache.test.js.map +1 -1
  696. package/dist/native/cli.js +21 -1
  697. package/dist/native/cli.js.map +1 -1
  698. package/dist/native/compiler.js +8 -6
  699. package/dist/native/compiler.js.map +1 -1
  700. package/dist/native/executable-cache.d.ts +1 -1
  701. package/dist/native/executable-cache.js +2 -2
  702. package/dist/native/executable-cache.js.map +1 -1
  703. package/dist/native/prepare.d.ts +4 -2
  704. package/dist/native/prepare.js +130 -32
  705. package/dist/native/prepare.js.map +1 -1
  706. package/dist/native/prepare.test.js +96 -20
  707. package/dist/native/prepare.test.js.map +1 -1
  708. package/dist/native/sanitizer.test.js +2 -0
  709. package/dist/native/sanitizer.test.js.map +1 -1
  710. package/dist/native/text-file.d.ts +13 -3
  711. package/dist/native/text-file.js +63 -9
  712. package/dist/native/text-file.js.map +1 -1
  713. package/dist/native/text-file.test.d.ts +1 -0
  714. package/dist/native/text-file.test.js +49 -0
  715. package/dist/native/text-file.test.js.map +1 -0
  716. package/dist/native/toolchain.js +4 -4
  717. package/dist/native/toolchain.js.map +1 -1
  718. package/dist/native/toolchain.test.js +3 -3
  719. package/dist/native/toolchain.test.js.map +1 -1
  720. package/package.json +21 -21
  721. package/shims/chalk/v5.ts +688 -0
  722. package/shims/hono-node-server/v2.ts +645 -0
  723. package/shims/hot-shots/client.ts +1126 -0
  724. package/shims/hot-shots/v8-unix-dgram.ts +8 -0
  725. package/shims/hot-shots/v8.ts +8 -0
  726. package/surface-manifest.json +27 -7
@@ -15,18 +15,21 @@ import { loopTestsEveryIteration } from "../loop-polls.js";
15
15
  import { isDynTypedRefType, isRefCounted, isUnitType, POINTER_KINDS, RUNTIME_EMITTER_CLASS, RUNTIME_EVENT_CLASS, RUNTIME_EVENT_TARGET_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, typeEquals, typeKey, VOID, classJsName, } from "../../ir/ir.js";
16
16
  import { moduleRuntimeFeatures } from "../../ir/runtime-features.js";
17
17
  import { captureFreeFunctions, observesStacks } from "../stack-observations.js";
18
- import {} from "./dense-array-loops.js";
19
18
  import { findInitializedByteLoopBindings } from "./byte-windows.js";
20
19
  import { matchBytesLoopVersion } from "./bytes-loop-versions.js";
21
20
  import { globalSlotAlias } from "./bytes-alias.js";
22
21
  import { materializeSplitPiece, } from "./split-loops.js";
23
22
  import { scalarizeNumericRecords } from "../../ir/scalar-records.js";
24
- import { addRecordResultEntries } from "./record-results.js";
23
+ import { addRecordResultEntries, resultEntryName } from "./record-results.js";
25
24
  import { specializeCallbackCalls } from "../../ir/callback-specialization.js";
25
+ import { EmitJournal, registerReplay, renameChunk, replayJournal, } from "./emit-journal.js";
26
26
  import { specializeNumericCalls } from "../../ir/numeric-call-specialization.js";
27
+ import { versionLoopBoundParameters } from "../../ir/parameter-versions.js";
28
+ import { allocatedLiteral, fillAllocationLength, int32ArrayKey, selectInt32Arrays, } from "../../ir/int32-arrays.js";
27
29
  import { everyExpr, everyExprChild, everyStmtChild, everyStmtList } from "../../ir/traverse.js";
28
- import { INT32_RANGE } from "../../ir/integer-ranges.js";
30
+ import { INT32_RANGE, withinInt32, } from "../../ir/integer-ranges.js";
29
31
  import { unshareNodes } from "../../ir/unshare.js";
32
+ import { runPairedWhileLoopsAsFor } from "../../ir/paired-while-loops.js";
30
33
  import { copyStableCaptures } from "../../ir/capture-values.js";
31
34
  import { resolveSelfCaptures } from "../../ir/self-captures.js";
32
35
  import { analyzeInt32Slots, dynamicFieldStores } from "../../ir/int32-slots.js";
@@ -35,10 +38,11 @@ import { foldConstantGlobals } from "../../ir/constant-globals.js";
35
38
  import { dropUnwrittenPropertyBags } from "../../ir/property-bags.js";
36
39
  import { freezeInitOnlyGlobals } from "../../ir/init-only-globals.js";
37
40
  import { hoistFinalFieldReads } from "../../ir/field-values.js";
41
+ import { holdCharLocalsAsUnits } from "../../ir/char-unit-locals.js";
38
42
  import { findInt32Abis, INT32_ABI_SUFFIX, SCALAR_UNION_DUMMY, SCALAR_UNION_RESULT, } from "./int32-abi.js";
39
43
  import {} from "./int32-locals.js";
40
44
  import { findIntegerClones, NO_INTEGER_CLONES } from "./integer-clones.js";
41
- import { exactInteger, narrowInteger } from "./integer-values.js";
45
+ import { exactInteger, narrowInteger, widenInteger } from "./integer-values.js";
42
46
  import { findInitializerBindings } from "../../ir/initializer-bindings.js";
43
47
  import { findConstantNumericTables } from "../../ir/constant-tables.js";
44
48
  import { allocateFfiCallbackAdapters, hasForeignFfiCallback, hasRetainedFfiCallback, } from "../ffi-callbacks.js";
@@ -52,12 +56,13 @@ import { NullableRefFields } from "./nullable-fields.js";
52
56
  import { InlineUnionFields, loadInlineUnion, presentBits, stackUnionBox, storeInlineUnion, unionBoxBits, } from "./inline-unions.js";
53
57
  import { OptionalArrayReads } from "./local-array-reads.js";
54
58
  import { CheckedNarrows } from "./checked-narrows.js";
55
- import { emitDenseArraySet, emitDenseSlotUnlink } from "./dense-array-access.js";
59
+ import { emitDenseArraySet, emitDenseSlotUnlink, SCR_ELEM_I32, } from "./dense-array-access.js";
56
60
  import { matchMapRead } from "./map-read-lifetimes.js";
57
61
  import {} from "./map-entry-fusion.js";
58
62
  import { emitBorrowedFieldSequence, guardedValue } from "./borrowed-receivers.js";
59
63
  import { emitBorrowedInputs } from "./borrowed-inputs.js";
60
64
  import { findWalkBorrows } from "./walk-borrows.js";
65
+ import { IrNodeIndex } from "../../ir/node-index.js";
61
66
  import { lastUseRead } from "./local-extents.js";
62
67
  import { findReboundParameters } from "./rebound-parameters.js";
63
68
  import { ReferenceEffects } from "./reference-effects.js";
@@ -69,7 +74,7 @@ import { AmbientReceiverReaders, findConstantCallbacks } from "./constant-callba
69
74
  import { findLentStringParameters, } from "./string-slices.js";
70
75
  import { LazyCaptures } from "./lazy-captures.js";
71
76
  import { StackCaptures } from "./stack-captures.js";
72
- import { emitFieldAbsentTest, f64Lit } from "./common.js";
77
+ import { emitFieldAbsentTest, f64Lit, SCR_ARR_FIELD, SCR_ARR_FROZEN } from "./common.js";
73
78
  import { ffiExtendsNarrowIntegers } from "../targets.js";
74
79
  import { emitLiteralExpr, emitOperatorExpr, emitStringExpr, emitContainerExpr, emitRecordExpr, } from "./expr-primitives.js";
75
80
  import { emitControlExpr } from "./expr-control.js";
@@ -78,8 +83,10 @@ import { emitDynamicExpr } from "./expr-dynamic.js";
78
83
  import { emitIntrinsicExpr, emitSerializationExpr, emitAsyncExpr } from "./expr-async.js";
79
84
  import { PublishWalkers } from "./publish.js";
80
85
  import { computeImmutableFields, stableGlobals } from "../immutability.js";
86
+ import { computeCycleMutability, hierarchyUnitOfClass } from "../cycle-mutability.js";
81
87
  import { computePublishedTypes } from "../publication.js";
82
88
  import { emitExpr } from "./expr-dispatch.js";
89
+ import { LOOPS } from "./loop-state.js";
83
90
  import { dynKind, raceAdapterFor, genResultThunkFor, childExitThunkFor, childExitSignalThunkFor, childDataDynThunkFor, childDataThunkFor, execFileThunkFor, ipcMessageThunkFor, ipcSendThunkFor, emitterFixedAdapter, emitterOnceAdapter, wrapEmitterListener, unwrapNullableClosure, closeBindThunkFor, closeOverrideWrapFor, } from "./expr-callbacks.js";
84
91
  import { streamDataAdapter, streamDoneFnFor, cryptoBytesThunkFor, cryptoIntThunkFor, fsRenameThunkFor, streamCbThunkFor, zlibBytesThunkFor, } from "./expr-stream-callbacks.js";
85
92
  import { emitStableReceiver, resolveThunkFor, tagInSet, arrPush, emitArrayCopyLoop, emitStrIntrinsic, emitArrIntrinsic, wrapNullable, emitMapNew, mapSet, emitMapLikeIntrinsic, emitSetNew, } from "./expr-containers.js";
@@ -140,23 +147,58 @@ export function ffiCallbackDummyLl(callback) {
140
147
  export function lowRegionTarget(platform, sanitize) {
141
148
  return platform === "linux" && !sanitize;
142
149
  }
143
- export function emitLlvmModule(input, options = {}) {
150
+ /** Function versions on loop-bounding number parameters
151
+ * (ir/parameter-versions.ts). Library builds have no int32 entries, and a
152
+ * module that observes call stacks could see the version's frame. */
153
+ function versionParameters(mod) {
154
+ if (mod.lib !== undefined || observesStacks(mod))
155
+ return mod;
156
+ return versionLoopBoundParameters(mod, mangleFunction);
157
+ }
158
+ /** The int32 arrays the int32 slot analysis keeps in `mod` (proven and
159
+ * checked), under the inputs LlEmitter gives it (selectInt32Arrays). */
160
+ function provenInt32Arrays(mod) {
161
+ const slots = analyzeInt32Slots(mod, {
162
+ dynamicStores: dynamicFieldStores(mod),
163
+ initializerBindings: findInitializerBindings(mod),
164
+ });
165
+ return new Set([...slots.int32Arrays, ...slots.checkedInt32Arrays]);
166
+ }
167
+ /** The functions whose calls the backend may emit as calls of their
168
+ * result-slot entries (record-results.ts). */
169
+ function resultEntryTargets(mod) {
170
+ const names = new Set(mod.functions.map((fn) => fn.name));
171
+ const targets = new Set();
172
+ for (const name of names)
173
+ if (names.has(resultEntryName(name)))
174
+ targets.add(name);
175
+ return targets;
176
+ }
177
+ /** The emitter for `input` after the module passes every emission runs. */
178
+ function moduleEmitter(input, options) {
144
179
  // Facts are keyed by node identity: emit the same module whether it was
145
180
  // lowered in memory or read back from its serialized form.
146
181
  const mod = unshareNodes(input);
147
182
  // Keep source storage intact for debugger inspection in dev builds.
148
183
  return new LlEmitter(options.debugSources === undefined
149
- ? addRecordResultEntries(scalarizeNumericRecords(specializeCallbackCalls(specializeNumericCalls(foldConstantGlobals(copyStableCaptures(resolveSelfCaptures(hoistFinalFieldReads(freezeInitOnlyGlobals(dropUnwrittenPropertyBags(mod)))))), mangleFunction), mangleFunction)))
150
- : mod, options).emit();
184
+ ? selectInt32Arrays(versionParameters(addRecordResultEntries(scalarizeNumericRecords(specializeCallbackCalls(specializeNumericCalls(foldConstantGlobals(copyStableCaptures(resolveSelfCaptures(hoistFinalFieldReads(freezeInitOnlyGlobals(holdCharLocalsAsUnits(dropUnwrittenPropertyBags(runPairedWhileLoopsAsFor(mod)))))))), mangleFunction), mangleFunction)))), provenInt32Arrays, resultEntryTargets)
185
+ : mod, options);
186
+ }
187
+ export function emitLlvmModule(input, options = {}) {
188
+ return moduleEmitter(input, options).emit();
189
+ }
190
+ /** emitLlvmModule's text as parts that concatenate to it, without the copy
191
+ * that joining them makes: a large program's text is 150 MB. */
192
+ export function emitLlvmModuleParts(input, options = {}) {
193
+ return moduleEmitter(input, options)
194
+ .emitParts()
195
+ .flatMap((part, index) => (index === 0 ? [part] : ["\n", part]));
151
196
  }
152
197
  /** Keep large translation units below the host's single-string limit. */
153
198
  export function emitLlvmModuleSource(input, options = {}) {
154
199
  // IR validation, contracts and the frontend's disposal run after lowering without checks.
155
200
  relieveHeapPressure(true);
156
- const mod = unshareNodes(input);
157
- const parts = new LlEmitter(options.debugSources === undefined
158
- ? addRecordResultEntries(scalarizeNumericRecords(specializeCallbackCalls(specializeNumericCalls(foldConstantGlobals(copyStableCaptures(resolveSelfCaptures(hoistFinalFieldReads(freezeInitOnlyGlobals(dropUnwrittenPropertyBags(mod)))))), mangleFunction), mangleFunction)))
159
- : mod, options).emitParts();
201
+ const parts = moduleEmitter(input, options).emitParts();
160
202
  const length = parts.reduce((total, part) => total + part.length, Math.max(0, parts.length - 1));
161
203
  if (length <= 256 * 1024 * 1024)
162
204
  return parts.join("\n");
@@ -272,6 +314,8 @@ function countLocalMentions(body, id) {
272
314
  }
273
315
  export class LlEmitter {
274
316
  mod;
317
+ /** Per-feature state (emitter-state.ts), indexed by each key's slot. */
318
+ moduleStates = [];
275
319
  localArrayReads = new Map();
276
320
  loopArrayBorrows = new Set();
277
321
  scalarStringSlices = new Map();
@@ -297,9 +341,11 @@ export class LlEmitter {
297
341
  * 32-bit references to compact class instances (LlClassMeta.compressed):
298
342
  * loadField/loadRef decode them and storeField/storeRef encode them. */
299
343
  compressedFieldPtrs = new Set();
300
- /** Whether a class has compressed fields: main reserves the region before
301
- * compiled code runs (scr_plr_init). */
302
- usesCompactRefs = false;
344
+ /** Compact class instances live in the program-lifetime region below
345
+ * 32 GiB (LlvmTargetOptions.lowRegion, and the program has compact
346
+ * classes): main reserves it before compiled code runs (scr_plr_init), and
347
+ * fields and arrays of compactRefType hold 32-bit references. */
348
+ compactRegion = false;
303
349
  /** Native class fields with different property names cannot occupy the
304
350
  * same slot of one object. Inherited views of the same property share a
305
351
  * tag. Array storage has its own disjoint categories; untagged runtime
@@ -315,6 +361,7 @@ export class LlEmitter {
315
361
  tag = 2 + this.fieldAliasTags.size * 2;
316
362
  this.fieldAliasTags.set(field, tag);
317
363
  }
364
+ this.journal?.entry("tag", field, tag);
318
365
  this.fieldPointerTags.set(ptr, tag);
319
366
  }
320
367
  /** The alias tag of a runtime word that emitted code reads and writes
@@ -327,19 +374,225 @@ export class LlEmitter {
327
374
  tag = 2 + this.fieldAliasTags.size * 2;
328
375
  this.fieldAliasTags.set(category, tag);
329
376
  }
377
+ this.journal?.entry("tag", category, tag);
330
378
  return `, !tbaa !${tag}`;
331
379
  }
380
+ /** The current function's int32 array allocations: the array literals
381
+ * its int32 arrays are written with. They construct SCR_ELEM_I32 arrays. */
382
+ int32Allocations = new Set();
383
+ /** The fill temporaries (`new Array(n).fill(v)`) of those allocations:
384
+ * the same arrays, so int32 too. */
385
+ int32ArrayTemps = new Set();
386
+ /** The same for the current function's int32 arrays with checked stores,
387
+ * which are only allocated by fills (ir/int32-arrays.ts
388
+ * checkableInt32Allocations): their temporaries' literals, with the fill's
389
+ * length (a literal constructs SCR_ELEM_I32 storage when that length is at
390
+ * least CHECKED_INT32_MIN_LENGTH, SCR_ELEM_F64 otherwise), and their
391
+ * temporaries. */
392
+ checkedAllocations = new Map();
393
+ checkedArrayTemps = new Set();
394
+ /** The fill calls (`.fill(v)`) of those allocations: a value that is not
395
+ * an int32 widens the new array first. */
396
+ checkedFills = new Set();
397
+ /** Collect the int32 allocations of `fn`, about to be emitted. */
398
+ findInt32Allocations(fn) {
399
+ this.int32Allocations.clear();
400
+ this.int32ArrayTemps.clear();
401
+ this.checkedAllocations.clear();
402
+ this.checkedArrayTemps.clear();
403
+ this.checkedFills.clear();
404
+ const { int32Arrays, checkedInt32Arrays } = this.int32Slots;
405
+ if (int32Arrays.size === 0 && checkedInt32Arrays.size === 0)
406
+ return;
407
+ everyStmtList(fn.body, {
408
+ stmt: (s) => {
409
+ if (s.kind !== "varDecl" && s.kind !== "assign")
410
+ return true;
411
+ const key = int32ArrayKey(fn.name, s.localId);
412
+ const checked = checkedInt32Arrays.has(key);
413
+ if (!checked && !int32Arrays.has(key))
414
+ return true;
415
+ const value = s.kind === "varDecl" ? s.init : s.value;
416
+ const allocation = value && allocatedLiteral(value);
417
+ if (!allocation)
418
+ return true;
419
+ const length = checked ? fillAllocationLength(value) : null;
420
+ if (length !== null)
421
+ this.checkedAllocations.set(allocation.literal, length);
422
+ else if (!checked)
423
+ this.int32Allocations.add(allocation.literal);
424
+ if (allocation.temporary !== null)
425
+ (checked ? this.checkedArrayTemps : this.int32ArrayTemps).add(allocation.temporary);
426
+ if (checked && value !== allocation.literal)
427
+ this.checkedFills.add(value);
428
+ return true;
429
+ },
430
+ expr: () => true,
431
+ });
432
+ }
433
+ /** Whether `arr` reads one of the int32 arrays (ir/int32-arrays.ts, kept
434
+ * by the int32 slot analysis): a local or parameter of the current
435
+ * function, or a module global. */
436
+ int32Array(arr) {
437
+ if (arr.kind !== "varRef")
438
+ return false;
439
+ if (this.int32KindArray(arr))
440
+ return true;
441
+ if (this.int32Slots.int32Arrays.size === 0)
442
+ return false;
443
+ return (this.int32ArrayTemps.has(arr.localId) ||
444
+ this.int32Slots.int32Arrays.has(int32ArrayKey(this.currentFunctionName, arr.localId)));
445
+ }
446
+ /** Whether `arr` is one of the current function's int32 arrays with
447
+ * checked stores: int32 slots until a store widens it to doubles. Every
448
+ * access tests its kind (emitByElementKind), except in the fast copy of
449
+ * an int32 kind loop, which reads and writes it as an int32 array. */
450
+ checkedInt32Array(arr) {
451
+ if (arr.kind !== "varRef" || this.int32KindArray(arr))
452
+ return false;
453
+ if (this.int32Kinds?.wide.has(`${this.currentFunctionName}\0${arr.localId}`))
454
+ return false;
455
+ return this.checkedInt32Local(arr.localId);
456
+ }
457
+ /** Whether the local `localId` holds one of the current function's int32
458
+ * arrays with checked stores. */
459
+ checkedInt32Local(localId) {
460
+ if (this.int32Slots.checkedInt32Arrays.size === 0)
461
+ return false;
462
+ return (this.checkedArrayTemps.has(localId) ||
463
+ this.int32Slots.checkedInt32Arrays.has(`${this.currentFunctionName}\0${localId}`));
464
+ }
465
+ /** Whether `arr` is an int32 array with checked stores that the fast copy
466
+ * of the int32 kind loop being emitted holds as an int32 array. */
467
+ int32KindArray(arr) {
468
+ return (this.int32Kinds !== null &&
469
+ arr.kind === "varRef" &&
470
+ this.int32Kinds.int32.has(`${this.currentFunctionName}\0${arr.localId}`));
471
+ }
472
+ /** Before a store of `value` (of `expr`) into `arr`, in the fast copy of
473
+ * an int32 kind loop: continue when it is an int32 that is not -0, and
474
+ * otherwise leave for the statement's resume point, where it re-executes
475
+ * with kind tests. Returns the value as an i32 when it is at hand as an
476
+ * integer, or null when the store converts the double itself. */
477
+ emitInt32KindStoreCheck(arr, value, expr) {
478
+ if (!this.int32KindArray(arr) || withinInt32(this.integerRanges.get(expr)))
479
+ return null;
480
+ const integer = exactInteger(this, value, expr);
481
+ if (integer !== null && withinInt32(integer.range))
482
+ return narrowInteger(this, integer);
483
+ const resume = this.int32KindResume;
484
+ if (resume === null)
485
+ throw new InternalCompilerError("llvm emitter bug: an int32 kind store without a resume");
486
+ const B = this.B;
487
+ const ok = B.tmp(), int = B.tmp();
488
+ if (integer !== null) {
489
+ // An exact integer: a range test on its 64-bit form.
490
+ const wide = widenInteger(this, integer), low = B.tmp(), high = B.tmp();
491
+ B.line(`${low} = icmp sge i64 ${wide}, -2147483648`);
492
+ B.line(`${high} = icmp sle i64 ${wide}, 2147483647`);
493
+ B.line(`${ok} = and i1 ${low}, ${high}`);
494
+ const store = B.newLabel("arr.store.i32");
495
+ B.condBr(ok, store, resume);
496
+ B.startBlock(store);
497
+ B.line(`${int} = trunc i64 ${wide} to i32`);
498
+ return int;
499
+ }
500
+ this.declare("declare i32 @llvm.fptosi.sat.i32.f64(double)");
501
+ const back = B.tmp(), exact = B.tmp(), bits = B.tmp(), notNegativeZero = B.tmp();
502
+ B.line(`${int} = call i32 @llvm.fptosi.sat.i32.f64(double ${value.name})`);
503
+ B.line(`${back} = sitofp i32 ${int} to double`);
504
+ B.line(`${exact} = fcmp oeq double ${back}, ${value.name}`);
505
+ B.line(`${bits} = bitcast double ${value.name} to i64`);
506
+ B.line(`${notNegativeZero} = icmp ne i64 ${bits}, -9223372036854775808`);
507
+ B.line(`${ok} = and i1 ${exact}, ${notNegativeZero}`);
508
+ const store = B.newLabel("arr.store.i32");
509
+ B.condBr(ok, store, resume);
510
+ B.startBlock(store);
511
+ return int;
512
+ }
513
+ /** Emit an access to the checked int32 array `array` once per element
514
+ * kind: `arm("i32", widened)` while it holds int32 slots and
515
+ * `arm("f64", widened)` after it widened, joined after both. `widened` is
516
+ * the label of the double arm, where an int32 arm's store of a value that
517
+ * is not an int32 continues after widening the array. Returns the phi of
518
+ * the arms' results (of LLVM type `ty`), or null when `ty` is null. */
519
+ emitByElementKind(array, ty, arm) {
520
+ const B = this.B;
521
+ const narrow = B.newLabel("arr.kind.i32"), wide = B.newLabel("arr.kind.f64"), join = B.newLabel("arr.kind.join");
522
+ const kindPtr = B.tmp(), kind = B.tmp(), isInt32 = B.tmp();
523
+ B.line(`${kindPtr} = getelementptr inbounds %ScrArr, ptr ${array}, i32 0, i32 ${SCR_ARR_FIELD.elem}`);
524
+ this.markMemoryPointer(kindPtr, "array:header");
525
+ B.line(`${kind} = load i8, ptr ${kindPtr}${this.fieldAliasAttachment(kindPtr)}`);
526
+ B.line(`${isInt32} = icmp eq i8 ${kind}, ${SCR_ELEM_I32}`);
527
+ B.condBr(isInt32, narrow, wide);
528
+ B.startBlock(narrow);
529
+ const narrowValue = arm("i32", wide);
530
+ const narrowEnd = B.isTerminated() ? null : B.currentLabel();
531
+ if (narrowEnd !== null)
532
+ B.br(join);
533
+ B.startBlock(wide);
534
+ const wideValue = arm("f64", wide);
535
+ const wideEnd = B.isTerminated() ? null : B.currentLabel();
536
+ if (wideEnd !== null)
537
+ B.br(join);
538
+ B.startBlock(join);
539
+ // Arms that end in their own branches (a read's shared join) leave this
540
+ // join without predecessors.
541
+ if (narrowEnd === null && wideEnd === null)
542
+ B.terminate("unreachable");
543
+ if (ty === null)
544
+ return null;
545
+ const arms = [];
546
+ if (narrowEnd !== null)
547
+ arms.push(`[ ${narrowValue}, %${narrowEnd} ]`);
548
+ if (wideEnd !== null)
549
+ arms.push(`[ ${wideValue}, %${wideEnd} ]`);
550
+ const result = B.tmp();
551
+ B.line(`${result} = phi ${ty} ${arms.join(", ")}`);
552
+ return result;
553
+ }
554
+ /** Before storing the double `value` (of `expr`) into an int32 arm
555
+ * (emitByElementKind) of the checked int32 array `array`: continue in this
556
+ * arm when it is an int32 that is not -0, or widen the array and continue
557
+ * at `widened`. A value proven an int32 needs no test. */
558
+ emitCheckedInt32Store(array, value, expr, widened) {
559
+ if (withinInt32(this.integerRanges.get(expr)))
560
+ return;
561
+ const B = this.B;
562
+ this.declare("declare i32 @llvm.fptosi.sat.i32.f64(double)");
563
+ this.declare("declare void @scr_arr_widen_i32(ptr)");
564
+ const int = B.tmp(), back = B.tmp(), exact = B.tmp(), bits = B.tmp(), notNegativeZero = B.tmp(), ok = B.tmp();
565
+ B.line(`${int} = call i32 @llvm.fptosi.sat.i32.f64(double ${value})`);
566
+ B.line(`${back} = sitofp i32 ${int} to double`);
567
+ B.line(`${exact} = fcmp oeq double ${back}, ${value}`);
568
+ B.line(`${bits} = bitcast double ${value} to i64`);
569
+ B.line(`${notNegativeZero} = icmp ne i64 ${bits}, -9223372036854775808`);
570
+ B.line(`${ok} = and i1 ${exact}, ${notNegativeZero}`);
571
+ const store = B.newLabel("arr.store.i32"), widen = B.newLabel("arr.widen");
572
+ B.condBr(ok, store, widen);
573
+ B.startBlock(widen);
574
+ B.line(`call void @scr_arr_widen_i32(ptr ${array})`);
575
+ B.br(widened);
576
+ B.startBlock(store);
577
+ }
578
+ /** The access an element operation on `arr` (of element type `elem`)
579
+ * takes: int32 arrays read and write their 4-byte slots. */
580
+ arrayAccess(arr, elem) {
581
+ if (this.checkedInt32Array(arr))
582
+ throw new InternalCompilerError("llvm emitter bug: a checked int32 array without its kind test");
583
+ return this.int32Array(arr) ? "i32" : elemAccess(elem);
584
+ }
332
585
  /** Whether an element access at `index` of `arr` lies in the hole-free
333
- * prefix: the counter of a dense array loop's fast copy indexing one of
334
- * the arrays its entry test covered. */
586
+ * prefix: a counter of a dense array loop's fast copy indexing one of the
587
+ * arrays its entry test covered. */
335
588
  provenDenseIndex(arr, index) {
336
- const loop = this.denseLoop;
589
+ const loop = LOOPS.of(this).denseLoop;
337
590
  return (loop !== null &&
338
591
  arr.kind === "varRef" &&
339
592
  loop.arrays.has(arr.localId) &&
340
593
  index.kind === "varRef" &&
341
- index.localId === loop.counter &&
342
- this.integerLoopBindings.has(loop.counter));
594
+ (index.localId === loop.counter || index.localId === loop.pair?.high) &&
595
+ this.integerLoopBindings.has(index.localId));
343
596
  }
344
597
  fieldAliasAttachment(ptr) {
345
598
  const tag = this.fieldPointerTags.get(ptr);
@@ -389,6 +642,7 @@ export class LlEmitter {
389
642
  emitLibraryIdentity;
390
643
  runtimeAbiMarker;
391
644
  detachedExit;
645
+ targetCpu;
392
646
  wasmBoundsChecks;
393
647
  /** Interned string literals: UTF-8 text → { symbol, byte length } —
394
648
  * first-use order, the runtime ABI’s determinism discipline. */
@@ -430,6 +684,10 @@ export class LlEmitter {
430
684
  cstrs = new Map();
431
685
  /** Interned ScrMapOps descriptors (scr_map.h): initializer → symbol. */
432
686
  mapOpsConsts = new Map();
687
+ /** Method-id slots of checked-dynamic method calls
688
+ * (scr_dyn_invoke_prepared_id): method name → symbol of an i32 the
689
+ * runtime fills with the name's id on the first call. */
690
+ methodIdSlots = new Map();
433
691
  /** Type-directed walker functions (JSON serializers, the indent
434
692
  * rewriter, union ToString/join) — interned per typeKey/unionId, defs
435
693
  * flushed with the shape helpers. */
@@ -478,6 +736,9 @@ export class LlEmitter {
478
736
  callLifetimes;
479
737
  constantCallbacks;
480
738
  currentConstantCallbacks = new Map();
739
+ /** The current function's running maximum and minimum updates, whose
740
+ * branches are weighted as rarely taken (running-extrema.ts). */
741
+ runningExtrema = new Set();
481
742
  /** Callback bindings whose closures an enclosing callback loop version
482
743
  * proved to hold their known function: calls take the direct entry with
483
744
  * no fallback (emitCallbackVersionedLoop). */
@@ -526,6 +787,9 @@ export class LlEmitter {
526
787
  /** Module constants that keep one value once initialized
527
788
  * (immutability.ts stableGlobals). */
528
789
  stableGlobals = new Set();
790
+ /** Every function body's nodes in walk order (ir/node-index.ts), for the
791
+ * constructor's analyses. */
792
+ nodeIndex;
529
793
  tdzGlobals = new Map();
530
794
  constantNumericTables;
531
795
  /** Constant-key reads on checked-dynamic objects, each with its own
@@ -593,7 +857,7 @@ export class LlEmitter {
593
857
  /** The module's runtime features (moduleRuntimeFeatures), found with one
594
858
  * walk of the module the first time any of them is read. */
595
859
  get runtimeFeatures() {
596
- return (this.runtimeFeaturesValue ??= moduleRuntimeFeatures(this.mod));
860
+ return (this.runtimeFeaturesValue ??= moduleRuntimeFeatures(this.mod, this.nodeIndex));
597
861
  }
598
862
  /** Whether timer and tick scheduling goes through the *_als entry
599
863
  * points (RuntimeFeatures asyncContext). */
@@ -618,6 +882,11 @@ export class LlEmitter {
618
882
  get usesDynBuiltinStream() {
619
883
  return this.runtimeFeatures.dynBuiltinStream;
620
884
  }
885
+ /** A checked-dynamic for-await may hold a native stream: the program
886
+ * links the stream unit (and the dyn-async one the loop needs). */
887
+ get dynForAwaitStreams() {
888
+ return this.runtimeFeatures.stream && this.runtimeFeatures.dynAsync;
889
+ }
621
890
  /** Runtime-arm dispatchers for live union values. */
622
891
  liveDynUnionRefAdapters = new Map();
623
892
  dynPromiseAdapters = new Map();
@@ -706,14 +975,6 @@ export class LlEmitter {
706
975
  * immortal from construction (classes.ts programLifetimeClass). */
707
976
  programLifetime;
708
977
  numericLocals = new Map();
709
- /** Local arrays of the current function that no other binding can hold
710
- * (ir/array-length-stability.ts). */
711
- unaliasedArrays = new Set();
712
- /** Dense array loops (dense-array-loops.ts) run in this function. */
713
- denseLoopsEnabled = false;
714
- denseLoopEntries = new Map();
715
- /** The fast copy of a dense array loop being emitted. */
716
- denseLoop = null;
717
978
  captureIds = new Set();
718
979
  /** Active induction bindings retain their width independently of size_t. */
719
980
  integerLoopBindings = new Map();
@@ -725,7 +986,6 @@ export class LlEmitter {
725
986
  * async or generator body resumes with its locals in its frame, which
726
987
  * an entry alloca is not part of. */
727
988
  integerTempsEnabled = false;
728
- countedLoopsEnabled = false;
729
989
  /** Speculative integer loops (speculative-integers.ts) run in this function. */
730
990
  speculativeLoopsEnabled = false;
731
991
  /** The fast copy of a speculative integer loop being emitted: its
@@ -739,6 +999,14 @@ export class LlEmitter {
739
999
  * (`enterLoopHeader`): records the ordinary copy's header, or sends the
740
1000
  * third copy's header there. */
741
1001
  speculationHeader = null;
1002
+ /** A copy of an int32 kind loop (int32-kind-loops.ts) being emitted: the
1003
+ * int32 arrays with checked stores it reads and writes as int32 arrays
1004
+ * (the fast copy) or as double arrays (an ordinary copy entered only
1005
+ * after they widened), as `function\0local` keys, and where each of the
1006
+ * fast copy's writes resumes in the third copy. */
1007
+ int32Kinds = null;
1008
+ /** The resume label of the fast-copy write being emitted. */
1009
+ int32KindResume = null;
742
1010
  /** The function being emitted, for speculative globals. */
743
1011
  speculativeFunction = "";
744
1012
  /** Every function that writes each number global (computed on demand). */
@@ -756,20 +1024,14 @@ export class LlEmitter {
756
1024
  int32Elements = null;
757
1025
  /** Sums whose result only feeds 32-bit conversions (wrapping-sums.ts). */
758
1026
  wrappingSums = new Set();
759
- byteWindowsEnabled = true;
760
- byteWindowEntries = new Map();
761
- /** Typed-array loop versioning (bytes-loop-versions.ts) for the current
762
- * function: off in debug and suspending functions and inside a copy. */
763
- bytesLoopVersionsEnabled = false;
764
- /** Loops being versioned around the statement being emitted: a loop is
765
- * never versioned inside its own copies, and versions nest boundedly. */
766
- bytesLoopVersioning = new Set();
767
- bytesLoopEntries = null;
768
- bytesLoopFunction = null;
769
- /** Counted loops whose integer-form safety test an enclosing version
770
- * guard already passed. */
771
- provenCountedGuards = new Set();
1027
+ /** Number locals of the current function that hold exact integers or NaN
1028
+ * (findIntegerOrNaNLocals in wrapping-sums.ts). */
1029
+ integerOrNaNLocals = new Map();
772
1030
  bytesBounds = new Set();
1031
+ /** The charCodeAt reads standing for charAt reads the emitter rewrote
1032
+ * (one-unit tests and switches, charAtUnitRead), with the charAt each
1033
+ * stands for: a loop version's proof for the charAt covers its read. */
1034
+ charAtUnitReads = new Map();
773
1035
  /** Worker programs: typed-array accesses whose views an enclosing version
774
1036
  * guard proved thread-owned. */
775
1037
  bytesOwned = new Set();
@@ -823,31 +1085,50 @@ export class LlEmitter {
823
1085
  chainSlots = new Map();
824
1086
  logArgSlots = 0;
825
1087
  stackTraces;
1088
+ /** The options this emitter was built with (chunk emitters reuse them). */
1089
+ targetOptions;
1090
+ /** Records the module-level effects of emitting a range of functions,
1091
+ * which the emitter that merges the range replays (emit-journal.ts). Null
1092
+ * when this emitter emits the whole module itself. */
1093
+ journal;
1094
+ /** The emitter's hosts forward to `journal` (journal set, or workers). */
1095
+ journaled;
826
1096
  /** Stack-trace mode: functions no capture can include (no frame push). */
827
1097
  unframedFunctions;
828
- constructor(mod, options) {
1098
+ constructor(mod, options, journal = null) {
829
1099
  this.mod = mod;
830
- this.stackTraces = observesStacks(mod);
831
- this.nullableUnions = new NullableUnions(mod, options.debugSources === undefined);
1100
+ this.targetOptions = options;
1101
+ this.journal = journal;
1102
+ this.journaled =
1103
+ journal !== null ||
1104
+ ((options.functionWorkers ?? 1) > 1 &&
1105
+ options.forkPrimitives !== undefined &&
1106
+ options.debugSources === undefined);
1107
+ // One walk of every body, which the analyses below read instead of
1108
+ // walking the bodies themselves.
1109
+ this.nodeIndex = new IrNodeIndex(mod);
1110
+ this.stackTraces = observesStacks(mod, this.nodeIndex);
1111
+ this.nullableUnions = new NullableUnions(mod, options.debugSources === undefined, this.nodeIndex);
832
1112
  this.mockTimers = this.runtimeFeatures.mockTimers;
833
1113
  this.debug =
834
1114
  options.debugSources === undefined
835
1115
  ? null
836
1116
  : new LlvmDebugInfo(mod.sourceFile, options.debugSources, options.pointerBits, mod.unions, this.nullableUnions.armTypes());
837
1117
  this.constantNumericTables = findConstantNumericTables(mod);
838
- this.initializerBindings = findInitializerBindings(mod);
1118
+ this.initializerBindings = findInitializerBindings(mod, this.nodeIndex);
839
1119
  // One walk finds the dynamic field stores every analysis below consults.
840
- const dynamicStores = dynamicFieldStores(mod);
1120
+ const dynamicStores = dynamicFieldStores(mod, undefined, undefined, this.nodeIndex);
841
1121
  this.int32Slots = analyzeInt32Slots(mod, {
842
1122
  dynamicStores,
843
1123
  initializerBindings: this.initializerBindings,
1124
+ nodes: this.nodeIndex,
844
1125
  });
845
1126
  this.liveViewsReadOnly =
846
1127
  mod.lib === undefined && !dynamicStores.all && dynamicStores.names.size === 0;
847
1128
  this.int32Abis = this.debug === null ? findInt32Abis(mod, this.int32Slots) : new Map();
848
1129
  this.immortalGlobals = new Set(mod.contracts?.immortalGlobals ?? []);
849
1130
  this.programLifetime = new Set(mod.contracts?.programLifetime ?? []);
850
- this.finalFields = analyzeFinalFields(mod, false, dynamicStores);
1131
+ this.finalFields = analyzeFinalFields(mod, false, dynamicStores, this.nodeIndex);
851
1132
  this.sizeType = options.pointerBits === 32 ? "i32" : "i64";
852
1133
  this.ffiExtendNarrowIntegers =
853
1134
  options.wasi === true || ffiExtendsNarrowIntegers(options.targetTriple);
@@ -879,6 +1160,7 @@ export class LlEmitter {
879
1160
  this.emitLibraryIdentity = options.emitLibraryIdentity !== false;
880
1161
  this.runtimeAbiMarker = options.runtimeAbiMarker === true;
881
1162
  this.detachedExit = options.detachedExit === true;
1163
+ this.targetCpu = options.targetCpu;
882
1164
  this.wasmBoundsChecks =
883
1165
  options.wasmBoundsChecks === true ||
884
1166
  wasmBoundsChecks({
@@ -896,7 +1178,7 @@ export class LlEmitter {
896
1178
  this.ffiHasForeignCallback = hasForeignFfiCallback(mod.ffiImports ?? []);
897
1179
  for (const fn of mod.functions)
898
1180
  this.fnByName.set(fn.name, fn);
899
- this.appendedArrayLiterals = findAppendedArrayLiterals(mod);
1181
+ this.appendedArrayLiterals = findAppendedArrayLiterals(mod, this.nodeIndex);
900
1182
  for (const entry of mod.ffiImports ?? []) {
901
1183
  this.ffiByName.set(entry.name, entry);
902
1184
  }
@@ -904,8 +1186,11 @@ export class LlEmitter {
904
1186
  // and per async fiber; WASI, Windows and library builds have none.
905
1187
  const triple = (options.targetTriple ?? "").toLowerCase();
906
1188
  const windows = triple === "" ? process.platform === "win32" : triple.includes("windows");
1189
+ this.publishedTypes = computePublishedTypes(mod, this.nodeIndex);
907
1190
  const mt = computeMayThrow(mod, {
908
1191
  stackChecks: !this.wasi && mod.lib === undefined && !windows,
1192
+ published: this.publishedTypes,
1193
+ nodes: this.nodeIndex,
909
1194
  });
910
1195
  this.mayThrow = mt.fns;
911
1196
  this.workerEntryPolls = mt.workerEntryPolls ?? null;
@@ -914,11 +1199,12 @@ export class LlEmitter {
914
1199
  // runtime moves deep prefix nests to a fresh stack using the guard,
915
1200
  // which Windows lacks.
916
1201
  this.stacklessAsyncAllowed = this.stacklessGenerators && mod.lib === undefined && !windows;
917
- this.publishedTypes = computePublishedTypes(mod);
918
1202
  this.unframedFunctions = this.stackTraces
919
1203
  ? captureFreeFunctions(mod, this.stackChecks, this.publishedTypes)
920
1204
  : new Set();
921
- this.immutableFields = computeImmutableFields(mod, dynamicStores);
1205
+ // One field-mutability answer serves immutable fields and traced shapes.
1206
+ const cycleMutability = computeCycleMutability(mod, hierarchyUnitOfClass(mod), dynamicStores);
1207
+ this.immutableFields = computeImmutableFields(mod, dynamicStores, cycleMutability);
922
1208
  this.constructorFunctions = new Set((mod.classes ?? []).map((c) => `%${c.name}.constructor`));
923
1209
  this.indirectMayThrow = mt.indirect || mod.workers === true;
924
1210
  for (const cls of mod.classes ?? []) {
@@ -951,12 +1237,13 @@ export class LlEmitter {
951
1237
  this.checkedNarrows = new CheckedNarrows(this.fnByName);
952
1238
  this.referenceEffects = new ReferenceEffects(this.fnByName, (call) => this.optionalArrayReads.get(call) !== null, mod.classes ?? []);
953
1239
  if (this.debug === null)
954
- this.referenceWrites = new ReferenceWrites(this.fnByName, mod.classes ?? [], (call) => this.optionalArrayReads.get(call) !== null, new Set((mod.globals ?? []).map((g) => g.id)), { unions: mod.unions, records: mod.records }, this.immutableFields);
1240
+ this.referenceWrites = new ReferenceWrites(this.fnByName, mod.classes ?? [], (call) => this.optionalArrayReads.get(call) !== null, new Set((mod.globals ?? []).map((g) => g.id)), { unions: mod.unions, records: mod.records }, this.immutableFields, this.nodeIndex);
955
1241
  const walkParameters = new Map();
956
1242
  if (this.debug === null) {
957
1243
  const host = {
958
1244
  pointerLocal: (local) => this.plainReference(local.type),
959
1245
  borrowsWithoutOwning: (e) => this.borrowsWithoutOwning(e),
1246
+ nodes: this.nodeIndex,
960
1247
  };
961
1248
  for (const fn of this.fnByName.values()) {
962
1249
  const preserving = this.referenceEffects.functions.has(fn.name);
@@ -1003,7 +1290,7 @@ export class LlEmitter {
1003
1290
  });
1004
1291
  this.lentStringParameters =
1005
1292
  this.debug === null ? findLentStringParameters(this.fnByName, this.callLifetimes) : new Map();
1006
- this.constantCallbacks = findConstantCallbacks(mod, this.callLifetimes);
1293
+ this.constantCallbacks = findConstantCallbacks(mod, this.callLifetimes, this.nodeIndex);
1007
1294
  // Integer clones signal a stack overflow through their result, which
1008
1295
  // needs the single-threaded guard; worker programs also poll for
1009
1296
  // termination, and debug builds and stack traces keep every frame.
@@ -1022,7 +1309,7 @@ export class LlEmitter {
1022
1309
  this.receiverReaders = new AmbientReceiverReaders(this.fnByName);
1023
1310
  this.stackCaptures = new StackCaptures(this.fnByName, this.callLifetimes, this.stackCallbacks);
1024
1311
  this.lazyCaptures = new LazyCaptures(this.fnByName);
1025
- const traced = computeTraced(mod, dynamicStores);
1312
+ const traced = computeTraced(mod, dynamicStores, cycleMutability);
1026
1313
  this.tracedShapes = traced.shapes;
1027
1314
  this.tracedUnions = traced.unions;
1028
1315
  // A shape union's value is whichever record it holds, and the collector
@@ -1046,6 +1333,22 @@ export class LlEmitter {
1046
1333
  }
1047
1334
  }
1048
1335
  this.shapeHost = {
1336
+ // Journal hooks only on emitters that can emit ranges (chunk
1337
+ // emitters, and emitters whose workers take a journal after the
1338
+ // fork), so the host's optional calls cost nothing otherwise.
1339
+ journalAllocated: !this.journaled
1340
+ ? undefined
1341
+ : (name, op, args) => this.journal?.allocated(name, op, args),
1342
+ journalBuilt: !this.journaled ? undefined : () => this.journal?.built(),
1343
+ journalOpened: !this.journaled ? undefined : (op) => this.journal?.opened(op),
1344
+ journalUsed: !this.journaled
1345
+ ? undefined
1346
+ : (name, op, args) => this.journal?.used(name, op, args),
1347
+ journalEntry: !this.journaled
1348
+ ? undefined
1349
+ : (table, key, value) => this.journal?.entry(table, key, value),
1350
+ compactArrayElem: (elem) => this.compactArrayElem(elem),
1351
+ compactRegion: () => this.compactRegion,
1049
1352
  sizeType: this.sizeType,
1050
1353
  cycleBufOffset: this.cycleBufOffset,
1051
1354
  tracedShapes: this.tracedShapes,
@@ -1084,9 +1387,16 @@ export class LlEmitter {
1084
1387
  liveDynRefAdapter: (type) => this.liveDynRefAdapter(type),
1085
1388
  usesDynBuiltinStream: () => this.usesDynBuiltinStream,
1086
1389
  liveDynUnionRefAdapter: (type) => this.liveDynUnionRefAdapter(type),
1390
+ declBoundary: () => this.mod.declBoundary === true,
1087
1391
  dynPromiseAdapter: (type) => this.dynPromiseAdapter(type),
1088
1392
  isErrorClass: (name) => this.classMeta.get(name)?.root.def.name === "%Error",
1089
1393
  classRootOf: (name) => this.classMeta.get(name)?.root.def.name,
1394
+ releasesNothing: (t) => {
1395
+ if (t.kind !== "object" || (this.shapeHost.regions ?? null) !== null)
1396
+ return false;
1397
+ const meta = this.classMeta.get(t.className);
1398
+ return meta !== undefined && programLifetimeClass(this.shapeHost, meta);
1399
+ },
1090
1400
  classSubtypes: (name) => {
1091
1401
  const target = this.classMetaOf(name);
1092
1402
  const intervals = classMembershipIntervals(this.classMeta, target.def.name);
@@ -1119,7 +1429,7 @@ export class LlEmitter {
1119
1429
  if (g.tdz)
1120
1430
  this.tdzGlobals.set(g.id, g.name);
1121
1431
  }
1122
- this.stableGlobals = stableGlobals(mod);
1432
+ this.stableGlobals = stableGlobals(mod, this.nodeIndex);
1123
1433
  // Runtime error, EventEmitter, stream, EventTarget and Event classes
1124
1434
  // have known layouts. Subclasses embed the runtime prefixes from
1125
1435
  // classes.ts.
@@ -1165,21 +1475,18 @@ export class LlEmitter {
1165
1475
  const f = cls.fields[i];
1166
1476
  if (this.inlineUnions.classField(cls.name, f.name))
1167
1477
  return false;
1168
- const t = f.type;
1169
- if (t.kind === "object")
1170
- return isCompact(t.className);
1171
- if (t.kind !== "union")
1172
- return false;
1173
- const single = this.nullableUnions.single(t.unionId);
1174
- if (single !== null)
1175
- return (single.nullTag < 0 &&
1176
- single.arm.kind === "object" &&
1177
- isCompact(single.arm.className));
1178
- const nullable = this.nullableFields.get(cls.name, f.name);
1478
+ if (this.compactRefType(f.type, isCompact))
1479
+ return true;
1480
+ const nullable = f.type.kind === "union" && this.nullableUnions.single(f.type.unionId) === null
1481
+ ? this.nullableFields.get(cls.name, f.name)
1482
+ : null;
1179
1483
  return nullable !== null && isCompact(nullable.arm.className);
1180
1484
  }
1181
1485
  : undefined);
1182
- this.usesCompactRefs = [...this.classMeta.values()].some((m) => m.compressed.some(Boolean));
1486
+ this.compactRegion =
1487
+ mod.lib === undefined &&
1488
+ options.lowRegion === true &&
1489
+ [...this.classMeta.values()].some((m) => m.compact);
1183
1490
  for (const [name, rec] of RUNTIME_ERROR_CLASSES) {
1184
1491
  const meta = this.classMeta.get(name);
1185
1492
  if (!meta)
@@ -1229,7 +1536,6 @@ export class LlEmitter {
1229
1536
  return "ptr";
1230
1537
  switch (t.kind) {
1231
1538
  case "f64":
1232
- case "date":
1233
1539
  return "double";
1234
1540
  case "bool":
1235
1541
  return "i1";
@@ -1333,7 +1639,6 @@ export class LlEmitter {
1333
1639
  this.declare(`declare void @scr_promise_fulfill_void(ptr)`);
1334
1640
  return [` call void @scr_promise_fulfill_void(ptr ${promise})`];
1335
1641
  case "f64":
1336
- case "date":
1337
1642
  this.declare(`declare void @scr_promise_fulfill_f64(ptr, double)`);
1338
1643
  return [` call void @scr_promise_fulfill_f64(ptr ${promise}, double %r)`];
1339
1644
  case "bool":
@@ -1574,7 +1879,7 @@ export class LlEmitter {
1574
1879
  return { name: "", type };
1575
1880
  }
1576
1881
  const t = B.tmp();
1577
- if (type.kind === "f64" || type.kind === "date") {
1882
+ if (type.kind === "f64") {
1578
1883
  this.declare(`declare double @scr_coro_direct_f64(ptr)`);
1579
1884
  B.line(`${t} = call double @scr_coro_direct_f64(ptr ${record})`);
1580
1885
  }
@@ -1777,7 +2082,7 @@ export class LlEmitter {
1777
2082
  B.startBlock(clean);
1778
2083
  if (acc === "ref")
1779
2084
  this.toHeap(value);
1780
- this.arrPush(values, acc, value.name);
2085
+ this.arrPush(values, acc, value.name, elem);
1781
2086
  B.br(next);
1782
2087
  B.startBlock(rejected);
1783
2088
  const promise = B.tmp();
@@ -1891,6 +2196,7 @@ export class LlEmitter {
1891
2196
  };
1892
2197
  this.literals.set(text, lit);
1893
2198
  }
2199
+ this.journal?.entry("literal", text, lit);
1894
2200
  const name = `@${lit.sym}`;
1895
2201
  this.immortalValues.add(name);
1896
2202
  return name;
@@ -1900,6 +2206,7 @@ export class LlEmitter {
1900
2206
  literalEquals(text) {
1901
2207
  const literal = this.internLiteral(text);
1902
2208
  const name = `@sc_streq_${literal.slice("@sc_lit_".length)}`;
2209
+ this.journal?.entry("literalEquality", text, name);
1903
2210
  if (!this.literalEqualities.has(text)) {
1904
2211
  this.literalEqualities.set(text, name);
1905
2212
  if (Buffer.byteLength(text, "utf8") > INLINE_LITERAL_BYTES) {
@@ -1926,6 +2233,7 @@ export class LlEmitter {
1926
2233
  lit = { sym: this.contentSymbol("sc_bigint_", key), value };
1927
2234
  this.bigintLiterals.set(key, lit);
1928
2235
  }
2236
+ this.journal?.entry("bigint", key, { sym: lit.sym, value: lit.value.toString() });
1929
2237
  const name = `@${lit.sym}`;
1930
2238
  this.immortalValues.add(name);
1931
2239
  return name;
@@ -1938,8 +2246,19 @@ export class LlEmitter {
1938
2246
  c = { sym: this.contentSymbol("sc_cs_", text), len: Buffer.byteLength(text, "utf8") };
1939
2247
  this.cstrs.set(text, c);
1940
2248
  }
2249
+ this.journal?.entry("cstr", text, c);
1941
2250
  return `@${c.sym}`;
1942
2251
  }
2252
+ /** The method-id slot for a constant method name (methodIdSlots). */
2253
+ methodIdSlot(name) {
2254
+ let sym = this.methodIdSlots.get(name);
2255
+ if (!sym) {
2256
+ sym = this.contentSymbol("sc_mid_", name);
2257
+ this.methodIdSlots.set(name, sym);
2258
+ }
2259
+ this.journal?.entry("methodIdSlot", name, sym);
2260
+ return `@${sym}`;
2261
+ }
1943
2262
  needBadTag() {
1944
2263
  this.needsBadTag = true;
1945
2264
  }
@@ -1953,6 +2272,7 @@ export class LlEmitter {
1953
2272
  sym = this.contentSymbol("sc_map_ops_", body);
1954
2273
  this.mapOpsConsts.set(body, sym);
1955
2274
  }
2275
+ this.journal?.entry("mapOps", body, sym);
1956
2276
  return `@${sym}`;
1957
2277
  }
1958
2278
  /** The interned immortal instance for a UNIT arm of a union — asserts
@@ -1976,6 +2296,7 @@ export class LlEmitter {
1976
2296
  sym = `sc_unit_${this.unitInstances.size}`;
1977
2297
  this.unitInstances.set(key, sym);
1978
2298
  }
2299
+ this.journal?.entry("unit", key, sym);
1979
2300
  const name = `@${sym}`;
1980
2301
  this.immortalValues.add(name);
1981
2302
  return name;
@@ -1988,6 +2309,7 @@ export class LlEmitter {
1988
2309
  sym = `sc_retype_guard_${this.retypeGuards.size}`;
1989
2310
  this.retypeGuards.set(unionId, sym);
1990
2311
  }
2312
+ this.journal?.entry("retype", unionId, sym);
1991
2313
  return `@${sym}`;
1992
2314
  }
1993
2315
  /** The immortal ABSENT state of an undefined-armed record field slot
@@ -2006,6 +2328,7 @@ export class LlEmitter {
2006
2328
  sym = `sc_absent_${this.absentInstances.size}`;
2007
2329
  this.absentInstances.set(unionId, sym);
2008
2330
  }
2331
+ this.journal?.entry("absent", unionId, sym);
2009
2332
  const name = `@${sym}`;
2010
2333
  this.immortalValues.add(name);
2011
2334
  return name;
@@ -2046,6 +2369,7 @@ export class LlEmitter {
2046
2369
  return out;
2047
2370
  }
2048
2371
  declare(decl) {
2372
+ this.journal?.entry("decl", decl, null);
2049
2373
  this.decls.add(decl);
2050
2374
  }
2051
2375
  needOom() {
@@ -2912,8 +3236,12 @@ export class LlEmitter {
2912
3236
  // ── union plumbing ──────────────────────────────────────────────────────
2913
3237
  /** A union value's tag (i32): the box's tag word, or the NULL test of a
2914
3238
  * nullable union's pointer. */
3239
+ /** A box's tag and payload words are written only where the box is
3240
+ * built (runtime constructors and untagged stack stores), so their loads
3241
+ * carry their own alias tags: element and field stores cannot change
3242
+ * them, and loops keep them hoisted. */
2915
3243
  unionTag(uName, unionId) {
2916
- return emitUnionTag(this.B, this.nullableUnions.get(unionId), uName);
3244
+ return emitUnionTag(this.B, this.nullableUnions.get(unionId), uName, this.memoryAliasAttachment("union.tag"));
2917
3245
  }
2918
3246
  /** Guard for helpers that build or read a union's `%ScrUnion` box
2919
3247
  * directly (library-shaped unions with fixed arms): a nullable union
@@ -2925,7 +3253,7 @@ export class LlEmitter {
2925
3253
  /** The BORROWED payload pointer of a ref arm (scr_union_peek inlined —
2926
3254
  * the runtime's is a static inline); a nullable union is its payload. */
2927
3255
  unionPeek(uName, unionId) {
2928
- return emitUnionPeek(this.B, this.nullableUnions.get(unionId), uName);
3256
+ return emitUnionPeek(this.B, this.nullableUnions.get(unionId), uName, this.memoryAliasAttachment("union.payload"));
2929
3257
  }
2930
3258
  /** Emits `switch` over a union's tag with one block per arm; each arm
2931
3259
  * body must TERMINATE its block (the callers branch to a join). The
@@ -3056,6 +3384,24 @@ export class LlEmitter {
3056
3384
  this.compressedFieldPtrs.add(p);
3057
3385
  return { ptr: p, type, inline: this.inlineUnions.classField(className, field), compressed };
3058
3386
  }
3387
+ /** Whether values of `t` are NULL or a compact class instance: `C`,
3388
+ * `C | undefined` or `C | null` for a compact class `C`. `C | null |
3389
+ * undefined` is not: its null is a sentinel outside the region. */
3390
+ compactRefType(t, isCompact = (name) => this.classMeta.get(name)?.compact === true) {
3391
+ if (t.kind === "object")
3392
+ return isCompact(t.className);
3393
+ if (t.kind !== "union")
3394
+ return false;
3395
+ const single = this.nullableUnions.single(t.unionId);
3396
+ return (single !== null &&
3397
+ single.nullTag < 0 &&
3398
+ single.arm.kind === "object" &&
3399
+ isCompact(single.arm.className));
3400
+ }
3401
+ /** Whether arrays of `elem` hold 32-bit references (SCR_ELEM_CREF). */
3402
+ compactArrayElem(elem) {
3403
+ return this.compactRegion && this.compactRefType(elem);
3404
+ }
3059
3405
  /** Loads the reference a field pointer addresses: a pointer, or the
3060
3406
  * decoded 32-bit reference of a compressed field (compressedFieldPtrs).
3061
3407
  * `tagged`: the load carries the field's alias tags. */
@@ -3104,6 +3450,7 @@ export class LlEmitter {
3104
3450
  const meta = this.classMetaOf(className);
3105
3451
  this.classObjs.set(className, { nameSym: this.internLiteral(classJsName(meta.def)) });
3106
3452
  }
3453
+ this.journal?.entry("classObj", className, this.classObjs.get(className));
3107
3454
  return mangleClassObj(className);
3108
3455
  }
3109
3456
  // ── record plumbing ─────────────────────────────────────────────────────
@@ -3292,12 +3639,12 @@ export class LlEmitter {
3292
3639
  // ── bindings ────────────────────────────────────────────────────────────
3293
3640
  /** A binding's storage: a module global, a plain local slot, or a boxed
3294
3641
  * local (the slot holds the capture BOX; access goes through it). */
3295
- matchBytesLoopVersion(s, counted) {
3296
- const fn = this.bytesLoopFunction;
3642
+ matchBytesLoopVersion(s, counted, paired = null) {
3643
+ const fn = LOOPS.of(this).bytesLoopFunction;
3297
3644
  if (!fn)
3298
3645
  return null;
3299
- this.bytesLoopEntries ??= findInitializedByteLoopBindings(fn);
3300
- const initialized = this.bytesLoopEntries.get(s);
3646
+ LOOPS.of(this).bytesLoopEntries ??= findInitializedByteLoopBindings(fn);
3647
+ const initialized = LOOPS.of(this).bytesLoopEntries.get(s);
3301
3648
  if (!initialized)
3302
3649
  return null;
3303
3650
  const invariantGlobals = new Set(this.stableGlobals);
@@ -3312,7 +3659,8 @@ export class LlEmitter {
3312
3659
  proven: this.bytesBounds,
3313
3660
  workers: this.mod.workers === true,
3314
3661
  owned: this.bytesOwned,
3315
- });
3662
+ scalarStrings: new Set(this.stringSlices.keys()),
3663
+ }, paired);
3316
3664
  }
3317
3665
  /** The alias tag of a whole-slot load of a binding (module globals only). */
3318
3666
  slotAlias(id) {
@@ -3456,7 +3804,7 @@ export class LlEmitter {
3456
3804
  const acc = boxAccess(t);
3457
3805
  const cell = B.tmp();
3458
3806
  B.line(`${cell} = ${arrNewCall(this.shapeHost, t, "1")} ; TDZ cell`);
3459
- this.arrPush(cell, acc === "bool" ? "bool" : "f64", value);
3807
+ this.arrPush(cell, acc === "bool" ? "bool" : "f64", value, null);
3460
3808
  this.declare(`declare void @scr_box_set_ref(ptr, ptr)`);
3461
3809
  B.line(`call void @scr_box_set_ref(ptr ${box}, ptr ${cell})`);
3462
3810
  }
@@ -3746,6 +4094,171 @@ export class LlEmitter {
3746
4094
  emitFunction(fn) {
3747
4095
  return emitFunction(this, fn);
3748
4096
  }
4097
+ /** What this range emitter (chunkEmitter) hands the merging emitter, as
4098
+ * plain data a worker process can write: its journal and the sets and
4099
+ * flags its functions set. */
4100
+ chunkResult() {
4101
+ return {
4102
+ entries: this.journal.entries,
4103
+ flags: {
4104
+ usesCoroutines: this.usesCoroutines,
4105
+ usesTimers: this.usesTimers,
4106
+ usesGenSlots: this.usesGenSlots,
4107
+ needsUnionNone: this.needsUnionNone,
4108
+ needsNullableAbsent: this.needsNullableAbsent,
4109
+ needsOom: this.needsOom,
4110
+ needsBadTag: this.needsBadTag,
4111
+ needsBadKey: this.needsBadKey,
4112
+ needsRetainBox: this.needsRetainBox,
4113
+ },
4114
+ publishedNamesSym: this.publishedNamesSym,
4115
+ rcHelpers: this.rcHelpers === null ? [] : [...this.rcHelpers],
4116
+ immortalValues: [...this.immortalValues],
4117
+ fnValues: [...this.fnValues],
4118
+ arraySearchKinds: [...this.arraySearchKinds],
4119
+ recordCloneShapes: [...this.recordCloneShapes],
4120
+ awaitCallees: [...this.awaitCallees],
4121
+ adoptCallees: [...this.adoptCallees],
4122
+ directAwaitCallees: [...this.directAwaitCallees],
4123
+ inlineAwaitCallees: [...this.inlineAwaitCallees],
4124
+ };
4125
+ }
4126
+ /** Merges a range emitter's result (chunkResult) into this emitter, in
4127
+ * the range's order, and answers the rename of the range's text to this
4128
+ * emitter's numbered helpers. Ranges merge in function order. */
4129
+ mergeChunk(chunk) {
4130
+ const names = new Map();
4131
+ const tags = new Map();
4132
+ // The range's helpers and table entries first, in its order; then the
4133
+ // sets and flags, which replayed definitions must find as serial
4134
+ // emission left them (a helper set guards the declarations its first
4135
+ // request adds).
4136
+ replayJournal(this, chunk.entries, names, tags);
4137
+ const flags = chunk.flags;
4138
+ this.usesCoroutines ||= flags.usesCoroutines;
4139
+ this.usesTimers ||= flags.usesTimers;
4140
+ this.usesGenSlots ||= flags.usesGenSlots;
4141
+ this.needsUnionNone ||= flags.needsUnionNone;
4142
+ this.needsNullableAbsent ||= flags.needsNullableAbsent;
4143
+ this.needsOom ||= flags.needsOom;
4144
+ this.needsBadTag ||= flags.needsBadTag;
4145
+ this.needsBadKey ||= flags.needsBadKey;
4146
+ this.needsRetainBox ||= flags.needsRetainBox;
4147
+ this.publishedNamesSym ??= chunk.publishedNamesSym;
4148
+ if (this.rcHelpers !== null)
4149
+ for (const key of chunk.rcHelpers)
4150
+ this.rcHelpers.add(key);
4151
+ for (const name of chunk.immortalValues)
4152
+ this.immortalValues.add(name);
4153
+ for (const name of chunk.fnValues)
4154
+ this.fnValues.add(name);
4155
+ for (const kind of chunk.arraySearchKinds)
4156
+ this.arraySearchKinds.add(kind);
4157
+ for (const shapeId of chunk.recordCloneShapes)
4158
+ this.recordCloneShapes.add(shapeId);
4159
+ for (const name of chunk.awaitCallees)
4160
+ this.awaitCallees.add(name);
4161
+ for (const name of chunk.adoptCallees)
4162
+ this.adoptCallees.add(name);
4163
+ for (const name of chunk.directAwaitCallees)
4164
+ this.directAwaitCallees.add(name);
4165
+ for (const name of chunk.inlineAwaitCallees)
4166
+ this.inlineAwaitCallees.add(name);
4167
+ return renameChunk(names, tags);
4168
+ }
4169
+ /** Adds a content-named constant a chunk interned. Its symbol is this
4170
+ * emitter's own: a digest collision retries in first-use order, which a
4171
+ * chunk alone does not know. */
4172
+ addContentEntry(into, key, entry, prefix, names) {
4173
+ let own = into.get(key);
4174
+ if (own === undefined) {
4175
+ own = { ...entry, sym: this.contentSymbol(prefix, key) };
4176
+ into.set(key, own);
4177
+ }
4178
+ if (own.sym !== entry.sym)
4179
+ names.set(entry.sym, own.sym);
4180
+ }
4181
+ /** Applies a chunk's table entry (EmitJournal.entry) at its place in the
4182
+ * chunk's order: a key this emitter lacks is added, numbered after its
4183
+ * own entries where the table numbers them, and the chunk's name for it
4184
+ * is renamed to this emitter's. */
4185
+ applyJournalEntry(table, key, value, names, tags) {
4186
+ switch (table) {
4187
+ case "decl":
4188
+ this.decls.add(key);
4189
+ return;
4190
+ case "literal":
4191
+ this.addContentEntry(this.literals, key, value, "sc_lit_", names);
4192
+ return;
4193
+ case "literalEquality":
4194
+ addEntry(this.literalEqualities, key, value);
4195
+ return;
4196
+ case "bigint":
4197
+ {
4198
+ const entry = value;
4199
+ this.addContentEntry(this.bigintLiterals, key, { sym: entry.sym, value: BigInt(entry.value) }, "sc_bigint_", names);
4200
+ }
4201
+ return;
4202
+ case "cstr":
4203
+ this.addContentEntry(this.cstrs, key, value, "sc_cs_", names);
4204
+ return;
4205
+ case "mapOps": {
4206
+ let own = this.mapOpsConsts.get(key);
4207
+ if (own === undefined) {
4208
+ own = this.contentSymbol("sc_map_ops_", key);
4209
+ this.mapOpsConsts.set(key, own);
4210
+ }
4211
+ if (own !== value)
4212
+ names.set(value, own);
4213
+ return;
4214
+ }
4215
+ case "methodIdSlot": {
4216
+ let own = this.methodIdSlots.get(key);
4217
+ if (own === undefined) {
4218
+ own = this.contentSymbol("sc_mid_", key);
4219
+ this.methodIdSlots.set(key, own);
4220
+ }
4221
+ if (own !== value)
4222
+ names.set(value, own);
4223
+ return;
4224
+ }
4225
+ case "classObj":
4226
+ addEntry(this.classObjs, key, value);
4227
+ return;
4228
+ case "retainWrapper":
4229
+ addEntry(this.nullableUnions.retainWrappers, key, value);
4230
+ return;
4231
+ case "unit":
4232
+ return addNumbered(this.unitInstances, key, value, "sc_unit_", names);
4233
+ case "absent":
4234
+ return addNumbered(this.absentInstances, key, value, "sc_absent_", names);
4235
+ case "retype":
4236
+ return addNumbered(this.retypeGuards, key, value, "sc_retype_guard_", names);
4237
+ case "slots":
4238
+ return addNumbered(this.threadSlotsBlocks, key, value, "@sc_slots_", names);
4239
+ case "regex":
4240
+ return addNumberedSymbol(this.regexInstances, key, value, "sc_re_", names);
4241
+ case "templateStrings":
4242
+ return addNumberedSymbol(this.templateStringsInstances, key, value, "sc_tsa_", names);
4243
+ case "tag": {
4244
+ let own = this.fieldAliasTags.get(key);
4245
+ if (own === undefined) {
4246
+ own = 2 + this.fieldAliasTags.size * 2;
4247
+ this.fieldAliasTags.set(key, own);
4248
+ }
4249
+ if (own !== value)
4250
+ tags.set(value, own);
4251
+ return;
4252
+ }
4253
+ default:
4254
+ throw new InternalCompilerError(`llvm emitter bug: no journal table ${table}`);
4255
+ }
4256
+ }
4257
+ /** An emitter for a range of this module's functions: the same facts,
4258
+ * empty module-level tables, and a journal of what the range adds. */
4259
+ chunkEmitter() {
4260
+ return new LlEmitter(this.mod, { ...this.targetOptions, functionChunks: 1 }, new EmitJournal());
4261
+ }
3749
4262
  /** The double-ABI entry of a function with an i32 entry: every caller
3750
4263
  * that is not a direct call (closures, dispatch, adapters, the runtime)
3751
4264
  * enters here. A pending exception passes through to its caller. */
@@ -4341,11 +4854,15 @@ export class LlEmitter {
4341
4854
  const loop = s.kind === "while" || s.kind === "doWhile" || s.kind === "for" || s.kind === "forOf";
4342
4855
  if (loop)
4343
4856
  this.loopDepth++;
4857
+ // An int32 kind loop's fast-copy write leaves for its resume point.
4858
+ const kindResume = this.int32KindResume;
4859
+ this.int32KindResume = this.int32Kinds?.resume.get(s) ?? null;
4344
4860
  try {
4345
4861
  this.emitStmtBody(s);
4346
4862
  }
4347
4863
  finally {
4348
4864
  this.B.debugLocation = previous;
4865
+ this.int32KindResume = kindResume;
4349
4866
  if (loop)
4350
4867
  this.loopDepth--;
4351
4868
  }
@@ -4669,6 +5186,7 @@ export class LlEmitter {
4669
5186
  sym = `@sc_slots_${this.threadSlotsBlocks.size}`;
4670
5187
  this.threadSlotsBlocks.set(name, sym);
4671
5188
  }
5189
+ this.journal?.entry("slots", name, sym);
4672
5190
  return sym;
4673
5191
  }
4674
5192
  /** InternTable's runtime calls (scr_itable.c). Table and entry handles
@@ -4822,6 +5340,20 @@ export class LlEmitter {
4822
5340
  return this.publishWalkersCache;
4823
5341
  const byPre = [...this.classMeta.values()].sort((a, b) => a.pre - b.pre);
4824
5342
  this.publishWalkersCache = new PublishWalkers({
5343
+ // Journal hooks only on emitters that can emit ranges (chunk
5344
+ // emitters, and emitters whose workers take a journal after the
5345
+ // fork), so the host's optional calls cost nothing otherwise.
5346
+ journalAllocated: !this.journaled
5347
+ ? undefined
5348
+ : (name, op, args) => this.journal?.allocated(name, op, args),
5349
+ journalBuilt: !this.journaled ? undefined : () => this.journal?.built(),
5350
+ journalOpened: !this.journaled ? undefined : (op) => this.journal?.opened(op),
5351
+ journalUsed: !this.journaled
5352
+ ? undefined
5353
+ : (name, op, args) => this.journal?.used(name, op, args),
5354
+ journalEntry: !this.journaled
5355
+ ? undefined
5356
+ : (table, key, value) => this.journal?.entry(table, key, value),
4825
5357
  declare: (decl) => this.declare(decl),
4826
5358
  cstr: (text) => this.cstr(text),
4827
5359
  sizeType: this.sizeType,
@@ -4906,6 +5438,33 @@ export class LlEmitter {
4906
5438
  B.startBlock(cold);
4907
5439
  return ok;
4908
5440
  }
5441
+ /** Branches on "the array `arr` is frozen" (SCR_ARR_FROZEN in its storage
5442
+ * flags, scr_array.h), or published too when `published`; like
5443
+ * emitPublishedTest, leaves the builder in the cold block and answers the
5444
+ * continuation label. */
5445
+ emitFrozenArrayTest(arr, published) {
5446
+ const B = this.B;
5447
+ const sparep = B.tmp(), spare = B.tmp(), bit = B.tmp();
5448
+ let frozen = B.tmp();
5449
+ B.line(`${sparep} = getelementptr inbounds %ScrArr, ptr ${arr}, i32 0, i32 ${SCR_ARR_FIELD.spare}`);
5450
+ B.line(`${spare} = load i16, ptr ${sparep}`);
5451
+ B.line(`${bit} = and i16 ${spare}, ${SCR_ARR_FROZEN}`);
5452
+ B.line(`${frozen} = icmp ne i16 ${bit}, 0`);
5453
+ if (published) {
5454
+ const rc = B.tmp(), immortal = B.tmp(), either = B.tmp();
5455
+ B.line(`${rc} = load ${this.sizeType}, ptr ${arr}`);
5456
+ B.line(`${immortal} = icmp eq ${this.sizeType} ${rc}, -1`);
5457
+ B.line(`${either} = or i1 ${frozen}, ${immortal}`);
5458
+ frozen = either;
5459
+ }
5460
+ this.declare(`declare i1 @llvm.expect.i1(i1, i1)`);
5461
+ const expected = B.tmp();
5462
+ B.line(`${expected} = call i1 @llvm.expect.i1(i1 ${frozen}, i1 false)`);
5463
+ const cold = B.newLabel("arr.frozen"), ok = B.newLabel("arr.ok");
5464
+ B.condBr(expected, cold, ok);
5465
+ B.startBlock(cold);
5466
+ return ok;
5467
+ }
4909
5468
  publishedNamesSym = null;
4910
5469
  /** The class-name table the hierarchy field guards index by preorder. */
4911
5470
  publishedClassNamesDefs() {
@@ -4960,14 +5519,24 @@ export class LlEmitter {
4960
5519
  }
4961
5520
  /** The frozen-array guard (scr_throw_published_array's ops): `index` and
4962
5521
  * `count` are doubles (the written index, the argument count). */
4963
- emitPublishedArrayGuard(arr, arrType, op, index = f64Lit(0), count = f64Lit(0)) {
4964
- if (this.publishedTypes?.containerGuarded(arrType) !== true)
5522
+ emitPublishedArrayGuard(arr, arrType, op, index = f64Lit(0), count = f64Lit(0), third = null) {
5523
+ const published = this.publishedTypes;
5524
+ if (published?.containerGuarded(arrType) !== true)
4965
5525
  return;
4966
5526
  const B = this.B;
4967
- const ok = this.emitPublishedTest(arr);
4968
- this.declare(`declare zeroext i1 @scr_throw_published_array(i32, ptr, double, double)`);
5527
+ const guards = published.arrayGuards(arrType);
5528
+ const ok = guards.frozen
5529
+ ? this.emitFrozenArrayTest(arr, guards.published)
5530
+ : this.emitPublishedTest(arr);
4969
5531
  const threw = B.tmp();
4970
- B.line(`${threw} = call zeroext i1 @scr_throw_published_array(i32 ${op}, ptr ${arr}, double ${index}, double ${count})`);
5532
+ if (third === null) {
5533
+ this.declare(`declare zeroext i1 @scr_throw_published_array(i32, ptr, double, double)`);
5534
+ B.line(`${threw} = call zeroext i1 @scr_throw_published_array(i32 ${op}, ptr ${arr}, double ${index}, double ${count})`);
5535
+ }
5536
+ else {
5537
+ this.declare(`declare zeroext i1 @scr_throw_published_array_range(i32, ptr, double, double, double)`);
5538
+ B.line(`${threw} = call zeroext i1 @scr_throw_published_array_range(i32 ${op}, ptr ${arr}, double ${index}, double ${count}, double ${third})`);
5539
+ }
4971
5540
  const unwind = B.newLabel("pub.throw");
4972
5541
  B.condBr(threw, unwind, ok);
4973
5542
  B.startBlock(unwind);
@@ -5253,11 +5822,25 @@ export class LlEmitter {
5253
5822
  return (this.jsIcSitesMemo ??= new JsIcSites(this.mod));
5254
5823
  }
5255
5824
  jsIcSite() {
5256
- return `@sc_js_ic_${this.jsIcSiteCount++}`;
5825
+ const name = `@sc_js_ic_${this.jsIcSiteCount++}`;
5826
+ this.journal?.site(name, "jsIcSite");
5827
+ return name;
5257
5828
  }
5258
5829
  /** A fresh read-site cache for one constant-key dyn read. */
5259
5830
  dynReadIcSite() {
5260
- return `@sc_dyn_read_ic_${this.dynReadIcSites++}`;
5831
+ const name = `@sc_dyn_read_ic_${this.dynReadIcSites++}`;
5832
+ this.journal?.site(name, "dynReadIcSite");
5833
+ return name;
5834
+ }
5835
+ /** A fresh speculative loop site: the global that counts its bailing
5836
+ * entries in a row. */
5837
+ speculativeLoopSite() {
5838
+ const name = `@sc_spec_bails_${this.speculativeLoopSites++}`;
5839
+ this.journal?.site(name, "speculativeLoopSite");
5840
+ this.journal?.opened("speculativeLoopSite");
5841
+ this.declare(`${name} = internal global i8 0`);
5842
+ this.journal?.built();
5843
+ return name;
5261
5844
  }
5262
5845
  dynKind(d) {
5263
5846
  return dynKind(this, d);
@@ -5334,8 +5917,8 @@ export class LlEmitter {
5334
5917
  tagInSet(uName, unionId, tags) {
5335
5918
  return tagInSet(this, uName, unionId, tags);
5336
5919
  }
5337
- arrPush(arr, acc, value) {
5338
- return arrPush(this, arr, acc, value);
5920
+ arrPush(arr, acc, value, element) {
5921
+ return arrPush(this, arr, acc, value, element);
5339
5922
  }
5340
5923
  emitArrayCopyLoop(dst, src, acc) {
5341
5924
  return emitArrayCopyLoop(this, dst, src, acc);
@@ -5534,4 +6117,64 @@ export function adoptingAwaitOf(value) {
5534
6117
  });
5535
6118
  return found;
5536
6119
  }
6120
+ /** Adds `key` to `into` when it lacks it. */
6121
+ function addEntry(into, key, value) {
6122
+ if (!into.has(key))
6123
+ into.set(key, value);
6124
+ }
6125
+ /** Adds `key` to a numbered table when it lacks it, numbering it after the
6126
+ * table's own entries (`prefix` and its index), and records the rename of
6127
+ * the chunk's `name` for it. */
6128
+ function addNumbered(into, key, name, prefix, names) {
6129
+ let own = into.get(key);
6130
+ if (own === undefined) {
6131
+ own = `${prefix}${into.size}`;
6132
+ into.set(key, own);
6133
+ }
6134
+ if (own !== name)
6135
+ names.set(name.replace(/^@/, ""), own.replace(/^@/, ""));
6136
+ }
6137
+ /** addNumbered for entries that keep their numbered name in `sym`. */
6138
+ function addNumberedSymbol(into, key, entry, prefix, names) {
6139
+ let own = into.get(key);
6140
+ if (own === undefined) {
6141
+ own = { ...entry, sym: `${prefix}${into.size}` };
6142
+ into.set(key, own);
6143
+ }
6144
+ if (own.sym !== entry.sym)
6145
+ names.set(entry.sym, own.sym);
6146
+ }
6147
+ registerReplay("jsIcSite", (emitter) => emitter.jsIcSite());
6148
+ registerReplay("dynReadIcSite", (emitter) => emitter.dynReadIcSite());
6149
+ registerReplay("speculativeLoopSite", (emitter) => emitter.speculativeLoopSite());
6150
+ for (const op of [
6151
+ "dyn.collectionDynOps",
6152
+ "dyn.dynMatchHelper",
6153
+ "dyn.jsonSchema",
6154
+ "dyn.recordNameTable",
6155
+ "dyn.jsonParseHelper",
6156
+ "dyn.dynCheckHelper",
6157
+ "dyn.toDynHelper",
6158
+ "dyn.promiseDynAdapterHelper",
6159
+ "dyn.dynFuncThunkHelper",
6160
+ "dyn.dynFuncBoxHelper",
6161
+ "dyn.dynFuncAdapterHelper",
6162
+ "dyn.dynToStrHelper",
6163
+ "dyn.dynIterNHelper",
6164
+ "dyn.dynDestrCheckHelper",
6165
+ "dyn.dynKeyGetHelper",
6166
+ "dyn.dynComputedKeyGetHelper",
6167
+ "dyn.caughtToDynHelper",
6168
+ "dyn.messageListenerHelper",
6169
+ "dyn.messageReaderHelper",
6170
+ ])
6171
+ registerReplay(op, (emitter, args) => emitter.dyn.replayHelper(op, args));
6172
+ for (const op of [
6173
+ "walkers.jsonWriteHelper",
6174
+ "walkers.recordFieldWriter",
6175
+ "walkers.unionJoinHelper",
6176
+ ])
6177
+ registerReplay(op, (emitter, args) => emitter.walkers.replayHelper(op, args));
6178
+ for (const op of ["publish.walker", "publish.refusal"])
6179
+ registerReplay(op, (emitter, args) => emitter.publishWalkers.replayHelper(op, args));
5537
6180
  //# sourceMappingURL=emitter.js.map