@geastack/compiler 1.0.36 → 1.0.38

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 (544) hide show
  1. package/dist/cli-emit.js +5 -0
  2. package/dist/cli.js +10 -0
  3. package/dist/compiler.d.ts +10 -3
  4. package/dist/compiler.js +364 -224
  5. package/dist/conversion/build.d.ts +13 -1
  6. package/dist/conversion/build.js +336 -141
  7. package/dist/conversion/graph-validation.d.ts +7 -2
  8. package/dist/conversion/graph-validation.js +36 -22
  9. package/dist/conversion/native-sum.js +106 -17
  10. package/dist/diagnostics/sweep.js +1 -1
  11. package/dist/ir/callable-class-flow.d.ts +0 -11
  12. package/dist/ir/callable-class-flow.js +970 -169
  13. package/dist/ir/certificate.d.ts +1 -1
  14. package/dist/ir/certificate.js +12 -1
  15. package/dist/ir/certify/carrier-keys.d.ts +17 -1
  16. package/dist/ir/certify/carrier-keys.js +35 -2
  17. package/dist/ir/certify/function-source.js +2 -1
  18. package/dist/ir/certify/has-property-key.d.ts +6 -0
  19. package/dist/ir/certify/has-property-key.js +8 -1
  20. package/dist/ir/certify/property-access-keys.js +2 -1
  21. package/dist/ir/certify/runtime-helper.js +2 -1
  22. package/dist/ir/construction-only-fields.d.ts +35 -2
  23. package/dist/ir/construction-only-fields.js +100 -0
  24. package/dist/ir/emission-representations.d.ts +2 -2
  25. package/dist/ir/emission-representations.js +9 -3
  26. package/dist/ir/generic-call-entry.d.ts +3 -1
  27. package/dist/ir/logical-receivers.js +29 -1
  28. package/dist/ir/lower-completion.js +11 -6
  29. package/dist/ir/lower-destructuring.js +3 -2
  30. package/dist/ir/native-host-method-reads.d.ts +5 -0
  31. package/dist/ir/native-host-method-reads.js +30 -21
  32. package/dist/ir/operation-conversions.js +4 -1
  33. package/dist/ir/publish-conversion-recipes.js +12 -1
  34. package/dist/plugins/apple/jsx.js +1 -1
  35. package/dist/plugins/gea/component-classes.js +1 -1
  36. package/dist/plugins/gea/component-inline.js +1 -1
  37. package/dist/plugins/gea/contract.d.ts +1 -1
  38. package/dist/plugins/gea/contract.js +1 -1
  39. package/dist/plugins/gea/host.js +27 -1
  40. package/dist/plugins/gea/lower.js +8 -1
  41. package/dist/plugins/gea/producer.js +1 -1
  42. package/dist/plugins/gea/reactive-slots.d.ts +1 -1
  43. package/dist/plugins/gea/reactive-slots.js +1 -1
  44. package/dist/plugins/load.js +51 -22
  45. package/dist/preflight/run.d.ts +12 -1
  46. package/dist/preflight/run.js +65 -29
  47. package/dist/projection/native-callable-data.js +2 -1
  48. package/dist/representation/plan.js +102 -4
  49. package/dist/semantics/alias-this-field-declaration-transform.js +1 -1
  50. package/dist/semantics/ambient-type-realization-transform.js +1 -1
  51. package/dist/semantics/ambient.d.ts +1 -1
  52. package/dist/semantics/ambient.js +1 -1
  53. package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +1 -1
  54. package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +1 -1
  55. package/dist/semantics/call-invalidated-narrowing.d.ts +1 -1
  56. package/dist/semantics/call-invalidated-narrowing.js +4 -2
  57. package/dist/semantics/callable-own-data-slots.d.ts +6 -0
  58. package/dist/semantics/callable-own-data-slots.js +177 -101
  59. package/dist/semantics/class-alias.d.ts +1 -1
  60. package/dist/semantics/class-alias.js +1 -1
  61. package/dist/semantics/class-heritage.d.ts +1 -1
  62. package/dist/semantics/class-heritage.js +1 -1
  63. package/dist/semantics/commonjs-wrapper.d.ts +4 -3
  64. package/dist/semantics/commonjs-wrapper.js +50 -7
  65. package/dist/semantics/constructor-function-class-source-transform.js +1 -1
  66. package/dist/semantics/constructor-slot-subclasses.d.ts +1 -1
  67. package/dist/semantics/constructor-slot-subclasses.js +1 -1
  68. package/dist/semantics/declaration-overlay-transform.js +3 -2
  69. package/dist/semantics/declared-integers.d.ts +1 -1
  70. package/dist/semantics/declared-integers.js +1 -1
  71. package/dist/semantics/define-property-source-transform.js +1 -1
  72. package/dist/semantics/diagnostic-source-preparation.d.ts +1 -1
  73. package/dist/semantics/documentation-ranges.d.ts +1 -1
  74. package/dist/semantics/documentation-ranges.js +1 -1
  75. package/dist/semantics/dynamic-fallback.d.ts +1 -1
  76. package/dist/semantics/dynamic-fallback.js +1 -1
  77. package/dist/semantics/frontend-timing.js +19 -0
  78. package/dist/semantics/frontend.d.ts +2 -2
  79. package/dist/semantics/frontend.js +127 -54
  80. package/dist/semantics/host-declaration-provenance.d.ts +1 -1
  81. package/dist/semantics/host-methods.d.ts +1 -1
  82. package/dist/semantics/host-methods.js +1 -1
  83. package/dist/semantics/host-protocols.d.ts +1 -1
  84. package/dist/semantics/host-protocols.js +1 -1
  85. package/dist/semantics/inherited-accessor.d.ts +1 -1
  86. package/dist/semantics/inherited-accessor.js +1 -1
  87. package/dist/semantics/interface-families.d.ts +1 -1
  88. package/dist/semantics/interface-families.js +1 -1
  89. package/dist/semantics/interface-implementors.d.ts +1 -1
  90. package/dist/semantics/interface-implementors.js +1 -1
  91. package/dist/semantics/jsdoc-namepath-transform.js +1 -1
  92. package/dist/semantics/jsx-runtime-provider.d.ts +1 -1
  93. package/dist/semantics/jsx-runtime-provider.js +1 -1
  94. package/dist/semantics/known-caller-predicate-parameters.d.ts +1 -1
  95. package/dist/semantics/known-caller-predicate-parameters.js +1 -1
  96. package/dist/semantics/model/edges.d.ts +124 -0
  97. package/dist/semantics/model/edges.js +192 -0
  98. package/dist/semantics/model/graph.d.ts +26 -2
  99. package/dist/semantics/model/graph.js +54 -0
  100. package/dist/semantics/model/sealed-facts.d.ts +19 -0
  101. package/dist/semantics/model/sealed-facts.js +221 -0
  102. package/dist/semantics/model/selected-signature.d.ts +1 -1
  103. package/dist/semantics/model/selected-signature.js +1 -1
  104. package/dist/semantics/module-resolution.d.ts +1 -1
  105. package/dist/semantics/module-resolution.js +1 -1
  106. package/dist/semantics/native-function-signatures.d.ts +1 -1
  107. package/dist/semantics/native-function-signatures.js +1 -1
  108. package/dist/semantics/native-object-data-slots.js +20 -4
  109. package/dist/semantics/new-callee-class-tag-source-transform.js +1 -1
  110. package/dist/semantics/node-project.d.ts +1 -1
  111. package/dist/semantics/node-project.js +1 -1
  112. package/dist/semantics/node-source-hooks.js +1 -1
  113. package/dist/semantics/normalize/absent-globals.d.ts +1 -1
  114. package/dist/semantics/normalize/absent-globals.js +1 -1
  115. package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
  116. package/dist/semantics/normalize/any-cast-member-call.js +1 -1
  117. package/dist/semantics/normalize/arguments-objects.d.ts +1 -1
  118. package/dist/semantics/normalize/arguments-objects.js +1 -1
  119. package/dist/semantics/normalize/asserted-argument-arms.d.ts +1 -1
  120. package/dist/semantics/normalize/asserted-argument-arms.js +1 -1
  121. package/dist/semantics/normalize/asserted-arm-absence.d.ts +1 -1
  122. package/dist/semantics/normalize/asserted-arm-absence.js +1 -1
  123. package/dist/semantics/normalize/assignment-patterns.d.ts +1 -1
  124. package/dist/semantics/normalize/assignment-patterns.js +1 -1
  125. package/dist/semantics/normalize/bag-absence.d.ts +1 -1
  126. package/dist/semantics/normalize/bag-absence.js +1 -1
  127. package/dist/semantics/normalize/binding-fixpoint.js +9 -2
  128. package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +1 -1
  129. package/dist/semantics/normalize/bivariant-slot-parameter.js +1 -1
  130. package/dist/semantics/normalize/callable-data-write.d.ts +1 -1
  131. package/dist/semantics/normalize/callable-data-write.js +1 -1
  132. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +1 -1
  133. package/dist/semantics/normalize/callback-parameter-contracts.js +1 -1
  134. package/dist/semantics/normalize/cells/agreement.d.ts +18 -1
  135. package/dist/semantics/normalize/cells/agreement.js +8 -0
  136. package/dist/semantics/normalize/cells/candidates.d.ts +1 -1
  137. package/dist/semantics/normalize/cells/candidates.js +1 -1
  138. package/dist/semantics/normalize/cells/facts.d.ts +1 -1
  139. package/dist/semantics/normalize/cells/facts.js +1 -1
  140. package/dist/semantics/normalize/cells/index.d.ts +2 -2
  141. package/dist/semantics/normalize/cells/index.js +1 -1
  142. package/dist/semantics/normalize/cells/model.d.ts +1 -1
  143. package/dist/semantics/normalize/cells/policies/bag.d.ts +1 -1
  144. package/dist/semantics/normalize/cells/policies/collection.d.ts +1 -1
  145. package/dist/semantics/normalize/cells/policies/collection.js +1 -1
  146. package/dist/semantics/normalize/cells/policies/field.d.ts +1 -1
  147. package/dist/semantics/normalize/cells/policies/field.js +1 -1
  148. package/dist/semantics/normalize/cells/policies/index.d.ts +1 -1
  149. package/dist/semantics/normalize/cells/policies/local.d.ts +1 -1
  150. package/dist/semantics/normalize/cells/policies/local.js +1 -1
  151. package/dist/semantics/normalize/cells/policies/parameter.d.ts +1 -1
  152. package/dist/semantics/normalize/cells/policies/parameter.js +1 -1
  153. package/dist/semantics/normalize/cells/policies/return.d.ts +1 -1
  154. package/dist/semantics/normalize/cells/policies/return.js +1 -1
  155. package/dist/semantics/normalize/cells/policies/shared.d.ts +1 -1
  156. package/dist/semantics/normalize/cells/policy.d.ts +1 -1
  157. package/dist/semantics/normalize/census.d.ts +1 -1
  158. package/dist/semantics/normalize/census.js +45 -12
  159. package/dist/semantics/normalize/class-instance-record-statement.d.ts +1 -1
  160. package/dist/semantics/normalize/class-instance-record-statement.js +1 -1
  161. package/dist/semantics/normalize/collection-bindings.d.ts +1 -1
  162. package/dist/semantics/normalize/collection-bindings.js +1 -1
  163. package/dist/semantics/normalize/commonjs-module-record.d.ts +1 -1
  164. package/dist/semantics/normalize/commonjs-module-record.js +1 -1
  165. package/dist/semantics/normalize/commonjs-require.d.ts +1 -1
  166. package/dist/semantics/normalize/commonjs-require.js +1 -1
  167. package/dist/semantics/normalize/contribution.d.ts +4 -3
  168. package/dist/semantics/normalize/contribution.js +145 -42
  169. package/dist/semantics/normalize/dead-event-emissions.d.ts +1 -1
  170. package/dist/semantics/normalize/dead-event-emissions.js +1 -1
  171. package/dist/semantics/normalize/dead-method-copies.d.ts +1 -1
  172. package/dist/semantics/normalize/dead-method-copies.js +1 -1
  173. package/dist/semantics/normalize/dead-typeof-guards.d.ts +1 -1
  174. package/dist/semantics/normalize/dead-typeof-guards.js +1 -1
  175. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +1 -1
  176. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +1 -1
  177. package/dist/semantics/normalize/derived-expression-type.d.ts +1 -1
  178. package/dist/semantics/normalize/derived-expression-type.js +4 -4
  179. package/dist/semantics/normalize/evaluation-order.d.ts +1 -1
  180. package/dist/semantics/normalize/evaluation-order.js +1 -1
  181. package/dist/semantics/normalize/field-bindings.d.ts +1 -1
  182. package/dist/semantics/normalize/field-bindings.js +4 -3
  183. package/dist/semantics/normalize/flow/array-element-continuation.d.ts +1 -1
  184. package/dist/semantics/normalize/flow/array-element-continuation.js +3 -3
  185. package/dist/semantics/normalize/flow/callable-array-origins.d.ts +1 -1
  186. package/dist/semantics/normalize/flow/callable-array-origins.js +1 -1
  187. package/dist/semantics/normalize/flow/callable-completions.d.ts +1 -1
  188. package/dist/semantics/normalize/flow/callable-completions.js +1 -1
  189. package/dist/semantics/normalize/flow/callable-reach.d.ts +1 -1
  190. package/dist/semantics/normalize/flow/callable-reach.js +73 -52
  191. package/dist/semantics/normalize/flow/class-family-member-read.d.ts +1 -1
  192. package/dist/semantics/normalize/flow/class-family-member-read.js +3 -3
  193. package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +1 -1
  194. package/dist/semantics/normalize/flow/collection-value-continuation.js +1 -1
  195. package/dist/semantics/normalize/flow/component-solver.d.ts +181 -3
  196. package/dist/semantics/normalize/flow/component-solver.js +705 -164
  197. package/dist/semantics/normalize/flow/computed-key-set.d.ts +1 -1
  198. package/dist/semantics/normalize/flow/computed-key-set.js +1 -1
  199. package/dist/semantics/normalize/flow/export-importers.d.ts +1 -1
  200. package/dist/semantics/normalize/flow/export-importers.js +13 -3
  201. package/dist/semantics/normalize/flow/host-text-sink.d.ts +1 -1
  202. package/dist/semantics/normalize/flow/host-text-sink.js +1 -1
  203. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +1 -1
  204. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +1 -1
  205. package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +1 -1
  206. package/dist/semantics/normalize/flow/intrinsic-data-definition.js +1 -1
  207. package/dist/semantics/normalize/flow/invocation-facts.d.ts +1 -1
  208. package/dist/semantics/normalize/flow/invocation-facts.js +1 -1
  209. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +1 -1
  210. package/dist/semantics/normalize/flow/member-call-forwarding.js +1 -1
  211. package/dist/semantics/normalize/flow/model.d.ts +1 -1
  212. package/dist/semantics/normalize/flow/model.js +5 -1
  213. package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +1 -1
  214. package/dist/semantics/normalize/flow/native-collection-protocol.js +1 -1
  215. package/dist/semantics/normalize/flow/node-path-token.d.ts +1 -1
  216. package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +1 -1
  217. package/dist/semantics/normalize/flow/object-binding-continuation.js +1 -1
  218. package/dist/semantics/normalize/flow/origin-authority.d.ts +1 -1
  219. package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +1 -1
  220. package/dist/semantics/normalize/flow/owned-class-receivers.js +1 -1
  221. package/dist/semantics/normalize/flow/parameter-values.d.ts +1 -1
  222. package/dist/semantics/normalize/flow/parameter-values.js +1 -1
  223. package/dist/semantics/normalize/flow/record-alias-closure.d.ts +1 -1
  224. package/dist/semantics/normalize/flow/record-alias-closure.js +1 -1
  225. package/dist/semantics/normalize/flow/seeded-origins.d.ts +1 -1
  226. package/dist/semantics/normalize/flow/seeded-origins.js +1 -1
  227. package/dist/semantics/normalize/flow/source-accessor-descriptor.d.ts +1 -1
  228. package/dist/semantics/normalize/flow/source-accessor-descriptor.js +1 -1
  229. package/dist/semantics/normalize/flow/source-callable-own-data.d.ts +1 -1
  230. package/dist/semantics/normalize/flow/source-callable-own-data.js +1 -1
  231. package/dist/semantics/normalize/flow/source-callable-readonly-set.d.ts +1 -1
  232. package/dist/semantics/normalize/flow/source-callable-readonly-set.js +1 -1
  233. package/dist/semantics/normalize/flow/source-class-data.d.ts +1 -1
  234. package/dist/semantics/normalize/flow/source-class-data.js +1 -1
  235. package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +1 -1
  236. package/dist/semantics/normalize/flow/source-class-instanceof.js +1 -1
  237. package/dist/semantics/normalize/flow/source-class-static-data.d.ts +1 -1
  238. package/dist/semantics/normalize/flow/source-class-static-data.js +1 -1
  239. package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +1 -1
  240. package/dist/semantics/normalize/flow/source-construction-frames.d.ts +1 -1
  241. package/dist/semantics/normalize/flow/source-construction-frames.js +1 -1
  242. package/dist/semantics/normalize/flow/source-descriptor-protocol.d.ts +1 -1
  243. package/dist/semantics/normalize/flow/source-descriptor-protocol.js +1 -1
  244. package/dist/semantics/normalize/flow/source-executing-parameter-values.d.ts +1 -1
  245. package/dist/semantics/normalize/flow/source-executing-parameter-values.js +1 -1
  246. package/dist/semantics/normalize/flow/source-global-binding.d.ts +1 -1
  247. package/dist/semantics/normalize/flow/source-global-binding.js +1 -1
  248. package/dist/semantics/normalize/flow/source-intrinsic-member-data.d.ts +1 -1
  249. package/dist/semantics/normalize/flow/source-intrinsic-member-data.js +1 -1
  250. package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +1 -1
  251. package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +24 -32
  252. package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +1 -1
  253. package/dist/semantics/normalize/flow/source-invocation-receiver.js +1 -1
  254. package/dist/semantics/normalize/flow/source-native-class-alias.d.ts +1 -1
  255. package/dist/semantics/normalize/flow/source-native-class-alias.js +1 -1
  256. package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +1 -1
  257. package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +1 -1
  258. package/dist/semantics/normalize/flow/source-native-origin.d.ts +1 -1
  259. package/dist/semantics/normalize/flow/source-native-origin.js +1 -1
  260. package/dist/semantics/normalize/flow/source-normal-predecessor.d.ts +1 -1
  261. package/dist/semantics/normalize/flow/source-normal-predecessor.js +1 -1
  262. package/dist/semantics/normalize/flow/source-property-key.d.ts +1 -1
  263. package/dist/semantics/normalize/flow/source-property-key.js +1 -1
  264. package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +1 -1
  265. package/dist/semantics/normalize/flow/source-prototype-method-identity.js +1 -1
  266. package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +1 -1
  267. package/dist/semantics/normalize/flow/source-proxy-operation.js +1 -1
  268. package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +1 -1
  269. package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +1 -1
  270. package/dist/semantics/normalize/flow/source-read-protocol.d.ts +1 -1
  271. package/dist/semantics/normalize/flow/source-read-protocol.js +1 -1
  272. package/dist/semantics/normalize/flow/source-record-data.d.ts +1 -1
  273. package/dist/semantics/normalize/flow/source-record-data.js +1 -1
  274. package/dist/semantics/normalize/flow/source-value-session.d.ts +33 -3
  275. package/dist/semantics/normalize/flow/source-value-session.js +381 -173
  276. package/dist/semantics/normalize/flow/standard-prototype-method-source.d.ts +1 -1
  277. package/dist/semantics/normalize/flow/standard-prototype-method-source.js +1 -1
  278. package/dist/semantics/normalize/flow/targets.d.ts +1 -1
  279. package/dist/semantics/normalize/flow/targets.js +1 -1
  280. package/dist/semantics/normalize/flow/value-flow.d.ts +1 -1
  281. package/dist/semantics/normalize/flow/value-flow.js +243 -52
  282. package/dist/semantics/normalize/flow/value-provenance.d.ts +1 -1
  283. package/dist/semantics/normalize/flow/value-provenance.js +1 -1
  284. package/dist/semantics/normalize/fresh-dictionary-storage.d.ts +1 -1
  285. package/dist/semantics/normalize/fresh-dictionary-storage.js +1 -1
  286. package/dist/semantics/normalize/fresh-ordinary-object.d.ts +1 -1
  287. package/dist/semantics/normalize/fresh-ordinary-object.js +1 -1
  288. package/dist/semantics/normalize/fresh-table-last-use.d.ts +1 -1
  289. package/dist/semantics/normalize/fresh-table-last-use.js +1 -1
  290. package/dist/semantics/normalize/gating.d.ts +3 -3
  291. package/dist/semantics/normalize/gating.js +17 -20
  292. package/dist/semantics/normalize/generic-function-choice.d.ts +1 -1
  293. package/dist/semantics/normalize/generic-function-choice.js +1 -1
  294. package/dist/semantics/normalize/global-host-mutations.d.ts +1 -1
  295. package/dist/semantics/normalize/global-host-mutations.js +420 -138
  296. package/dist/semantics/normalize/host-effect-contracts.d.ts +1 -1
  297. package/dist/semantics/normalize/host-effect-contracts.js +1 -1
  298. package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +1 -1
  299. package/dist/semantics/normalize/host-mutation-key-reader.d.ts +1 -1
  300. package/dist/semantics/normalize/host-mutation-key-reader.js +1 -1
  301. package/dist/semantics/normalize/identities.d.ts +41 -1
  302. package/dist/semantics/normalize/identities.js +75 -9
  303. package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +1 -1
  304. package/dist/semantics/normalize/implicit-arguments-tuple.js +1 -1
  305. package/dist/semantics/normalize/implicit-arguments.d.ts +1 -1
  306. package/dist/semantics/normalize/implicit-arguments.js +1 -1
  307. package/dist/semantics/normalize/installed-global-properties.d.ts +1 -1
  308. package/dist/semantics/normalize/installed-global-properties.js +1 -1
  309. package/dist/semantics/normalize/instantiation.d.ts +1 -1
  310. package/dist/semantics/normalize/instantiation.js +1 -1
  311. package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +1 -1
  312. package/dist/semantics/normalize/intrinsic-accessor-getter.js +1 -1
  313. package/dist/semantics/normalize/intrinsic-property-call.d.ts +1 -1
  314. package/dist/semantics/normalize/intrinsic-property-call.js +1 -1
  315. package/dist/semantics/normalize/intrinsic-prototype.d.ts +1 -1
  316. package/dist/semantics/normalize/intrinsic-prototype.js +1 -1
  317. package/dist/semantics/normalize/intrinsic-return-identity.d.ts +1 -1
  318. package/dist/semantics/normalize/intrinsic-return-identity.js +1 -1
  319. package/dist/semantics/normalize/intrinsic-static-member.d.ts +1 -1
  320. package/dist/semantics/normalize/jsdoc-type-names.d.ts +1 -1
  321. package/dist/semantics/normalize/jsdoc-type-names.js +1 -1
  322. package/dist/semantics/normalize/local-bindings.d.ts +1 -1
  323. package/dist/semantics/normalize/local-bindings.js +3 -2
  324. package/dist/semantics/normalize/logical-object-truthiness.d.ts +1 -1
  325. package/dist/semantics/normalize/logical-object-truthiness.js +1 -1
  326. package/dist/semantics/normalize/logical-result-type.d.ts +1 -1
  327. package/dist/semantics/normalize/logical-result-type.js +1 -1
  328. package/dist/semantics/normalize/merged-declaration.d.ts +1 -1
  329. package/dist/semantics/normalize/merged-declaration.js +1 -1
  330. package/dist/semantics/normalize/namespace-paths.d.ts +1 -1
  331. package/dist/semantics/normalize/namespace-paths.js +1 -1
  332. package/dist/semantics/normalize/never-override-result.d.ts +1 -1
  333. package/dist/semantics/normalize/never-override-result.js +1 -1
  334. package/dist/semantics/normalize/normalize.d.ts +23 -4
  335. package/dist/semantics/normalize/normalize.js +125 -15
  336. package/dist/semantics/normalize/null-blind-parameter.d.ts +1 -1
  337. package/dist/semantics/normalize/null-blind-parameter.js +1 -1
  338. package/dist/semantics/normalize/nullable-memo.d.ts +28 -0
  339. package/dist/semantics/normalize/nullable-memo.js +99 -0
  340. package/dist/semantics/normalize/object-bag-bindings.d.ts +1 -1
  341. package/dist/semantics/normalize/object-bag-bindings.js +15 -4
  342. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +1 -1
  343. package/dist/semantics/normalize/omitted-stated-parameter.js +1 -1
  344. package/dist/semantics/normalize/open-type-form.d.ts +1 -1
  345. package/dist/semantics/normalize/open-type-form.js +1 -1
  346. package/dist/semantics/normalize/override-field-arms.d.ts +1 -1
  347. package/dist/semantics/normalize/override-field-arms.js +1 -1
  348. package/dist/semantics/normalize/parameter-bindings.d.ts +1 -52
  349. package/dist/semantics/normalize/parameter-bindings.js +105 -10
  350. package/dist/semantics/normalize/parameter-slot.d.ts +1 -1
  351. package/dist/semantics/normalize/parameter-slot.js +1 -1
  352. package/dist/semantics/normalize/physical-overload-result.d.ts +1 -1
  353. package/dist/semantics/normalize/physical-overload-result.js +1 -1
  354. package/dist/semantics/normalize/primitive-property-absence.d.ts +1 -1
  355. package/dist/semantics/normalize/producer-context.d.ts +1 -1
  356. package/dist/semantics/normalize/producers/allocations.d.ts +1 -1
  357. package/dist/semantics/normalize/producers/allocations.js +1 -1
  358. package/dist/semantics/normalize/producers/binding-kind.d.ts +1 -1
  359. package/dist/semantics/normalize/producers/binding-kind.js +1 -1
  360. package/dist/semantics/normalize/producers/bindings.d.ts +1 -1
  361. package/dist/semantics/normalize/producers/bindings.js +1 -1
  362. package/dist/semantics/normalize/producers/boundary.d.ts +1 -1
  363. package/dist/semantics/normalize/producers/boundary.js +1 -1
  364. package/dist/semantics/normalize/producers/cited-value-type.d.ts +1 -1
  365. package/dist/semantics/normalize/producers/cited-value-type.js +1 -1
  366. package/dist/semantics/normalize/producers/class-lifecycle.js +1 -1
  367. package/dist/semantics/normalize/producers/computations.js +1 -1
  368. package/dist/semantics/normalize/producers/conditional-guard.d.ts +1 -1
  369. package/dist/semantics/normalize/producers/control-loops.d.ts +1 -1
  370. package/dist/semantics/normalize/producers/control-loops.js +1 -1
  371. package/dist/semantics/normalize/producers/control.d.ts +1 -1
  372. package/dist/semantics/normalize/producers/control.js +1 -1
  373. package/dist/semantics/normalize/producers/declaration-lifecycle.js +1 -1
  374. package/dist/semantics/normalize/producers/destructuring.d.ts +1 -1
  375. package/dist/semantics/normalize/producers/destructuring.js +1 -1
  376. package/dist/semantics/normalize/producers/dynamic-language.js +1 -1
  377. package/dist/semantics/normalize/producers/enums.d.ts +1 -1
  378. package/dist/semantics/normalize/producers/enums.js +1 -1
  379. package/dist/semantics/normalize/producers/erasure.d.ts +1 -1
  380. package/dist/semantics/normalize/producers/erasure.js +1 -1
  381. package/dist/semantics/normalize/producers/exact-arms.d.ts +1 -1
  382. package/dist/semantics/normalize/producers/exact-arms.js +1 -1
  383. package/dist/semantics/normalize/producers/intrinsic-accessor-getter.d.ts +1 -1
  384. package/dist/semantics/normalize/producers/invocations.d.ts +1 -1
  385. package/dist/semantics/normalize/producers/invocations.js +1 -1
  386. package/dist/semantics/normalize/producers/iteration-yield.d.ts +1 -1
  387. package/dist/semantics/normalize/producers/iteration-yield.js +1 -1
  388. package/dist/semantics/normalize/producers/jsx.js +1 -1
  389. package/dist/semantics/normalize/producers/logical-merge-type.d.ts +1 -1
  390. package/dist/semantics/normalize/producers/logical-merge-type.js +1 -1
  391. package/dist/semantics/normalize/producers/mint.js +88 -5
  392. package/dist/semantics/normalize/producers/native-callable-readonly-set.d.ts +1 -1
  393. package/dist/semantics/normalize/producers/native-own-assignment.d.ts +1 -1
  394. package/dist/semantics/normalize/producers/native-own-assignment.js +1 -1
  395. package/dist/semantics/normalize/producers/nullish.d.ts +1 -1
  396. package/dist/semantics/normalize/producers/nullish.js +1 -1
  397. package/dist/semantics/normalize/producers/object-assignment.d.ts +1 -1
  398. package/dist/semantics/normalize/producers/object-assignment.js +1 -1
  399. package/dist/semantics/normalize/producers/object-tag.d.ts +1 -1
  400. package/dist/semantics/normalize/producers/object-tag.js +1 -1
  401. package/dist/semantics/normalize/producers/optional-chain.d.ts +1 -1
  402. package/dist/semantics/normalize/producers/optional-chain.js +1 -1
  403. package/dist/semantics/normalize/producers/properties.d.ts +1 -1
  404. package/dist/semantics/normalize/producers/properties.js +1 -1
  405. package/dist/semantics/normalize/producers/protocol.d.ts +1 -1
  406. package/dist/semantics/normalize/producers/protocol.js +1 -1
  407. package/dist/semantics/normalize/producers/references.d.ts +1 -1
  408. package/dist/semantics/normalize/producers/references.js +1 -1
  409. package/dist/semantics/normalize/producers/shared.d.ts +1 -1
  410. package/dist/semantics/normalize/producers/shared.js +1 -1
  411. package/dist/semantics/normalize/producers/spread-arguments.d.ts +1 -1
  412. package/dist/semantics/normalize/producers/spread-arguments.js +1 -1
  413. package/dist/semantics/normalize/producers/tagged-template.d.ts +1 -1
  414. package/dist/semantics/normalize/producers/tagged-template.js +1 -1
  415. package/dist/semantics/normalize/producers/tuple-spread.d.ts +1 -1
  416. package/dist/semantics/normalize/producers/tuple-spread.js +1 -1
  417. package/dist/semantics/normalize/property-key-domain.d.ts +8 -1
  418. package/dist/semantics/normalize/property-key-domain.js +74 -47
  419. package/dist/semantics/normalize/reachability.d.ts +1 -1
  420. package/dist/semantics/normalize/reachability.js +3 -2
  421. package/dist/semantics/normalize/reassigned-bindings.d.ts +1 -1
  422. package/dist/semantics/normalize/record-home-arms.d.ts +1 -1
  423. package/dist/semantics/normalize/record-home-arms.js +1 -1
  424. package/dist/semantics/normalize/record-link-families.d.ts +1 -1
  425. package/dist/semantics/normalize/record-link-families.js +1 -1
  426. package/dist/semantics/normalize/record-stand-in-arms.d.ts +1 -1
  427. package/dist/semantics/normalize/record-stand-in-arms.js +1 -1
  428. package/dist/semantics/normalize/record-storage-families.d.ts +1 -1
  429. package/dist/semantics/normalize/record-storage-families.js +1 -1
  430. package/dist/semantics/normalize/return-bindings.d.ts +1 -1
  431. package/dist/semantics/normalize/return-bindings.js +1 -1
  432. package/dist/semantics/normalize/return-paths.d.ts +1 -1
  433. package/dist/semantics/normalize/return-paths.js +1 -1
  434. package/dist/semantics/normalize/round-tables.d.ts +21 -0
  435. package/dist/semantics/normalize/round-tables.js +59 -0
  436. package/dist/semantics/normalize/script-global-redefinition.d.ts +1 -1
  437. package/dist/semantics/normalize/script-global-redefinition.js +1 -1
  438. package/dist/semantics/normalize/shared-array-storage.d.ts +1 -1
  439. package/dist/semantics/normalize/shared-array-storage.js +1 -1
  440. package/dist/semantics/normalize/sloppy-absence.d.ts +1 -1
  441. package/dist/semantics/normalize/sloppy-absence.js +1 -1
  442. package/dist/semantics/normalize/source-native-iterable.d.ts +2 -2
  443. package/dist/semantics/normalize/source-native-iterable.js +4 -2
  444. package/dist/semantics/normalize/source-object-prototype-absence.d.ts +1 -1
  445. package/dist/semantics/normalize/source-object-prototype-absence.js +1 -1
  446. package/dist/semantics/normalize/specialization.d.ts +1 -1
  447. package/dist/semantics/normalize/specialization.js +1 -1
  448. package/dist/semantics/normalize/specialized-source-frames.d.ts +1 -1
  449. package/dist/semantics/normalize/specialized-source-frames.js +12 -4
  450. package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
  451. package/dist/semantics/normalize/structural-any-binding-consumer.js +1 -1
  452. package/dist/semantics/normalize/structural-array-element.d.ts +1 -1
  453. package/dist/semantics/normalize/structural-array-element.js +1 -1
  454. package/dist/semantics/normalize/structural-array-read.d.ts +1 -1
  455. package/dist/semantics/normalize/structural-array-read.js +1 -1
  456. package/dist/semantics/normalize/structural-callable.d.ts +1 -1
  457. package/dist/semantics/normalize/structural-callable.js +1 -1
  458. package/dist/semantics/normalize/structural-creation-order.d.ts +1 -1
  459. package/dist/semantics/normalize/structural-creation-order.js +1 -1
  460. package/dist/semantics/normalize/structural-declarations.d.ts +1 -1
  461. package/dist/semantics/normalize/structural-declarations.js +1 -1
  462. package/dist/semantics/normalize/structural-declared-body.d.ts +1 -1
  463. package/dist/semantics/normalize/structural-declared-body.js +1 -1
  464. package/dist/semantics/normalize/structural-generics.d.ts +1 -1
  465. package/dist/semantics/normalize/structural-generics.js +1 -1
  466. package/dist/semantics/normalize/structural-indexed-access.d.ts +1 -1
  467. package/dist/semantics/normalize/structural-indexed-access.js +1 -1
  468. package/dist/semantics/normalize/structural-instantiated-member.d.ts +1 -1
  469. package/dist/semantics/normalize/structural-instantiated-member.js +199 -68
  470. package/dist/semantics/normalize/structural-joins.d.ts +1 -1
  471. package/dist/semantics/normalize/structural-layout-relevance.d.ts +1 -1
  472. package/dist/semantics/normalize/structural-layout-relevance.js +1 -1
  473. package/dist/semantics/normalize/structural-layout-type.d.ts +1 -1
  474. package/dist/semantics/normalize/structural-layout-type.js +14 -2
  475. package/dist/semantics/normalize/structural-leaves.d.ts +1 -1
  476. package/dist/semantics/normalize/structural-leaves.js +1 -1
  477. package/dist/semantics/normalize/structural-local-union.d.ts +1 -1
  478. package/dist/semantics/normalize/structural-local-union.js +21 -16
  479. package/dist/semantics/normalize/structural-members.d.ts +1 -1
  480. package/dist/semantics/normalize/structural-members.js +1 -1
  481. package/dist/semantics/normalize/structural-mutable-field.d.ts +1 -2
  482. package/dist/semantics/normalize/structural-mutable-field.js +17 -4
  483. package/dist/semantics/normalize/structural-mutable-method.d.ts +1 -1
  484. package/dist/semantics/normalize/structural-mutable-method.js +1 -1
  485. package/dist/semantics/normalize/structural-parts.d.ts +1 -1
  486. package/dist/semantics/normalize/structural-parts.js +1 -1
  487. package/dist/semantics/normalize/structural-receiver.d.ts +1 -1
  488. package/dist/semantics/normalize/structural-receiver.js +1 -1
  489. package/dist/semantics/normalize/structural-rules.d.ts +4 -4
  490. package/dist/semantics/normalize/structural-rules.js +30 -12
  491. package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
  492. package/dist/semantics/normalize/structural-self-reference.js +1 -1
  493. package/dist/semantics/normalize/structural.d.ts +1 -1
  494. package/dist/semantics/normalize/structural.js +2467 -2239
  495. package/dist/semantics/normalize/suppressed-write-arms.d.ts +1 -1
  496. package/dist/semantics/normalize/suppressed-write-arms.js +1 -1
  497. package/dist/semantics/normalize/symbol-keyed-this-slots.d.ts +1 -1
  498. package/dist/semantics/normalize/symbol-keyed-this-slots.js +1 -1
  499. package/dist/semantics/normalize/unreduced-type-form.d.ts +1 -1
  500. package/dist/semantics/normalize/unreduced-type-form.js +1 -1
  501. package/dist/semantics/normalize/unresolvable-names.d.ts +1 -1
  502. package/dist/semantics/normalize/unresolvable-names.js +1 -1
  503. package/dist/semantics/normalize/unshared-array-result.d.ts +1 -1
  504. package/dist/semantics/normalize/unshared-array-result.js +1 -1
  505. package/dist/semantics/package-sources.d.ts +1 -1
  506. package/dist/semantics/package-sources.js +1 -1
  507. package/dist/semantics/program.d.ts +1 -1
  508. package/dist/semantics/program.js +11 -5
  509. package/dist/semantics/prototype-install-source-transform.js +1 -1
  510. package/dist/semantics/prototype-object-class-source-transform.js +1 -1
  511. package/dist/semantics/prototype-reparenting.d.ts +1 -1
  512. package/dist/semantics/prototype-reparenting.js +1 -1
  513. package/dist/semantics/shared-declaration-files.d.ts +1 -1
  514. package/dist/semantics/source-transform-exports.js +1 -1
  515. package/dist/semantics/stable-checker.d.ts +9 -1
  516. package/dist/semantics/stable-checker.js +21 -5
  517. package/dist/semantics/subclass-member-overlay-transform.js +46 -5
  518. package/dist/semantics/symbol-keyed-expando-source-transform.js +1 -1
  519. package/dist/semantics/this-constructor-source-transform.js +1 -1
  520. package/dist/semantics/typescript.d.ts +12 -0
  521. package/dist/semantics/typescript.js +12 -0
  522. package/dist/semantics/uncached-jsdoc-tags.d.ts +16 -0
  523. package/dist/semantics/uncached-jsdoc-tags.js +23 -0
  524. package/dist/semantics/unchecked-guard-argument-copies.d.ts +1 -1
  525. package/dist/semantics/unchecked-guard-argument-copies.js +1 -1
  526. package/dist/semantics/unchecked-write-member-declarations.d.ts +1 -1
  527. package/dist/semantics/unchecked-write-member-declarations.js +1 -1
  528. package/dist/semantics/uninstantiable-classes.d.ts +1 -1
  529. package/dist/semantics/uninstantiable-classes.js +1 -1
  530. package/dist/targets/cpp/conversions.js +137 -87
  531. package/dist/targets/cpp/emit-bindings.js +13 -0
  532. package/dist/targets/cpp/emit-context.d.ts +13 -0
  533. package/dist/targets/cpp/emit-context.js +9 -0
  534. package/dist/targets/cpp/emit-in.js +2 -1
  535. package/dist/targets/cpp/emit-iterator.d.ts +6 -5
  536. package/dist/targets/cpp/emit-iterator.js +23 -13
  537. package/dist/targets/cpp/emit-narrowing.d.ts +8 -0
  538. package/dist/targets/cpp/emit-narrowing.js +11 -1
  539. package/dist/targets/cpp/emit-properties.js +9 -0
  540. package/dist/targets/cpp/emit-record-view.d.ts +9 -0
  541. package/dist/targets/cpp/emit-record-view.js +12 -1
  542. package/dist/targets/cpp/emit.js +14 -2
  543. package/package.json +7 -1
  544. package/src/targets/cpp/runtime/gea_runtime.h +10 -2
