@geastack/compiler 1.0.37 → 1.0.39

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 (537) 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/emission-representations.d.ts +2 -2
  23. package/dist/ir/emission-representations.js +9 -3
  24. package/dist/ir/generic-call-entry.d.ts +3 -1
  25. package/dist/ir/logical-receivers.js +29 -1
  26. package/dist/ir/lower-completion.js +11 -6
  27. package/dist/ir/lower-destructuring.js +3 -2
  28. package/dist/ir/native-host-method-reads.d.ts +5 -0
  29. package/dist/ir/native-host-method-reads.js +30 -21
  30. package/dist/ir/operation-conversions.js +4 -1
  31. package/dist/ir/publish-conversion-recipes.js +12 -1
  32. package/dist/plugins/apple/jsx.js +1 -1
  33. package/dist/plugins/gea/component-classes.js +1 -1
  34. package/dist/plugins/gea/component-inline.js +1 -1
  35. package/dist/plugins/gea/contract.d.ts +1 -1
  36. package/dist/plugins/gea/contract.js +1 -1
  37. package/dist/plugins/gea/host.js +27 -1
  38. package/dist/plugins/gea/lower.js +8 -1
  39. package/dist/plugins/gea/producer.js +1 -1
  40. package/dist/plugins/gea/reactive-slots.d.ts +1 -1
  41. package/dist/plugins/gea/reactive-slots.js +1 -1
  42. package/dist/plugins/load.js +51 -22
  43. package/dist/preflight/run.d.ts +12 -1
  44. package/dist/preflight/run.js +65 -29
  45. package/dist/projection/native-callable-data.js +2 -1
  46. package/dist/representation/plan.js +102 -4
  47. package/dist/semantics/alias-this-field-declaration-transform.js +1 -1
  48. package/dist/semantics/ambient-type-realization-transform.js +1 -1
  49. package/dist/semantics/ambient.d.ts +1 -1
  50. package/dist/semantics/ambient.js +1 -1
  51. package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +1 -1
  52. package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +1 -1
  53. package/dist/semantics/call-invalidated-narrowing.d.ts +1 -1
  54. package/dist/semantics/call-invalidated-narrowing.js +4 -2
  55. package/dist/semantics/callable-own-data-slots.d.ts +6 -0
  56. package/dist/semantics/callable-own-data-slots.js +177 -101
  57. package/dist/semantics/class-alias.d.ts +1 -1
  58. package/dist/semantics/class-alias.js +1 -1
  59. package/dist/semantics/class-heritage.d.ts +1 -1
  60. package/dist/semantics/class-heritage.js +1 -1
  61. package/dist/semantics/commonjs-wrapper.d.ts +4 -3
  62. package/dist/semantics/commonjs-wrapper.js +50 -7
  63. package/dist/semantics/constructor-function-class-source-transform.js +1 -1
  64. package/dist/semantics/constructor-slot-subclasses.d.ts +1 -1
  65. package/dist/semantics/constructor-slot-subclasses.js +1 -1
  66. package/dist/semantics/declaration-overlay-transform.js +3 -2
  67. package/dist/semantics/declared-integers.d.ts +1 -1
  68. package/dist/semantics/declared-integers.js +1 -1
  69. package/dist/semantics/define-property-source-transform.js +1 -1
  70. package/dist/semantics/diagnostic-source-preparation.d.ts +1 -1
  71. package/dist/semantics/documentation-ranges.d.ts +1 -1
  72. package/dist/semantics/documentation-ranges.js +1 -1
  73. package/dist/semantics/dynamic-fallback.d.ts +1 -1
  74. package/dist/semantics/dynamic-fallback.js +1 -1
  75. package/dist/semantics/frontend-timing.js +19 -0
  76. package/dist/semantics/frontend.d.ts +2 -2
  77. package/dist/semantics/frontend.js +127 -54
  78. package/dist/semantics/host-declaration-provenance.d.ts +1 -1
  79. package/dist/semantics/host-methods.d.ts +1 -1
  80. package/dist/semantics/host-methods.js +1 -1
  81. package/dist/semantics/host-protocols.d.ts +1 -1
  82. package/dist/semantics/host-protocols.js +1 -1
  83. package/dist/semantics/inherited-accessor.d.ts +1 -1
  84. package/dist/semantics/inherited-accessor.js +1 -1
  85. package/dist/semantics/interface-families.d.ts +1 -1
  86. package/dist/semantics/interface-families.js +1 -1
  87. package/dist/semantics/interface-implementors.d.ts +1 -1
  88. package/dist/semantics/interface-implementors.js +1 -1
  89. package/dist/semantics/jsdoc-namepath-transform.js +1 -1
  90. package/dist/semantics/jsx-runtime-provider.d.ts +1 -1
  91. package/dist/semantics/jsx-runtime-provider.js +1 -1
  92. package/dist/semantics/known-caller-predicate-parameters.d.ts +1 -1
  93. package/dist/semantics/known-caller-predicate-parameters.js +1 -1
  94. package/dist/semantics/model/edges.d.ts +124 -0
  95. package/dist/semantics/model/edges.js +192 -0
  96. package/dist/semantics/model/graph.d.ts +26 -2
  97. package/dist/semantics/model/graph.js +54 -0
  98. package/dist/semantics/model/sealed-facts.d.ts +19 -0
  99. package/dist/semantics/model/sealed-facts.js +221 -0
  100. package/dist/semantics/model/selected-signature.d.ts +1 -1
  101. package/dist/semantics/model/selected-signature.js +1 -1
  102. package/dist/semantics/module-resolution.d.ts +1 -1
  103. package/dist/semantics/module-resolution.js +1 -1
  104. package/dist/semantics/native-function-signatures.d.ts +1 -1
  105. package/dist/semantics/native-function-signatures.js +1 -1
  106. package/dist/semantics/native-object-data-slots.js +20 -4
  107. package/dist/semantics/new-callee-class-tag-source-transform.js +1 -1
  108. package/dist/semantics/node-project.d.ts +1 -1
  109. package/dist/semantics/node-project.js +1 -1
  110. package/dist/semantics/node-source-hooks.js +1 -1
  111. package/dist/semantics/normalize/absent-globals.d.ts +1 -1
  112. package/dist/semantics/normalize/absent-globals.js +1 -1
  113. package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
  114. package/dist/semantics/normalize/any-cast-member-call.js +1 -1
  115. package/dist/semantics/normalize/arguments-objects.d.ts +1 -1
  116. package/dist/semantics/normalize/arguments-objects.js +1 -1
  117. package/dist/semantics/normalize/asserted-argument-arms.d.ts +1 -1
  118. package/dist/semantics/normalize/asserted-argument-arms.js +1 -1
  119. package/dist/semantics/normalize/asserted-arm-absence.d.ts +1 -1
  120. package/dist/semantics/normalize/asserted-arm-absence.js +1 -1
  121. package/dist/semantics/normalize/assignment-patterns.d.ts +1 -1
  122. package/dist/semantics/normalize/assignment-patterns.js +1 -1
  123. package/dist/semantics/normalize/bag-absence.d.ts +1 -1
  124. package/dist/semantics/normalize/bag-absence.js +1 -1
  125. package/dist/semantics/normalize/binding-fixpoint.js +9 -2
  126. package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +1 -1
  127. package/dist/semantics/normalize/bivariant-slot-parameter.js +1 -1
  128. package/dist/semantics/normalize/callable-data-write.d.ts +1 -1
  129. package/dist/semantics/normalize/callable-data-write.js +1 -1
  130. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +1 -1
  131. package/dist/semantics/normalize/callback-parameter-contracts.js +1 -1
  132. package/dist/semantics/normalize/cells/agreement.d.ts +18 -1
  133. package/dist/semantics/normalize/cells/agreement.js +8 -0
  134. package/dist/semantics/normalize/cells/candidates.d.ts +1 -1
  135. package/dist/semantics/normalize/cells/candidates.js +1 -1
  136. package/dist/semantics/normalize/cells/facts.d.ts +1 -1
  137. package/dist/semantics/normalize/cells/facts.js +1 -1
  138. package/dist/semantics/normalize/cells/index.d.ts +2 -2
  139. package/dist/semantics/normalize/cells/index.js +1 -1
  140. package/dist/semantics/normalize/cells/model.d.ts +1 -1
  141. package/dist/semantics/normalize/cells/policies/bag.d.ts +1 -1
  142. package/dist/semantics/normalize/cells/policies/collection.d.ts +1 -1
  143. package/dist/semantics/normalize/cells/policies/collection.js +1 -1
  144. package/dist/semantics/normalize/cells/policies/field.d.ts +1 -1
  145. package/dist/semantics/normalize/cells/policies/field.js +1 -1
  146. package/dist/semantics/normalize/cells/policies/index.d.ts +1 -1
  147. package/dist/semantics/normalize/cells/policies/local.d.ts +1 -1
  148. package/dist/semantics/normalize/cells/policies/local.js +1 -1
  149. package/dist/semantics/normalize/cells/policies/parameter.d.ts +1 -1
  150. package/dist/semantics/normalize/cells/policies/parameter.js +1 -1
  151. package/dist/semantics/normalize/cells/policies/return.d.ts +1 -1
  152. package/dist/semantics/normalize/cells/policies/return.js +1 -1
  153. package/dist/semantics/normalize/cells/policies/shared.d.ts +1 -1
  154. package/dist/semantics/normalize/cells/policy.d.ts +1 -1
  155. package/dist/semantics/normalize/census.d.ts +1 -1
  156. package/dist/semantics/normalize/census.js +45 -12
  157. package/dist/semantics/normalize/class-instance-record-statement.d.ts +1 -1
  158. package/dist/semantics/normalize/class-instance-record-statement.js +1 -1
  159. package/dist/semantics/normalize/collection-bindings.d.ts +1 -1
  160. package/dist/semantics/normalize/collection-bindings.js +1 -1
  161. package/dist/semantics/normalize/commonjs-module-record.d.ts +1 -1
  162. package/dist/semantics/normalize/commonjs-module-record.js +1 -1
  163. package/dist/semantics/normalize/commonjs-require.d.ts +1 -1
  164. package/dist/semantics/normalize/commonjs-require.js +1 -1
  165. package/dist/semantics/normalize/contribution.d.ts +4 -3
  166. package/dist/semantics/normalize/contribution.js +145 -42
  167. package/dist/semantics/normalize/dead-event-emissions.d.ts +1 -1
  168. package/dist/semantics/normalize/dead-event-emissions.js +1 -1
  169. package/dist/semantics/normalize/dead-method-copies.d.ts +1 -1
  170. package/dist/semantics/normalize/dead-method-copies.js +1 -1
  171. package/dist/semantics/normalize/dead-typeof-guards.d.ts +1 -1
  172. package/dist/semantics/normalize/dead-typeof-guards.js +1 -1
  173. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +1 -1
  174. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +1 -1
  175. package/dist/semantics/normalize/derived-expression-type.d.ts +1 -1
  176. package/dist/semantics/normalize/derived-expression-type.js +4 -4
  177. package/dist/semantics/normalize/evaluation-order.d.ts +1 -1
  178. package/dist/semantics/normalize/evaluation-order.js +1 -1
  179. package/dist/semantics/normalize/field-bindings.d.ts +1 -1
  180. package/dist/semantics/normalize/field-bindings.js +4 -3
  181. package/dist/semantics/normalize/flow/array-element-continuation.d.ts +1 -1
  182. package/dist/semantics/normalize/flow/array-element-continuation.js +3 -3
  183. package/dist/semantics/normalize/flow/callable-array-origins.d.ts +1 -1
  184. package/dist/semantics/normalize/flow/callable-array-origins.js +1 -1
  185. package/dist/semantics/normalize/flow/callable-completions.d.ts +1 -1
  186. package/dist/semantics/normalize/flow/callable-completions.js +1 -1
  187. package/dist/semantics/normalize/flow/callable-reach.d.ts +1 -1
  188. package/dist/semantics/normalize/flow/callable-reach.js +73 -52
  189. package/dist/semantics/normalize/flow/class-family-member-read.d.ts +1 -1
  190. package/dist/semantics/normalize/flow/class-family-member-read.js +3 -3
  191. package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +1 -1
  192. package/dist/semantics/normalize/flow/collection-value-continuation.js +1 -1
  193. package/dist/semantics/normalize/flow/component-solver.d.ts +181 -3
  194. package/dist/semantics/normalize/flow/component-solver.js +705 -164
  195. package/dist/semantics/normalize/flow/computed-key-set.d.ts +1 -1
  196. package/dist/semantics/normalize/flow/computed-key-set.js +1 -1
  197. package/dist/semantics/normalize/flow/export-importers.d.ts +1 -1
  198. package/dist/semantics/normalize/flow/export-importers.js +13 -3
  199. package/dist/semantics/normalize/flow/host-text-sink.d.ts +1 -1
  200. package/dist/semantics/normalize/flow/host-text-sink.js +1 -1
  201. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +1 -1
  202. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +1 -1
  203. package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +1 -1
  204. package/dist/semantics/normalize/flow/intrinsic-data-definition.js +1 -1
  205. package/dist/semantics/normalize/flow/invocation-facts.d.ts +1 -1
  206. package/dist/semantics/normalize/flow/invocation-facts.js +1 -1
  207. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +1 -1
  208. package/dist/semantics/normalize/flow/member-call-forwarding.js +1 -1
  209. package/dist/semantics/normalize/flow/model.d.ts +1 -1
  210. package/dist/semantics/normalize/flow/model.js +5 -1
  211. package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +1 -1
  212. package/dist/semantics/normalize/flow/native-collection-protocol.js +1 -1
  213. package/dist/semantics/normalize/flow/node-path-token.d.ts +1 -1
  214. package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +1 -1
  215. package/dist/semantics/normalize/flow/object-binding-continuation.js +1 -1
  216. package/dist/semantics/normalize/flow/origin-authority.d.ts +1 -1
  217. package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +1 -1
  218. package/dist/semantics/normalize/flow/owned-class-receivers.js +1 -1
  219. package/dist/semantics/normalize/flow/parameter-values.d.ts +1 -1
  220. package/dist/semantics/normalize/flow/parameter-values.js +1 -1
  221. package/dist/semantics/normalize/flow/record-alias-closure.d.ts +1 -1
  222. package/dist/semantics/normalize/flow/record-alias-closure.js +1 -1
  223. package/dist/semantics/normalize/flow/seeded-origins.d.ts +1 -1
  224. package/dist/semantics/normalize/flow/seeded-origins.js +1 -1
  225. package/dist/semantics/normalize/flow/source-accessor-descriptor.d.ts +1 -1
  226. package/dist/semantics/normalize/flow/source-accessor-descriptor.js +1 -1
  227. package/dist/semantics/normalize/flow/source-callable-own-data.d.ts +1 -1
  228. package/dist/semantics/normalize/flow/source-callable-own-data.js +1 -1
  229. package/dist/semantics/normalize/flow/source-callable-readonly-set.d.ts +1 -1
  230. package/dist/semantics/normalize/flow/source-callable-readonly-set.js +1 -1
  231. package/dist/semantics/normalize/flow/source-class-data.d.ts +1 -1
  232. package/dist/semantics/normalize/flow/source-class-data.js +1 -1
  233. package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +1 -1
  234. package/dist/semantics/normalize/flow/source-class-instanceof.js +1 -1
  235. package/dist/semantics/normalize/flow/source-class-static-data.d.ts +1 -1
  236. package/dist/semantics/normalize/flow/source-class-static-data.js +1 -1
  237. package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +1 -1
  238. package/dist/semantics/normalize/flow/source-construction-frames.d.ts +1 -1
  239. package/dist/semantics/normalize/flow/source-construction-frames.js +1 -1
  240. package/dist/semantics/normalize/flow/source-descriptor-protocol.d.ts +1 -1
  241. package/dist/semantics/normalize/flow/source-descriptor-protocol.js +1 -1
  242. package/dist/semantics/normalize/flow/source-executing-parameter-values.d.ts +1 -1
  243. package/dist/semantics/normalize/flow/source-executing-parameter-values.js +1 -1
  244. package/dist/semantics/normalize/flow/source-global-binding.d.ts +1 -1
  245. package/dist/semantics/normalize/flow/source-global-binding.js +1 -1
  246. package/dist/semantics/normalize/flow/source-intrinsic-member-data.d.ts +1 -1
  247. package/dist/semantics/normalize/flow/source-intrinsic-member-data.js +1 -1
  248. package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +1 -1
  249. package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +24 -32
  250. package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +1 -1
  251. package/dist/semantics/normalize/flow/source-invocation-receiver.js +1 -1
  252. package/dist/semantics/normalize/flow/source-native-class-alias.d.ts +1 -1
  253. package/dist/semantics/normalize/flow/source-native-class-alias.js +1 -1
  254. package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +1 -1
  255. package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +1 -1
  256. package/dist/semantics/normalize/flow/source-native-origin.d.ts +1 -1
  257. package/dist/semantics/normalize/flow/source-native-origin.js +1 -1
  258. package/dist/semantics/normalize/flow/source-normal-predecessor.d.ts +1 -1
  259. package/dist/semantics/normalize/flow/source-normal-predecessor.js +1 -1
  260. package/dist/semantics/normalize/flow/source-property-key.d.ts +1 -1
  261. package/dist/semantics/normalize/flow/source-property-key.js +1 -1
  262. package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +1 -1
  263. package/dist/semantics/normalize/flow/source-prototype-method-identity.js +1 -1
  264. package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +1 -1
  265. package/dist/semantics/normalize/flow/source-proxy-operation.js +1 -1
  266. package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +1 -1
  267. package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +1 -1
  268. package/dist/semantics/normalize/flow/source-read-protocol.d.ts +1 -1
  269. package/dist/semantics/normalize/flow/source-read-protocol.js +1 -1
  270. package/dist/semantics/normalize/flow/source-record-data.d.ts +1 -1
  271. package/dist/semantics/normalize/flow/source-record-data.js +1 -1
  272. package/dist/semantics/normalize/flow/source-value-session.d.ts +33 -3
  273. package/dist/semantics/normalize/flow/source-value-session.js +381 -173
  274. package/dist/semantics/normalize/flow/standard-prototype-method-source.d.ts +1 -1
  275. package/dist/semantics/normalize/flow/standard-prototype-method-source.js +1 -1
  276. package/dist/semantics/normalize/flow/targets.d.ts +1 -1
  277. package/dist/semantics/normalize/flow/targets.js +1 -1
  278. package/dist/semantics/normalize/flow/value-flow.d.ts +1 -1
  279. package/dist/semantics/normalize/flow/value-flow.js +243 -52
  280. package/dist/semantics/normalize/flow/value-provenance.d.ts +1 -1
  281. package/dist/semantics/normalize/flow/value-provenance.js +1 -1
  282. package/dist/semantics/normalize/fresh-dictionary-storage.d.ts +1 -1
  283. package/dist/semantics/normalize/fresh-dictionary-storage.js +1 -1
  284. package/dist/semantics/normalize/fresh-ordinary-object.d.ts +1 -1
  285. package/dist/semantics/normalize/fresh-ordinary-object.js +1 -1
  286. package/dist/semantics/normalize/fresh-table-last-use.d.ts +1 -1
  287. package/dist/semantics/normalize/fresh-table-last-use.js +1 -1
  288. package/dist/semantics/normalize/gating.d.ts +3 -3
  289. package/dist/semantics/normalize/gating.js +17 -20
  290. package/dist/semantics/normalize/generic-function-choice.d.ts +1 -1
  291. package/dist/semantics/normalize/generic-function-choice.js +1 -1
  292. package/dist/semantics/normalize/global-host-mutations.d.ts +1 -1
  293. package/dist/semantics/normalize/global-host-mutations.js +420 -138
  294. package/dist/semantics/normalize/host-effect-contracts.d.ts +1 -1
  295. package/dist/semantics/normalize/host-effect-contracts.js +1 -1
  296. package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +1 -1
  297. package/dist/semantics/normalize/host-mutation-key-reader.d.ts +1 -1
  298. package/dist/semantics/normalize/host-mutation-key-reader.js +1 -1
  299. package/dist/semantics/normalize/identities.d.ts +41 -1
  300. package/dist/semantics/normalize/identities.js +75 -9
  301. package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +1 -1
  302. package/dist/semantics/normalize/implicit-arguments-tuple.js +1 -1
  303. package/dist/semantics/normalize/implicit-arguments.d.ts +1 -1
  304. package/dist/semantics/normalize/implicit-arguments.js +1 -1
  305. package/dist/semantics/normalize/installed-global-properties.d.ts +1 -1
  306. package/dist/semantics/normalize/installed-global-properties.js +1 -1
  307. package/dist/semantics/normalize/instantiation.d.ts +1 -1
  308. package/dist/semantics/normalize/instantiation.js +1 -1
  309. package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +1 -1
  310. package/dist/semantics/normalize/intrinsic-accessor-getter.js +1 -1
  311. package/dist/semantics/normalize/intrinsic-property-call.d.ts +1 -1
  312. package/dist/semantics/normalize/intrinsic-property-call.js +1 -1
  313. package/dist/semantics/normalize/intrinsic-prototype.d.ts +1 -1
  314. package/dist/semantics/normalize/intrinsic-prototype.js +1 -1
  315. package/dist/semantics/normalize/intrinsic-return-identity.d.ts +1 -1
  316. package/dist/semantics/normalize/intrinsic-return-identity.js +1 -1
  317. package/dist/semantics/normalize/intrinsic-static-member.d.ts +1 -1
  318. package/dist/semantics/normalize/jsdoc-type-names.d.ts +1 -1
  319. package/dist/semantics/normalize/jsdoc-type-names.js +1 -1
  320. package/dist/semantics/normalize/local-bindings.d.ts +1 -1
  321. package/dist/semantics/normalize/local-bindings.js +3 -2
  322. package/dist/semantics/normalize/logical-object-truthiness.d.ts +1 -1
  323. package/dist/semantics/normalize/logical-object-truthiness.js +1 -1
  324. package/dist/semantics/normalize/logical-result-type.d.ts +1 -1
  325. package/dist/semantics/normalize/logical-result-type.js +1 -1
  326. package/dist/semantics/normalize/merged-declaration.d.ts +1 -1
  327. package/dist/semantics/normalize/merged-declaration.js +1 -1
  328. package/dist/semantics/normalize/namespace-paths.d.ts +1 -1
  329. package/dist/semantics/normalize/namespace-paths.js +1 -1
  330. package/dist/semantics/normalize/never-override-result.d.ts +1 -1
  331. package/dist/semantics/normalize/never-override-result.js +1 -1
  332. package/dist/semantics/normalize/normalize.d.ts +23 -4
  333. package/dist/semantics/normalize/normalize.js +125 -15
  334. package/dist/semantics/normalize/null-blind-parameter.d.ts +1 -1
  335. package/dist/semantics/normalize/null-blind-parameter.js +1 -1
  336. package/dist/semantics/normalize/nullable-memo.d.ts +28 -0
  337. package/dist/semantics/normalize/nullable-memo.js +99 -0
  338. package/dist/semantics/normalize/object-bag-bindings.d.ts +1 -1
  339. package/dist/semantics/normalize/object-bag-bindings.js +15 -4
  340. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +1 -1
  341. package/dist/semantics/normalize/omitted-stated-parameter.js +1 -1
  342. package/dist/semantics/normalize/open-type-form.d.ts +1 -1
  343. package/dist/semantics/normalize/open-type-form.js +1 -1
  344. package/dist/semantics/normalize/override-field-arms.d.ts +1 -1
  345. package/dist/semantics/normalize/override-field-arms.js +1 -1
  346. package/dist/semantics/normalize/parameter-bindings.d.ts +1 -52
  347. package/dist/semantics/normalize/parameter-bindings.js +105 -10
  348. package/dist/semantics/normalize/parameter-slot.d.ts +1 -1
  349. package/dist/semantics/normalize/parameter-slot.js +1 -1
  350. package/dist/semantics/normalize/physical-overload-result.d.ts +1 -1
  351. package/dist/semantics/normalize/physical-overload-result.js +1 -1
  352. package/dist/semantics/normalize/primitive-property-absence.d.ts +1 -1
  353. package/dist/semantics/normalize/producer-context.d.ts +1 -1
  354. package/dist/semantics/normalize/producers/allocations.d.ts +1 -1
  355. package/dist/semantics/normalize/producers/allocations.js +1 -1
  356. package/dist/semantics/normalize/producers/binding-kind.d.ts +1 -1
  357. package/dist/semantics/normalize/producers/binding-kind.js +1 -1
  358. package/dist/semantics/normalize/producers/bindings.d.ts +1 -1
  359. package/dist/semantics/normalize/producers/bindings.js +1 -1
  360. package/dist/semantics/normalize/producers/boundary.d.ts +1 -1
  361. package/dist/semantics/normalize/producers/boundary.js +1 -1
  362. package/dist/semantics/normalize/producers/cited-value-type.d.ts +1 -1
  363. package/dist/semantics/normalize/producers/cited-value-type.js +1 -1
  364. package/dist/semantics/normalize/producers/class-lifecycle.js +1 -1
  365. package/dist/semantics/normalize/producers/computations.js +1 -1
  366. package/dist/semantics/normalize/producers/conditional-guard.d.ts +1 -1
  367. package/dist/semantics/normalize/producers/control-loops.d.ts +1 -1
  368. package/dist/semantics/normalize/producers/control-loops.js +1 -1
  369. package/dist/semantics/normalize/producers/control.d.ts +1 -1
  370. package/dist/semantics/normalize/producers/control.js +1 -1
  371. package/dist/semantics/normalize/producers/declaration-lifecycle.js +1 -1
  372. package/dist/semantics/normalize/producers/destructuring.d.ts +1 -1
  373. package/dist/semantics/normalize/producers/destructuring.js +1 -1
  374. package/dist/semantics/normalize/producers/dynamic-language.js +1 -1
  375. package/dist/semantics/normalize/producers/enums.d.ts +1 -1
  376. package/dist/semantics/normalize/producers/enums.js +1 -1
  377. package/dist/semantics/normalize/producers/erasure.d.ts +1 -1
  378. package/dist/semantics/normalize/producers/erasure.js +1 -1
  379. package/dist/semantics/normalize/producers/exact-arms.d.ts +1 -1
  380. package/dist/semantics/normalize/producers/exact-arms.js +1 -1
  381. package/dist/semantics/normalize/producers/intrinsic-accessor-getter.d.ts +1 -1
  382. package/dist/semantics/normalize/producers/invocations.d.ts +1 -1
  383. package/dist/semantics/normalize/producers/invocations.js +1 -1
  384. package/dist/semantics/normalize/producers/iteration-yield.d.ts +1 -1
  385. package/dist/semantics/normalize/producers/iteration-yield.js +1 -1
  386. package/dist/semantics/normalize/producers/jsx.js +1 -1
  387. package/dist/semantics/normalize/producers/logical-merge-type.d.ts +1 -1
  388. package/dist/semantics/normalize/producers/logical-merge-type.js +1 -1
  389. package/dist/semantics/normalize/producers/mint.js +88 -5
  390. package/dist/semantics/normalize/producers/native-callable-readonly-set.d.ts +1 -1
  391. package/dist/semantics/normalize/producers/native-own-assignment.d.ts +1 -1
  392. package/dist/semantics/normalize/producers/native-own-assignment.js +1 -1
  393. package/dist/semantics/normalize/producers/nullish.d.ts +1 -1
  394. package/dist/semantics/normalize/producers/nullish.js +1 -1
  395. package/dist/semantics/normalize/producers/object-assignment.d.ts +1 -1
  396. package/dist/semantics/normalize/producers/object-assignment.js +1 -1
  397. package/dist/semantics/normalize/producers/object-tag.d.ts +1 -1
  398. package/dist/semantics/normalize/producers/object-tag.js +1 -1
  399. package/dist/semantics/normalize/producers/optional-chain.d.ts +1 -1
  400. package/dist/semantics/normalize/producers/optional-chain.js +1 -1
  401. package/dist/semantics/normalize/producers/properties.d.ts +1 -1
  402. package/dist/semantics/normalize/producers/properties.js +1 -1
  403. package/dist/semantics/normalize/producers/protocol.d.ts +1 -1
  404. package/dist/semantics/normalize/producers/protocol.js +1 -1
  405. package/dist/semantics/normalize/producers/references.d.ts +1 -1
  406. package/dist/semantics/normalize/producers/references.js +1 -1
  407. package/dist/semantics/normalize/producers/shared.d.ts +1 -1
  408. package/dist/semantics/normalize/producers/shared.js +1 -1
  409. package/dist/semantics/normalize/producers/spread-arguments.d.ts +1 -1
  410. package/dist/semantics/normalize/producers/spread-arguments.js +1 -1
  411. package/dist/semantics/normalize/producers/tagged-template.d.ts +1 -1
  412. package/dist/semantics/normalize/producers/tagged-template.js +1 -1
  413. package/dist/semantics/normalize/producers/tuple-spread.d.ts +1 -1
  414. package/dist/semantics/normalize/producers/tuple-spread.js +1 -1
  415. package/dist/semantics/normalize/property-key-domain.d.ts +8 -1
  416. package/dist/semantics/normalize/property-key-domain.js +74 -47
  417. package/dist/semantics/normalize/reachability.d.ts +1 -1
  418. package/dist/semantics/normalize/reachability.js +3 -2
  419. package/dist/semantics/normalize/reassigned-bindings.d.ts +1 -1
  420. package/dist/semantics/normalize/record-home-arms.d.ts +1 -1
  421. package/dist/semantics/normalize/record-home-arms.js +1 -1
  422. package/dist/semantics/normalize/record-link-families.d.ts +1 -1
  423. package/dist/semantics/normalize/record-link-families.js +1 -1
  424. package/dist/semantics/normalize/record-stand-in-arms.d.ts +1 -1
  425. package/dist/semantics/normalize/record-stand-in-arms.js +1 -1
  426. package/dist/semantics/normalize/record-storage-families.d.ts +1 -1
  427. package/dist/semantics/normalize/record-storage-families.js +1 -1
  428. package/dist/semantics/normalize/return-bindings.d.ts +1 -1
  429. package/dist/semantics/normalize/return-bindings.js +1 -1
  430. package/dist/semantics/normalize/return-paths.d.ts +1 -1
  431. package/dist/semantics/normalize/return-paths.js +1 -1
  432. package/dist/semantics/normalize/round-tables.d.ts +21 -0
  433. package/dist/semantics/normalize/round-tables.js +59 -0
  434. package/dist/semantics/normalize/script-global-redefinition.d.ts +1 -1
  435. package/dist/semantics/normalize/script-global-redefinition.js +1 -1
  436. package/dist/semantics/normalize/shared-array-storage.d.ts +1 -1
  437. package/dist/semantics/normalize/shared-array-storage.js +1 -1
  438. package/dist/semantics/normalize/sloppy-absence.d.ts +1 -1
  439. package/dist/semantics/normalize/sloppy-absence.js +1 -1
  440. package/dist/semantics/normalize/source-native-iterable.d.ts +2 -2
  441. package/dist/semantics/normalize/source-native-iterable.js +4 -2
  442. package/dist/semantics/normalize/source-object-prototype-absence.d.ts +1 -1
  443. package/dist/semantics/normalize/source-object-prototype-absence.js +1 -1
  444. package/dist/semantics/normalize/specialization.d.ts +1 -1
  445. package/dist/semantics/normalize/specialization.js +1 -1
  446. package/dist/semantics/normalize/specialized-source-frames.d.ts +1 -1
  447. package/dist/semantics/normalize/specialized-source-frames.js +12 -4
  448. package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
  449. package/dist/semantics/normalize/structural-any-binding-consumer.js +1 -1
  450. package/dist/semantics/normalize/structural-array-element.d.ts +1 -1
  451. package/dist/semantics/normalize/structural-array-element.js +1 -1
  452. package/dist/semantics/normalize/structural-array-read.d.ts +1 -1
  453. package/dist/semantics/normalize/structural-array-read.js +1 -1
  454. package/dist/semantics/normalize/structural-callable.d.ts +1 -1
  455. package/dist/semantics/normalize/structural-callable.js +1 -1
  456. package/dist/semantics/normalize/structural-creation-order.d.ts +1 -1
  457. package/dist/semantics/normalize/structural-creation-order.js +1 -1
  458. package/dist/semantics/normalize/structural-declarations.d.ts +1 -1
  459. package/dist/semantics/normalize/structural-declarations.js +1 -1
  460. package/dist/semantics/normalize/structural-declared-body.d.ts +1 -1
  461. package/dist/semantics/normalize/structural-declared-body.js +1 -1
  462. package/dist/semantics/normalize/structural-generics.d.ts +1 -1
  463. package/dist/semantics/normalize/structural-generics.js +1 -1
  464. package/dist/semantics/normalize/structural-indexed-access.d.ts +1 -1
  465. package/dist/semantics/normalize/structural-indexed-access.js +1 -1
  466. package/dist/semantics/normalize/structural-instantiated-member.d.ts +1 -1
  467. package/dist/semantics/normalize/structural-instantiated-member.js +199 -68
  468. package/dist/semantics/normalize/structural-joins.d.ts +1 -1
  469. package/dist/semantics/normalize/structural-layout-relevance.d.ts +1 -1
  470. package/dist/semantics/normalize/structural-layout-relevance.js +1 -1
  471. package/dist/semantics/normalize/structural-layout-type.d.ts +1 -1
  472. package/dist/semantics/normalize/structural-layout-type.js +14 -2
  473. package/dist/semantics/normalize/structural-leaves.d.ts +1 -1
  474. package/dist/semantics/normalize/structural-leaves.js +1 -1
  475. package/dist/semantics/normalize/structural-local-union.d.ts +1 -1
  476. package/dist/semantics/normalize/structural-local-union.js +21 -16
  477. package/dist/semantics/normalize/structural-members.d.ts +1 -1
  478. package/dist/semantics/normalize/structural-members.js +1 -1
  479. package/dist/semantics/normalize/structural-mutable-field.d.ts +1 -2
  480. package/dist/semantics/normalize/structural-mutable-field.js +17 -4
  481. package/dist/semantics/normalize/structural-mutable-method.d.ts +1 -1
  482. package/dist/semantics/normalize/structural-mutable-method.js +1 -1
  483. package/dist/semantics/normalize/structural-parts.d.ts +1 -1
  484. package/dist/semantics/normalize/structural-parts.js +1 -1
  485. package/dist/semantics/normalize/structural-receiver.d.ts +1 -1
  486. package/dist/semantics/normalize/structural-receiver.js +1 -1
  487. package/dist/semantics/normalize/structural-rules.d.ts +4 -4
  488. package/dist/semantics/normalize/structural-rules.js +30 -12
  489. package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
  490. package/dist/semantics/normalize/structural-self-reference.js +1 -1
  491. package/dist/semantics/normalize/structural.d.ts +1 -1
  492. package/dist/semantics/normalize/structural.js +2467 -2239
  493. package/dist/semantics/normalize/suppressed-write-arms.d.ts +1 -1
  494. package/dist/semantics/normalize/suppressed-write-arms.js +1 -1
  495. package/dist/semantics/normalize/symbol-keyed-this-slots.d.ts +1 -1
  496. package/dist/semantics/normalize/symbol-keyed-this-slots.js +1 -1
  497. package/dist/semantics/normalize/unreduced-type-form.d.ts +1 -1
  498. package/dist/semantics/normalize/unreduced-type-form.js +1 -1
  499. package/dist/semantics/normalize/unresolvable-names.d.ts +1 -1
  500. package/dist/semantics/normalize/unresolvable-names.js +1 -1
  501. package/dist/semantics/normalize/unshared-array-result.d.ts +1 -1
  502. package/dist/semantics/normalize/unshared-array-result.js +1 -1
  503. package/dist/semantics/package-sources.d.ts +1 -1
  504. package/dist/semantics/package-sources.js +1 -1
  505. package/dist/semantics/program.d.ts +1 -1
  506. package/dist/semantics/program.js +11 -5
  507. package/dist/semantics/prototype-install-source-transform.js +1 -1
  508. package/dist/semantics/prototype-object-class-source-transform.js +1 -1
  509. package/dist/semantics/prototype-reparenting.d.ts +1 -1
  510. package/dist/semantics/prototype-reparenting.js +1 -1
  511. package/dist/semantics/shared-declaration-files.d.ts +1 -1
  512. package/dist/semantics/source-transform-exports.js +1 -1
  513. package/dist/semantics/stable-checker.d.ts +9 -1
  514. package/dist/semantics/stable-checker.js +21 -5
  515. package/dist/semantics/subclass-member-overlay-transform.js +46 -5
  516. package/dist/semantics/symbol-keyed-expando-source-transform.js +1 -1
  517. package/dist/semantics/this-constructor-source-transform.js +1 -1
  518. package/dist/semantics/typescript.d.ts +12 -0
  519. package/dist/semantics/typescript.js +12 -0
  520. package/dist/semantics/uncached-jsdoc-tags.d.ts +16 -0
  521. package/dist/semantics/uncached-jsdoc-tags.js +23 -0
  522. package/dist/semantics/unchecked-guard-argument-copies.d.ts +1 -1
  523. package/dist/semantics/unchecked-guard-argument-copies.js +1 -1
  524. package/dist/semantics/unchecked-write-member-declarations.d.ts +1 -1
  525. package/dist/semantics/unchecked-write-member-declarations.js +1 -1
  526. package/dist/semantics/uninstantiable-classes.d.ts +1 -1
  527. package/dist/semantics/uninstantiable-classes.js +1 -1
  528. package/dist/targets/cpp/conversions.js +137 -87
  529. package/dist/targets/cpp/emit-in.js +2 -1
  530. package/dist/targets/cpp/emit-iterator.d.ts +6 -5
  531. package/dist/targets/cpp/emit-iterator.js +23 -13
  532. package/dist/targets/cpp/emit-narrowing.d.ts +8 -0
  533. package/dist/targets/cpp/emit-narrowing.js +11 -1
  534. package/dist/targets/cpp/emit-record-view.d.ts +9 -0
  535. package/dist/targets/cpp/emit-record-view.js +12 -1
  536. package/package.json +7 -1
  537. package/src/targets/cpp/runtime/gea_runtime.h +6 -1
