@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.
- package/dist/cli-emit.js +5 -0
- package/dist/cli.js +10 -0
- package/dist/compiler.d.ts +10 -3
- package/dist/compiler.js +364 -224
- package/dist/conversion/build.d.ts +13 -1
- package/dist/conversion/build.js +336 -141
- package/dist/conversion/graph-validation.d.ts +7 -2
- package/dist/conversion/graph-validation.js +36 -22
- package/dist/conversion/native-sum.js +106 -17
- package/dist/diagnostics/sweep.js +1 -1
- package/dist/ir/callable-class-flow.d.ts +0 -11
- package/dist/ir/callable-class-flow.js +970 -169
- package/dist/ir/certificate.d.ts +1 -1
- package/dist/ir/certificate.js +12 -1
- package/dist/ir/certify/carrier-keys.d.ts +17 -1
- package/dist/ir/certify/carrier-keys.js +35 -2
- package/dist/ir/certify/function-source.js +2 -1
- package/dist/ir/certify/has-property-key.d.ts +6 -0
- package/dist/ir/certify/has-property-key.js +8 -1
- package/dist/ir/certify/property-access-keys.js +2 -1
- package/dist/ir/certify/runtime-helper.js +2 -1
- package/dist/ir/construction-only-fields.d.ts +35 -2
- package/dist/ir/construction-only-fields.js +100 -0
- package/dist/ir/emission-representations.d.ts +2 -2
- package/dist/ir/emission-representations.js +9 -3
- package/dist/ir/generic-call-entry.d.ts +3 -1
- package/dist/ir/logical-receivers.js +29 -1
- package/dist/ir/lower-completion.js +11 -6
- package/dist/ir/lower-destructuring.js +3 -2
- package/dist/ir/native-host-method-reads.d.ts +5 -0
- package/dist/ir/native-host-method-reads.js +30 -21
- package/dist/ir/operation-conversions.js +4 -1
- package/dist/ir/publish-conversion-recipes.js +12 -1
- package/dist/plugins/apple/jsx.js +1 -1
- package/dist/plugins/gea/component-classes.js +1 -1
- package/dist/plugins/gea/component-inline.js +1 -1
- package/dist/plugins/gea/contract.d.ts +1 -1
- package/dist/plugins/gea/contract.js +1 -1
- package/dist/plugins/gea/host.js +27 -1
- package/dist/plugins/gea/lower.js +8 -1
- package/dist/plugins/gea/producer.js +1 -1
- package/dist/plugins/gea/reactive-slots.d.ts +1 -1
- package/dist/plugins/gea/reactive-slots.js +1 -1
- package/dist/plugins/load.js +51 -22
- package/dist/preflight/run.d.ts +12 -1
- package/dist/preflight/run.js +65 -29
- package/dist/projection/native-callable-data.js +2 -1
- package/dist/representation/plan.js +102 -4
- package/dist/semantics/alias-this-field-declaration-transform.js +1 -1
- package/dist/semantics/ambient-type-realization-transform.js +1 -1
- package/dist/semantics/ambient.d.ts +1 -1
- package/dist/semantics/ambient.js +1 -1
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +1 -1
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +1 -1
- package/dist/semantics/call-invalidated-narrowing.d.ts +1 -1
- package/dist/semantics/call-invalidated-narrowing.js +4 -2
- package/dist/semantics/callable-own-data-slots.d.ts +6 -0
- package/dist/semantics/callable-own-data-slots.js +177 -101
- package/dist/semantics/class-alias.d.ts +1 -1
- package/dist/semantics/class-alias.js +1 -1
- package/dist/semantics/class-heritage.d.ts +1 -1
- package/dist/semantics/class-heritage.js +1 -1
- package/dist/semantics/commonjs-wrapper.d.ts +4 -3
- package/dist/semantics/commonjs-wrapper.js +50 -7
- package/dist/semantics/constructor-function-class-source-transform.js +1 -1
- package/dist/semantics/constructor-slot-subclasses.d.ts +1 -1
- package/dist/semantics/constructor-slot-subclasses.js +1 -1
- package/dist/semantics/declaration-overlay-transform.js +3 -2
- package/dist/semantics/declared-integers.d.ts +1 -1
- package/dist/semantics/declared-integers.js +1 -1
- package/dist/semantics/define-property-source-transform.js +1 -1
- package/dist/semantics/diagnostic-source-preparation.d.ts +1 -1
- package/dist/semantics/documentation-ranges.d.ts +1 -1
- package/dist/semantics/documentation-ranges.js +1 -1
- package/dist/semantics/dynamic-fallback.d.ts +1 -1
- package/dist/semantics/dynamic-fallback.js +1 -1
- package/dist/semantics/frontend-timing.js +19 -0
- package/dist/semantics/frontend.d.ts +2 -2
- package/dist/semantics/frontend.js +127 -54
- package/dist/semantics/host-declaration-provenance.d.ts +1 -1
- package/dist/semantics/host-methods.d.ts +1 -1
- package/dist/semantics/host-methods.js +1 -1
- package/dist/semantics/host-protocols.d.ts +1 -1
- package/dist/semantics/host-protocols.js +1 -1
- package/dist/semantics/inherited-accessor.d.ts +1 -1
- package/dist/semantics/inherited-accessor.js +1 -1
- package/dist/semantics/interface-families.d.ts +1 -1
- package/dist/semantics/interface-families.js +1 -1
- package/dist/semantics/interface-implementors.d.ts +1 -1
- package/dist/semantics/interface-implementors.js +1 -1
- package/dist/semantics/jsdoc-namepath-transform.js +1 -1
- package/dist/semantics/jsx-runtime-provider.d.ts +1 -1
- package/dist/semantics/jsx-runtime-provider.js +1 -1
- package/dist/semantics/known-caller-predicate-parameters.d.ts +1 -1
- package/dist/semantics/known-caller-predicate-parameters.js +1 -1
- package/dist/semantics/model/edges.d.ts +124 -0
- package/dist/semantics/model/edges.js +192 -0
- package/dist/semantics/model/graph.d.ts +26 -2
- package/dist/semantics/model/graph.js +54 -0
- package/dist/semantics/model/sealed-facts.d.ts +19 -0
- package/dist/semantics/model/sealed-facts.js +221 -0
- package/dist/semantics/model/selected-signature.d.ts +1 -1
- package/dist/semantics/model/selected-signature.js +1 -1
- package/dist/semantics/module-resolution.d.ts +1 -1
- package/dist/semantics/module-resolution.js +1 -1
- package/dist/semantics/native-function-signatures.d.ts +1 -1
- package/dist/semantics/native-function-signatures.js +1 -1
- package/dist/semantics/native-object-data-slots.js +20 -4
- package/dist/semantics/new-callee-class-tag-source-transform.js +1 -1
- package/dist/semantics/node-project.d.ts +1 -1
- package/dist/semantics/node-project.js +1 -1
- package/dist/semantics/node-source-hooks.js +1 -1
- package/dist/semantics/normalize/absent-globals.d.ts +1 -1
- package/dist/semantics/normalize/absent-globals.js +1 -1
- package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
- package/dist/semantics/normalize/any-cast-member-call.js +1 -1
- package/dist/semantics/normalize/arguments-objects.d.ts +1 -1
- package/dist/semantics/normalize/arguments-objects.js +1 -1
- package/dist/semantics/normalize/asserted-argument-arms.d.ts +1 -1
- package/dist/semantics/normalize/asserted-argument-arms.js +1 -1
- package/dist/semantics/normalize/asserted-arm-absence.d.ts +1 -1
- package/dist/semantics/normalize/asserted-arm-absence.js +1 -1
- package/dist/semantics/normalize/assignment-patterns.d.ts +1 -1
- package/dist/semantics/normalize/assignment-patterns.js +1 -1
- package/dist/semantics/normalize/bag-absence.d.ts +1 -1
- package/dist/semantics/normalize/bag-absence.js +1 -1
- package/dist/semantics/normalize/binding-fixpoint.js +9 -2
- package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +1 -1
- package/dist/semantics/normalize/bivariant-slot-parameter.js +1 -1
- package/dist/semantics/normalize/callable-data-write.d.ts +1 -1
- package/dist/semantics/normalize/callable-data-write.js +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.js +1 -1
- package/dist/semantics/normalize/cells/agreement.d.ts +18 -1
- package/dist/semantics/normalize/cells/agreement.js +8 -0
- package/dist/semantics/normalize/cells/candidates.d.ts +1 -1
- package/dist/semantics/normalize/cells/candidates.js +1 -1
- package/dist/semantics/normalize/cells/facts.d.ts +1 -1
- package/dist/semantics/normalize/cells/facts.js +1 -1
- package/dist/semantics/normalize/cells/index.d.ts +2 -2
- package/dist/semantics/normalize/cells/index.js +1 -1
- package/dist/semantics/normalize/cells/model.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/bag.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/collection.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/collection.js +1 -1
- package/dist/semantics/normalize/cells/policies/field.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/field.js +1 -1
- package/dist/semantics/normalize/cells/policies/index.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/local.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/local.js +1 -1
- package/dist/semantics/normalize/cells/policies/parameter.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/parameter.js +1 -1
- package/dist/semantics/normalize/cells/policies/return.d.ts +1 -1
- package/dist/semantics/normalize/cells/policies/return.js +1 -1
- package/dist/semantics/normalize/cells/policies/shared.d.ts +1 -1
- package/dist/semantics/normalize/cells/policy.d.ts +1 -1
- package/dist/semantics/normalize/census.d.ts +1 -1
- package/dist/semantics/normalize/census.js +45 -12
- package/dist/semantics/normalize/class-instance-record-statement.d.ts +1 -1
- package/dist/semantics/normalize/class-instance-record-statement.js +1 -1
- package/dist/semantics/normalize/collection-bindings.d.ts +1 -1
- package/dist/semantics/normalize/collection-bindings.js +1 -1
- package/dist/semantics/normalize/commonjs-module-record.d.ts +1 -1
- package/dist/semantics/normalize/commonjs-module-record.js +1 -1
- package/dist/semantics/normalize/commonjs-require.d.ts +1 -1
- package/dist/semantics/normalize/commonjs-require.js +1 -1
- package/dist/semantics/normalize/contribution.d.ts +4 -3
- package/dist/semantics/normalize/contribution.js +145 -42
- package/dist/semantics/normalize/dead-event-emissions.d.ts +1 -1
- package/dist/semantics/normalize/dead-event-emissions.js +1 -1
- package/dist/semantics/normalize/dead-method-copies.d.ts +1 -1
- package/dist/semantics/normalize/dead-method-copies.js +1 -1
- package/dist/semantics/normalize/dead-typeof-guards.d.ts +1 -1
- package/dist/semantics/normalize/dead-typeof-guards.js +1 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +1 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +1 -1
- package/dist/semantics/normalize/derived-expression-type.d.ts +1 -1
- package/dist/semantics/normalize/derived-expression-type.js +4 -4
- package/dist/semantics/normalize/evaluation-order.d.ts +1 -1
- package/dist/semantics/normalize/evaluation-order.js +1 -1
- package/dist/semantics/normalize/field-bindings.d.ts +1 -1
- package/dist/semantics/normalize/field-bindings.js +4 -3
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +1 -1
- package/dist/semantics/normalize/flow/array-element-continuation.js +3 -3
- package/dist/semantics/normalize/flow/callable-array-origins.d.ts +1 -1
- package/dist/semantics/normalize/flow/callable-array-origins.js +1 -1
- package/dist/semantics/normalize/flow/callable-completions.d.ts +1 -1
- package/dist/semantics/normalize/flow/callable-completions.js +1 -1
- package/dist/semantics/normalize/flow/callable-reach.d.ts +1 -1
- package/dist/semantics/normalize/flow/callable-reach.js +73 -52
- package/dist/semantics/normalize/flow/class-family-member-read.d.ts +1 -1
- package/dist/semantics/normalize/flow/class-family-member-read.js +3 -3
- package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +1 -1
- package/dist/semantics/normalize/flow/collection-value-continuation.js +1 -1
- package/dist/semantics/normalize/flow/component-solver.d.ts +181 -3
- package/dist/semantics/normalize/flow/component-solver.js +705 -164
- package/dist/semantics/normalize/flow/computed-key-set.d.ts +1 -1
- package/dist/semantics/normalize/flow/computed-key-set.js +1 -1
- package/dist/semantics/normalize/flow/export-importers.d.ts +1 -1
- package/dist/semantics/normalize/flow/export-importers.js +13 -3
- package/dist/semantics/normalize/flow/host-text-sink.d.ts +1 -1
- package/dist/semantics/normalize/flow/host-text-sink.js +1 -1
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +1 -1
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +1 -1
- package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +1 -1
- package/dist/semantics/normalize/flow/intrinsic-data-definition.js +1 -1
- package/dist/semantics/normalize/flow/invocation-facts.d.ts +1 -1
- package/dist/semantics/normalize/flow/invocation-facts.js +1 -1
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +1 -1
- package/dist/semantics/normalize/flow/member-call-forwarding.js +1 -1
- package/dist/semantics/normalize/flow/model.d.ts +1 -1
- package/dist/semantics/normalize/flow/model.js +5 -1
- package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +1 -1
- package/dist/semantics/normalize/flow/native-collection-protocol.js +1 -1
- package/dist/semantics/normalize/flow/node-path-token.d.ts +1 -1
- package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +1 -1
- package/dist/semantics/normalize/flow/object-binding-continuation.js +1 -1
- package/dist/semantics/normalize/flow/origin-authority.d.ts +1 -1
- package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +1 -1
- package/dist/semantics/normalize/flow/owned-class-receivers.js +1 -1
- package/dist/semantics/normalize/flow/parameter-values.d.ts +1 -1
- package/dist/semantics/normalize/flow/parameter-values.js +1 -1
- package/dist/semantics/normalize/flow/record-alias-closure.d.ts +1 -1
- package/dist/semantics/normalize/flow/record-alias-closure.js +1 -1
- package/dist/semantics/normalize/flow/seeded-origins.d.ts +1 -1
- package/dist/semantics/normalize/flow/seeded-origins.js +1 -1
- package/dist/semantics/normalize/flow/source-accessor-descriptor.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-accessor-descriptor.js +1 -1
- package/dist/semantics/normalize/flow/source-callable-own-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-callable-own-data.js +1 -1
- package/dist/semantics/normalize/flow/source-callable-readonly-set.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-callable-readonly-set.js +1 -1
- package/dist/semantics/normalize/flow/source-class-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-class-data.js +1 -1
- package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-class-instanceof.js +1 -1
- package/dist/semantics/normalize/flow/source-class-static-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-class-static-data.js +1 -1
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-construction-frames.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-construction-frames.js +1 -1
- package/dist/semantics/normalize/flow/source-descriptor-protocol.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-descriptor-protocol.js +1 -1
- package/dist/semantics/normalize/flow/source-executing-parameter-values.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-executing-parameter-values.js +1 -1
- package/dist/semantics/normalize/flow/source-global-binding.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-global-binding.js +1 -1
- package/dist/semantics/normalize/flow/source-intrinsic-member-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-intrinsic-member-data.js +1 -1
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +24 -32
- package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-invocation-receiver.js +1 -1
- package/dist/semantics/normalize/flow/source-native-class-alias.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-native-class-alias.js +1 -1
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +1 -1
- package/dist/semantics/normalize/flow/source-native-origin.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-native-origin.js +1 -1
- package/dist/semantics/normalize/flow/source-normal-predecessor.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-normal-predecessor.js +1 -1
- package/dist/semantics/normalize/flow/source-property-key.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-property-key.js +1 -1
- package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-prototype-method-identity.js +1 -1
- package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-proxy-operation.js +1 -1
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +1 -1
- package/dist/semantics/normalize/flow/source-read-protocol.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-read-protocol.js +1 -1
- package/dist/semantics/normalize/flow/source-record-data.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-record-data.js +1 -1
- package/dist/semantics/normalize/flow/source-value-session.d.ts +33 -3
- package/dist/semantics/normalize/flow/source-value-session.js +381 -173
- package/dist/semantics/normalize/flow/standard-prototype-method-source.d.ts +1 -1
- package/dist/semantics/normalize/flow/standard-prototype-method-source.js +1 -1
- package/dist/semantics/normalize/flow/targets.d.ts +1 -1
- package/dist/semantics/normalize/flow/targets.js +1 -1
- package/dist/semantics/normalize/flow/value-flow.d.ts +1 -1
- package/dist/semantics/normalize/flow/value-flow.js +243 -52
- package/dist/semantics/normalize/flow/value-provenance.d.ts +1 -1
- package/dist/semantics/normalize/flow/value-provenance.js +1 -1
- package/dist/semantics/normalize/fresh-dictionary-storage.d.ts +1 -1
- package/dist/semantics/normalize/fresh-dictionary-storage.js +1 -1
- package/dist/semantics/normalize/fresh-ordinary-object.d.ts +1 -1
- package/dist/semantics/normalize/fresh-ordinary-object.js +1 -1
- package/dist/semantics/normalize/fresh-table-last-use.d.ts +1 -1
- package/dist/semantics/normalize/fresh-table-last-use.js +1 -1
- package/dist/semantics/normalize/gating.d.ts +3 -3
- package/dist/semantics/normalize/gating.js +17 -20
- package/dist/semantics/normalize/generic-function-choice.d.ts +1 -1
- package/dist/semantics/normalize/generic-function-choice.js +1 -1
- package/dist/semantics/normalize/global-host-mutations.d.ts +1 -1
- package/dist/semantics/normalize/global-host-mutations.js +420 -138
- package/dist/semantics/normalize/host-effect-contracts.d.ts +1 -1
- package/dist/semantics/normalize/host-effect-contracts.js +1 -1
- package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +1 -1
- package/dist/semantics/normalize/host-mutation-key-reader.d.ts +1 -1
- package/dist/semantics/normalize/host-mutation-key-reader.js +1 -1
- package/dist/semantics/normalize/identities.d.ts +41 -1
- package/dist/semantics/normalize/identities.js +75 -9
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +1 -1
- package/dist/semantics/normalize/implicit-arguments-tuple.js +1 -1
- package/dist/semantics/normalize/implicit-arguments.d.ts +1 -1
- package/dist/semantics/normalize/implicit-arguments.js +1 -1
- package/dist/semantics/normalize/installed-global-properties.d.ts +1 -1
- package/dist/semantics/normalize/installed-global-properties.js +1 -1
- package/dist/semantics/normalize/instantiation.d.ts +1 -1
- package/dist/semantics/normalize/instantiation.js +1 -1
- package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-accessor-getter.js +1 -1
- package/dist/semantics/normalize/intrinsic-property-call.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-property-call.js +1 -1
- package/dist/semantics/normalize/intrinsic-prototype.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-prototype.js +1 -1
- package/dist/semantics/normalize/intrinsic-return-identity.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-return-identity.js +1 -1
- package/dist/semantics/normalize/intrinsic-static-member.d.ts +1 -1
- package/dist/semantics/normalize/jsdoc-type-names.d.ts +1 -1
- package/dist/semantics/normalize/jsdoc-type-names.js +1 -1
- package/dist/semantics/normalize/local-bindings.d.ts +1 -1
- package/dist/semantics/normalize/local-bindings.js +3 -2
- package/dist/semantics/normalize/logical-object-truthiness.d.ts +1 -1
- package/dist/semantics/normalize/logical-object-truthiness.js +1 -1
- package/dist/semantics/normalize/logical-result-type.d.ts +1 -1
- package/dist/semantics/normalize/logical-result-type.js +1 -1
- package/dist/semantics/normalize/merged-declaration.d.ts +1 -1
- package/dist/semantics/normalize/merged-declaration.js +1 -1
- package/dist/semantics/normalize/namespace-paths.d.ts +1 -1
- package/dist/semantics/normalize/namespace-paths.js +1 -1
- package/dist/semantics/normalize/never-override-result.d.ts +1 -1
- package/dist/semantics/normalize/never-override-result.js +1 -1
- package/dist/semantics/normalize/normalize.d.ts +23 -4
- package/dist/semantics/normalize/normalize.js +125 -15
- package/dist/semantics/normalize/null-blind-parameter.d.ts +1 -1
- package/dist/semantics/normalize/null-blind-parameter.js +1 -1
- package/dist/semantics/normalize/nullable-memo.d.ts +28 -0
- package/dist/semantics/normalize/nullable-memo.js +99 -0
- package/dist/semantics/normalize/object-bag-bindings.d.ts +1 -1
- package/dist/semantics/normalize/object-bag-bindings.js +15 -4
- package/dist/semantics/normalize/omitted-stated-parameter.d.ts +1 -1
- package/dist/semantics/normalize/omitted-stated-parameter.js +1 -1
- package/dist/semantics/normalize/open-type-form.d.ts +1 -1
- package/dist/semantics/normalize/open-type-form.js +1 -1
- package/dist/semantics/normalize/override-field-arms.d.ts +1 -1
- package/dist/semantics/normalize/override-field-arms.js +1 -1
- package/dist/semantics/normalize/parameter-bindings.d.ts +1 -52
- package/dist/semantics/normalize/parameter-bindings.js +105 -10
- package/dist/semantics/normalize/parameter-slot.d.ts +1 -1
- package/dist/semantics/normalize/parameter-slot.js +1 -1
- package/dist/semantics/normalize/physical-overload-result.d.ts +1 -1
- package/dist/semantics/normalize/physical-overload-result.js +1 -1
- package/dist/semantics/normalize/primitive-property-absence.d.ts +1 -1
- package/dist/semantics/normalize/producer-context.d.ts +1 -1
- package/dist/semantics/normalize/producers/allocations.d.ts +1 -1
- package/dist/semantics/normalize/producers/allocations.js +1 -1
- package/dist/semantics/normalize/producers/binding-kind.d.ts +1 -1
- package/dist/semantics/normalize/producers/binding-kind.js +1 -1
- package/dist/semantics/normalize/producers/bindings.d.ts +1 -1
- package/dist/semantics/normalize/producers/bindings.js +1 -1
- package/dist/semantics/normalize/producers/boundary.d.ts +1 -1
- package/dist/semantics/normalize/producers/boundary.js +1 -1
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +1 -1
- package/dist/semantics/normalize/producers/cited-value-type.js +1 -1
- package/dist/semantics/normalize/producers/class-lifecycle.js +1 -1
- package/dist/semantics/normalize/producers/computations.js +1 -1
- package/dist/semantics/normalize/producers/conditional-guard.d.ts +1 -1
- package/dist/semantics/normalize/producers/control-loops.d.ts +1 -1
- package/dist/semantics/normalize/producers/control-loops.js +1 -1
- package/dist/semantics/normalize/producers/control.d.ts +1 -1
- package/dist/semantics/normalize/producers/control.js +1 -1
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +1 -1
- package/dist/semantics/normalize/producers/destructuring.d.ts +1 -1
- package/dist/semantics/normalize/producers/destructuring.js +1 -1
- package/dist/semantics/normalize/producers/dynamic-language.js +1 -1
- package/dist/semantics/normalize/producers/enums.d.ts +1 -1
- package/dist/semantics/normalize/producers/enums.js +1 -1
- package/dist/semantics/normalize/producers/erasure.d.ts +1 -1
- package/dist/semantics/normalize/producers/erasure.js +1 -1
- package/dist/semantics/normalize/producers/exact-arms.d.ts +1 -1
- package/dist/semantics/normalize/producers/exact-arms.js +1 -1
- package/dist/semantics/normalize/producers/intrinsic-accessor-getter.d.ts +1 -1
- package/dist/semantics/normalize/producers/invocations.d.ts +1 -1
- package/dist/semantics/normalize/producers/invocations.js +1 -1
- package/dist/semantics/normalize/producers/iteration-yield.d.ts +1 -1
- package/dist/semantics/normalize/producers/iteration-yield.js +1 -1
- package/dist/semantics/normalize/producers/jsx.js +1 -1
- package/dist/semantics/normalize/producers/logical-merge-type.d.ts +1 -1
- package/dist/semantics/normalize/producers/logical-merge-type.js +1 -1
- package/dist/semantics/normalize/producers/mint.js +88 -5
- package/dist/semantics/normalize/producers/native-callable-readonly-set.d.ts +1 -1
- package/dist/semantics/normalize/producers/native-own-assignment.d.ts +1 -1
- package/dist/semantics/normalize/producers/native-own-assignment.js +1 -1
- package/dist/semantics/normalize/producers/nullish.d.ts +1 -1
- package/dist/semantics/normalize/producers/nullish.js +1 -1
- package/dist/semantics/normalize/producers/object-assignment.d.ts +1 -1
- package/dist/semantics/normalize/producers/object-assignment.js +1 -1
- package/dist/semantics/normalize/producers/object-tag.d.ts +1 -1
- package/dist/semantics/normalize/producers/object-tag.js +1 -1
- package/dist/semantics/normalize/producers/optional-chain.d.ts +1 -1
- package/dist/semantics/normalize/producers/optional-chain.js +1 -1
- package/dist/semantics/normalize/producers/properties.d.ts +1 -1
- package/dist/semantics/normalize/producers/properties.js +1 -1
- package/dist/semantics/normalize/producers/protocol.d.ts +1 -1
- package/dist/semantics/normalize/producers/protocol.js +1 -1
- package/dist/semantics/normalize/producers/references.d.ts +1 -1
- package/dist/semantics/normalize/producers/references.js +1 -1
- package/dist/semantics/normalize/producers/shared.d.ts +1 -1
- package/dist/semantics/normalize/producers/shared.js +1 -1
- package/dist/semantics/normalize/producers/spread-arguments.d.ts +1 -1
- package/dist/semantics/normalize/producers/spread-arguments.js +1 -1
- package/dist/semantics/normalize/producers/tagged-template.d.ts +1 -1
- package/dist/semantics/normalize/producers/tagged-template.js +1 -1
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +1 -1
- package/dist/semantics/normalize/producers/tuple-spread.js +1 -1
- package/dist/semantics/normalize/property-key-domain.d.ts +8 -1
- package/dist/semantics/normalize/property-key-domain.js +74 -47
- package/dist/semantics/normalize/reachability.d.ts +1 -1
- package/dist/semantics/normalize/reachability.js +3 -2
- package/dist/semantics/normalize/reassigned-bindings.d.ts +1 -1
- package/dist/semantics/normalize/record-home-arms.d.ts +1 -1
- package/dist/semantics/normalize/record-home-arms.js +1 -1
- package/dist/semantics/normalize/record-link-families.d.ts +1 -1
- package/dist/semantics/normalize/record-link-families.js +1 -1
- package/dist/semantics/normalize/record-stand-in-arms.d.ts +1 -1
- package/dist/semantics/normalize/record-stand-in-arms.js +1 -1
- package/dist/semantics/normalize/record-storage-families.d.ts +1 -1
- package/dist/semantics/normalize/record-storage-families.js +1 -1
- package/dist/semantics/normalize/return-bindings.d.ts +1 -1
- package/dist/semantics/normalize/return-bindings.js +1 -1
- package/dist/semantics/normalize/return-paths.d.ts +1 -1
- package/dist/semantics/normalize/return-paths.js +1 -1
- package/dist/semantics/normalize/round-tables.d.ts +21 -0
- package/dist/semantics/normalize/round-tables.js +59 -0
- package/dist/semantics/normalize/script-global-redefinition.d.ts +1 -1
- package/dist/semantics/normalize/script-global-redefinition.js +1 -1
- package/dist/semantics/normalize/shared-array-storage.d.ts +1 -1
- package/dist/semantics/normalize/shared-array-storage.js +1 -1
- package/dist/semantics/normalize/sloppy-absence.d.ts +1 -1
- package/dist/semantics/normalize/sloppy-absence.js +1 -1
- package/dist/semantics/normalize/source-native-iterable.d.ts +2 -2
- package/dist/semantics/normalize/source-native-iterable.js +4 -2
- package/dist/semantics/normalize/source-object-prototype-absence.d.ts +1 -1
- package/dist/semantics/normalize/source-object-prototype-absence.js +1 -1
- package/dist/semantics/normalize/specialization.d.ts +1 -1
- package/dist/semantics/normalize/specialization.js +1 -1
- package/dist/semantics/normalize/specialized-source-frames.d.ts +1 -1
- package/dist/semantics/normalize/specialized-source-frames.js +12 -4
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
- package/dist/semantics/normalize/structural-any-binding-consumer.js +1 -1
- package/dist/semantics/normalize/structural-array-element.d.ts +1 -1
- package/dist/semantics/normalize/structural-array-element.js +1 -1
- package/dist/semantics/normalize/structural-array-read.d.ts +1 -1
- package/dist/semantics/normalize/structural-array-read.js +1 -1
- package/dist/semantics/normalize/structural-callable.d.ts +1 -1
- package/dist/semantics/normalize/structural-callable.js +1 -1
- package/dist/semantics/normalize/structural-creation-order.d.ts +1 -1
- package/dist/semantics/normalize/structural-creation-order.js +1 -1
- package/dist/semantics/normalize/structural-declarations.d.ts +1 -1
- package/dist/semantics/normalize/structural-declarations.js +1 -1
- package/dist/semantics/normalize/structural-declared-body.d.ts +1 -1
- package/dist/semantics/normalize/structural-declared-body.js +1 -1
- package/dist/semantics/normalize/structural-generics.d.ts +1 -1
- package/dist/semantics/normalize/structural-generics.js +1 -1
- package/dist/semantics/normalize/structural-indexed-access.d.ts +1 -1
- package/dist/semantics/normalize/structural-indexed-access.js +1 -1
- package/dist/semantics/normalize/structural-instantiated-member.d.ts +1 -1
- package/dist/semantics/normalize/structural-instantiated-member.js +199 -68
- package/dist/semantics/normalize/structural-joins.d.ts +1 -1
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +1 -1
- package/dist/semantics/normalize/structural-layout-relevance.js +1 -1
- package/dist/semantics/normalize/structural-layout-type.d.ts +1 -1
- package/dist/semantics/normalize/structural-layout-type.js +14 -2
- package/dist/semantics/normalize/structural-leaves.d.ts +1 -1
- package/dist/semantics/normalize/structural-leaves.js +1 -1
- package/dist/semantics/normalize/structural-local-union.d.ts +1 -1
- package/dist/semantics/normalize/structural-local-union.js +21 -16
- package/dist/semantics/normalize/structural-members.d.ts +1 -1
- package/dist/semantics/normalize/structural-members.js +1 -1
- package/dist/semantics/normalize/structural-mutable-field.d.ts +1 -2
- package/dist/semantics/normalize/structural-mutable-field.js +17 -4
- package/dist/semantics/normalize/structural-mutable-method.d.ts +1 -1
- package/dist/semantics/normalize/structural-mutable-method.js +1 -1
- package/dist/semantics/normalize/structural-parts.d.ts +1 -1
- package/dist/semantics/normalize/structural-parts.js +1 -1
- package/dist/semantics/normalize/structural-receiver.d.ts +1 -1
- package/dist/semantics/normalize/structural-receiver.js +1 -1
- package/dist/semantics/normalize/structural-rules.d.ts +4 -4
- package/dist/semantics/normalize/structural-rules.js +30 -12
- package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
- package/dist/semantics/normalize/structural-self-reference.js +1 -1
- package/dist/semantics/normalize/structural.d.ts +1 -1
- package/dist/semantics/normalize/structural.js +2467 -2239
- package/dist/semantics/normalize/suppressed-write-arms.d.ts +1 -1
- package/dist/semantics/normalize/suppressed-write-arms.js +1 -1
- package/dist/semantics/normalize/symbol-keyed-this-slots.d.ts +1 -1
- package/dist/semantics/normalize/symbol-keyed-this-slots.js +1 -1
- package/dist/semantics/normalize/unreduced-type-form.d.ts +1 -1
- package/dist/semantics/normalize/unreduced-type-form.js +1 -1
- package/dist/semantics/normalize/unresolvable-names.d.ts +1 -1
- package/dist/semantics/normalize/unresolvable-names.js +1 -1
- package/dist/semantics/normalize/unshared-array-result.d.ts +1 -1
- package/dist/semantics/normalize/unshared-array-result.js +1 -1
- package/dist/semantics/package-sources.d.ts +1 -1
- package/dist/semantics/package-sources.js +1 -1
- package/dist/semantics/program.d.ts +1 -1
- package/dist/semantics/program.js +11 -5
- package/dist/semantics/prototype-install-source-transform.js +1 -1
- package/dist/semantics/prototype-object-class-source-transform.js +1 -1
- package/dist/semantics/prototype-reparenting.d.ts +1 -1
- package/dist/semantics/prototype-reparenting.js +1 -1
- package/dist/semantics/shared-declaration-files.d.ts +1 -1
- package/dist/semantics/source-transform-exports.js +1 -1
- package/dist/semantics/stable-checker.d.ts +9 -1
- package/dist/semantics/stable-checker.js +21 -5
- package/dist/semantics/subclass-member-overlay-transform.js +46 -5
- package/dist/semantics/symbol-keyed-expando-source-transform.js +1 -1
- package/dist/semantics/this-constructor-source-transform.js +1 -1
- package/dist/semantics/typescript.d.ts +12 -0
- package/dist/semantics/typescript.js +12 -0
- package/dist/semantics/uncached-jsdoc-tags.d.ts +16 -0
- package/dist/semantics/uncached-jsdoc-tags.js +23 -0
- package/dist/semantics/unchecked-guard-argument-copies.d.ts +1 -1
- package/dist/semantics/unchecked-guard-argument-copies.js +1 -1
- package/dist/semantics/unchecked-write-member-declarations.d.ts +1 -1
- package/dist/semantics/unchecked-write-member-declarations.js +1 -1
- package/dist/semantics/uninstantiable-classes.d.ts +1 -1
- package/dist/semantics/uninstantiable-classes.js +1 -1
- package/dist/targets/cpp/conversions.js +137 -87
- package/dist/targets/cpp/emit-bindings.js +13 -0
- package/dist/targets/cpp/emit-context.d.ts +13 -0
- package/dist/targets/cpp/emit-context.js +9 -0
- package/dist/targets/cpp/emit-in.js +2 -1
- package/dist/targets/cpp/emit-iterator.d.ts +6 -5
- package/dist/targets/cpp/emit-iterator.js +23 -13
- package/dist/targets/cpp/emit-narrowing.d.ts +8 -0
- package/dist/targets/cpp/emit-narrowing.js +11 -1
- package/dist/targets/cpp/emit-properties.js +9 -0
- package/dist/targets/cpp/emit-record-view.d.ts +9 -0
- package/dist/targets/cpp/emit-record-view.js +12 -1
- package/dist/targets/cpp/emit.js +14 -2
- package/package.json +7 -1
- package/src/targets/cpp/runtime/gea_runtime.h +10 -2
|
@@ -39,6 +39,525 @@ import { nativeGenericCallEntriesOf, nativeGenericSelectorMatches } from './gene
|
|
|
39
39
|
import { classConstructorBodyMatches, constructMatchesAbi, explicitObjectConstructEntryOf, ordinaryConstructBodyMatches } from './construct-entry.js';
|
|
40
40
|
import { observesNativeCarrierOnly, operandsOfIrOperation, resultOfIrOperation } from './queries.js';
|
|
41
41
|
import { nativeCallablePrimitiveDataWritePreservesOwner } from './native-callable-data-flow.js';
|
|
42
|
+
/**
|
|
43
|
+
* The collections an origin cell starts with. There is one cell per IR value
|
|
44
|
+
* and binding, and most of their eleven collections never receive an entry:
|
|
45
|
+
* allocating them eagerly held gigabytes of empty `Set`s and `Map`s on a large
|
|
46
|
+
* program and ran it out of memory. Every cell shares these until its first
|
|
47
|
+
* write installs its own (`ownSet`/`ownMap`, and `ownCellSet`/`ownCellMap`/
|
|
48
|
+
* `ownSourceSet` for the frozen empties below), and they throw on mutation, so
|
|
49
|
+
* a write that bypasses the installers fails instead of corrupting every other
|
|
50
|
+
* cell.
|
|
51
|
+
*/
|
|
52
|
+
const sharedEmpty = () => {
|
|
53
|
+
throw new Error('a shared empty origin-cell collection was written in place');
|
|
54
|
+
};
|
|
55
|
+
const emptySet = Object.assign(new Set(), { add: sharedEmpty, delete: sharedEmpty, clear: sharedEmpty });
|
|
56
|
+
const emptyMap = Object.assign(new Map(), { set: sharedEmpty, delete: sharedEmpty, clear: sharedEmpty });
|
|
57
|
+
const ownSet = (current, install) => {
|
|
58
|
+
if (current !== emptySet)
|
|
59
|
+
return current;
|
|
60
|
+
const own = new Set();
|
|
61
|
+
install(own);
|
|
62
|
+
return own;
|
|
63
|
+
};
|
|
64
|
+
const ownMap = (current, install) => {
|
|
65
|
+
if (current !== emptyMap)
|
|
66
|
+
return current;
|
|
67
|
+
const own = new Map();
|
|
68
|
+
install(own);
|
|
69
|
+
return own;
|
|
70
|
+
};
|
|
71
|
+
const absent = Symbol('absent');
|
|
72
|
+
/**
|
|
73
|
+
* An origin cell's hot sets. Four in five of the incoming, heap, function and
|
|
74
|
+
* escape-source sets that get a member never get a second, and a one-member
|
|
75
|
+
* `Set` costs several times the inline slot that holds it here; a `Set` is
|
|
76
|
+
* built only for a second member. Iteration is insertion order and visits a
|
|
77
|
+
* member added while it runs, exactly as a `Set`'s does, so no visit order --
|
|
78
|
+
* and no answer -- depends on which form a cell holds.
|
|
79
|
+
*/
|
|
80
|
+
class CellSet {
|
|
81
|
+
first = absent;
|
|
82
|
+
members = null;
|
|
83
|
+
/** Held by more than one cell (`shareHeaps`): the next write copies it first. */
|
|
84
|
+
shared = false;
|
|
85
|
+
get size() {
|
|
86
|
+
return this.members !== null ? this.members.size : this.first === absent ? 0 : 1;
|
|
87
|
+
}
|
|
88
|
+
has(member) {
|
|
89
|
+
return this.members !== null ? this.members.has(member) : this.first === member;
|
|
90
|
+
}
|
|
91
|
+
add(member) {
|
|
92
|
+
if (this.members !== null)
|
|
93
|
+
this.members.add(member);
|
|
94
|
+
else if (this.first === absent)
|
|
95
|
+
this.first = member;
|
|
96
|
+
else if (this.first !== member)
|
|
97
|
+
this.members = new Set([this.first, member]);
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
*[Symbol.iterator]() {
|
|
101
|
+
if (this.members === null) {
|
|
102
|
+
if (this.first === absent)
|
|
103
|
+
return;
|
|
104
|
+
yield this.first;
|
|
105
|
+
if (this.members === null)
|
|
106
|
+
return;
|
|
107
|
+
let skipped = false;
|
|
108
|
+
for (const member of this.members) {
|
|
109
|
+
if (skipped)
|
|
110
|
+
yield member;
|
|
111
|
+
skipped = true;
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
yield* this.members;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** `CellSet` for the edge map: one target inline, a `Map` from the second. */
|
|
119
|
+
class CellMap {
|
|
120
|
+
key = absent;
|
|
121
|
+
value = undefined;
|
|
122
|
+
entries = null;
|
|
123
|
+
get size() {
|
|
124
|
+
return this.entries !== null ? this.entries.size : this.key === absent ? 0 : 1;
|
|
125
|
+
}
|
|
126
|
+
get(key) {
|
|
127
|
+
return this.entries !== null ? this.entries.get(key) : this.key === key ? this.value : undefined;
|
|
128
|
+
}
|
|
129
|
+
has(key) {
|
|
130
|
+
return this.entries !== null ? this.entries.has(key) : this.key === key;
|
|
131
|
+
}
|
|
132
|
+
set(key, value) {
|
|
133
|
+
if (this.entries !== null)
|
|
134
|
+
this.entries.set(key, value);
|
|
135
|
+
else if (this.key === absent || this.key === key) {
|
|
136
|
+
this.key = key;
|
|
137
|
+
this.value = value;
|
|
138
|
+
}
|
|
139
|
+
else
|
|
140
|
+
this.entries = new Map([
|
|
141
|
+
[this.key, this.value],
|
|
142
|
+
[key, value]
|
|
143
|
+
]);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
*[Symbol.iterator]() {
|
|
147
|
+
if (this.entries === null) {
|
|
148
|
+
if (this.key === absent)
|
|
149
|
+
return;
|
|
150
|
+
yield [this.key, this.value];
|
|
151
|
+
if (this.entries === null)
|
|
152
|
+
return;
|
|
153
|
+
let skipped = false;
|
|
154
|
+
for (const entry of this.entries) {
|
|
155
|
+
if (skipped)
|
|
156
|
+
yield entry;
|
|
157
|
+
skipped = true;
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
yield* this.entries;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Escape sources: a `CellSet` that also answers by insertion index, which an
|
|
166
|
+
* absorber resumes from (`escapeAbsorbed`). The index is kept only once there
|
|
167
|
+
* are two, beside the `Set` -- the separate list every escaped cell carried
|
|
168
|
+
* was a seventeen-slot array for its one source.
|
|
169
|
+
*/
|
|
170
|
+
class SourceSet {
|
|
171
|
+
first = absent;
|
|
172
|
+
list = null;
|
|
173
|
+
members = null;
|
|
174
|
+
get size() {
|
|
175
|
+
return this.list !== null ? this.list.length : this.first === absent ? 0 : 1;
|
|
176
|
+
}
|
|
177
|
+
has(member) {
|
|
178
|
+
return this.members !== null ? this.members.has(member) : this.first === member;
|
|
179
|
+
}
|
|
180
|
+
at(index) {
|
|
181
|
+
return this.list !== null ? this.list[index] : this.first;
|
|
182
|
+
}
|
|
183
|
+
add(member) {
|
|
184
|
+
if (this.members !== null) {
|
|
185
|
+
if (!this.members.has(member)) {
|
|
186
|
+
this.members.add(member);
|
|
187
|
+
this.list.push(member);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else if (this.first === absent)
|
|
191
|
+
this.first = member;
|
|
192
|
+
else if (this.first !== member) {
|
|
193
|
+
this.list = [this.first, member];
|
|
194
|
+
this.members = new Set(this.list);
|
|
195
|
+
}
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
*[Symbol.iterator]() {
|
|
199
|
+
for (let index = 0; index < this.size; index++)
|
|
200
|
+
yield this.at(index);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const emptyCellSet = Object.freeze(new CellSet());
|
|
204
|
+
const emptyCellMap = Object.freeze(new CellMap());
|
|
205
|
+
const emptySourceSet = Object.freeze(new SourceSet());
|
|
206
|
+
const ownCellSet = (current, install) => {
|
|
207
|
+
if (current !== emptyCellSet && !current.shared)
|
|
208
|
+
return current;
|
|
209
|
+
const own = new CellSet();
|
|
210
|
+
if (current !== emptyCellSet) {
|
|
211
|
+
own.first = current.first;
|
|
212
|
+
own.members = current.members === null ? null : new Set(current.members);
|
|
213
|
+
}
|
|
214
|
+
install(own);
|
|
215
|
+
return own;
|
|
216
|
+
};
|
|
217
|
+
const ownSourceSet = (current, install) => {
|
|
218
|
+
if (current !== emptySourceSet)
|
|
219
|
+
return current;
|
|
220
|
+
const own = new SourceSet();
|
|
221
|
+
install(own);
|
|
222
|
+
return own;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* A table keyed by SSA value id. `irValueId` spells a value as its defining
|
|
226
|
+
* body and an ordinal, so the table keeps one array per body, indexed by the
|
|
227
|
+
* ordinal: a `Map` over the program's every value costs about forty bytes an
|
|
228
|
+
* entry, and the solve held two of them through its peak. An id of any other
|
|
229
|
+
* spelling goes to a `Map`. Iteration is insertion order and visits an entry
|
|
230
|
+
* added while it runs, as a `Map`'s does.
|
|
231
|
+
*/
|
|
232
|
+
class ValueTable {
|
|
233
|
+
ordered;
|
|
234
|
+
byBody = new Map();
|
|
235
|
+
other = new Map();
|
|
236
|
+
order = [];
|
|
237
|
+
lastBody = '';
|
|
238
|
+
lastSlots = null;
|
|
239
|
+
ordinal = 0;
|
|
240
|
+
/** `order` is kept only for a table that is iterated. */
|
|
241
|
+
constructor(ordered) {
|
|
242
|
+
this.ordered = ordered;
|
|
243
|
+
}
|
|
244
|
+
/** The body's slots with `ordinal` set; undefined for an id of another spelling, null for an unknown body. */
|
|
245
|
+
slotsOf(id, create) {
|
|
246
|
+
const bar = id.lastIndexOf('|');
|
|
247
|
+
const end = id.length;
|
|
248
|
+
if (bar <= 4 || end - bar - 1 > 9 || bar + 1 === end || (id.charCodeAt(bar + 1) === 48 && end > bar + 2) || !id.startsWith('ssa|'))
|
|
249
|
+
return undefined;
|
|
250
|
+
let ordinal = 0;
|
|
251
|
+
for (let at = bar + 1; at < end; at++) {
|
|
252
|
+
const digit = id.charCodeAt(at) - 48;
|
|
253
|
+
if (digit < 0 || digit > 9)
|
|
254
|
+
return undefined;
|
|
255
|
+
ordinal = ordinal * 10 + digit;
|
|
256
|
+
}
|
|
257
|
+
this.ordinal = ordinal;
|
|
258
|
+
if (this.lastSlots !== null && bar === 4 + this.lastBody.length && id.startsWith(this.lastBody, 4))
|
|
259
|
+
return this.lastSlots;
|
|
260
|
+
const body = id.slice(4, bar);
|
|
261
|
+
let slots = this.byBody.get(body);
|
|
262
|
+
if (slots === undefined) {
|
|
263
|
+
if (!create)
|
|
264
|
+
return null;
|
|
265
|
+
slots = [];
|
|
266
|
+
this.byBody.set(body, slots);
|
|
267
|
+
}
|
|
268
|
+
this.lastBody = body;
|
|
269
|
+
this.lastSlots = slots;
|
|
270
|
+
return slots;
|
|
271
|
+
}
|
|
272
|
+
get(id) {
|
|
273
|
+
const slots = this.slotsOf(id, false);
|
|
274
|
+
return slots === undefined ? this.other.get(id) : slots === null ? undefined : slots[this.ordinal];
|
|
275
|
+
}
|
|
276
|
+
has(id) {
|
|
277
|
+
return this.get(id) !== undefined;
|
|
278
|
+
}
|
|
279
|
+
set(id, entry) {
|
|
280
|
+
const slots = this.slotsOf(id, true);
|
|
281
|
+
if (slots === undefined) {
|
|
282
|
+
if (this.ordered && !this.other.has(id))
|
|
283
|
+
this.order.push(id);
|
|
284
|
+
this.other.set(id, entry);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (this.ordered && slots[this.ordinal] === undefined)
|
|
288
|
+
this.order.push(id);
|
|
289
|
+
slots[this.ordinal] = entry;
|
|
290
|
+
}
|
|
291
|
+
clear() {
|
|
292
|
+
this.byBody.clear();
|
|
293
|
+
this.other.clear();
|
|
294
|
+
this.order.length = 0;
|
|
295
|
+
this.lastBody = '';
|
|
296
|
+
this.lastSlots = null;
|
|
297
|
+
}
|
|
298
|
+
*[Symbol.iterator]() {
|
|
299
|
+
for (let at = 0; at < this.order.length; at++)
|
|
300
|
+
yield [this.order[at], this.get(this.order[at])];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const QUEUED = 1;
|
|
304
|
+
const DOCUMENT_INSTALLED = 2;
|
|
305
|
+
const DOCUMENT_BLOCKED = 4;
|
|
306
|
+
const UNKNOWN = 8;
|
|
307
|
+
const ESCAPED = 16;
|
|
308
|
+
const LOGICAL_RECEIVER = 32;
|
|
309
|
+
const DYNAMIC_RECEIVER = 64;
|
|
310
|
+
const IGNORES_LOGICAL_RECEIVER = 128;
|
|
311
|
+
const UNRESTRICTED_UNKNOWN_HEAPS = 256;
|
|
312
|
+
/** `OriginCell.state` keeps the flags below this and the version above it. */
|
|
313
|
+
const FLAG_SPAN = 512;
|
|
314
|
+
/**
|
|
315
|
+
* One per IR value and binding, so the solve holds hundreds of thousands at
|
|
316
|
+
* once, at the peak of a large program's compile. The cell keeps its eight
|
|
317
|
+
* flags in one word and moves what few cells ever hold to `rare`, behind the
|
|
318
|
+
* same property names, so every reader and writer below is unchanged: a
|
|
319
|
+
* plain object of twenty-one properties was twice the size.
|
|
320
|
+
*/
|
|
321
|
+
class OriginCell {
|
|
322
|
+
index;
|
|
323
|
+
/** The cells with an edge into this one (`incomingAdd`, `incomingEach`). */
|
|
324
|
+
incoming = null;
|
|
325
|
+
functions = emptyCellSet;
|
|
326
|
+
heaps = emptyCellSet;
|
|
327
|
+
/**
|
|
328
|
+
* Null transfers every origin; native selection can exclude incompatible
|
|
329
|
+
* heaps. A lone unrestricted edge is the target cell itself (`edgeGet`,
|
|
330
|
+
* `edgeSet`, `edgesOf`): most cells with an edge have just that one.
|
|
331
|
+
*/
|
|
332
|
+
edges = emptyCellMap;
|
|
333
|
+
escapeSources = emptySourceSet;
|
|
334
|
+
/** The flags, and above `FLAG_SPAN` the version bumped by every `changed(cell)` (see `heapEffect`). */
|
|
335
|
+
state = 0;
|
|
336
|
+
rare = null;
|
|
337
|
+
constructor(index) {
|
|
338
|
+
this.index = index;
|
|
339
|
+
}
|
|
340
|
+
get version() {
|
|
341
|
+
return Math.floor(this.state / FLAG_SPAN);
|
|
342
|
+
}
|
|
343
|
+
set version(version) {
|
|
344
|
+
this.state = version * FLAG_SPAN + (this.state % FLAG_SPAN);
|
|
345
|
+
}
|
|
346
|
+
flag(bit) {
|
|
347
|
+
return ((this.state % FLAG_SPAN) & bit) !== 0;
|
|
348
|
+
}
|
|
349
|
+
setFlag(bit, on) {
|
|
350
|
+
const flags = this.state % FLAG_SPAN;
|
|
351
|
+
this.state += (on ? flags | bit : flags & ~bit) - flags;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Null is unrestricted; a canonical checked sum can bound its unknown normal
|
|
355
|
+
* destinations. Under one cell in three hundred bounds them, so the set
|
|
356
|
+
* lives in `rare` and unrestricted is a flag.
|
|
357
|
+
*/
|
|
358
|
+
get unknownHeaps() {
|
|
359
|
+
return this.flag(UNRESTRICTED_UNKNOWN_HEAPS) ? null : (this.rare?.unknownHeaps ?? emptySet);
|
|
360
|
+
}
|
|
361
|
+
set unknownHeaps(own) {
|
|
362
|
+
this.setFlag(UNRESTRICTED_UNKNOWN_HEAPS, own === null);
|
|
363
|
+
if (own !== null && (own !== emptySet || this.rare !== null))
|
|
364
|
+
this.own().unknownHeaps = own;
|
|
365
|
+
}
|
|
366
|
+
own() {
|
|
367
|
+
return (this.rare ??= {
|
|
368
|
+
unknownHeaps: undefined,
|
|
369
|
+
documents: emptyMap,
|
|
370
|
+
arrayViews: emptySet,
|
|
371
|
+
descriptorSnapshots: emptySet,
|
|
372
|
+
fieldViews: emptySet,
|
|
373
|
+
escapeAbsorbed: undefined,
|
|
374
|
+
unknownReason: undefined,
|
|
375
|
+
escapeReason: undefined
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
get queued() {
|
|
379
|
+
return this.flag(QUEUED);
|
|
380
|
+
}
|
|
381
|
+
set queued(on) {
|
|
382
|
+
this.setFlag(QUEUED, on);
|
|
383
|
+
}
|
|
384
|
+
get documentInstalled() {
|
|
385
|
+
return this.flag(DOCUMENT_INSTALLED);
|
|
386
|
+
}
|
|
387
|
+
set documentInstalled(on) {
|
|
388
|
+
this.setFlag(DOCUMENT_INSTALLED, on);
|
|
389
|
+
}
|
|
390
|
+
get documentBlocked() {
|
|
391
|
+
return this.flag(DOCUMENT_BLOCKED);
|
|
392
|
+
}
|
|
393
|
+
set documentBlocked(on) {
|
|
394
|
+
this.setFlag(DOCUMENT_BLOCKED, on);
|
|
395
|
+
}
|
|
396
|
+
get unknown() {
|
|
397
|
+
return this.flag(UNKNOWN);
|
|
398
|
+
}
|
|
399
|
+
set unknown(on) {
|
|
400
|
+
this.setFlag(UNKNOWN, on);
|
|
401
|
+
}
|
|
402
|
+
get escaped() {
|
|
403
|
+
return this.flag(ESCAPED);
|
|
404
|
+
}
|
|
405
|
+
set escaped(on) {
|
|
406
|
+
this.setFlag(ESCAPED, on);
|
|
407
|
+
}
|
|
408
|
+
get logicalReceiver() {
|
|
409
|
+
return this.flag(LOGICAL_RECEIVER);
|
|
410
|
+
}
|
|
411
|
+
set logicalReceiver(on) {
|
|
412
|
+
this.setFlag(LOGICAL_RECEIVER, on);
|
|
413
|
+
}
|
|
414
|
+
get dynamicReceiver() {
|
|
415
|
+
return this.flag(DYNAMIC_RECEIVER);
|
|
416
|
+
}
|
|
417
|
+
set dynamicReceiver(on) {
|
|
418
|
+
this.setFlag(DYNAMIC_RECEIVER, on);
|
|
419
|
+
}
|
|
420
|
+
get ignoresLogicalReceiver() {
|
|
421
|
+
return this.flag(IGNORES_LOGICAL_RECEIVER);
|
|
422
|
+
}
|
|
423
|
+
set ignoresLogicalReceiver(on) {
|
|
424
|
+
this.setFlag(IGNORES_LOGICAL_RECEIVER, on);
|
|
425
|
+
}
|
|
426
|
+
get documents() {
|
|
427
|
+
return this.rare?.documents ?? emptyMap;
|
|
428
|
+
}
|
|
429
|
+
set documents(own) {
|
|
430
|
+
this.own().documents = own;
|
|
431
|
+
}
|
|
432
|
+
/** Possible installed array callbacks survive unknown/mixed aliases too. */
|
|
433
|
+
get arrayViews() {
|
|
434
|
+
return this.rare?.arrayViews ?? emptySet;
|
|
435
|
+
}
|
|
436
|
+
set arrayViews(own) {
|
|
437
|
+
this.own().arrayViews = own;
|
|
438
|
+
}
|
|
439
|
+
get descriptorSnapshots() {
|
|
440
|
+
return this.rare?.descriptorSnapshots ?? emptySet;
|
|
441
|
+
}
|
|
442
|
+
set descriptorSnapshots(own) {
|
|
443
|
+
this.own().descriptorSnapshots = own;
|
|
444
|
+
}
|
|
445
|
+
/** Installed readers can retain an allocation while changing its access protocol. */
|
|
446
|
+
get fieldViews() {
|
|
447
|
+
return this.rare?.fieldViews ?? emptySet;
|
|
448
|
+
}
|
|
449
|
+
set fieldViews(own) {
|
|
450
|
+
this.own().fieldViews = own;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* How many of each escaped alias target's `escapeSources` this cell has
|
|
454
|
+
* already absorbed. The set only grows, so an unchanged size means nothing
|
|
455
|
+
* new to absorb: re-walking every target's whole set on every pop was nearly a
|
|
456
|
+
* third of a large program's compile time.
|
|
457
|
+
*/
|
|
458
|
+
get escapeAbsorbed() {
|
|
459
|
+
return this.rare?.escapeAbsorbed;
|
|
460
|
+
}
|
|
461
|
+
set escapeAbsorbed(own) {
|
|
462
|
+
this.own().escapeAbsorbed = own;
|
|
463
|
+
}
|
|
464
|
+
get unknownReason() {
|
|
465
|
+
return this.rare?.unknownReason;
|
|
466
|
+
}
|
|
467
|
+
set unknownReason(reason) {
|
|
468
|
+
this.own().unknownReason = reason;
|
|
469
|
+
}
|
|
470
|
+
get escapeReason() {
|
|
471
|
+
return this.rare?.escapeReason;
|
|
472
|
+
}
|
|
473
|
+
set escapeReason(reason) {
|
|
474
|
+
this.own().escapeReason = reason;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const incomingListLimit = 8;
|
|
478
|
+
const incomingAdd = (to, from) => {
|
|
479
|
+
const current = to.incoming;
|
|
480
|
+
if (current === null)
|
|
481
|
+
to.incoming = from;
|
|
482
|
+
else if (current instanceof OriginCell) {
|
|
483
|
+
if (current !== from)
|
|
484
|
+
to.incoming = [current, from];
|
|
485
|
+
}
|
|
486
|
+
else if (Array.isArray(current)) {
|
|
487
|
+
if (current.includes(from))
|
|
488
|
+
return;
|
|
489
|
+
if (current.length < incomingListLimit) {
|
|
490
|
+
const next = new Array(current.length + 1);
|
|
491
|
+
for (let at = 0; at < current.length; at++)
|
|
492
|
+
next[at] = current[at];
|
|
493
|
+
next[current.length] = from;
|
|
494
|
+
to.incoming = next;
|
|
495
|
+
}
|
|
496
|
+
else
|
|
497
|
+
to.incoming = new Set([...current, from]);
|
|
498
|
+
}
|
|
499
|
+
else
|
|
500
|
+
current.add(from);
|
|
501
|
+
};
|
|
502
|
+
const incomingEach = (cell, visit) => {
|
|
503
|
+
const current = cell.incoming;
|
|
504
|
+
if (current === null)
|
|
505
|
+
return;
|
|
506
|
+
if (current instanceof OriginCell)
|
|
507
|
+
visit(current);
|
|
508
|
+
else
|
|
509
|
+
for (const incoming of current)
|
|
510
|
+
visit(incoming);
|
|
511
|
+
};
|
|
512
|
+
const edgeGet = (from, to) => {
|
|
513
|
+
const edges = from.edges;
|
|
514
|
+
return edges instanceof OriginCell ? (edges === to ? null : undefined) : edges.get(to);
|
|
515
|
+
};
|
|
516
|
+
const edgeHas = (from, to) => {
|
|
517
|
+
const edges = from.edges;
|
|
518
|
+
return edges instanceof OriginCell ? edges === to : edges.has(to);
|
|
519
|
+
};
|
|
520
|
+
const edgeSet = (from, to, allowed) => {
|
|
521
|
+
const edges = from.edges;
|
|
522
|
+
if (edges instanceof OriginCell) {
|
|
523
|
+
if (edges === to && allowed === null)
|
|
524
|
+
return;
|
|
525
|
+
const own = new CellMap();
|
|
526
|
+
own.set(edges, null);
|
|
527
|
+
own.set(to, allowed);
|
|
528
|
+
from.edges = own;
|
|
529
|
+
}
|
|
530
|
+
else if (edges === emptyCellMap) {
|
|
531
|
+
if (allowed === null)
|
|
532
|
+
from.edges = to;
|
|
533
|
+
else
|
|
534
|
+
from.edges = new CellMap().set(to, allowed);
|
|
535
|
+
}
|
|
536
|
+
else
|
|
537
|
+
edges.set(to, allowed);
|
|
538
|
+
};
|
|
539
|
+
/**
|
|
540
|
+
* The edges out of a cell, in insertion order, visiting an edge added while
|
|
541
|
+
* this runs exactly as iterating the cell's `CellMap` did: a lone edge that
|
|
542
|
+
* grows into a map continues past the entry already visited.
|
|
543
|
+
*/
|
|
544
|
+
function* edgesOf(cell) {
|
|
545
|
+
const edges = cell.edges;
|
|
546
|
+
if (!(edges instanceof OriginCell)) {
|
|
547
|
+
yield* edges;
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
yield [edges, null];
|
|
551
|
+
const grown = cell.edges;
|
|
552
|
+
if (grown instanceof OriginCell || grown === emptyCellMap)
|
|
553
|
+
return;
|
|
554
|
+
let skipped = false;
|
|
555
|
+
for (const entry of grown) {
|
|
556
|
+
if (skipped)
|
|
557
|
+
yield entry;
|
|
558
|
+
skipped = true;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
42
561
|
/**
|
|
43
562
|
* Flow-insensitive native field provenance. A field write contributes
|
|
44
563
|
* every implementation it can store; it never establishes an immutable-field
|
|
@@ -50,6 +569,14 @@ import { nativeCallablePrimitiveDataWritePreservesOwner } from './native-callabl
|
|
|
50
569
|
* which that demand needs. Unsupported transports fail closed. In particular,
|
|
51
570
|
* an arbitrary matching callable signature is never an implementation source.
|
|
52
571
|
*/
|
|
572
|
+
const ownedOperationKinds = new Set([
|
|
573
|
+
'get',
|
|
574
|
+
'set',
|
|
575
|
+
'define-own-property',
|
|
576
|
+
'receiver',
|
|
577
|
+
'return',
|
|
578
|
+
'super-initialize'
|
|
579
|
+
]);
|
|
53
580
|
const computeNativeCallableFlow = (bodies, placements, classes, conversions, trace, deriver, programConversions, constructionTopology) => {
|
|
54
581
|
const propertyLayoutCache = new Map();
|
|
55
582
|
const nativePropertyLayoutOf = (representation) => hasNativePropertyLayout(representation, deriver ?? null, classes, new Set(), propertyLayoutCache);
|
|
@@ -120,13 +647,13 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
120
647
|
}
|
|
121
648
|
if (cell.functions.has(id))
|
|
122
649
|
return;
|
|
123
|
-
cell.functions.add(id);
|
|
650
|
+
ownCellSet(cell.functions, (own) => (cell.functions = own)).add(id);
|
|
124
651
|
changed(cell);
|
|
125
652
|
};
|
|
126
653
|
const addHeap = (cell, heap) => {
|
|
127
654
|
if (cell.heaps.has(heap))
|
|
128
655
|
return;
|
|
129
|
-
cell.heaps.add(heap);
|
|
656
|
+
ownCellSet(cell.heaps, (own) => (cell.heaps = own)).add(heap);
|
|
130
657
|
changed(cell);
|
|
131
658
|
};
|
|
132
659
|
const markUnknown = (cell, reason, admitted, installedDocumentSource = false) => {
|
|
@@ -161,14 +688,12 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
161
688
|
cell.escaped = true;
|
|
162
689
|
for (const source of sources)
|
|
163
690
|
if (!cell.escapeSources.has(source)) {
|
|
164
|
-
cell.escapeSources.add(source);
|
|
165
|
-
cell.escapeSourceList.push(source);
|
|
691
|
+
ownSourceSet(cell.escapeSources, (own) => (cell.escapeSources = own)).add(source);
|
|
166
692
|
grew = true;
|
|
167
693
|
}
|
|
168
694
|
if (grew) {
|
|
169
695
|
changed(cell);
|
|
170
|
-
|
|
171
|
-
schedule(incoming);
|
|
696
|
+
incomingEach(cell, schedule);
|
|
172
697
|
}
|
|
173
698
|
if (trace && reason !== undefined)
|
|
174
699
|
cell.escapeReason ??= reason;
|
|
@@ -186,16 +711,15 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
186
711
|
if (!cell.escaped) {
|
|
187
712
|
cell.escaped = true;
|
|
188
713
|
changed(cell);
|
|
189
|
-
|
|
190
|
-
schedule(incoming);
|
|
714
|
+
incomingEach(cell, schedule);
|
|
191
715
|
}
|
|
192
716
|
if (trace && target.escapeReason !== undefined)
|
|
193
717
|
cell.escapeReason ??= target.escapeReason;
|
|
194
718
|
return;
|
|
195
719
|
}
|
|
196
|
-
const list = target.
|
|
720
|
+
const list = target.escapeSources;
|
|
197
721
|
const from = cell.escapeAbsorbed?.get(target) ?? 0;
|
|
198
|
-
if (from === list.
|
|
722
|
+
if (from === list.size && cell.escaped) {
|
|
199
723
|
if (trace && target.escapeReason !== undefined)
|
|
200
724
|
cell.escapeReason ??= target.escapeReason;
|
|
201
725
|
return;
|
|
@@ -205,22 +729,20 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
205
729
|
// and it adds them in the same order.
|
|
206
730
|
let grew = !cell.escaped;
|
|
207
731
|
cell.escaped = true;
|
|
208
|
-
for (let at = from; at < list.
|
|
209
|
-
const source = list
|
|
732
|
+
for (let at = from; at < list.size; at++) {
|
|
733
|
+
const source = list.at(at);
|
|
210
734
|
if (!cell.escapeSources.has(source)) {
|
|
211
|
-
cell.escapeSources.add(source);
|
|
212
|
-
cell.escapeSourceList.push(source);
|
|
735
|
+
ownSourceSet(cell.escapeSources, (own) => (cell.escapeSources = own)).add(source);
|
|
213
736
|
grew = true;
|
|
214
737
|
}
|
|
215
738
|
}
|
|
216
739
|
if (grew) {
|
|
217
740
|
changed(cell);
|
|
218
|
-
|
|
219
|
-
schedule(incoming);
|
|
741
|
+
incomingEach(cell, schedule);
|
|
220
742
|
}
|
|
221
743
|
if (trace && target.escapeReason !== undefined)
|
|
222
744
|
cell.escapeReason ??= target.escapeReason;
|
|
223
|
-
(cell.escapeAbsorbed ??= new Map()).set(target, list.
|
|
745
|
+
(cell.escapeAbsorbed ??= new Map()).set(target, list.size);
|
|
224
746
|
};
|
|
225
747
|
const markLogicalReceiver = (cell, dynamic = false) => {
|
|
226
748
|
if (!cell.logicalReceiver) {
|
|
@@ -239,33 +761,11 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
239
761
|
}
|
|
240
762
|
};
|
|
241
763
|
const fresh = () => {
|
|
242
|
-
const cell =
|
|
243
|
-
index: cells.length,
|
|
244
|
-
incoming: new Set(),
|
|
245
|
-
queued: false,
|
|
246
|
-
functions: new Set(),
|
|
247
|
-
heaps: new Set(),
|
|
248
|
-
edges: new Map(),
|
|
249
|
-
documents: new Map(),
|
|
250
|
-
arrayViews: new Set(),
|
|
251
|
-
descriptorSnapshots: new Set(),
|
|
252
|
-
fieldViews: new Set(),
|
|
253
|
-
documentInstalled: false,
|
|
254
|
-
documentBlocked: false,
|
|
255
|
-
unknown: false,
|
|
256
|
-
unknownHeaps: new Set(),
|
|
257
|
-
escaped: false,
|
|
258
|
-
escapeSources: new Set(),
|
|
259
|
-
escapeSourceList: [],
|
|
260
|
-
version: 0,
|
|
261
|
-
logicalReceiver: false,
|
|
262
|
-
dynamicReceiver: false,
|
|
263
|
-
ignoresLogicalReceiver: false
|
|
264
|
-
};
|
|
764
|
+
const cell = new OriginCell(cells.length);
|
|
265
765
|
cells.push(cell);
|
|
266
766
|
return cell;
|
|
267
767
|
};
|
|
268
|
-
const values = new
|
|
768
|
+
const values = new ValueTable(true);
|
|
269
769
|
const value = (id) => {
|
|
270
770
|
const found = values.get(id);
|
|
271
771
|
if (found)
|
|
@@ -387,8 +887,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
387
887
|
viewMethodFields.set(fields.target.shapeId, methods);
|
|
388
888
|
}
|
|
389
889
|
}
|
|
390
|
-
const
|
|
391
|
-
const producers = new Map();
|
|
890
|
+
const producers = new ValueTable(false);
|
|
392
891
|
const bodyById = new Map();
|
|
393
892
|
const physicalBodiesBySource = new Map();
|
|
394
893
|
const returns = new Map();
|
|
@@ -396,8 +895,20 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
396
895
|
// and lowering therefore produces no receiver SSA operation.
|
|
397
896
|
const frameReceivers = new Map();
|
|
398
897
|
const parameters = new Map();
|
|
399
|
-
|
|
898
|
+
// An operation's source owner is its physical body's: one table, not a
|
|
899
|
+
// second of the same half million operations. Only the kinds asked about
|
|
900
|
+
// are entered -- reads, writes and definitions for their presence guards, and frame
|
|
901
|
+
// entries and returns -- about one operation in nine; asking about any
|
|
902
|
+
// other kind is a defect here, not an absent owner.
|
|
400
903
|
const physicalOwner = new Map();
|
|
904
|
+
const physicalOwnerOf = (operation) => {
|
|
905
|
+
if (!ownedOperationKinds.has(operation.kind))
|
|
906
|
+
throw new Error(`callable flow: no owner is recorded for a ${operation.kind} operation`);
|
|
907
|
+
return physicalOwner.get(operation);
|
|
908
|
+
};
|
|
909
|
+
const owner = {
|
|
910
|
+
get: (operation) => physicalOwnerOf(operation)?.sourceOwner
|
|
911
|
+
};
|
|
401
912
|
for (const body of bodies) {
|
|
402
913
|
const id = body.sourceOwner;
|
|
403
914
|
const physicalBodies = physicalBodiesBySource.get(id) ?? [];
|
|
@@ -410,8 +921,8 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
410
921
|
const inputs = [];
|
|
411
922
|
for (const block of body.blocks.values())
|
|
412
923
|
for (const operation of [...block.operations, block.terminator]) {
|
|
413
|
-
|
|
414
|
-
|
|
924
|
+
if (ownedOperationKinds.has(operation.kind))
|
|
925
|
+
physicalOwner.set(operation, body);
|
|
415
926
|
if (operation.kind === 'parameter' || operation.kind === 'receiver')
|
|
416
927
|
inputs.push(operation);
|
|
417
928
|
}
|
|
@@ -436,24 +947,28 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
436
947
|
}
|
|
437
948
|
const arrayInsertions = new Map();
|
|
438
949
|
const insertionReads = new Set();
|
|
439
|
-
const uses = new Map();
|
|
440
950
|
for (const operation of operations) {
|
|
441
|
-
for (const operand of operandsOfIrOperation(operation)) {
|
|
442
|
-
const users = uses.get(operand.value) ?? new Set();
|
|
443
|
-
users.add(operation);
|
|
444
|
-
uses.set(operand.value, users);
|
|
445
|
-
}
|
|
446
951
|
if (operation.kind !== 'call')
|
|
447
952
|
continue;
|
|
448
953
|
const insertion = nativeArrayInsertionOf(operation, (id) => producers.get(id) ?? null, classes, conversions);
|
|
449
954
|
if (insertion !== null)
|
|
450
955
|
arrayInsertions.set(operation, insertion);
|
|
451
956
|
}
|
|
957
|
+
// Only the users of an insertion's extracted read are asked about: a table
|
|
958
|
+
// of every value's users was a `Set` per value of the program, held through
|
|
959
|
+
// the whole solve.
|
|
960
|
+
const uses = new Map();
|
|
961
|
+
for (const insertion of arrayInsertions.values())
|
|
962
|
+
uses.set(insertion.read.result.id, new Set());
|
|
963
|
+
if (uses.size > 0)
|
|
964
|
+
for (const operation of operations)
|
|
965
|
+
for (const operand of operandsOfIrOperation(operation))
|
|
966
|
+
uses.get(operand.value)?.add(operation);
|
|
452
967
|
// An extracted method can be published or rebound. Only the exact fused
|
|
453
968
|
// uses above can keep its receiver's allocation closed.
|
|
454
969
|
for (const insertion of arrayInsertions.values()) {
|
|
455
970
|
const users = uses.get(insertion.read.result.id);
|
|
456
|
-
if (users
|
|
971
|
+
if (users.size > 0 &&
|
|
457
972
|
[...users].every((user) => user.kind === 'call' && user.callee.value === insertion.read.result.id && arrayInsertions.has(user)))
|
|
458
973
|
insertionReads.add(insertion.read);
|
|
459
974
|
}
|
|
@@ -657,7 +1172,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
657
1172
|
if (at === undefined || cell.unknown || cell.escaped || heaps.length === 0 || !heaps.every(ordinaryAllocated))
|
|
658
1173
|
return { heaps, present: false };
|
|
659
1174
|
presenceConsulted = true;
|
|
660
|
-
const guard = propertyPresence.get(
|
|
1175
|
+
const guard = propertyPresence.get(physicalOwnerOf(at))?.(receiver, key, at, (operation, guard) => preservesPresence(operation, key, guard));
|
|
661
1176
|
if (guard === undefined || guard === null)
|
|
662
1177
|
return { heaps, present: false };
|
|
663
1178
|
// The sealed standard-prototype absence fact plus this complete ordinary
|
|
@@ -715,10 +1230,10 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
715
1230
|
markEscaped(cell, reason, [operation ?? null]);
|
|
716
1231
|
};
|
|
717
1232
|
const link = (from, to) => {
|
|
718
|
-
if (from
|
|
1233
|
+
if (edgeGet(from, to) === null)
|
|
719
1234
|
return;
|
|
720
|
-
from
|
|
721
|
-
to
|
|
1235
|
+
edgeSet(from, to, null);
|
|
1236
|
+
incomingAdd(to, from);
|
|
722
1237
|
changed(from);
|
|
723
1238
|
};
|
|
724
1239
|
const linkPayload = (from, to, representations) => {
|
|
@@ -726,11 +1241,11 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
726
1241
|
// Only a sealed payload-preserving conversion calls this. Layouts bound
|
|
727
1242
|
// which input allocations can survive its native tag/identity selection;
|
|
728
1243
|
// they never create an origin for an allocation not present in the input.
|
|
729
|
-
if (references.some((reference) => !reference.complete) || from
|
|
1244
|
+
if (references.some((reference) => !reference.complete) || edgeHas(from, to))
|
|
730
1245
|
link(from, to);
|
|
731
1246
|
else {
|
|
732
|
-
from
|
|
733
|
-
to
|
|
1247
|
+
edgeSet(from, to, references.flatMap((reference) => reference.heaps));
|
|
1248
|
+
incomingAdd(to, from);
|
|
734
1249
|
changed(from);
|
|
735
1250
|
}
|
|
736
1251
|
};
|
|
@@ -1737,7 +2252,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
1737
2252
|
representationKey(node.target) === representationKey(to)) {
|
|
1738
2253
|
const cell = value(operation.result.id);
|
|
1739
2254
|
if (!cell.fieldViews.has(node.id)) {
|
|
1740
|
-
cell.fieldViews.add(node.id);
|
|
2255
|
+
ownSet(cell.fieldViews, (own) => (cell.fieldViews = own)).add(node.id);
|
|
1741
2256
|
changed(cell);
|
|
1742
2257
|
}
|
|
1743
2258
|
}
|
|
@@ -1763,7 +2278,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
1763
2278
|
sources.has(representationKey(child.source)) &&
|
|
1764
2279
|
representationKey(child.target) === representationKey(payload) &&
|
|
1765
2280
|
!cell.fieldViews.has(child.id)) {
|
|
1766
|
-
cell.fieldViews.add(child.id);
|
|
2281
|
+
ownSet(cell.fieldViews, (own) => (cell.fieldViews = own)).add(child.id);
|
|
1767
2282
|
changed(cell);
|
|
1768
2283
|
}
|
|
1769
2284
|
}
|
|
@@ -1777,7 +2292,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
1777
2292
|
cell.documentInstalled = true;
|
|
1778
2293
|
cell.documentBlocked = false;
|
|
1779
2294
|
if (!cell.documents.has(node.id)) {
|
|
1780
|
-
cell.documents.set(node.id, document);
|
|
2295
|
+
ownMap(cell.documents, (own) => (cell.documents = own)).set(node.id, document);
|
|
1781
2296
|
changed(cell);
|
|
1782
2297
|
}
|
|
1783
2298
|
}
|
|
@@ -1789,7 +2304,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
1789
2304
|
if (conversions && nativeArrayRootViewPlansOf(node, conversions.nodeById).length > 0) {
|
|
1790
2305
|
const cell = value(operation.result.id);
|
|
1791
2306
|
if (!cell.arrayViews.has(node.id)) {
|
|
1792
|
-
cell.arrayViews.add(node.id);
|
|
2307
|
+
ownSet(cell.arrayViews, (own) => (cell.arrayViews = own)).add(node.id);
|
|
1793
2308
|
changed(cell);
|
|
1794
2309
|
}
|
|
1795
2310
|
}
|
|
@@ -1946,7 +2461,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
1946
2461
|
node.capability.materializer.nativeDescriptorSnapshot &&
|
|
1947
2462
|
representationKey(node.target) === representationKey(operation.result.representation)) {
|
|
1948
2463
|
const snapshot = value(operation.result.id);
|
|
1949
|
-
snapshot.descriptorSnapshots.add(operation.result.id);
|
|
2464
|
+
ownSet(snapshot.descriptorSnapshots, (own) => (snapshot.descriptorSnapshots = own)).add(operation.result.id);
|
|
1950
2465
|
changed(snapshot);
|
|
1951
2466
|
break;
|
|
1952
2467
|
}
|
|
@@ -2097,20 +2612,20 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2097
2612
|
while (pendingCells.length > 0) {
|
|
2098
2613
|
const cell = popCell();
|
|
2099
2614
|
sweepIndex = cell.index;
|
|
2100
|
-
for (const [target, allowed] of cell
|
|
2615
|
+
for (const [target, allowed] of edgesOf(cell)) {
|
|
2101
2616
|
for (const id of cell.fieldViews)
|
|
2102
2617
|
if (!target.fieldViews.has(id)) {
|
|
2103
|
-
target.fieldViews.add(id);
|
|
2618
|
+
ownSet(target.fieldViews, (own) => (target.fieldViews = own)).add(id);
|
|
2104
2619
|
changed(target);
|
|
2105
2620
|
}
|
|
2106
2621
|
for (const id of cell.descriptorSnapshots)
|
|
2107
2622
|
if (!target.descriptorSnapshots.has(id)) {
|
|
2108
|
-
target.descriptorSnapshots.add(id);
|
|
2623
|
+
ownSet(target.descriptorSnapshots, (own) => (target.descriptorSnapshots = own)).add(id);
|
|
2109
2624
|
changed(target);
|
|
2110
2625
|
}
|
|
2111
2626
|
for (const id of cell.arrayViews)
|
|
2112
2627
|
if (!target.arrayViews.has(id)) {
|
|
2113
|
-
target.arrayViews.add(id);
|
|
2628
|
+
ownSet(target.arrayViews, (own) => (target.arrayViews = own)).add(id);
|
|
2114
2629
|
changed(target);
|
|
2115
2630
|
}
|
|
2116
2631
|
if (!target.documentInstalled) {
|
|
@@ -2120,7 +2635,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2120
2635
|
}
|
|
2121
2636
|
for (const [id, entry] of cell.documents)
|
|
2122
2637
|
if (!target.documents.has(id)) {
|
|
2123
|
-
target.documents.set(id, entry);
|
|
2638
|
+
ownMap(target.documents, (own) => (target.documents = own)).set(id, entry);
|
|
2124
2639
|
changed(target);
|
|
2125
2640
|
}
|
|
2126
2641
|
}
|
|
@@ -2131,9 +2646,18 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2131
2646
|
// origin is any allocation of another layout: `ContextLike | null`
|
|
2132
2647
|
// holding a class instance behind a record view. Dropping that origin
|
|
2133
2648
|
// left the record arm the sole implementation of a field it never held.
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2649
|
+
// A target with no allocation of its own that takes every one of
|
|
2650
|
+
// this cell's holds the very same set until either writes it: most
|
|
2651
|
+
// multi-allocation cells hold exactly the set of a cell before them.
|
|
2652
|
+
if (target.heaps === emptyCellSet && target !== cell && cell.heaps.size > 0 && (allowed === null || cell.fieldViews.size > 0)) {
|
|
2653
|
+
cell.heaps.shared = true;
|
|
2654
|
+
target.heaps = cell.heaps;
|
|
2655
|
+
changed(target);
|
|
2656
|
+
}
|
|
2657
|
+
else
|
|
2658
|
+
for (const heap of cell.heaps)
|
|
2659
|
+
if (allowed === null || cell.fieldViews.size > 0 || heapAdmitted(heap, allowed))
|
|
2660
|
+
addHeap(target, heap);
|
|
2137
2661
|
if (cell.unknown) {
|
|
2138
2662
|
const admitted = cell.unknownHeaps === null
|
|
2139
2663
|
? undefined
|
|
@@ -2344,6 +2868,12 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2344
2868
|
heapEffects.every((effect) => rejectedHeapEffects.has(effect.operation) || effect.apply()))
|
|
2345
2869
|
break;
|
|
2346
2870
|
}
|
|
2871
|
+
// The solve is settled and nothing below replays a heap effect. The answers
|
|
2872
|
+
// built from here on are the backend's peak, so the solve-only effect list
|
|
2873
|
+
// goes first and the program-wide carrier table is built only now.
|
|
2874
|
+
heapEffects.length = 0;
|
|
2875
|
+
releasePropagation(cells);
|
|
2876
|
+
const valueCarriers = valueCarriersOf(bodies);
|
|
2347
2877
|
const result = new Map();
|
|
2348
2878
|
// Presence is checked by the later optional conversion. This fact names
|
|
2349
2879
|
// possible implementations, never a physical call ABI or a non-null value.
|
|
@@ -2424,21 +2954,41 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2424
2954
|
const nativeFieldStorageValues = new Map();
|
|
2425
2955
|
const nativeFieldMethodValues = new Map();
|
|
2426
2956
|
const nativeAccessorStorageValues = new Map();
|
|
2957
|
+
// The fields every heap of a value has in common are a function of the heap
|
|
2958
|
+
// set alone, and most values share theirs with many others: one table per
|
|
2959
|
+
// distinct set, not per value, which was half a million tables on a large
|
|
2960
|
+
// program for a few thousand distinct answers.
|
|
2961
|
+
const heapNumbers = new Map();
|
|
2962
|
+
const commonByHeaps = new Map();
|
|
2963
|
+
const accessorsByHeaps = new Map();
|
|
2427
2964
|
for (const [id, cell] of values) {
|
|
2428
2965
|
if (cell.unknown || cell.heaps.size === 0 || [...cell.heaps].some((heap) => !heap.valid || heap.proxy))
|
|
2429
2966
|
continue;
|
|
2430
|
-
const
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2967
|
+
const heapsKey = [...cell.heaps]
|
|
2968
|
+
.map((heap) => {
|
|
2969
|
+
let number = heapNumbers.get(heap);
|
|
2970
|
+
if (number === undefined)
|
|
2971
|
+
heapNumbers.set(heap, (number = heapNumbers.size));
|
|
2972
|
+
return number;
|
|
2973
|
+
})
|
|
2974
|
+
.sort((left, right) => left - right)
|
|
2975
|
+
.join(',');
|
|
2976
|
+
let common = commonByHeaps.get(heapsKey);
|
|
2977
|
+
if (common === undefined) {
|
|
2978
|
+
const fields = new Map();
|
|
2979
|
+
for (const heap of cell.heaps) {
|
|
2980
|
+
for (const [key, slot] of heap.fields) {
|
|
2981
|
+
const members = fields.get(key) ?? [];
|
|
2982
|
+
if (!members.some((member) => representationKey(member) === representationKey(slot.representation)))
|
|
2983
|
+
members.push(slot.representation);
|
|
2984
|
+
fields.set(key, members);
|
|
2985
|
+
}
|
|
2437
2986
|
}
|
|
2987
|
+
for (const key of [...fields.keys()])
|
|
2988
|
+
if ([...cell.heaps].some((heap) => !heap.fields.has(key)))
|
|
2989
|
+
fields.delete(key);
|
|
2990
|
+
commonByHeaps.set(heapsKey, (common = fields));
|
|
2438
2991
|
}
|
|
2439
|
-
for (const key of [...common.keys()])
|
|
2440
|
-
if ([...cell.heaps].some((heap) => !heap.fields.has(key)))
|
|
2441
|
-
common.delete(key);
|
|
2442
2992
|
nativeFieldStorageValues.set(id, common);
|
|
2443
2993
|
const carrier = valueCarriers.get(id);
|
|
2444
2994
|
const methods = carrier && 'shapeId' in carrier ? viewMethodFields.get(carrier.shapeId) : undefined;
|
|
@@ -2447,32 +2997,37 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2447
2997
|
for (const key of admitted.keys())
|
|
2448
2998
|
if ([...cell.heaps].some((heap) => heap.declaration === null || classMemberOf(classes, heap.declaration, key)?.kind !== 'method'))
|
|
2449
2999
|
admitted.delete(key);
|
|
2450
|
-
nativeFieldMethodValues.set(id, admitted);
|
|
3000
|
+
nativeFieldMethodValues.set(id, admitted.size === 0 ? emptyMap : admitted);
|
|
2451
3001
|
}
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
seen
|
|
2459
|
-
for (
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
3002
|
+
let accessors = accessorsByHeaps.get(heapsKey);
|
|
3003
|
+
if (accessors === undefined) {
|
|
3004
|
+
const built = new Map();
|
|
3005
|
+
for (const heap of cell.heaps) {
|
|
3006
|
+
if (heap.declaration === null)
|
|
3007
|
+
continue;
|
|
3008
|
+
const seen = new Set();
|
|
3009
|
+
for (let current = heap.declaration; current !== null && !seen.has(current); current = classes.get(current)?.base ?? null) {
|
|
3010
|
+
seen.add(current);
|
|
3011
|
+
for (const accessor of classes.get(current)?.accessors ?? []) {
|
|
3012
|
+
const selected = classMemberOf(classes, heap.declaration, accessor.key);
|
|
3013
|
+
if (selected?.kind !== 'accessor' || selected.owner !== current)
|
|
3014
|
+
continue;
|
|
3015
|
+
const getter = accessor.getter === null ? null : bodyById.get(accessor.getter)?.abi;
|
|
3016
|
+
const setter = accessor.setter === null ? null : bodyById.get(accessor.setter)?.abi;
|
|
3017
|
+
if (!getter)
|
|
3018
|
+
continue;
|
|
3019
|
+
const entries = built.get(accessor.key) ?? [];
|
|
3020
|
+
entries.push({ read: getter.result, write: setter?.parameters[0]?.value ?? null });
|
|
3021
|
+
built.set(accessor.key, entries);
|
|
3022
|
+
}
|
|
2470
3023
|
}
|
|
2471
3024
|
}
|
|
3025
|
+
for (const key of [...built.keys()])
|
|
3026
|
+
if ([...cell.heaps].some((heap) => heap.declaration === null || classMemberOf(classes, heap.declaration, key)?.kind !== 'accessor'))
|
|
3027
|
+
built.delete(key);
|
|
3028
|
+
// Under one heap set in a hundred has an accessor: the rest share one empty table.
|
|
3029
|
+
accessorsByHeaps.set(heapsKey, (accessors = built.size === 0 ? emptyMap : built));
|
|
2472
3030
|
}
|
|
2473
|
-
for (const key of [...accessors.keys()])
|
|
2474
|
-
if ([...cell.heaps].some((heap) => heap.declaration === null || classMemberOf(classes, heap.declaration, key)?.kind !== 'accessor'))
|
|
2475
|
-
accessors.delete(key);
|
|
2476
3031
|
nativeAccessorStorageValues.set(id, accessors);
|
|
2477
3032
|
}
|
|
2478
3033
|
// What a spread's copy left natively in an allocation's expando, by the
|
|
@@ -2561,25 +3116,9 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2561
3116
|
for (const key of extending ? keys : forwardedKeys)
|
|
2562
3117
|
storeExpando(home, key, operation.value.representation);
|
|
2563
3118
|
}
|
|
2564
|
-
const expandoStoredOf = (
|
|
2565
|
-
const byKey = expandoStored.get(shapeId);
|
|
2566
|
-
if (byKey === undefined)
|
|
2567
|
-
return [];
|
|
2568
|
-
// `null`: whatever any key may hold -- an open runtime key reads them all.
|
|
2569
|
-
if (key === null) {
|
|
2570
|
-
const all = [];
|
|
2571
|
-
for (const values of byKey.values())
|
|
2572
|
-
for (const value of values)
|
|
2573
|
-
if (!all.some((one) => representationKey(one) === representationKey(value)))
|
|
2574
|
-
all.push(value);
|
|
2575
|
-
return all;
|
|
2576
|
-
}
|
|
2577
|
-
const keyed = byKey.get(key) ?? [];
|
|
2578
|
-
const any = byKey.get(null) ?? [];
|
|
2579
|
-
return [...keyed, ...any.filter((value) => !keyed.some((one) => representationKey(one) === representationKey(value)))];
|
|
2580
|
-
};
|
|
3119
|
+
const expandoStoredOf = expandoStoredReaderOf(expandoStored);
|
|
2581
3120
|
const nativeFieldViewStorageValues = new Map();
|
|
2582
|
-
const descriptorDomainsOf =
|
|
3121
|
+
const descriptorDomainsOf = descriptorDomainsOver(viewNodes, deriver, bodyById, classes, expandoStored);
|
|
2583
3122
|
for (const [id, carrier] of valueCarriers) {
|
|
2584
3123
|
const fields = descriptorDomainsOf(carrier);
|
|
2585
3124
|
if (fields !== null)
|
|
@@ -2587,6 +3126,11 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2587
3126
|
}
|
|
2588
3127
|
const nativeFieldOperationStorageValues = new Map();
|
|
2589
3128
|
const originDomains = new Map();
|
|
3129
|
+
// The fields every selected heap holds are a function of the selection
|
|
3130
|
+
// alone, and thousands of reads select the same few: one table per
|
|
3131
|
+
// selection, which a read copies only to add what is its own.
|
|
3132
|
+
const selectionNumbers = new Map();
|
|
3133
|
+
const fieldsBySelection = new Map();
|
|
2590
3134
|
for (const operation of operations) {
|
|
2591
3135
|
if (operation.kind !== 'get' && operation.kind !== 'set')
|
|
2592
3136
|
continue;
|
|
@@ -2597,17 +3141,31 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2597
3141
|
const { heaps, present } = heapSelectionAt(operation.receiver, key, operation);
|
|
2598
3142
|
if (heaps === null || heaps.length === 0 || !heaps.every(ordinaryAllocated))
|
|
2599
3143
|
continue;
|
|
2600
|
-
const
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
3144
|
+
const selection = heaps
|
|
3145
|
+
.map((heap) => {
|
|
3146
|
+
let number = selectionNumbers.get(heap);
|
|
3147
|
+
if (number === undefined)
|
|
3148
|
+
selectionNumbers.set(heap, (number = selectionNumbers.size));
|
|
3149
|
+
return number;
|
|
3150
|
+
})
|
|
3151
|
+
.join(',');
|
|
3152
|
+
let shared = fieldsBySelection.get(selection);
|
|
3153
|
+
if (shared === undefined) {
|
|
3154
|
+
const built = new Map();
|
|
3155
|
+
for (const name of heaps[0].fields.keys()) {
|
|
3156
|
+
if (!heaps.every((heap) => heap.fields.has(name)))
|
|
3157
|
+
continue;
|
|
3158
|
+
const entries = new Map();
|
|
3159
|
+
for (const heap of heaps) {
|
|
3160
|
+
const stored = heap.fields.get(name).representation;
|
|
3161
|
+
entries.set(representationKey(stored), { read: stored, write: stored });
|
|
3162
|
+
}
|
|
3163
|
+
built.set(name, [...entries.values()]);
|
|
2608
3164
|
}
|
|
2609
|
-
|
|
3165
|
+
fieldsBySelection.set(selection, (shared = built));
|
|
2610
3166
|
}
|
|
3167
|
+
let domains = shared;
|
|
3168
|
+
const writable = () => (domains === shared ? (domains = new Map(shared)) : domains);
|
|
2611
3169
|
if (operation.kind === 'get' &&
|
|
2612
3170
|
heaps.some((heap) => !heap.fields.has(key)) &&
|
|
2613
3171
|
heaps.every((heap) => heap.fields.has(key) || originalDescriptorAbsent(operation, key, heap))) {
|
|
@@ -2618,7 +3176,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2618
3176
|
? { read: { kind: 'undefined' }, write: null, originalAbsent: true }
|
|
2619
3177
|
: { read: slot.representation, write: slot.representation });
|
|
2620
3178
|
}
|
|
2621
|
-
|
|
3179
|
+
writable().set(key, entries);
|
|
2622
3180
|
}
|
|
2623
3181
|
// A receiver that may hold a live view also holds, in this cell, the
|
|
2624
3182
|
// allocations behind each view -- of another layout, which the plain
|
|
@@ -2642,7 +3200,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2642
3200
|
: { read: slot.representation, write: slot.representation };
|
|
2643
3201
|
entries.set(`${representationKey(entry.read)}:${entry.originalAbsent === true}`, entry);
|
|
2644
3202
|
}
|
|
2645
|
-
|
|
3203
|
+
writable().set(key, [...entries.values()]);
|
|
2646
3204
|
}
|
|
2647
3205
|
}
|
|
2648
3206
|
if (receiver.fieldViews.size > 0) {
|
|
@@ -2668,7 +3226,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2668
3226
|
// answer (`native-field-view-domains.ts`) and is no route behind them.
|
|
2669
3227
|
if (routes.some((route) => route.originalAbsent === true || route.dynamicGet === true || route.nativeData === true))
|
|
2670
3228
|
continue;
|
|
2671
|
-
|
|
3229
|
+
writable().set(name, [
|
|
2672
3230
|
...(domains.get(name) ?? []),
|
|
2673
3231
|
...(present && name === key ? routes.filter((route) => route.sourceAbsent !== true) : routes)
|
|
2674
3232
|
]);
|
|
@@ -2676,6 +3234,8 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2676
3234
|
}
|
|
2677
3235
|
nativeFieldOperationStorageValues.set(operation, domains);
|
|
2678
3236
|
}
|
|
3237
|
+
// `keyOf` above was the last reader of the producer table.
|
|
3238
|
+
producers.clear();
|
|
2679
3239
|
const callableIdentityOrigins = new Map();
|
|
2680
3240
|
const callablePublications = new Map();
|
|
2681
3241
|
for (const cell of cells)
|
|
@@ -2758,10 +3318,7 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2758
3318
|
nativeFieldViewStorageValues,
|
|
2759
3319
|
nativeFieldViewOpenWriteValues,
|
|
2760
3320
|
nativeFieldViewForwardedWrites,
|
|
2761
|
-
nativeFieldViewAbsentRoutesOf: (
|
|
2762
|
-
const carrier = valueCarriers.get(receiver);
|
|
2763
|
-
return carrier === undefined ? null : descriptorDomainsOf.absentRoutesOf(carrier, key);
|
|
2764
|
-
},
|
|
3321
|
+
nativeFieldViewAbsentRoutesOf: absentRoutesReaderOf(valueCarriers, viewShapes, descriptorDomainsOf),
|
|
2765
3322
|
nativeFieldStorageValues,
|
|
2766
3323
|
nativeFieldMethodValues,
|
|
2767
3324
|
nativeAccessorStorageValues,
|
|
@@ -2895,15 +3452,222 @@ const flowOverCopy = (flow, pairs) => {
|
|
|
2895
3452
|
const answer = { ...moved, callables: callees };
|
|
2896
3453
|
if (absentRoutesOf === undefined)
|
|
2897
3454
|
return answer;
|
|
3455
|
+
return { ...answer, nativeFieldViewAbsentRoutesOf: repointedAbsentRoutesOf(absentRoutesOf, pairs) };
|
|
3456
|
+
};
|
|
3457
|
+
/** The solved reader and the one pairing a re-pointed reader applies to its answers. */
|
|
3458
|
+
const repointedReaders = new WeakMap();
|
|
3459
|
+
/**
|
|
3460
|
+
* Outside `flowOverCopy` for the reason `expandoStoredReaderOf` states: an
|
|
3461
|
+
* arrow made there shared its context with `seen` and `fresh`, every object of
|
|
3462
|
+
* both programs.
|
|
3463
|
+
*
|
|
3464
|
+
* A reader re-pointed again is not wrapped again: the two pairings are
|
|
3465
|
+
* composed into one over the solved reader's own program. Wrapping kept every
|
|
3466
|
+
* intermediate copy's pairing -- and through it every intermediate program --
|
|
3467
|
+
* alive for as long as the newest flow was remembered. Composing is exact:
|
|
3468
|
+
* re-pointing through the first pairing and then the second is re-pointing
|
|
3469
|
+
* each first-pairing partner through the second, and leaving every object the
|
|
3470
|
+
* first did not pair to the second.
|
|
3471
|
+
*/
|
|
3472
|
+
const repointedAbsentRoutesOf = (absentRoutesOf, pairs) => {
|
|
3473
|
+
const earlier = repointedReaders.get(absentRoutesOf);
|
|
3474
|
+
const base = earlier?.base ?? absentRoutesOf;
|
|
3475
|
+
let composed = answerReachablePairsOf(pairs);
|
|
3476
|
+
if (earlier !== undefined) {
|
|
3477
|
+
const seen = new Map();
|
|
3478
|
+
const unreached = { objects: new Set(), reached: false };
|
|
3479
|
+
const both = new Map();
|
|
3480
|
+
for (const [old, partner] of earlier.pairs)
|
|
3481
|
+
both.set(old, repointed(partner, pairs, seen, unreached));
|
|
3482
|
+
for (const [old, partner] of composed)
|
|
3483
|
+
if (!both.has(old))
|
|
3484
|
+
both.set(old, partner);
|
|
3485
|
+
composed = both;
|
|
3486
|
+
}
|
|
3487
|
+
const reader = absentRoutesReaderOver(base, composed);
|
|
3488
|
+
repointedReaders.set(reader, { base, pairs: composed });
|
|
3489
|
+
return reader;
|
|
3490
|
+
};
|
|
3491
|
+
/**
|
|
3492
|
+
* The part of a pairing an absent-routes answer can reach. An answer holds
|
|
3493
|
+
* storage domains over representations and conversion nodes, and none of those
|
|
3494
|
+
* ever holds an IR operation, block or body, or a container of one. So the
|
|
3495
|
+
* pairing's entries for the program's own structure are never consulted when
|
|
3496
|
+
* an answer is re-pointed. Kept whole, a reader pinned both programs it paired
|
|
3497
|
+
* -- every block, operation and operand list, up to a million entries per
|
|
3498
|
+
* reader on a large app -- for the rest of the compile.
|
|
3499
|
+
*/
|
|
3500
|
+
const answerReachablePairsOf = (pairs) => {
|
|
3501
|
+
const structural = new Map();
|
|
3502
|
+
const isStructure = (value) => {
|
|
3503
|
+
if (typeof value !== 'object' || value === null)
|
|
3504
|
+
return false;
|
|
3505
|
+
const known = structural.get(value);
|
|
3506
|
+
if (known !== undefined)
|
|
3507
|
+
return known;
|
|
3508
|
+
structural.set(value, false);
|
|
3509
|
+
let answer;
|
|
3510
|
+
if (Array.isArray(value))
|
|
3511
|
+
answer = value.some(isStructure);
|
|
3512
|
+
else if (value instanceof Map)
|
|
3513
|
+
answer = [...value.values()].some(isStructure) || [...value.keys()].some(isStructure);
|
|
3514
|
+
else if (value instanceof Set)
|
|
3515
|
+
answer = [...value].some(isStructure);
|
|
3516
|
+
else
|
|
3517
|
+
answer = 'lineage' in value || ('operations' in value && 'terminator' in value) || ('blocks' in value && 'sourceOwner' in value);
|
|
3518
|
+
structural.set(value, answer);
|
|
3519
|
+
return answer;
|
|
3520
|
+
};
|
|
3521
|
+
const kept = new Map();
|
|
3522
|
+
for (const [old, partner] of pairs)
|
|
3523
|
+
if (!isStructure(old))
|
|
3524
|
+
kept.set(old, partner);
|
|
3525
|
+
return kept;
|
|
3526
|
+
};
|
|
3527
|
+
const absentRoutesReaderOver = (base, pairs) => (receiver, key) => repointed(base(receiver, key), pairs, new Map(), { objects: new Set(), reached: false });
|
|
3528
|
+
/**
|
|
3529
|
+
* The readers a flow hands back are built here, outside the solve, because V8
|
|
3530
|
+
* gives every closure one function creates a single shared context: an arrow
|
|
3531
|
+
* made inside `computeNativeCallableFlow` kept its whole scope -- every origin
|
|
3532
|
+
* cell, value and heap -- alive for as long as the remembered flow was, which
|
|
3533
|
+
* held gigabytes on a large program. Each captures only what it reads.
|
|
3534
|
+
*/
|
|
3535
|
+
const expandoStoredReaderOf = (expandoStored) => (shapeId, key) => {
|
|
3536
|
+
const byKey = expandoStored.get(shapeId);
|
|
3537
|
+
if (byKey === undefined)
|
|
3538
|
+
return [];
|
|
3539
|
+
// `null`: whatever any key may hold -- an open runtime key reads them all.
|
|
3540
|
+
if (key === null) {
|
|
3541
|
+
const all = [];
|
|
3542
|
+
for (const values of byKey.values())
|
|
3543
|
+
for (const value of values)
|
|
3544
|
+
if (!all.some((one) => representationKey(one) === representationKey(value)))
|
|
3545
|
+
all.push(value);
|
|
3546
|
+
return all;
|
|
3547
|
+
}
|
|
3548
|
+
const keyed = byKey.get(key) ?? [];
|
|
3549
|
+
const any = byKey.get(null) ?? [];
|
|
3550
|
+
return [...keyed, ...any.filter((value) => !keyed.some((one) => representationKey(one) === representationKey(value)))];
|
|
3551
|
+
};
|
|
3552
|
+
const descriptorDomainsOver = (viewNodes, deriver, bodyById, classes, expandoStored) => {
|
|
3553
|
+
// The domains outlive the solve inside every remembered and re-pointed
|
|
3554
|
+
// reader, so they keep the ABIs rather than `bodyById`, which held the
|
|
3555
|
+
// solved body generation for as long as any reader did.
|
|
3556
|
+
const abis = new Map();
|
|
3557
|
+
for (const [id, body] of bodyById)
|
|
3558
|
+
abis.set(id, body?.abi ?? null);
|
|
3559
|
+
return nativeFieldViewDomainsOf(viewNodes, deriver, (id) => abis.get(id) ?? null, classes, expandoStoredReaderOf(expandoStored));
|
|
3560
|
+
};
|
|
3561
|
+
/** Whether `id` is `irValueId(owner, n)` for some ordinal, read without slicing it. */
|
|
3562
|
+
/**
|
|
3563
|
+
* Ends a settled solve's propagation state. The edges, the cells feeding each
|
|
3564
|
+
* cell and the escape-absorption marks carry propagation only, and nothing
|
|
3565
|
+
* propagates once the solve has settled; held through the answers built
|
|
3566
|
+
* after it, they made those answers the solve's peak. A heap set equal, in
|
|
3567
|
+
* members and order, to an earlier cell's becomes that one set, shared (and
|
|
3568
|
+
* copied on any later write): most cells holding several allocations hold
|
|
3569
|
+
* exactly another's.
|
|
3570
|
+
*/
|
|
3571
|
+
const releasePropagation = (cells) => {
|
|
3572
|
+
const sets = new Map();
|
|
3573
|
+
const numbers = new Map();
|
|
3574
|
+
const numberOf = (heap) => {
|
|
3575
|
+
let number = numbers.get(heap);
|
|
3576
|
+
if (number === undefined)
|
|
3577
|
+
numbers.set(heap, (number = numbers.size));
|
|
3578
|
+
return number;
|
|
3579
|
+
};
|
|
3580
|
+
const sameMembers = (left, right) => {
|
|
3581
|
+
const theirs = right[Symbol.iterator]();
|
|
3582
|
+
for (const heap of left)
|
|
3583
|
+
if (theirs.next().value !== heap)
|
|
3584
|
+
return false;
|
|
3585
|
+
return true;
|
|
3586
|
+
};
|
|
3587
|
+
for (const cell of cells) {
|
|
3588
|
+
cell.edges = emptyCellMap;
|
|
3589
|
+
cell.incoming = null;
|
|
3590
|
+
if (cell.escapeAbsorbed !== undefined)
|
|
3591
|
+
cell.escapeAbsorbed = undefined;
|
|
3592
|
+
const heaps = cell.heaps;
|
|
3593
|
+
if (heaps.members === null)
|
|
3594
|
+
continue;
|
|
3595
|
+
let last;
|
|
3596
|
+
for (const heap of heaps.members)
|
|
3597
|
+
last = heap;
|
|
3598
|
+
const key = `${heaps.size}:${numberOf(heaps.first)}:${numberOf(last)}`;
|
|
3599
|
+
const candidates = sets.get(key);
|
|
3600
|
+
const found = candidates?.find((candidate) => candidate === heaps || sameMembers(candidate, heaps));
|
|
3601
|
+
if (found !== undefined)
|
|
3602
|
+
cell.heaps = found;
|
|
3603
|
+
else {
|
|
3604
|
+
heaps.shared = true;
|
|
3605
|
+
if (candidates === undefined)
|
|
3606
|
+
sets.set(key, [heaps]);
|
|
3607
|
+
else
|
|
3608
|
+
candidates.push(heaps);
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
};
|
|
3612
|
+
const valueOwnedBy = (id, owner) => id.startsWith('ssa|') && id.startsWith(owner, 4) && id.charCodeAt(4 + owner.length) === 124 && id.indexOf('|', 5 + owner.length) === -1;
|
|
3613
|
+
/**
|
|
3614
|
+
* Every SSA value's carrier, read through the bodies rather than copied into
|
|
3615
|
+
* one table: a table of the program's every value, built at the solve's end,
|
|
3616
|
+
* was the largest single thing the solve allocated beside its answers. A value
|
|
3617
|
+
* names the body that defines it (`irValueId`), so a lookup goes straight to
|
|
3618
|
+
* that body. Bodies whose values do not all name them, or two bodies of one
|
|
3619
|
+
* id, fall back to the table, which then answers exactly as before.
|
|
3620
|
+
*/
|
|
3621
|
+
const valueCarriersOf = (bodies) => {
|
|
3622
|
+
const byOwner = new Map();
|
|
3623
|
+
let owned = true;
|
|
3624
|
+
for (const body of bodies) {
|
|
3625
|
+
const ownerId = String(body.owner);
|
|
3626
|
+
if (byOwner.has(ownerId))
|
|
3627
|
+
owned = false;
|
|
3628
|
+
byOwner.set(ownerId, body);
|
|
3629
|
+
if (owned)
|
|
3630
|
+
for (const id of body.values.keys())
|
|
3631
|
+
if (!valueOwnedBy(id, ownerId))
|
|
3632
|
+
owned = false;
|
|
3633
|
+
if (!owned)
|
|
3634
|
+
break;
|
|
3635
|
+
}
|
|
3636
|
+
if (!owned)
|
|
3637
|
+
return new Map(bodies.flatMap((body) => [...body.values]));
|
|
2898
3638
|
return {
|
|
2899
|
-
|
|
2900
|
-
|
|
3639
|
+
get: (id) => byOwner.get(id.slice(4, id.lastIndexOf('|')))?.values.get(id),
|
|
3640
|
+
*[Symbol.iterator]() {
|
|
3641
|
+
for (const body of bodies)
|
|
3642
|
+
yield* body.values;
|
|
3643
|
+
}
|
|
3644
|
+
};
|
|
3645
|
+
};
|
|
3646
|
+
/**
|
|
3647
|
+
* `absentRoutesOf` answers null for any carrier that is not, under its
|
|
3648
|
+
* optional and borrowed wrappers, one of `viewShapes` -- a shape some view
|
|
3649
|
+
* installs a plan for. The reader keeps only the values whose carrier can
|
|
3650
|
+
* answer: every value of the program was a table per remembered flow.
|
|
3651
|
+
*/
|
|
3652
|
+
const absentRoutesReaderOf = (valueCarriers, viewShapes, domains) => {
|
|
3653
|
+
const viewed = new Map();
|
|
3654
|
+
if (viewShapes.size > 0)
|
|
3655
|
+
for (const [id, carrier] of valueCarriers) {
|
|
3656
|
+
let unwrapped = carrier;
|
|
3657
|
+
while (unwrapped.kind === 'optional' || unwrapped.kind === 'borrowed-ref')
|
|
3658
|
+
unwrapped = unwrapped.kind === 'optional' ? unwrapped.payload : unwrapped.referent;
|
|
3659
|
+
if ('shapeId' in unwrapped && viewShapes.has(unwrapped.shapeId))
|
|
3660
|
+
viewed.set(id, carrier);
|
|
3661
|
+
}
|
|
3662
|
+
return (receiver, key) => {
|
|
3663
|
+
const carrier = viewed.get(receiver);
|
|
3664
|
+
return carrier === undefined ? null : domains.absentRoutesOf(carrier, key);
|
|
2901
3665
|
};
|
|
2902
3666
|
};
|
|
2903
3667
|
/**
|
|
2904
3668
|
* The flow's answer is a function of its inputs' data -- the conversion census
|
|
2905
3669
|
* it consults is append-only and `nodeFor` is idempotent per pair -- so a
|
|
2906
|
-
* recent answer
|
|
3670
|
+
* recent answer for the class map is reused when every input is the same. The
|
|
2907
3671
|
* same objects reuse it directly. The publish passes between two solves
|
|
2908
3672
|
* rebuild every body and operation even when they change nothing, so an input
|
|
2909
3673
|
* that is the same DATA reuses the answer re-pointed at the new objects, since
|
|
@@ -2913,14 +3677,32 @@ const flowOverCopy = (flow, pairs) => {
|
|
|
2913
3677
|
* differ in what the flow reads (`logicalReceiver`, `closedCallable`,
|
|
2914
3678
|
* `presence`, recipe lists). A traced run reports reads as it solves and is
|
|
2915
3679
|
* always solved.
|
|
3680
|
+
*
|
|
3681
|
+
* Only the class map asked last keeps answers. Each answer holds its flow and
|
|
3682
|
+
* the body generation it was solved over, a few hundred megabytes on a large
|
|
3683
|
+
* program, and the pipeline moves to a new class map without returning to
|
|
3684
|
+
* the old one: kept per map, a dead map's answers stayed for the rest of the
|
|
3685
|
+
* compile. Held weakly, so nothing outlives the class map it answers.
|
|
2916
3686
|
*/
|
|
2917
3687
|
const rememberedFlows = new WeakMap();
|
|
2918
|
-
|
|
2919
|
-
|
|
3688
|
+
let rememberedClasses = null;
|
|
3689
|
+
/**
|
|
3690
|
+
* Callers alternate between asking with and without program conversions, so
|
|
3691
|
+
* one answer is kept per kind: a single remembered answer was always the
|
|
3692
|
+
* other kind. A newer answer of the same kind replaces the older one, which
|
|
3693
|
+
* was solved over an earlier body generation and is only ever a worse match.
|
|
3694
|
+
*/
|
|
3695
|
+
const flowKindOf = (programConversions, constructionTopology) => (programConversions == null ? 0 : 1) + (constructionTopology == null ? 0 : 2);
|
|
2920
3696
|
export const nativeCallableFlowOf = (...args) => {
|
|
2921
3697
|
const [bodies, placements, classes, conversions, trace, deriver, programConversions, constructionTopology] = args;
|
|
2922
3698
|
if (trace !== undefined)
|
|
2923
3699
|
return computeNativeCallableFlow(...args);
|
|
3700
|
+
const previous = rememberedClasses?.deref();
|
|
3701
|
+
if (previous !== classes) {
|
|
3702
|
+
if (previous !== undefined)
|
|
3703
|
+
rememberedFlows.delete(previous);
|
|
3704
|
+
rememberedClasses = new WeakRef(classes);
|
|
3705
|
+
}
|
|
2924
3706
|
let held = rememberedFlows.get(classes);
|
|
2925
3707
|
if (held === undefined)
|
|
2926
3708
|
rememberedFlows.set(classes, (held = []));
|
|
@@ -2928,6 +3710,10 @@ export const nativeCallableFlowOf = (...args) => {
|
|
|
2928
3710
|
const remember = (flow, replaced) => {
|
|
2929
3711
|
if (replaced !== -1)
|
|
2930
3712
|
entries.splice(replaced, 1);
|
|
3713
|
+
const kind = flowKindOf(programConversions, constructionTopology);
|
|
3714
|
+
for (let index = entries.length - 1; index >= 0; index--)
|
|
3715
|
+
if (flowKindOf(entries[index].programConversions, entries[index].constructionTopology) === kind)
|
|
3716
|
+
entries.splice(index, 1);
|
|
2931
3717
|
entries.unshift({
|
|
2932
3718
|
bodies,
|
|
2933
3719
|
placements,
|
|
@@ -2937,34 +3723,49 @@ export const nativeCallableFlowOf = (...args) => {
|
|
|
2937
3723
|
constructionTopology: constructionTopology ?? null,
|
|
2938
3724
|
flow
|
|
2939
3725
|
});
|
|
2940
|
-
entries.length = Math.min(entries.length, REMEMBERED_FLOWS);
|
|
2941
3726
|
return flow;
|
|
2942
3727
|
};
|
|
2943
3728
|
const sameContext = (entry) => entry.placements === placements && entry.conversions === conversions && entry.deriver === (deriver ?? null);
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
3729
|
+
// The search runs in its own frame: a failed pairing's map pairs both
|
|
3730
|
+
// programs object for object, and the loop's last `pairs` and `entry`
|
|
3731
|
+
// registers kept it, and the entry about to be replaced, alive through the
|
|
3732
|
+
// solve below -- the compile's peak.
|
|
3733
|
+
const found = (() => {
|
|
3734
|
+
for (const entry of entries)
|
|
3735
|
+
if (sameContext(entry) &&
|
|
3736
|
+
entry.programConversions === (programConversions ?? null) &&
|
|
3737
|
+
entry.constructionTopology === (constructionTopology ?? null) &&
|
|
3738
|
+
entry.bodies.length === bodies.length &&
|
|
3739
|
+
entry.bodies.every((body, index) => body === bodies[index]))
|
|
3740
|
+
return entry.flow;
|
|
3741
|
+
for (let index = 0; index < entries.length; index++) {
|
|
3742
|
+
const entry = entries[index];
|
|
3743
|
+
if (!sameContext(entry) ||
|
|
3744
|
+
entry.bodies.length !== bodies.length ||
|
|
3745
|
+
(entry.programConversions === null) !== (programConversions === undefined) ||
|
|
3746
|
+
(entry.constructionTopology === null) !== (constructionTopology === undefined))
|
|
3747
|
+
continue;
|
|
3748
|
+
const pairs = new Map();
|
|
3749
|
+
if (!pairSameData(entry.bodies, bodies, pairs) ||
|
|
3750
|
+
!pairSameData(entry.programConversions, programConversions ?? null, pairs) ||
|
|
3751
|
+
!pairSameData(entry.constructionTopology, constructionTopology ?? null, pairs))
|
|
3752
|
+
continue;
|
|
3753
|
+
const reused = flowOverCopy(entry.flow, pairs);
|
|
3754
|
+
if (reused === null)
|
|
3755
|
+
continue;
|
|
3756
|
+
return remember(reused, index);
|
|
3757
|
+
}
|
|
3758
|
+
return null;
|
|
3759
|
+
})();
|
|
3760
|
+
if (found !== null)
|
|
3761
|
+
return found;
|
|
3762
|
+
// A solve forgets every remembered answer first, not only the one of its
|
|
3763
|
+
// own kind that `remember` replaces: each holds its flow and the body
|
|
3764
|
+
// generation it was solved over, and the other kind's was most of what a
|
|
3765
|
+
// solve -- the compile's peak -- held beside its own state. An answer of the
|
|
3766
|
+
// other kind is still reused when no solve comes between, which is most
|
|
3767
|
+
// reuses; on a large program two more are solved.
|
|
3768
|
+
entries.length = 0;
|
|
2968
3769
|
const flow = computeNativeCallableFlow(...args);
|
|
2969
3770
|
return remember(flow, -1);
|
|
2970
3771
|
};
|