package/dist/compiler.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { mergeNativeIterableProviders } from './plugins/native-iterable-providers.js';
2
2
  import { nodeOfOperation, operationOfResult } from './identity/ids.js';
3
3
  import { readFileSync } from 'fs';
4
+ import { join } from 'path';
5
+ import { writeHeapSnapshot } from 'v8';
4
6
  import { projectAbis } from './projection/abi.js';
5
7
  import { publishConversionRecipes } from './ir/publish-conversion-recipes.js';
6
8
  import { discardUnreadCallResults } from './ir/dead-values.js';
@@ -72,6 +74,8 @@ import { createCppTargetManifest, withCppIrOperandHelpers } from './targets/cpp/
72
74
  import { coreHostConstants, coreHostFunctions, coreHostMembers } from './targets/cpp/host/host-members.js';
73
75
  import { coreGlobalClasses, coreGlobalFunctions, coreGlobalSingletons, coreNativeTypes } from './targets/cpp/host/core-globals.js';
74
76
  import { createCppConversionRegistry } from './targets/cpp/conversions.js';
77
+ import { forgetRecordRecastAnswers } from './targets/cpp/emit-narrowing.js';
78
+ import { forgetRecordViewPlans } from './targets/cpp/emit-record-view.js';
75
79
  import { recordLayoutPolicyOf } from './projection/fields.js';