@@ -1,7 +1,7 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  import { isGlobalObjectAssign } from '../derived-expression-type.js';
3
3
  import { isClassSpelledSourceClass } from './model.js';
4
- import { dependencyFactSolver } from './component-solver.js';
4
+ import { dependencyFactSolver, FactState } from './component-solver.js';
5
5
  import { classConstructorKeepsInstanceOf, exactSourceConstructionOf, ordinarySourceClassInstanceTestOf, sourceConstructorSelectionsOf } from './member-call-forwarding.js';
6
6
  import { sourceClassCallableMemberPlanOf, sourceClassDataMemberPlanOf, sourceClassKeyReadPlanOf } from './source-class-data.js';
7
7
  import { sourceClassFamilyOf } from './owned-class-receivers.js';
@@ -26,6 +26,48 @@ import { sourceObjectPrototypeAbsenceOf } from '../source-object-prototype-absen
26
26
  import { sourceFreshOrdinaryObjectOf } from '../fresh-ordinary-object.js';
27
27
  import { sourceIntrinsicMemberDataWriteOf, sourceIntrinsicMemberMayBeWrittenOf } from './source-intrinsic-member-data.js';
28
28
  import { sourceCommonJsExportUsesOf, sourceCommonJsExportValueOf } from './source-commonjs-exports.js';