76
80
  import { nativeClassFieldUsesOf, projectNativeClassStorage } from './projection/class-storage.js';
77
81
  import { finalizeNativeFieldOwnership } from './ir/native-field-owner.js';
@@ -217,9 +221,26 @@ export const compile = (request) => {
217
221
  const stage = (name) => {
218
222
  if (stageStartedAt) {
219
223
  const now = performance.now();
220
- process.stderr.write(`[STAGE] ${name.padEnd(16)} ${(now - stageStartedAt.at).toFixed(0)}ms\n`);
224
+ // Heap beside time: a compile that runs out of memory names the stage
225
+ // that grew, which a time column alone never could.
226
+ // `GEA_STAGE_TIMING=gc` (with `node --expose-gc`) collects first, so the
227
+ // heap column is what the stage RETAINS rather than what it left behind.
228
+ const collect = globalThis.gc;
229
+ if (process.env['GEA_STAGE_TIMING'] === 'gc' && collect)
230
+ collect();
231
+ const { heapUsed, rss } = process.memoryUsage();
232
+ const gb = (bytes) => (bytes / 1073741824).toFixed(2);
233
+ process.stderr.write(`[STAGE] ${name.padEnd(16)} ${(now - stageStartedAt.at).toFixed(0)}ms heap ${gb(heapUsed)}GB rss ${gb(rss)}GB\n`);
221
234
  stageStartedAt.at = now;
222
235
  }
236
+ // `GEA_HEAP_SNAPSHOT_AFTER=<name>` writes a V8 heap snapshot (into
237
+ // `GEA_HEAP_SNAPSHOT_DIR`, default the working directory) once that stage
238
+ // finishes: what a stage RETAINS, and through which references, is a
239
+ // question only the retainer graph answers.
240
+ if (process.env['GEA_HEAP_SNAPSHOT_AFTER'] === name) {
241
+ const directory = process.env['GEA_HEAP_SNAPSHOT_DIR'] ?? process.cwd();
242
+ process.stderr.write(`[STAGE] heap snapshot ${writeHeapSnapshot(join(directory, `after-${name}.heapsnapshot`))}\n`);
243
+ }
223
244
  if (stopAfterStage === name)
224
245
  process.exit(0);
225
246
  };
@@ -748,10 +769,78 @@ export const compile = (request) => {
748
769
  }
749
770
  })());