29
+ /**
30
+ * A query, which is also the session solver's node for it: each query is
31
+ * interned once per session and keyed into the session's one solver
32
+ * (`keysAreStates`), so a query record and a solver state per question --
33
+ * ~220K on a 48K-line app, two headers and a pointer each way -- are one
34
+ * object. The fields beyond `kind` and `node` share two slots, since no query
35
+ * has both a body and a key or both a subject and a root; the accessors tell
36
+ * them apart by the first slot's type and answer `undefined` for a field the
37
+ * query's kind does not have, as the plain record did.
38
+ */
39
+ class QueryState extends FactState {
40
+ kind;
41
+ node;
42
+ first;
43
+ second;
44
+ constructor(kind, node,
45
+ /** A frame's body or a keyed query's key. */
46
+ first,
47
+ /** A frame's subject, or a use's or publication's root. */
48
+ second) {
49
+ super();
50
+ this.kind = kind;
51
+ this.node = node;
52
+ this.first = first;
53
+ this.second = second;
54
+ }
55
+ get solverKey() {
56
+ return this;
57
+ }
58
+ get body() {
59
+ return typeof this.first === 'object' ? this.first : undefined;
60
+ }
61
+ get subject() {
62
+ return typeof this.first === 'object' ? this.second : undefined;
63
+ }
64
+ get key() {
65
+ return typeof this.first === 'string' ? this.first : undefined;
66
+ }
67
+ get root() {
68
+ return typeof this.first === 'object' ? undefined : this.second;
69
+ }
70
+ }
29
71
  /**
30
72
  * Walk two lists as one without building a third.
31
73
  *
@@ -58,6 +100,51 @@ const VALUE_CARRYING_KINDS = new Set([
58
100
  'constructor-completion'
59
101
  ]);
60
102
  const VALUE_ORIGIN = 'source-value-origin';
103
+ // Shared and never mutated -- consumers compare contents only. A fresh array
104
+ // per seal was about 12 MB of identical one- and zero-element arrays.
105
+ const VALUE_ORIGIN_DOMAIN = [VALUE_ORIGIN];
106
+ const NO_DOMAINS = [];
107
+ const NO_CAUSES = [];
108
+ const CARRIES_VALUE = 1;
109
+ const SEEDED = 2;
110
+ /**
111
+ * A seal with grounding edges and no causes: everything but its edges is one
112
+ * of four constants, read through getters. The solver keeps every node's last
113
+ * seal for the session, and ~90K of a 48K-line app's seals are this one, at
114
+ * 72 bytes as a six-field record against 40 here.
115
+ */
116
+ class GroundedSeal {
117
+ groundingKeys;
118
+ flags;
119
+ constructor(groundingKeys, flags) {
120
+ this.groundingKeys = groundingKeys;
121
+ this.flags = flags;
122
+ }
123
+ get locallyComplete() {
124
+ return true;
125
+ }
126
+ get causes() {
127
+ return NO_CAUSES;
128
+ }
129
+ get groundingRequirements() {
130
+ return (this.flags & CARRIES_VALUE) !== 0 ? VALUE_ORIGIN_DOMAIN : NO_DOMAINS;
131
+ }
132
+ get groundingSeeds() {
133
+ return (this.flags & SEEDED) !== 0 ? VALUE_ORIGIN_DOMAIN : NO_DOMAINS;
134
+ }
135
+ get groundingDomain() {
136
+ return VALUE_ORIGIN;
137
+ }
138
+ }
139
+ const NO_GROUNDING = [];
140
+ /** A set's entries in an array of exactly its size: a spread keeps growth slack, and a seal keeps its list for the session. */
141
+ const exactListOf = (set) => {
142
+ const list = new Array(set.size);
143
+ let at = 0;
144
+ for (const value of set)
145
+ list[at++] = value;
146
+ return list;
147
+ };
61
148
  // Read once at load, not per value transfer: `process.env` is a native interceptor.
62
149
  const noArrayKeys = process.env['GEA_NO_ARRAY_KEYS'] !== undefined;
63
150
  /**
@@ -182,6 +269,27 @@ export const shareSourceValueSession = (previous, next) => {
182
269
  sessions.set(next, known);
183
270
  return true;
184
271
  };
272
+ const internIn = (outer, owner, key, keyOf, make) => {
273
+ const held = outer.get(owner);
274
+ if (held === undefined) {
275
+ const query = make();
276
+ outer.set(owner, query);
277
+ return query;
278
+ }
279
+ if (!(held instanceof Map)) {
280
+ if (keyOf(held) === key)
281
+ return held;
282
+ const query = make();
283
+ outer.set(owner, new Map([[keyOf(held), held], [key, query]]));
284
+ return query;
285
+ }
286
+ let query = held.get(key);
287
+ if (query === undefined)
288
+ held.set(key, (query = make()));
289
+ return query;
290
+ };
291
+ const frameSubjectOf = (query) => query.subject;
292
+ const keyedQueryKey = (query) => query.key;
185
293
  const createSession = (checker, flow) => {
186
294
  const isFreshOrdinaryObject = (node) => sourceFreshOrdinaryObjectOf(checker, node);
187
295
  const isObjectRoot = (node) => isSpelledObjectRoot(node) || isFreshOrdinaryObject(node);
@@ -198,8 +306,21 @@ const createSession = (checker, flow) => {
198
306
  const keyReadQueries = new Map();
199
307
  const uses = new Map();
200
308
  const publications = new Map();
309
+ // Per call, the bodies and subjects it was asked about (see `frameQuery`).
201
310
  const frameQueries = new Map();
311
+ // A lone requirement is held as itself (a requirement is a record, never an
312
+ // array): ~36K of a 48K-line app's ~36K lists hold one.
202
313
  const requirements = new Map();
314
+ // One `{ names: [key] }` per key: the requirement it goes into is kept per
315
+ // query (`requirements`), and ~34K of them on a 48K-line app named a few
316
+ // thousand keys. The ledger reads it, never writes it.
317
+ const singleKeyQueries = new Map();
318
+ const singleKeyQueryOf = (key) => {
319
+ let query = singleKeyQueries.get(key);
320
+ if (!query)
321
+ singleKeyQueries.set(key, (query = { names: [key] }));
322
+ return query;
323
+ };
203
324
  const argumentsByFile = new Map();
204
325
  const argumentsUsesAt = (body) => {
205
326
  const file = body.getSourceFile();
@@ -324,7 +445,7 @@ const createSession = (checker, flow) => {
324
445
  unary.set(kind, (nodes = new Map()));
325
446
  let query = nodes.get(node);
326
447
  if (!query)
327
- nodes.set(node, (query = { kind, node }));
448
+ nodes.set(node, (query = new QueryState(kind, node, undefined, undefined)));
328
449
  return query;
329
450
  };
330
451
  const value = (expression) => nodeQuery('value', unwrapErasedExpression(expression));
@@ -332,16 +453,25 @@ const createSession = (checker, flow) => {
332
453
  let calls = frameQueries.get(kind);
333
454
  if (!calls)
334
455
  frameQueries.set(kind, (calls = new Map()));
335
- let bodies = calls.get(call);
336
- if (!bodies)
337
- calls.set(call, (bodies = new Map()));
338
- let subjects = bodies.get(body);
339
- if (!subjects)
340
- bodies.set(body, (subjects = new Map()));
341
- let query = subjects.get(subject);
342
- if (!query)
343
- subjects.set(subject, (query = { kind, node: call, body, subject }));
344
- return query;
456
+ const make = () => new QueryState(kind, call, body, subject);
457
+ // ~22K of a 48K-line app's ~26K per-call and per-body tables held one
458
+ // entry: one call asked about one body and one subject is held as that
459
+ // query, which names both.
460
+ const held = calls.get(call);
461
+ if (held === undefined) {
462
+ const query = make();
463
+ calls.set(call, query);
464
+ return query;
465
+ }
466
+ let bodies;
467
+ if (held instanceof Map)
468
+ bodies = held;
469
+ else {
470
+ if (held.body === body && held.subject === subject)
471
+ return held;
472
+ calls.set(call, (bodies = new Map([[held.body, held]])));
473
+ }
474
+ return internIn(bodies, body, subject, frameSubjectOf, make);
345
475
  };
346
476
  const closure = (root) => nodeQuery('closure', root);
347
477
  /**
@@ -399,13 +529,7 @@ const createSession = (checker, flow) => {
399
529
  * reverse lookup rather than by subscribing to every read of the key.
400
530
  */