750
771
  const conversionCensus = createConversionNodes({ registry: conversionRegistry, nodes: conversions.nodes });
772
+ // A build stops here once no translation unit can come out of it
773
+ // (`CompilationRequest.stopWhenUnemittable`): a sweep that is not clean
774
+ // mints no certificate, and a blocked body leaves the program incomplete,
775
+ // so every later stage -- minutes and most of the heap on a large program --
776
+ // could only add rows to a report the build already fails on.
777
+ const unemittable = (loweringBlockers) => {
778
+ stage('stopped');
779
+ return {
780
+ dynamicFallback: {
781
+ enabled: request.dynamicFallback ?? false,
782
+ valueCount: [...representations.plan.selected.values()].filter((value) => value.kind === 'dynamic' && value.reason === 'opt-in-fallback').length
783
+ },
784
+ locationOfNode: frontend.locationOfNode,
785
+ locationOfDeclaration: frontend.locationOfDeclaration,
786
+ textOfNode: frontend.textOfNode,
787
+ graph: frontend.graph,
788
+ sourceFileNames: frontend.sourceFileNames,
789
+ sourcePreparations: frontend.sourcePreparations,
790
+ representations,
791
+ manifest,
792
+ preflight,
793
+ certificate: null,
794
+ diagnostics,
795
+ uninstalledFamilies: frontend.uninstalledFamilies,
796
+ censusAccounting: frontend.censusAccounting,
797
+ cellFacts: frontend.cellFacts,
798
+ conversionNodes: conversions.nodes,
799
+ conversionCensus,
800
+ source: null,
801
+ units: [],
802
+ loweringBlockers,
803
+ certification: null,
804
+ refusals: refusalsOf(frontend.censusRefusals, abis.blocked, loweringBlockers, [], []),
805
+ slotDrift: [],
806
+ printerDrift: [],
807
+ abiBlockers: abis.blocked,
808
+ emissionRefusals: [],
809
+ artifacts: plugins.flatMap((plugin) => (plugin.writeArtifacts ? [plugin.writeArtifacts] : [])),
810
+ generatedSupportIncludes: [...new Set(plugins.flatMap((plugin) => plugin.capabilities.generatedSupportIncludes))].sort(),
811
+ projection: {
812
+ abis: abis.abis,
813
+ constructs: abis.constructs,
814
+ callableOrigins: abis.callableOrigins,
815
+ classes,
816
+ placements,
817
+ slotHooks: plugins.flatMap((plugin) => (plugin.slotOf ? [plugin.slotOf] : []))
818
+ },
819
+ emissionRepresentations: null,
820
+ reflection: null,
821
+ irBodies: null,
822
+ physicalClasses: null
823
+ };
824
+ };
825
+ if (request.stopWhenUnemittable && !diagnostics.clean)
826
+ return unemittable([]);
751
827
  // Lowering runs on the plan's verdict alone. An uncertified program lowers