401
531
  const keyReadsOf = (container, key) => {
402
- let keys = keyReadQueries.get(container);
403
- if (!keys)
404
- keyReadQueries.set(container, (keys = new Map()));
405
- let query = keys.get(key);
406
- if (!query)
407
- keys.set(key, (query = { kind: 'key-reads', node: container, key }));
408
- return query;
532
+ return internIn(keyReadQueries, container, key, keyedQueryKey, () => new QueryState('key-reads', container, key, undefined));
409
533
  };
410
534
  const targets = (call) => nodeQuery('targets', call);
411
535
  const superTargets = (call) => nodeQuery('super-targets', call);
@@ -577,22 +701,26 @@ const createSession = (checker, flow) => {
577
701
  }
578
702
  else
579
703
  return false;
580
- return deferredIntrinsicProtocolLedgerOf(flow)?.requirePrototypeKeys('Object', { names: [key] }, at) === true;
704
+ return deferredIntrinsicProtocolLedgerOf(flow)?.requirePrototypeKeys('Object', singleKeyQueryOf(key), at) === true;
581
705
  };
706
+ // The receivers of each key's named reads, in program order: `case
707
+ // 'key-reads'` seeds them and reads nothing else of a read.
582
708
  const readsByKey = new Map();
583
709
  const unknownReads = [];
584
710
  for (const access of flow.propertyAccesses) {
585
711
  const key = accessKey(access);
586
- const entry = { access, receiver: value(access.expression) };
712
+ const receiver = value(access.expression);
587
713
  if (key === null)
588
- unknownReads.push(entry);
714
+ unknownReads.push({ access, receiver });
589
715
  else {
590
716
  let reads = readsByKey.get(key);
591
717
  if (!reads)
592
718
  readsByKey.set(key, (reads = []));
593
- reads.push(entry);
719
+ reads.push(receiver);
594
720
  }
595
721
  }
722
+ for (const [key, receivers] of readsByKey)
723
+ readsByKey.set(key, receivers.slice());
596
724
  /**
597
725
  * `unknownReads`, indexed by the query that answers what its RECEIVER
598
726
  * holds -- the one hop `case 'unknown-reads'` needs from a holder key (a
@@ -612,7 +740,16 @@ const createSession = (checker, flow) => {
612
740
  entries.push(entry);
613
741
  }
614
742
  const namedReadsByReceiver = new Map();
743
+ const namedReadsOf = (receiver, key) => {
744
+ const held = namedReadsByReceiver.get(receiver);
745
+ if (held === undefined)
746
+ return undefined;
747
+ if (held instanceof Map)
748
+ return held.get(key);
749
+ return held.key === key ? held.positions : undefined;
750
+ };
615
751
  {
752
+ const building = new Map();
616
753
  let order = 0;
617
754
  for (const access of flow.propertyAccesses) {
618
755
  const key = accessKey(access);
@@ -620,13 +757,22 @@ const createSession = (checker, flow) => {
620
757
  if (key === null)
621
758
  continue;
622
759
  const receiver = value(access.expression);
623
- let byKey = namedReadsByReceiver.get(receiver);
760
+ let byKey = building.get(receiver);
624
761
  if (!byKey)
625
- namedReadsByReceiver.set(receiver, (byKey = new Map()));
626
- let entries = byKey.get(key);
627
- if (!entries)
628
- byKey.set(key, (entries = []));
629
- entries.push({ access, receiver, key, order: position });
762
+ building.set(receiver, (byKey = new Map()));
763
+ let positions = byKey.get(key);
764
+ if (!positions)
765
+ byKey.set(key, (positions = []));
766
+ positions.push(position);
767
+ }
768
+ // Copied to their exact length, as `writesByBodyValue`'s lists are.
769
+ for (const [receiver, byKey] of building) {
770
+ if (byKey.size === 1) {
771
+ const [key, positions] = byKey.entries().next().value;
772
+ namedReadsByReceiver.set(receiver, { key, positions: positions.slice() });
773
+ }
774
+ else
775
+ namedReadsByReceiver.set(receiver, new Map([...byKey].map(([key, positions]) => [key, positions.slice()])));
630
776
  }
631
777
  }
632
778
  /**
@@ -710,33 +856,9 @@ const createSession = (checker, flow) => {
710
856
  const aliased = checker.getAliasedSymbol(symbol).declarations ?? [];
711
857
  return aliased.length === 1 ? aliased[0] : null;
712
858
  };
713
- const slot = (root, key) => {
714
- let keys = slots.get(root);
715
- if (!keys)
716
- slots.set(root, (keys = new Map()));
717
- let query = keys.get(key);
718
- if (!query)
719
- keys.set(key, (query = { kind: 'slot', node: root, key }));
720
- return query;
721
- };
722
- const storedSlot = (root, key) => {
723
- let keys = storedSlots.get(root);
724
- if (!keys)
725
- storedSlots.set(root, (keys = new Map()));
726
- let query = keys.get(key);
727
- if (!query)
728
- keys.set(key, (query = { kind: 'stored-slot', node: root, key }));
729
- return query;
730
- };
731
- const use = (root, reference) => {
732
- let refs = uses.get(root);
733
- if (!refs)
734
- uses.set(root, (refs = new Map()));
735
- let query = refs.get(reference);
736
- if (!query)
737
- refs.set(reference, (query = { kind: 'use', root, node: reference }));
738
- return query;
739
- };
859
+ const slot = (root, key) => internIn(slots, root, key, keyedQueryKey, () => new QueryState('slot', root, key, undefined));
860
+ const storedSlot = (root, key) => internIn(storedSlots, root, key, keyedQueryKey, () => new QueryState('stored-slot', root, key, undefined));
861
+ const use = (root, reference) => internIn(uses, root, reference, (query) => query.node, () => new QueryState('use', reference, undefined, root));
740
862
  const publication = (root, container, key) => {
741
863
  let containers = publications.get(root);
742
864
  if (!containers)
@@ -746,7 +868,7 @@ const createSession = (checker, flow) => {
746
868
  containers.set(container, (keys = new Map()));
747
869
  let query = keys.get(key);
748
870
  if (!query)
749
- keys.set(key, (query = { kind: 'publication', root, node: container, key }));
871
+ keys.set(key, (query = new QueryState('publication', container, key, root)));
750
872
  return query;
751
873
  };
752
874
  /** The cell holding the object a binding element takes apart, as a query. */
@@ -1243,11 +1365,18 @@ const createSession = (checker, flow) => {
1243
1365
  if (write.value === undefined || write.value === null)
1244
1366
  continue;
1245
1367
  const held = unwrapErasedExpression(write.value);
1368
+ // Only a body is ever asked about, and only a function-like value can be one.
1369
+ if (!ts.isFunctionLike(held))
1370
+ continue;
1246
1371
  let writes = index.get(held);
1247
1372
  if (!writes)
1248
1373
  index.set(held, (writes = []));
1249
1374
  writes.push(write);
1250
1375
  }
1376
+ // Kept for the session, and nearly every list holds one write: copied
1377
+ // to its exact length, where a list grown by `push` reserves 17 slots.
1378
+ for (const [held, writes] of index)
1379
+ index.set(held, writes.slice());
1251
1380
  writesByBodyValue = index;
1252
1381
  }
1253
1382
  return writesByBodyValue.get(body) ?? [];
@@ -1310,20 +1439,22 @@ const createSession = (checker, flow) => {
1310
1439
  return false;
1311
1440
  return checker.isTypeAssignableTo(instance, stated);
1312
1441
  };