752
828
  // too, so its refusals are rows beside preflight's rather than a stage that
753
829
  // never ran; only emission waits for the certificate (see the header).
754
- const lowered = diagnostics.planClean
830
+ // Every pass from here to certification rebuilds the bodies it is handed, so
831
+ // each generation is a whole copy of the program's IR. `compile` runs in one
832
+ // interpreted frame, which keeps every local it names until it returns, so a
833
+ // generation held by a `const` lived through every later stage: nine copies
834
+ // at certification on a large program. Each generation is therefore a `let`,
835
+ // dropped once the next one is built, and the long-lived results (`lowered`,
836
+ // `shaken`) keep only their facts, not their bodies.
837
+ // Every step that consumes a generation runs through `inFrame`, reading the
838
+ // generation from this frame's context instead of taking it as an argument
839
+ // here: argument and literal registers of `compile`'s own frame outlive the
840
+ // call they were made for, and one of them kept the pre-shake generation
841
+ // alive through certification -- the compile's heap floor.
842
+ const inFrame = (step) => step();
843
+ let loweredProgram = diagnostics.planClean
755
844
  ? lowerToIr({
756
845
  graph: frontend.graph,
757
846
  plan: representations.plan,
@@ -768,12 +857,17 @@ export const compile = (request) => {
768
857
  plugins
769
858
  })
770
859
  : null;
860
+ const lowered = loweredProgram && { blocked: loweredProgram.blocked, slotDrift: loweredProgram.slotDrift };
861
+ forgetRecordViewPlans();
862
+ forgetRecordRecastAnswers();
771
863
  stage('lowering');
772
864
  // A partially lowered program renders a partially correct file, which is
773
865
  // worse than rendering none: the missing half is invisible in the output.
774
866
  // So text is produced only when every body lowered, and the blockers travel
775
867
  // back either way so the caller can say which ones did not.
776
868
  const complete = lowered !== null && lowered.blocked.length === 0;
869
+ if (request.stopWhenUnemittable && !complete)
870
+ return unemittable(lowered?.blocked ?? []);
777
871
  // A generator whose formals need real work (a default, or a destructured
778
872
  // pattern) was lowered as one body with a marker `ir/lower.ts` left on it
779
873
  // (`IrBody.generatorPrologueBoundary`); this carves that one body into the
@@ -782,9 +876,11 @@ export const compile = (request) => {
782
876
  // consumers of the body list, so the shaker and the emitter agree on which
783
877
  // bodies -- and which placements, since a bridged cell mints its own -- the
784
878
  // program actually has.
785
- const split = complete && lowered ? splitGeneratorBodies(lowered.bodies, placements) : null;
786
- const splitBodies = split?.bodies ?? lowered?.bodies ?? new Map();
787
- const splitPlacements = split?.placements ?? placements;
879
+ let split = complete && loweredProgram ? inFrame(() => splitGeneratorBodies(loweredProgram.bodies, placements)) : null;
880
+ let splitBodies = inFrame(() => split?.bodies ?? loweredProgram?.bodies ?? new Map());
881
+ const splitPlacements = inFrame(() => split?.placements ?? placements);
882
+ loweredProgram = null;
883
+ split = null;
788
884
  // Pruning is per body, and a body lowering blocked on is absent rather than
789
885
  // half built, so an incomplete program is pruned too. Gating it on
790
886
  // `complete` certified the proven-dead arms of every OTHER body whenever one
@@ -793,32 +889,30 @@ export const compile = (request) => {
793
889
  // while an unrelated file's lowering was blocked, and vanished whenever it
794
890
  // was not.
795
891
  stage('generator-split');
796
- const provenPruned = lowered
797
- ? pruneProvenBranches(splitBodies, frontend.graph, lowered.slotDrift)
798
- : { bodies: splitBodies, slotDrift: [] };
892
+ let provenPruned = inFrame(() => lowered ? pruneProvenBranches(splitBodies, frontend.graph, lowered.slotDrift) : { bodies: splitBodies, slotDrift: [] });
893
+ splitBodies = null;
894
+ const prunedSlotDrift = inFrame(() => provenPruned.slotDrift);
799
895
  // Run after the set rewrite so a body it left alone is still judged on its own;
800
896
  // the copy elision needs the placements to prove its cell is frame-local.
801
- const pruned = {
802
- ...provenPruned,
803
- bodies: publishLogicalReceivers(publishNativeHostMethodReads(publishNativeCallableDataSlots({
804
- bodies: publishNativeCallablePrivateSlots({
805
- bodies: elideReadOnlySpreadCopies(rewriteLiteralSetMembership(threadShortCircuitJoins(provenPruned.bodies)), splitPlacements, representations.deriver),
806
- placements: splitPlacements,
807
- conversions: conversionCensus,
808
- deriver: representations.deriver,
809
- classes,
810
- graph: frontend.graph
811
- }),
897
+ let prunedBodies = inFrame(() => publishLogicalReceivers(publishNativeHostMethodReads(publishNativeCallableDataSlots({
898
+ bodies: publishNativeCallablePrivateSlots({
899
+ bodies: elideReadOnlySpreadCopies(rewriteLiteralSetMembership(threadShortCircuitJoins(provenPruned.bodies)), splitPlacements, representations.deriver),
812
900
  placements: splitPlacements,
813
901
  conversions: conversionCensus,
814
902
  deriver: representations.deriver,
815
903
  classes,
816
- calleeRendering: slotsForClasses(classes).input,
817
- graph: frontend.graph,
818
- nativeCallableData: representations.nativeCallableData,
819
- programConversions: null
820
- }), slotsForClasses(classes).input, hosts.members), splitPlacements, classes, conversionCensus, representations.deriver, hosts)
821
- };
904
+ graph: frontend.graph
905
+ }),
906
+ placements: splitPlacements,
907
+ conversions: conversionCensus,
908
+ deriver: representations.deriver,
909
+ classes,
910
+ calleeRendering: slotsForClasses(classes).input,
911
+ graph: frontend.graph,
912
+ nativeCallableData: representations.nativeCallableData,
913
+ programConversions: null
914
+ }), slotsForClasses(classes).input, hosts.members), splitPlacements, classes, conversionCensus, representations.deriver, hosts));
915
+ provenPruned = null;
822
916
  stage('prune');
823
917
  // What the entry can reach, computed once over the whole lowered program.
824
918
  //
@@ -829,9 +923,9 @@ export const compile = (request) => {
829
923
  // thunks all read the body list, and two of them disagreeing about it is a
830
924
  // symbol declared and never defined. See `ir/shake.ts` for the rules and for
831
925
  // why the cut is after lowering rather than before it.
832
- const shaken = complete && lowered
833
- ? shakeProgram({
834
- bodies: pruned.bodies,
926
+ let shakeResult = complete && lowered
927
+ ? inFrame(() => shakeProgram({
928
+ bodies: prunedBodies,
835
929
  placements: splitPlacements,
836
930
  classes,
837
931
  conversions: conversionCensus,
@@ -851,8 +945,14 @@ export const compile = (request) => {
851
945
  const node = conversionCensus.nativeMethodFor(source, target) ?? conversionCensus.nodeFor(source, target);
852
946
  return [...recipeClosureOf([node], conversionCensus.nodeById).values()].every((recipe) => conversionCensus.nodeById(recipe.id) === recipe && isMaterializable(recipe.capability));
853
947
  }
854
- })
948
+ }))
855
949
  : null;
950
+ // An incomplete program has no shaken list, so it certifies the pruned one.
951
+ if (shakeResult)
952
+ prunedBodies = null;
953
+ let shakenBodies = inFrame(() => shakeResult?.bodies ?? null);
954
+ const shaken = inFrame(() => shakeResult && { ...shakeResult, bodies: null });
955
+ shakeResult = null;
856
956
  stage('shake');
857
957
  // Which cells a closure captures, and whether a captured cell is boxed
858
958
  // (a program fact, so it belongs to the IR), computed once here from the
@@ -862,9 +962,14 @@ export const compile = (request) => {
862
962
  // `targets/cpp/captures.ts` used to compute from this same, already-shaken
863
963
  // list at render time. `renderTranslationUnit` reads the published fact
864
964
  // off each body instead of re-deriving it from a fresh walk.
865
- const captureFacts = shaken
866
- ? publishCaptureFacts(shaken.bodies, splitPlacements, recordAccessorBodiesOf([...representations.plan.selected.values()], representations.deriver))
867
- : null;
965
+ //
966
+ // The shaken generation is spent once its capture facts are published:
967
+ // every later reader took `dispatchedBodies ?? shakenBodies`, and the first
968
+ // is set whenever the second is, so holding it kept a whole generation of
969
+ // the program's IR alive through every call/reflection round.
970
+ const captureFactsOf = () => publishCaptureFacts(shakenBodies, splitPlacements, recordAccessorBodiesOf([...representations.plan.selected.values()], representations.deriver));
971
+ let captureFacts = shakenBodies ? captureFactsOf() : null;
972
+ shakenBodies = null;
868
973
  // `CallOperation.target` (a fact moved out of the target): which
869
974
  // FunctionId a call's callee resolves to statically, so the target reads a
870
975
  // fact instead of re-deriving it from a whole-unit capture index at render
@@ -894,119 +999,155 @@ export const compile = (request) => {
894
999
  // Method provenance follows the exact adapter entries a Get will execute.
895
1000
  // Publish those recipes before settling dispatch, then publish again after
896
1001
  // the final rewrites so certification authenticates the operations printed.
897
- const publishNativeOperationFacts = (bodies, operationClasses) => publishLogicalReceivers(publishNativeAccessorDefinitions({
898
- bodies: publishNativeDataDefinitions({
899
- bodies: publishNativeFieldViewFacts({
900
- bodies: publishNativeArrayDescriptorSnapshots({
901
- bodies: publishNativeOwnAssignments({
902
- bodies: publishNativeObjectDataSlots({
903
- bodies: publishNativeCallableDataSlots({
904
- bodies: publishNativeCallablePrivateSlots({
905
- bodies,
906
- placements: splitPlacements,
907
- conversions: conversionCensus,
908
- deriver: representations.deriver,
909
- classes: operationClasses,
910
- graph: frontend.graph
911
- }),
912
- placements: splitPlacements,
913
- conversions: conversionCensus,
914
- deriver: representations.deriver,
915
- classes: operationClasses,
916
- calleeRendering: slotsForClasses(operationClasses).input,
917
- graph: frontend.graph,
918
- nativeCallableData: representations.nativeCallableData,
919
- programConversions: nativeProgramConversions ?? null
920
- }),
921
- placements: splitPlacements,
922
- conversions: conversionCensus,
923
- deriver: representations.deriver,
924
- graph: frontend.graph
925
- }),
926
- graph: frontend.graph,
927
- deriver: representations.deriver,
928
- conversions: conversionCensus,
929
- placements: splitPlacements,
930
- selected: representations.plan.selected,
931
- calleeRendering: slotsForClasses(operationClasses).input
932
- }),
933
- placements: splitPlacements,
934
- classes: operationClasses,
935
- conversions: conversionCensus,
936
- deriver: representations.deriver,
937
- calleeRendering: slotsForClasses(operationClasses).input
938
- }),
939
- placements: splitPlacements,
940
- classes: operationClasses,
941
- conversions: conversionCensus,
942
- deriver: representations.deriver,
943
- ...(nativeProgramConversions ? { programConversions: nativeProgramConversions } : {})
944
- }),
1002
+ // Each pass below rebuilds every body, so the chain is a sequence of
1003
+ // assignments rather than one nested expression: nested, every intermediate
1004
+ // generation stays in an argument or object-literal register of this frame
1005
+ // until the outermost call returns -- nine copies of the program's IR alive
1006
+ // at once, inside a round that is already the compile's peak.
1007
+ //
1008
+ // Handed a taker rather than the generation itself, and run as one frame
1009
+ // from the conversion recipes on: an argument stays in the caller's
1010
+ // register until that frame returns, so the generation a caller handed in,
1011
+ // or held between two of these steps, lived through every pass after it.
1012
+ const publishNativeOperationFacts = (take, operationClasses) => {
1013
+ const calleeRendering = slotsForClasses(operationClasses).input;
1014
+ let bodies = discardUnreadCallResults(take());
1015
+ bodies = publishConversionRecipes({
1016
+ calleeRendering,
1017
+ wellKnownSymbols: frontend.wellKnownSymbols,
1018
+ bodies,
1019
+ placements: splitPlacements,
945
1020
  classes: operationClasses,
1021
+ abis: abis.abis,
1022
+ deriver: representations.deriver,
1023
+ conversions: conversionCensus,
1024
+ hosts
1025
+ });
1026
+ bodies = publishNativeCallablePrivateSlots({
1027
+ bodies,
1028
+ placements: splitPlacements,
1029
+ conversions: conversionCensus,
946
1030
  deriver: representations.deriver,
1031
+ classes: operationClasses,
1032
+ graph: frontend.graph
1033
+ });
1034
+ bodies = publishNativeCallableDataSlots({
1035
+ bodies,
1036
+ placements: splitPlacements,
947
1037
  conversions: conversionCensus,
1038
+ deriver: representations.deriver,
1039
+ classes: operationClasses,
1040
+ calleeRendering: slotsForClasses(operationClasses).input,
948
1041
  graph: frontend.graph,
1042
+ nativeCallableData: representations.nativeCallableData,
1043
+ programConversions: nativeProgramConversions ?? null
1044
+ });
1045
+ bodies = publishNativeObjectDataSlots({
1046
+ bodies,
1047
+ placements: splitPlacements,
1048
+ conversions: conversionCensus,
1049
+ deriver: representations.deriver,
1050
+ graph: frontend.graph
1051
+ });
1052
+ bodies = publishNativeOwnAssignments({
1053
+ bodies,
1054
+ graph: frontend.graph,
1055
+ deriver: representations.deriver,
1056
+ conversions: conversionCensus,
1057
+ placements: splitPlacements,
1058
+ selected: representations.plan.selected,
949
1059
  calleeRendering: slotsForClasses(operationClasses).input
950
- }),
951
- graph: frontend.graph,
952
- abis: abis.abis,
953
- conversions: conversionCensus,
954
- calleeRendering: slotsForClasses(operationClasses).input
955
- }), splitPlacements, operationClasses, conversionCensus, representations.deriver, hosts);
956
- const dispatchRecipesOf = (bodies) => publishNativeOperationFacts(publishConversionRecipes({
957
- calleeRendering: slotsForClasses(shaken?.classes ?? classes).input,
958
- wellKnownSymbols: frontend.wellKnownSymbols,
959
- bodies: discardUnreadCallResults(bodies),
960
- placements: splitPlacements,
961
- classes: shaken?.classes ?? classes,
962
- abis: abis.abis,
963
- deriver: representations.deriver,
964
- conversions: conversionCensus,
965
- hosts
966
- }), shaken?.classes ?? classes);
967
- let dispatchedBodies = captureFacts && shaken && dispatchVerdict
968
- ? fillCallDispatchTargets(dispatchRecipesOf(captureFacts), splitPlacements, shaken.classes, (callable) => abis.abis.get(callable) ?? null, capturesNothingOf, dispatchVerdict, representations.deriver, conversionCensus)
969
- : captureFacts;
1060
+ });
1061
+ bodies = publishNativeArrayDescriptorSnapshots({
1062
+ bodies,
1063
+ placements: splitPlacements,
1064
+ classes: operationClasses,
1065
+ conversions: conversionCensus,
1066
+ deriver: representations.deriver,
1067
+ calleeRendering: slotsForClasses(operationClasses).input
1068
+ });
1069
+ bodies = publishNativeFieldViewFacts({
1070
+ bodies,
1071
+ placements: splitPlacements,
1072
+ classes: operationClasses,
1073
+ conversions: conversionCensus,
1074
+ deriver: representations.deriver,
1075
+ ...(nativeProgramConversions ? { programConversions: nativeProgramConversions } : {})
1076
+ });
1077
+ bodies = publishNativeDataDefinitions({
1078
+ bodies,
1079
+ classes: operationClasses,
1080
+ deriver: representations.deriver,
1081
+ conversions: conversionCensus,
1082
+ graph: frontend.graph,
1083
+ calleeRendering: slotsForClasses(operationClasses).input
1084
+ });
1085
+ bodies = publishNativeAccessorDefinitions({
1086
+ bodies,
1087
+ graph: frontend.graph,
1088
+ abis: abis.abis,
1089
+ conversions: conversionCensus,
1090
+ calleeRendering: slotsForClasses(operationClasses).input
1091
+ });
1092
+ return publishLogicalReceivers(bodies, splitPlacements, operationClasses, conversionCensus, representations.deriver, hosts);
1093
+ };
1094
+ let dispatchedBodies = captureFacts;
1095
+ captureFacts = null;
1096
+ const takeDispatched = () => {
1097
+ const taken = dispatchedBodies;
1098
+ dispatchedBodies = null;
1099
+ return taken;
1100
+ };
1101
+ // Every step of the call/reflection rounds below runs in a frame of its own
1102
+ // and reads the current generation from `dispatchedBodies` rather than
1103
+ // taking it as an argument: argument and literal registers of `compile`'s
1104
+ // own frame outlive the call they were made for, and each kept a generation
1105
+ // of the program's IR -- or an array or iterator over one -- alive through
1106
+ // every later round and on into certification.
1107
+ const dispatchRound = (exposure) => {
1108
+ const recipes = publishNativeOperationFacts(takeDispatched, shaken.classes);
1109
+ dispatchedBodies = fillCallDispatchTargets(recipes, splitPlacements, shaken.classes, (callable) => abis.abis.get(callable) ?? null, capturesNothingOf, dispatchVerdict, representations.deriver, conversionCensus, exposure);
1110
+ };
1111
+ if (dispatchedBodies && shaken && dispatchVerdict)
1112
+ dispatchRound(undefined);
970
1113
  stage('call-dispatch');
971
1114
  // Physical emission dependencies come from the final program. The sealed
972
1115
  // plan stays intact as carrier authority and as the incomplete-shake fallback.
973
1116
  const resolveClassRef = physicalClassInstanceResolverOf(shaken?.classes ?? classes, frontend.graph.structuralTypes, representations.deriver);
974
- let emissionRepresentations = shaken
975
- ? publishEmissionRepresentationsOf({
976
- bodies: dispatchedBodies ?? shaken.bodies,
977
- placements: splitPlacements,
978
- classes: shaken.classes,
979
- resolveClassRef,
980
- deriver: representations.deriver,
981
- conversions: conversionCensus,
982
- omitGlobals: shaken.unreferencedCells,
983
- complete: shaken.refused === null,
984
- fallbackRoots: [...representations.plan.selected.values()]
985
- })
986
- : undefined;
1117
+ const emissionRepresentationsOf = () => publishEmissionRepresentationsOf({
1118
+ bodies: dispatchedBodies,
1119
+ placements: splitPlacements,
1120
+ classes: shaken.classes,
1121
+ resolveClassRef,
1122
+ deriver: representations.deriver,
1123
+ conversions: conversionCensus,
1124
+ omitGlobals: shaken.unreferencedCells,
1125
+ complete: shaken.refused === null,
1126
+ fallbackRoots: [...representations.plan.selected.values()]
1127
+ });
1128
+ let emissionRepresentations = shaken ? emissionRepresentationsOf() : undefined;
987
1129
  stage('emission-carriers');
988
1130
  // Candidate native reads become executable only after the one reflection
989
1131
  // census proves their layouts stay closed across the reachable program.
990
- let reflection = shaken
991
- ? reflectionExposureOf([...(dispatchedBodies ?? shaken.bodies).values()], shaken.classes, representations.deriver, {
992
- representations: emissionRepresentations?.representations ?? [...representations.plan.selected.values()],
993
- wellKnownSymbols: frontend.wellKnownSymbols,
994
- physicalClasses: physicalClassLayoutsOf(shaken.classes, emissionRepresentations?.representations ?? [...representations.plan.selected.values()]).layouts,
995
- placements: splitPlacements,
996
- conversions: conversionCensus,
997
- adapterBoundaries,
998
- trace: request.includeIr === true,
999
- shakeComplete: shaken.refused === null && emissionRepresentations?.complete === true
1000
- })
1001
- : undefined;
1132
+ const firstReflectionOf = () => reflectionExposureOf([...dispatchedBodies.values()], shaken.classes, representations.deriver, {
1133
+ representations: emissionRepresentations?.representations ?? [...representations.plan.selected.values()],
1134
+ wellKnownSymbols: frontend.wellKnownSymbols,
1135
+ physicalClasses: physicalClassLayoutsOf(shaken.classes, emissionRepresentations?.representations ?? [...representations.plan.selected.values()]).layouts,
1136
+ placements: splitPlacements,
1137
+ conversions: conversionCensus,
1138
+ adapterBoundaries,
1139
+ trace: request.includeIr === true,
1140
+ shakeComplete: shaken.refused === null && emissionRepresentations?.complete === true
1141
+ });
1142
+ let reflection = shaken ? firstReflectionOf() : undefined;
1002
1143
  // Closed containers can transport callable records through their native
1003
1144
  // fields. Newly authenticated calls can close further containers. Grow the
1004
1145
  // same call/reflection censuses to a fixed point before ownership or emission
1005
1146
  // consumes either publication; no printer derives this provenance.
1006
1147
  if (shaken && dispatchedBodies && reflection && dispatchVerdict) {
1007
- const closedFactsOf = (bodies) => {
1148
+ const closedFactsOf = () => {
1008
1149
  let count = 0;
1009
- for (const body of bodies)
1150
+ for (const body of dispatchedBodies.values())
1010
1151
  for (const block of body.blocks.values())
1011
1152
  for (const operation of block.operations)
1012
1153
  if (operation.kind === 'get' || operation.kind === 'binding-read'
@@ -1015,55 +1156,48 @@ export const compile = (request) => {
1015
1156
  count++;
1016
1157
  return count;
1017
1158
  };
1018
- let count = closedFactsOf(dispatchedBodies.values());
1159
+ let count = closedFactsOf();
1160
+ const programRecipesOf = (exposure) => publishProgramConversionRecipes({
1161
+ bodies: dispatchedBodies.values(),
1162
+ classes: shaken.classes,
1163
+ deriver: representations.deriver,
1164
+ conversions: conversionCensus,
1165
+ reflection: exposure,
1166
+ representations: emissionRepresentations?.representations ?? [...representations.plan.selected.values()]
1167
+ });
1168
+ const nextReflectionOf = (emission) => reflectionExposureOf([...dispatchedBodies.values()], shaken.classes, representations.deriver, {
1169
+ representations: emission.representations,
1170
+ wellKnownSymbols: frontend.wellKnownSymbols,
1171
+ physicalClasses: physicalClassLayoutsOf(shaken.classes, emission.representations).layouts,
1172
+ placements: splitPlacements,
1173
+ conversions: conversionCensus,
1174
+ programConversions: nativeProgramConversions,
1175
+ adapterBoundaries,
1176
+ trace: request.includeIr === true,
1177
+ shakeComplete: shaken.refused === null && emission.complete
1178
+ });
1019
1179
  let programSignature = '';
1020
1180
  for (;;) {
1021
- nativeProgramConversions = publishProgramConversionRecipes({
1022
- bodies: dispatchedBodies.values(),
1023
- classes: shaken.classes,
1024
- deriver: representations.deriver,
1025
- conversions: conversionCensus,
1026
- reflection,
1027
- representations: emissionRepresentations?.representations ?? [...representations.plan.selected.values()]
1028
- });
1181
+ nativeProgramConversions = programRecipesOf(reflection);
1029
1182
  const nextProgramSignature = JSON.stringify(nativeProgramConversions.map((recipe) => [programConversionKey(recipe), recipe.conversion.id]).sort());
1030
1183
  const programChanged = nextProgramSignature !== programSignature;
1031
1184
  programSignature = nextProgramSignature;
1032
- const next = fillCallDispatchTargets(dispatchRecipesOf(dispatchedBodies), splitPlacements, shaken.classes, (callable) => abis.abis.get(callable) ?? null, capturesNothingOf, dispatchVerdict, representations.deriver, conversionCensus, reflection);
1033
- const nextCount = closedFactsOf(next.values());
1034
- dispatchedBodies = next;
1185
+ dispatchRound(reflection);
1186
+ const nextCount = closedFactsOf();
1187
+ stage('reflection-round');
1035
1188
  if (nextCount <= count && !programChanged)
1036
1189
  break;
1037
1190
  count = nextCount;
1038
- emissionRepresentations = publishEmissionRepresentationsOf({
1039
- bodies: dispatchedBodies,
1040
- placements: splitPlacements,
1041
- classes: shaken.classes,
1042
- resolveClassRef,
1043
- deriver: representations.deriver,
1044
- conversions: conversionCensus,
1045
- omitGlobals: shaken.unreferencedCells,
1046
- complete: shaken.refused === null,
1047
- fallbackRoots: [...representations.plan.selected.values()]
1048
- });
1049
- reflection = reflectionExposureOf([...dispatchedBodies.values()], shaken.classes, representations.deriver, {
1050
- representations: emissionRepresentations.representations,
1051
- wellKnownSymbols: frontend.wellKnownSymbols,
1052
- physicalClasses: physicalClassLayoutsOf(shaken.classes, emissionRepresentations.representations).layouts,
1053
- placements: splitPlacements,
1054
- conversions: conversionCensus,
1055
- programConversions: nativeProgramConversions,
1056
- adapterBoundaries,
1057
- trace: request.includeIr === true,
1058
- shakeComplete: shaken.refused === null && emissionRepresentations.complete
1059
- });
1191
+ emissionRepresentations = emissionRepresentationsOf();
1192
+ reflection = nextReflectionOf(emissionRepresentations);
1060
1193
  }
1061
1194
  }
1062
- const finalizedReads = shaken && reflection
1063
- ? finalizeTypedComputedReads(confirmUnboxedMethodBinds(dispatchedBodies ?? shaken.bodies, reflection, shaken.classes), reflection)
1195
+ let finalizedReads = shaken && reflection
1196
+ ? inFrame(() => finalizeTypedComputedReads(confirmUnboxedMethodBinds(dispatchedBodies, reflection, shaken.classes), reflection))
1064
1197
  : null;
1065
- const fieldOwnership = shaken && reflection && finalizedReads
1066
- ? finalizeNativeFieldOwnership(finalizedReads, shaken.classes, representations.deriver, conversionCensus, reflection, (reads) => nativeClassFieldUsesOf(frontend.graph, representations.plan, representations.deriver, classes, slotsForClasses(classes), reads))
1198
+ dispatchedBodies = null;
1199
+ let fieldOwnership = shaken && reflection && finalizedReads
1200
+ ? inFrame(() => finalizeNativeFieldOwnership(finalizedReads, shaken.classes, representations.deriver, conversionCensus, reflection, (reads) => nativeClassFieldUsesOf(frontend.graph, representations.plan, representations.deriver, classes, slotsForClasses(classes), reads)))
1067
1201
  : null;
1068
1202
  // Presence is the census's to prove, not the checker's to assert: a load out
1069
1203
  // of an `optional` that no program fact proves present tests before it reads
@@ -1077,18 +1211,21 @@ export const compile = (request) => {
1077
1211
  // Exact callable identities are available only after the call/reflection
1078
1212
  // fixed point. A closed body's actual normal return can now prove an edge
1079
1213
  // impossible without treating its declared return type as a runtime fact.
1080
- const normalResultPruned = (() => {
1081
- const bodies = fieldOwnership?.bodies ?? finalizedReads;
1082
- return bodies
1083
- ? pruneProvenBranches(bodies, frontend.graph, pruned.slotDrift, { conversions: conversionCensus, placements: splitPlacements })
1084
- : { bodies: null, slotDrift: pruned.slotDrift };
1085
- })();
1086
- const finalizedBodies = normalResultPruned.bodies ? withPresenceChecks(normalResultPruned.bodies, readsUnchecked) : null;
1087
- const executableClasses = fieldOwnership?.classes ?? shaken?.classes ?? classes;
1214
+ let normalResultPruned = fieldOwnership || finalizedReads
1215
+ ? inFrame(() => pruneProvenBranches(fieldOwnership?.bodies ?? finalizedReads, frontend.graph, prunedSlotDrift, {
1216
+ conversions: conversionCensus,
1217
+ placements: splitPlacements
1218
+ }))
1219
+ : { bodies: null, slotDrift: prunedSlotDrift };
1220
+ const normalResultSlotDrift = inFrame(() => normalResultPruned.slotDrift);
1221
+ let finalizedBodies = inFrame(() => (normalResultPruned.bodies ? withPresenceChecks(normalResultPruned.bodies, readsUnchecked) : null));
1222
+ normalResultPruned = null;
1223
+ finalizedReads = null;
1224
+ const executableClasses = inFrame(() => fieldOwnership?.classes ?? shaken?.classes ?? classes);
1088
1225
  if (shaken && fieldOwnership && fieldOwnership.classes !== shaken.classes) {
1089
1226
  // Relocation preserves every lowered field carrier, but changes which
1090
1227
  // native layouts and dispatch identities the emitted program requires.
1091
- emissionRepresentations = publishEmissionRepresentationsOf({
1228
+ emissionRepresentations = inFrame(() => publishEmissionRepresentationsOf({
1092
1229
  bodies: fieldOwnership.bodies,
1093
1230
  placements: splitPlacements,
1094
1231
  classes: executableClasses,
@@ -1098,17 +1235,19 @@ export const compile = (request) => {
1098
1235
  omitGlobals: shaken.unreferencedCells,
1099
1236
  complete: shaken.refused === null,
1100
1237
  fallbackRoots: [...representations.plan.selected.values()]
1101
- });
1238
+ }));
1102
1239
  }
1240
+ fieldOwnership = null;
1103
1241
  const physicalClasses = shaken && emissionRepresentations ? physicalClassLayoutsOf(executableClasses, emissionRepresentations.representations) : undefined;
1104
1242
  if (reflection && physicalClasses)
1105
1243
  reflection = closePhysicalClassReflection(reflection, physicalClasses.layouts);
1106
1244
  // A union read's class arm that provably lacks the key reads `undefined`;
1107
1245
  // only the CLOSED exposure can say its class never gained a dynamic protocol.
1108
- const absentArmBodies = finalizedBodies && reflection ? finalizeAbsentClassArms(finalizedBodies, reflection, executableClasses) : finalizedBodies;
1246
+ let absentArmBodies = inFrame(() => finalizedBodies && reflection ? finalizeAbsentClassArms(finalizedBodies, reflection, executableClasses) : finalizedBodies);
1247
+ finalizedBodies = null;
1109
1248
  // Last, so the call targets it follows into a callee are the final ones.
1110
- const sharedEmptyBodies = absentArmBodies
1111
- ? shareReadOnlyEmptyRecords(absentArmBodies, {
1249
+ let sharedEmptyBodies = absentArmBodies
1250
+ ? inFrame(() => shareReadOnlyEmptyRecords(absentArmBodies, {
1112
1251
  placements: splitPlacements,
1113
1252
  declaresField: (shapeId, key) => {
1114
1253
  const layout = recordLayoutOfShapeId(representations.deriver, shapeId);
@@ -1119,11 +1258,13 @@ export const compile = (request) => {
1119
1258
  return false;
1120
1259
  return representation.ownership === 'shared-refcount' && plainRecordFieldsOf(representation, representations.deriver) !== null;
1121
1260
  }
1122
- })
1261
+ }))
1123
1262
  : absentArmBodies;
1263
+ absentArmBodies = null;
1124
1264
  // Before the recipes and certification that read the final operation list:
1125
1265
  // a selection an `instanceof` no longer reads (`call-dispatch.ts`) goes.
1126
- const emittedBodies = sharedEmptyBodies ? dropUnreadPureConversions(sharedEmptyBodies, conversionCensus) : sharedEmptyBodies;
1266
+ let emittedBodies = inFrame(() => sharedEmptyBodies ? dropUnreadPureConversions(sharedEmptyBodies, conversionCensus) : sharedEmptyBodies);
1267
+ sharedEmptyBodies = null;
1127
1268
  stage('reflection');
1128
1269
  // Certification is a walk of the IR lowering actually built
1129
1270
  // (one question, one census): every capability the printer
@@ -1139,56 +1280,55 @@ export const compile = (request) => {
1139
1280
  // incomplete program has no shaken list at all, so it certifies the bodies
1140
1281
  // lowering did build: its refusals are the point of running at all, and
1141
1282
  // dropping them would hide why it did not lower.
1142
- const unsealedBodies = emittedBodies ?? (lowered ? pruned.bodies : null);
1143
- nativeProgramConversions = unsealedBodies
1144
- ? publishProgramConversionRecipes({
1145
- bodies: unsealedBodies.values(),
1146
- classes: executableClasses,
1147
- deriver: representations.deriver,
1148
- conversions: conversionCensus,
1149
- representations: emissionRepresentations?.representations ?? [...representations.plan.selected.values()],
1150
- ...(reflection ? { reflection } : {})
1151
- })
1152
- : undefined;
1153
- const operationBodies = unsealedBodies
1154
- ? publishNativeOperationFacts(publishConversionRecipes({
1155
- calleeRendering: slotsForClasses(executableClasses).input,
1156
- wellKnownSymbols: frontend.wellKnownSymbols,
1157
- bodies: discardUnreadCallResults(unsealedBodies),
1158
- placements: splitPlacements,
1159
- classes: executableClasses,
1160
- abis: abis.abis,
1161
- deriver: representations.deriver,
1162
- conversions: conversionCensus,
1163
- hosts
1164
- }), executableClasses)
1165
- : null;
1166
- const finalRecipeBodies = operationBodies
1167
- ? publishConversionRecipes({
1283
+ let unsealedBodies = inFrame(() => emittedBodies ?? (lowered ? prunedBodies : null));
1284
+ emittedBodies = null;
1285
+ prunedBodies = null;
1286
+ // Each step from here to certification is called through a closure that
1287
+ // reads its generation from this frame's context: an argument object or
1288
+ // iterator built in this frame stays in one of its registers until the
1289
+ // frame returns, and kept every spent generation alive through the
1290
+ // certification walk -- the compile's heap floor.
1291
+ const programRecipesOver = (bodies) => publishProgramConversionRecipes({
1292
+ bodies: bodies(),
1293
+ classes: executableClasses,
1294
+ deriver: representations.deriver,
1295
+ conversions: conversionCensus,
1296
+ representations: emissionRepresentations?.representations ?? [...representations.plan.selected.values()],
1297
+ ...(reflection ? { reflection } : {})
1298
+ });
1299
+ nativeProgramConversions = unsealedBodies ? programRecipesOver(() => unsealedBodies.values()) : undefined;
1300
+ const takeUnsealed = () => {
1301
+ const taken = unsealedBodies;
1302
+ unsealedBodies = null;
1303
+ return taken;
1304
+ };
1305
+ let operationBodies = unsealedBodies ? publishNativeOperationFacts(takeUnsealed, executableClasses) : null;
1306
+ unsealedBodies = null;
1307
+ const finalRecipesOf = () => {
1308
+ const taken = operationBodies;
1309
+ operationBodies = null;
1310
+ return publishConversionRecipes({
1168
1311
  calleeRendering: slotsForClasses(executableClasses).input,
1169
1312
  wellKnownSymbols: frontend.wellKnownSymbols,
1170
- bodies: operationBodies,
1313
+ bodies: taken,
1171
1314
  placements: splitPlacements,
1172
1315
  classes: executableClasses,
1173
1316
  abis: abis.abis,
1174
1317
  deriver: representations.deriver,
1175
1318
  conversions: conversionCensus,
1176
1319
  hosts
1177
- })
1178
- : null;
1179
- const certifiedBodies = finalRecipeBodies
1180
- ? new Map([...finalRecipeBodies].map(([id, body]) => [id, publishDenseLoopPlan(body, splitPlacements, conversionCensus)]))
1181
- : null;
1182
- const programConversionRecipes = certifiedBodies
1183
- ? publishProgramConversionRecipes({
1184
- bodies: certifiedBodies.values(),
1185
- classes: executableClasses,
1186
- deriver: representations.deriver,
1187
- conversions: conversionCensus,
1188
- representations: emissionRepresentations?.representations ?? [...representations.plan.selected.values()],
1189
- ...(reflection ? { reflection } : {})
1190
- })
1191
- : [];
1320
+ });
1321
+ };
1322
+ let finalRecipeBodies = operationBodies ? finalRecipesOf() : null;
1323
+ operationBodies = null;
1324
+ const denseLoopPlannedOf = () => {
1325
+ const taken = finalRecipeBodies;
1326
+ finalRecipeBodies = null;
1327
+ return new Map([...taken].map(([id, body]) => [id, publishDenseLoopPlan(body, splitPlacements, conversionCensus)]));
1328
+ };
1329
+ const certifiedBodies = finalRecipeBodies ? denseLoopPlannedOf() : null;
1330
+ finalRecipeBodies = null;
1331
+ const programConversionRecipes = certifiedBodies ? programRecipesOver(() => certifiedBodies.values()) : [];
1192
1332
  const parallelRegionEntries = new Set(plugins.flatMap((plugin) => [...(plugin.capabilities.parallelRegionEntries ?? [])]));
1193
1333
  const certificationManifest = certifiedBodies ? withCppIrOperandHelpers(manifest, certifiedBodies.values()) : manifest;
1194
1334
  const certification = lowered && certifiedBodies
@@ -1199,7 +1339,7 @@ export const compile = (request) => {
1199
1339
  programConversionRecipes,
1200
1340
  representations: emissionRepresentations?.representations ?? [...representations.plan.selected.values()],
1201
1341
  placements: splitPlacements,
1202
- slotDrift: normalResultPruned.slotDrift,
1342
+ slotDrift: normalResultSlotDrift,
1203
1343
  blocked: lowered.blocked,
1204
1344
  manifest: certificationManifest,
1205
1345
  conversions: conversionCensus,
@@ -1323,7 +1463,7 @@ export const compile = (request) => {
1323
1463
  loweringBlockers: lowered?.blocked ?? [],
1324
1464
  certification,
1325
1465
  refusals: refusalsOf(frontend.censusRefusals, abis.blocked, lowered?.blocked ?? [], certification?.refusals ?? [], rendered?.refused ?? []),
1326
- slotDrift: normalResultPruned.slotDrift,
1466
+ slotDrift: normalResultSlotDrift,
1327
1467
  printerDrift: rendered?.printerDrift ?? [],
1328
1468
  abiBlockers: abis.blocked,
1329
1469
  emissionRefusals: rendered?.refused ?? [],