1313
- const candidateCallersOf = (body) => {
1442
+ /**
1443
+ * The sites that may call `body`, in site order, as the whole-program lists
1444
+ * they come from: every call for a body no name reaches, else the calls no
1445
+ * name spells followed by those spelling one of its names. Kept as parts so
1446
+ * a whole-program part is indexed once and shared, not copied per body.
1447
+ */
1448
+ const candidateCallerPartsOf = (body) => {
1314
1449
  const index = buildCalleeIndex();
1315
1450
  const names = namesOf(body);
1316
1451
  if (names === null)
1317
- return flow.calls;
1318
- // `unspelledCallees` is a whole-program list and this runs once per
1319
- // TRANSFER, not once per program -- `[...unspelledCallees]` copied it on
1320
- // every call just to push a handful of named matches on top. `both`
1321
- // hands it back by reference when there is nothing to add.
1452
+ return [flow.calls];
1322
1453
  const named = [];
1323
1454
  for (const name of names)
1324
1455
  for (const site of index.get(name) ?? [])
1325
1456
  named.push(site);
1326
- return both(unspelledCallees, named);
1457
+ return [unspelledCallees, named].filter((part) => part.length > 0);
1327
1458
  };
1328
1459
  /**
1329
1460
  * The calls that actually target this body -- the same question
@@ -1360,56 +1491,47 @@ const createSession = (checker, flow) => {
1360
1491
  let valueIterationWrites = null;
1361
1492
  /**
1362
1493
  * The part of `case 'callers'` that no fact can move: which candidate sites
1363
- * are syntax-and-checker matches for `owner`. The transfer re-ran it on
1364
- * every re-evaluation, asking the checker for each member receiver's type and
1365
- * its assignability to the owner's class each time; on a large program that
1366
- * was the session's heaviest transfer. Kept in site order, so the facts the
1367
- * transfer adds keep their order.
1494
+ * are syntax-and-checker matches for `owner`. `new Factory( state )` on a
1495
+ * plain function enters the function's own argument frame exactly as a call
1496
+ * would; the construction domain names no class for it, so it is a caller
1497
+ * unconditionally. A member call is a candidate only where its receiver's
1498
+ * stated type admits the owner's class.
1368
1499
  */
1369
- const callerCandidates = new Map();
1370
- const callerCandidatesOf = (owner) => {
1371
- const known = callerCandidates.get(owner);
1372
- if (known !== undefined)
1373
- return known;
1374
- const ownerType = ownerInstanceTypeOf(owner);
1375
- const answer = [];
1376
- for (const site of candidateCallersOf(owner)) {
1377
- // `new Factory( state )` on a plain function enters the
1378
- // function's own argument frame exactly as a call would; the
1379
- // construction domain names no class for it, so it is a caller.
1380
- if (ts.isNewExpression(site.call)) {
1381
- if (ts.isFunctionDeclaration(owner) && constructorFunctionCalleeOf(site.call) === owner)
1382
- answer.push({ site, call: null });
1383
- continue;
1384
- }
1385
- if (!ts.isCallExpression(site.call))
1386
- continue;
1387
- if (ownerType !== null && !site.explicitThis && site.operands.dispatch.kind === 'member' && site.operands.receiver !== null) {
1388
- if (!statedTypeAdmits(checker.getTypeAtLocation(site.operands.receiver), ownerType))
1389
- continue;
1390
- }
1391
- answer.push({ site, call: site.call });
1392
- }
1393
- callerCandidates.set(owner, answer);
1394
- return answer;
1500
+ const unconditionalCaller = (owner, site) => ts.isNewExpression(site.call) && ts.isFunctionDeclaration(owner) && constructorFunctionCalleeOf(site.call) === owner;
1501
+ const conditionalCaller = (ownerType, site) => {
1502
+ if (!ts.isCallExpression(site.call))
1503
+ return false;
1504
+ if (ownerType === null || site.explicitThis || site.operands.dispatch.kind !== 'member' || site.operands.receiver === null)
1505
+ return true;
1506
+ return statedTypeAdmits(checker.getTypeAtLocation(site.operands.receiver), ownerType);
1395
1507
  };
1396
- const callerCandidateIndexes = new Map();
1397
- const callerCandidateIndexOf = (owner) => {
1398
- const known = callerCandidateIndexes.get(owner);
1508
+ const callerSites = new WeakMap();
1509
+ const indexedCallerSitesOf = (sites) => {
1510
+ const known = callerSites.get(sites);
1399
1511
  if (known !== undefined)
1400
1512
  return known;
1401
- const list = callerCandidatesOf(owner);
1402
1513
  const positions = new Map();
1403
- const unconditional = [];
1404
- list.forEach((candidate, position) => {
1405
- if (candidate.call === null)
1406
- unconditional.push(position);
1407
- else if (!positions.has(candidate.call))
1408
- positions.set(candidate.call, position);
1514
+ sites.forEach((site, position) => {
1515
+ if (ts.isCallExpression(site.call) && !positions.has(site.call))
1516
+ positions.set(site.call, position);
1409
1517
  });
1410
- const index = { list, positions, unconditional, seeded: false };
1411
- callerCandidateIndexes.set(owner, index);
1412
- return index;
1518
+ const built = { sites, positions, seeded: false };
1519
+ callerSites.set(sites, built);
1520
+ return built;
1521
+ };
1522
+ const callerSegments = new Map();
1523
+ const callerSegmentsOf = (owner) => {
1524
+ const known = callerSegments.get(owner);
1525
+ if (known !== undefined)
1526
+ return known;
1527
+ const ownerType = ownerInstanceTypeOf(owner);
1528
+ const segments = candidateCallerPartsOf(owner).map((sites) => ({
1529
+ sites: indexedCallerSitesOf(sites),
1530
+ ownerType,
1531
+ unconditional: null
1532
+ }));
1533
+ callerSegments.set(owner, segments);
1534
+ return segments;
1413
1535
  };
1414
1536
  let constructionsByOwner = null;
1415
1537
  /**
@@ -1428,7 +1550,8 @@ const createSession = (checker, flow) => {
1428
1550
  * it, the answer is the same set and the edges are none.
1429
1551
  */
1430
1552
  const NO_READS = [];
1431
- const NO_NAMED_READS = [];
1553
+ const NO_RECEIVERS = [];
1554
+ const NO_POSITIONS = [];
1432
1555
  const NO_SITES = [];
1433
1556
  let constructionSitesByTarget = null;
1434
1557
  const constructionSitesTargeting = (owner) => {
@@ -1592,23 +1715,48 @@ const createSession = (checker, flow) => {
1592
1715
  // a re-seal's causes by identity, and a fresh literal per evaluation made
1593
1716
  // every unchanged refusal look like a changed seal -- each one threw away
1594
1717
  // the component solve and re-expanded the whole sealed graph.
1718
+ // A node refused for one reason holds its cause directly rather than a
1719
+ // one-entry Map: ~15K nodes on a 48K-line app, all but a few dozen with a
1720
+ // single reason, and the cause already carries the reason it is keyed by.
1595
1721
  const internedCauses = new Map();
1596
1722
  const causeOf = (reason, node) => {
1597
- let byReason = internedCauses.get(node);
1598
- if (byReason === undefined)
1599
- internedCauses.set(node, (byReason = new Map()));
1600
- let cause = byReason.get(reason);
1723
+ const held = internedCauses.get(node);
1724
+ if (held === undefined) {
1725
+ const cause = { reason, node };
1726
+ internedCauses.set(node, cause);
1727
+ return cause;
1728
+ }
1729
+ if (!(held instanceof Map)) {
1730
+ if (held.reason === reason)
1731
+ return held;
1732
+ const cause = { reason, node };
1733
+ internedCauses.set(node, new Map([
1734
+ [held.reason, held],
1735
+ [reason, cause]
1736
+ ]));
1737
+ return cause;
1738
+ }
1739
+ let cause = held.get(reason);
1601
1740
  if (cause === undefined)
1602
- byReason.set(reason, (cause = { reason, node }));
1741
+ held.set(reason, (cause = { reason, node }));
1603
1742
  return cause;
1604
1743
  };
1605
- const define = (query) => {
1606
- let finalCauses = [];
1607
- let finalGrounding = [];
1608
- let seeded = false;
1609
- // Allocated on the first answer: most nodes never ask an own-key question.
1610
- let ownKeysAnswers = null;
1611
- const evaluate = (required, observe, holdersOf, sealing) => {
1744
+ /**
1745
+ * One definition for every node, handed the node it evaluates, rather than a
1746
+ * definition per node: `define` used to mint a transfer, a seal, a `run` and
1747
+ * an `evaluate` over each node's own variables, and the solver kept all four
1748
+ * and their context alive for the life of the session -- ~350 bytes for each
1749
+ * of ~224K nodes on a 48K-line app. What those variables carried is either
1750
+ * one evaluation's own (`seeded`, and the causes and grounding a seal reads
1751
+ * back through `outcome`) or a per-node cache kept in a map below.
1752
+ */
1753
+ const definition = (() => {
1754
+ // A node's map is allocated on its first answer: most nodes never ask an
1755
+ // own-key question.
1756
+ const ownKeysAnswersByQuery = new Map();
1757
+ const evaluate = (query, required, observe, holdersOf, sealing, outcome) => {
1758
+ let seeded = false;
1759
+ let ownKeysAnswers = ownKeysAnswersByQuery.get(query) ?? null;
1612
1760
  const facts = new Set();
1613
1761
  const causes = [];
1614
1762
  const grounding = new Set();
@@ -1766,7 +1914,9 @@ const createSession = (checker, flow) => {
1766
1914
  try {
1767
1915
  const answer = ownKeysUncached(root);
1768
1916
  ownKeys.set(root, answer);
1769
- (ownKeysAnswers ??= new Map()).set(root, { keys: answer, stamps, holderStamps });
1917
+ if (ownKeysAnswers === null)
1918
+ ownKeysAnswersByQuery.set(query, (ownKeysAnswers = new Map()));
1919
+ ownKeysAnswers.set(root, { keys: answer, stamps, holderStamps });
1770
1920
  return answer;
1771
1921
  }
1772
1922
  finally {
@@ -3803,27 +3953,45 @@ const createSession = (checker, flow) => {
3803
3953
  // candidate) pair -- for a body reached by name or handed to a host
3804
3954
  // callee, every same-named or unspelled call in the program -- and
3805
3955
  // that was the second-largest share of a large program's edges.
3806
- const candidates = callerCandidateIndexOf(owner);
3807
- if (!candidates.seeded) {
3808
- candidates.seeded = true;
3809
- for (const candidate of candidates.list)
3810
- if (candidate.call !== null)
3811
- seed(targets(candidate.call));
3812
- }
3813
- const matched = [];
3814
- for (const holder of holdersOf(owner)) {
3815
- if (holder.kind !== 'targets')
3956
+ const segments = callerSegmentsOf(owner);
3957
+ for (const segment of segments) {
3958
+ if (segment.unconditional !== null)
3816
3959
  continue;
3817
- const position = candidates.positions.get(holder.node);
3818
- if (position !== undefined)
3960
+ const { sites } = segment;
3961
+ const unconditional = [];
3962
+ // Without a receiver type or a `new F()` frame the candidates are
3963
+ // the same for every owner, and so is seeding them.
3964
+ const independent = segment.ownerType === null && !ts.isFunctionDeclaration(owner);
3965
+ if (!independent || !sites.seeded) {
3966
+ sites.sites.forEach((site, position) => {
3967
+ if (unconditionalCaller(owner, site))
3968
+ unconditional.push(position);
3969
+ else if (conditionalCaller(segment.ownerType, site))
3970
+ seed(targets(site.call));
3971
+ });
3972
+ if (independent)
3973
+ sites.seeded = true;
3974
+ }
3975
+ segment.unconditional = unconditional;
3976
+ }
3977
+ const holders = [...holdersOf(owner)];
3978
+ for (const segment of segments) {
3979
+ const { sites } = segment;
3980
+ const matched = [];
3981
+ for (const holder of holders) {
3982
+ if (holder.kind !== 'targets')
3983
+ continue;
3984
+ const position = sites.positions.get(holder.node);
3985
+ if (position !== undefined && conditionalCaller(segment.ownerType, sites.sites[position]))
3986
+ matched.push(position);
3987
+ }
3988
+ for (const position of segment.unconditional ?? [])
3819
3989
  matched.push(position);
3990
+ // Candidate order, the order the scan this replaces added them in.
3991
+ matched.sort((a, b) => a - b);
3992
+ for (const position of matched)
3993
+ facts.add(sites.sites[position].call);
3820
3994
  }
3821
- for (const position of candidates.unconditional)
3822
- matched.push(position);
3823
- // Candidate order, the order the scan this replaces added them in.
3824
- matched.sort((a, b) => a - b);
3825
- for (const position of matched)
3826
- facts.add(candidates.list[position].site.call);
3827
3995
  break;
3828
3996
  }
3829
3997
  case 'closure': {
@@ -3903,22 +4071,21 @@ const createSession = (checker, flow) => {
3903
4071
  if (seededReadKeys.has(key))
3904
4072
  continue;
3905
4073
  seededReadKeys.add(key);
3906
- for (const entry of readsByKey.get(key) ?? NO_READS)
3907
- seed(entry.receiver);
4074
+ for (const receiver of readsByKey.get(key) ?? NO_RECEIVERS)
4075
+ seed(receiver);
3908
4076
  }
3909
4077
  const found = [];
3910
4078
  for (const holder of holdersOf(container)) {
3911
- const byKey = namedReadsByReceiver.get(holder);
3912
- if (byKey === undefined)
4079
+ if (!namedReadsByReceiver.has(holder))
3913
4080
  continue;
3914
4081
  for (const key of reaching)
3915
- for (const entry of byKey.get(key) ?? NO_NAMED_READS)
3916
- found.push(entry);
4082
+ for (const position of namedReadsOf(holder, key) ?? NO_POSITIONS)
4083
+ found.push(position);
3917
4084
  }
3918
4085
  // Program order, the order the scan this replaces discovered them in.
3919
- found.sort((a, b) => a.order - b.order);
3920
- for (const entry of found)
3921
- facts.add(entry.access);
4086
+ found.sort((a, b) => a - b);
4087
+ for (const position of found)
4088
+ facts.add(flow.propertyAccesses[position]);
3922
4089
  break;
3923
4090
  }
3924
4091
  case 'own-keys': {
@@ -4032,22 +4199,30 @@ const createSession = (checker, flow) => {
4032
4199
  break;
4033
4200
  }
4034
4201
  }
4035
- finalCauses = causes;
4036
- // Only the seal reads the grounding edges, and the seal is the last
4037
- // call this query receives; materializing the list on every transfer
4038
- // allocated one object per carried edge per re-evaluation for nothing.
4039
- if (sealing)
4040
- finalGrounding = [...grounding].map((dependency) => ({ domain: VALUE_ORIGIN, dependency }));
4202
+ // Only the seal reads the causes and grounding edges, and the seal is
4203
+ // the last call this query receives; materializing the list on every
4204
+ // transfer allocated one object per carried edge per re-evaluation for
4205
+ // nothing.
4206
+ if (outcome !== null) {
4207
+ // Exactly sized: the solver keeps every seal's causes for the life
4208
+ // of the session, and a list grown by `push` reserves 17 slots.
4209
+ outcome.causes = causes.length === 0 ? NO_CAUSES : causes.slice();
4210
+ // The dependencies alone, all in `VALUE_ORIGIN` (`DependencyGroundingKeys`):
4211
+ // a lone one as itself, ~88K of a 48K-line app's seals keeping exactly one.
4212
+ outcome.grounding =
4213
+ grounding.size === 0 ? NO_GROUNDING : grounding.size === 1 ? grounding.values().next().value : exactListOf(grounding);
4214
+ outcome.seeded = seeded;
4215
+ }
4041
4216
  return facts;
4042
4217
  };
4043
- const run = (read, observe, holdersOf, sealing) => {
4218
+ const run = (query, read, observe, holdersOf, sealing, outcome) => {
4044
4219
  const ledger = deferredIntrinsicProtocolLedgerOf(flow);
4045
4220
  if (!ledger)
4046
- return evaluate(read, observe, holdersOf, sealing);
4047
- const captured = ledger.capture(() => evaluate(read, observe, holdersOf, sealing));
4048
- // Overwrite, not union -- like `finalCauses`/`finalGrounding` above,
4221
+ return evaluate(query, read, observe, holdersOf, sealing, outcome);
4222
+ const captured = ledger.capture(() => evaluate(query, read, observe, holdersOf, sealing, outcome));
4223
+ // Overwrite, not union -- like the seal's causes and grounding above,
4049
4224
  // this is safe ONLY because `evaluate` is monotone: `facts` published to
4050
- // the solver (`component-solver.ts`'s `state.facts`) accumulate forever
4225
+ // the solver (`component-solver.ts`'s `FactState`) accumulate forever
4051
4226
  // regardless of what any one call returns, so the LAST call for this
4052
4227
  // query (the seal that ends the re-seal loop) is the only one whose
4053
4228
  // `facts` can differ from that accumulated set, and then only by being
@@ -4063,25 +4238,54 @@ const createSession = (checker, flow) => {
4063
4238
  // is a wrong answer -- so if this invariant is ever broken again by a
4064
4239
  // NEW transfer, union (not overwrite) is the direction that cannot lie:
4065
4240
  // `both(requirements.get(query), captured.requirements)`.
4066
- requirements.set(query, captured.requirements);
4241
+ // Absent reads as empty (`?? []` below); one entry per state was a map of
4242
+ // mostly empty arrays.
4243
+ // Copied to its exact length (the ledger builds it by `filter`, which
4244
+ // reserves 17 slots for a one-element answer, and this map keeps one
4245
+ // per node for the life of the session), or held as its lone entry.
4246
+ if (captured.requirements.length === 0)
4247
+ requirements.delete(query);
4248
+ else
4249
+ requirements.set(query, captured.requirements.length === 1 ? captured.requirements[0] : captured.requirements.slice());
4067
4250
  return captured.value;
4068
4251
  };
4252
+ // The solver keeps every node's last seal for the life of the session and
4253
+ // only reads it, and a seal with no causes and no grounding edges is one
4254
+ // of these four -- ~140K of ~224K seals on a 48K-line app.
4255
+ const plainSeal = (carriesValue, seeded) => Object.freeze({
4256
+ locallyComplete: true,
4257
+ causes: NO_CAUSES,
4258
+ groundingRequirements: carriesValue ? VALUE_ORIGIN_DOMAIN : NO_DOMAINS,
4259
+ groundingSeeds: seeded ? VALUE_ORIGIN_DOMAIN : NO_DOMAINS,
4260
+ groundingDomain: VALUE_ORIGIN,
4261
+ groundingKeys: NO_GROUNDING
4262
+ });
4263
+ const plainSeals = [
4264
+ [plainSeal(false, false), plainSeal(false, true)],
4265
+ [plainSeal(true, false), plainSeal(true, true)]
4266
+ ];
4069
4267
  return {
4070
- transfer: (read, observe, holdersOf) => run(read, observe, holdersOf, false),
4071
- seal: (read, observe, holdersOf) => {
4072
- run(read, observe, holdersOf, true);
4268
+ transfer: (read, observe, holdersOf, query) => run(query, read, observe, holdersOf, false, null),
4269
+ seal: (read, observe, holdersOf, query) => {
4270
+ const outcome = { causes: NO_CAUSES, grounding: NO_GROUNDING, seeded: false };
4271
+ run(query, read, observe, holdersOf, true, outcome);
4073
4272
  const carriesValue = VALUE_CARRYING_KINDS.has(query.kind);
4273
+ if (outcome.causes === NO_CAUSES && outcome.grounding === NO_GROUNDING)
4274
+ return plainSeals[carriesValue ? 1 : 0][outcome.seeded ? 1 : 0];
4275
+ if (outcome.causes === NO_CAUSES)
4276
+ return new GroundedSeal(outcome.grounding, (carriesValue ? CARRIES_VALUE : 0) | (outcome.seeded ? SEEDED : 0));
4074
4277
  return {
4075
- locallyComplete: finalCauses.length === 0,
4076
- causes: finalCauses,
4077
- groundingRequirements: carriesValue ? [VALUE_ORIGIN] : [],
4078
- groundingSeeds: seeded ? [VALUE_ORIGIN] : [],
4079
- groundingDependencies: finalGrounding
4278
+ locallyComplete: outcome.causes.length === 0,
4279
+ causes: outcome.causes,
4280
+ groundingRequirements: carriesValue ? VALUE_ORIGIN_DOMAIN : NO_DOMAINS,
4281
+ groundingSeeds: outcome.seeded ? VALUE_ORIGIN_DOMAIN : NO_DOMAINS,
4282
+ groundingDomain: VALUE_ORIGIN,
4283
+ groundingKeys: outcome.grounding
4080
4284
  };
4081
4285
  }
4082
4286
  };
4083
- };
4084
- const { solve, requiredDependenciesOf, seed } = dependencyFactSolver(define, 'grounding-domains');
4287
+ })();
4288
+ const { solve, requiredDependenciesOf, seed } = dependencyFactSolver(definition, 'grounding-domains', true);
4085
4289
  // `case 'unknown-reads'` now asks `holdersOf` for the receivers that hold a
4086
4290
  // container, instead of `observe`-ing all 968 of them itself -- but a
4087
4291
  // reverse index only finds states that already EXIST and have already run.
@@ -4106,7 +4310,11 @@ const createSession = (checker, flow) => {
4106
4310
  if (visited.has(query))
4107
4311
  continue;
4108
4312
  visited.add(query);
4109
- found.push(...(requirements.get(query) ?? []));
4313
+ const held = requirements.get(query);
4314
+ if (Array.isArray(held))
4315
+ found.push(...held);
4316
+ else if (held !== undefined)
4317
+ found.push(held);
4110
4318
  for (const dependency of requiredDependenciesOf(query))
4111
4319
  queue.push(dependency);
4112
4320
  }