@geastack/compiler 1.0.27 → 1.0.30
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-coverage.js +2 -2
- package/dist/cli-emit.js +36 -12
- package/dist/compiler.d.ts +11 -9
- package/dist/compiler.js +264 -43
- package/dist/conversion/algebra.d.ts +84 -4
- package/dist/conversion/algebra.js +39 -0
- package/dist/conversion/array-view.d.ts +63 -0
- package/dist/conversion/array-view.js +186 -0
- package/dist/conversion/build.d.ts +8 -8
- package/dist/conversion/build.js +56 -50
- package/dist/conversion/certified-iterator-object-view.d.ts +13 -0
- package/dist/conversion/certified-iterator-object-view.js +31 -0
- package/dist/conversion/certified-iterator-protocols.d.ts +23 -0
- package/dist/conversion/certified-iterator-protocols.js +50 -0
- package/dist/conversion/checked-native-field-read.d.ts +7 -0
- package/dist/conversion/checked-native-field-read.js +36 -0
- package/dist/conversion/constructor-identity-family.d.ts +6 -6
- package/dist/conversion/constructor-identity-family.js +3 -3
- package/dist/conversion/derive.js +11 -8
- package/dist/conversion/dictionary-view.d.ts +114 -0
- package/dist/conversion/dictionary-view.js +293 -0
- package/dist/conversion/document-record-view.d.ts +89 -0
- package/dist/conversion/document-record-view.js +269 -0
- package/dist/conversion/dynamic-result-carriers.d.ts +6 -0
- package/dist/conversion/dynamic-result-carriers.js +43 -0
- package/dist/conversion/dynamic-wrapper.d.ts +57 -0
- package/dist/conversion/dynamic-wrapper.js +85 -0
- package/dist/conversion/impossible-field-read.d.ts +9 -0
- package/dist/conversion/impossible-field-read.js +28 -0
- package/dist/conversion/iterable-object-view.d.ts +1 -1
- package/dist/conversion/iterator-object-view.d.ts +2 -2
- package/dist/conversion/native-absence.d.ts +4 -0
- package/dist/conversion/native-absence.js +4 -0
- package/dist/conversion/native-buffer-method.d.ts +16 -0
- package/dist/conversion/native-buffer-method.js +37 -0
- package/dist/conversion/native-callable-adapter.d.ts +13 -0
- package/dist/conversion/native-callable-adapter.js +73 -0
- package/dist/conversion/native-descriptor-snapshot.d.ts +30 -0
- package/dist/conversion/native-descriptor-snapshot.js +75 -0
- package/dist/conversion/native-entry-writer.d.ts +21 -0
- package/dist/conversion/native-entry-writer.js +32 -0
- package/dist/conversion/native-field-view.d.ts +42 -0
- package/dist/conversion/native-field-view.js +145 -0
- package/dist/conversion/native-logical-receiver.d.ts +11 -0
- package/dist/conversion/native-logical-receiver.js +19 -0
- package/dist/conversion/native-method.d.ts +43 -0
- package/dist/conversion/native-method.js +56 -0
- package/dist/conversion/native-object-sample.d.ts +30 -0
- package/dist/conversion/native-object-sample.js +37 -0
- package/dist/conversion/native-payload-transport.d.ts +1 -1
- package/dist/conversion/native-payload-transport.js +1 -1
- package/dist/conversion/native-record-products.d.ts +15 -0
- package/dist/conversion/native-record-products.js +73 -0
- package/dist/conversion/native-selection.d.ts +18 -1
- package/dist/conversion/native-selection.js +117 -4
- package/dist/conversion/native-sum.d.ts +27 -0
- package/dist/conversion/native-sum.js +74 -9
- package/dist/conversion/native-view-origins.d.ts +12 -0
- package/dist/conversion/native-view-origins.js +97 -0
- package/dist/conversion/nodes.d.ts +75 -7
- package/dist/conversion/nodes.js +694 -19
- package/dist/conversion/number-storage.d.ts +8 -0
- package/dist/conversion/number-storage.js +8 -0
- package/dist/conversion/operand-view.js +10 -1
- package/dist/conversion/promise-adoption.d.ts +15 -0
- package/dist/conversion/promise-adoption.js +29 -0
- package/dist/conversion/protocol-iterator.d.ts +3 -3
- package/dist/conversion/recipe-closure.d.ts +14 -0
- package/dist/conversion/recipe-closure.js +135 -0
- package/dist/conversion/record-view.d.ts +51 -26
- package/dist/conversion/record-view.js +160 -97
- package/dist/conversion/registry.d.ts +18 -2
- package/dist/conversion/sibling-class.d.ts +4 -0
- package/dist/conversion/sibling-class.js +7 -0
- package/dist/conversion/structural-plan.d.ts +87 -0
- package/dist/conversion/structural-plan.js +487 -0
- package/dist/ir/absent-class-arm.d.ts +5 -1
- package/dist/ir/absent-class-arm.js +51 -3
- package/dist/ir/async-result-conventions.d.ts +15 -0
- package/dist/ir/async-result-conventions.js +140 -0
- package/dist/ir/borrowed-call-arguments.d.ts +3 -3
- package/dist/ir/borrowed-call-arguments.js +9 -9
- package/dist/ir/build.d.ts +20 -29
- package/dist/ir/build.js +116 -19
- package/dist/ir/call-dispatch.js +153 -40
- package/dist/ir/call-entry.d.ts +14 -3
- package/dist/ir/call-entry.js +72 -5
- package/dist/ir/callable-class-flow.d.ts +48 -3
- package/dist/ir/callable-class-flow.js +1509 -81
- package/dist/ir/callable-flow-candidates.d.ts +25 -0
- package/dist/ir/callable-flow-candidates.js +135 -0
- package/dist/ir/callable-identity-demand.d.ts +2 -2
- package/dist/ir/callable-identity-demand.js +33 -1
- package/dist/ir/callable-member-candidates.d.ts +1 -1
- package/dist/ir/callable-member-candidates.js +2 -2
- package/dist/ir/callable-records.js +1 -0
- package/dist/ir/callable-site-escape.js +3 -4
- package/dist/ir/captures.js +1 -1
- package/dist/ir/certificate.d.ts +1 -0
- package/dist/ir/certificate.js +2 -1
- package/dist/ir/certify/carrier-keys.d.ts +2 -2
- package/dist/ir/certify/carrier-keys.js +4 -4
- package/dist/ir/certify/has-property-key.d.ts +3 -3
- package/dist/ir/certify/has-property-key.js +3 -3
- package/dist/ir/certify/parallel-region.d.ts +26 -0
- package/dist/ir/certify/parallel-region.js +1331 -0
- package/dist/ir/certify/property-access-keys.d.ts +11 -11
- package/dist/ir/certify/property-access-keys.js +11 -11
- package/dist/ir/certify/property-access.js +7 -9
- package/dist/ir/certify.d.ts +66 -3
- package/dist/ir/certify.js +1209 -37
- package/dist/ir/class-allocation-domain.d.ts +9 -0
- package/dist/ir/class-allocation-domain.js +158 -0
- package/dist/ir/class-evaluation.d.ts +2 -3
- package/dist/ir/class-evaluation.js +2 -3
- package/dist/ir/class-static-fields.d.ts +12 -1
- package/dist/ir/class-static-fields.js +25 -0
- package/dist/ir/closed-normal-results.d.ts +18 -0
- package/dist/ir/closed-normal-results.js +208 -0
- package/dist/ir/construct-entry.js +1 -0
- package/dist/ir/construction-only-fields.d.ts +20 -1
- package/dist/ir/construction-only-fields.js +95 -9
- package/dist/ir/convert-carriers.d.ts +7 -0
- package/dist/ir/convert-carriers.js +12 -0
- package/dist/ir/coroutine-bodies.d.ts +74 -0
- package/dist/ir/coroutine-bodies.js +93 -0
- package/dist/ir/dead-logical-merge.d.ts +7 -0
- package/dist/ir/dead-logical-merge.js +84 -0
- package/dist/ir/dead-values.d.ts +7 -5
- package/dist/ir/dead-values.js +34 -5
- package/dist/ir/deferral.d.ts +3 -1
- package/dist/ir/deferral.js +19 -6
- package/dist/ir/dense-loops.d.ts +96 -7
- package/dist/ir/dense-loops.js +333 -17
- package/dist/ir/descriptor-own-protocol.d.ts +12 -0
- package/dist/ir/descriptor-own-protocol.js +35 -0
- package/dist/ir/dynamic-constructor-conversions.d.ts +17 -0
- package/dist/ir/dynamic-constructor-conversions.js +52 -0
- package/dist/ir/emission-representations.js +44 -2
- package/dist/ir/facts.d.ts +14 -2
- package/dist/ir/facts.js +23 -9
- package/dist/ir/fixed-data-definition-attributes.d.ts +10 -0
- package/dist/ir/fixed-data-definition-attributes.js +200 -0
- package/dist/ir/fixed-data-definition.d.ts +23 -5
- package/dist/ir/fixed-data-definition.js +80 -2
- package/dist/ir/function-reflection-demand.d.ts +11 -0
- package/dist/ir/function-reflection-demand.js +71 -0
- package/dist/ir/generic-call-entry.d.ts +18 -0
- package/dist/ir/generic-call-entry.js +94 -0
- package/dist/ir/hoist.d.ts +16 -3
- package/dist/ir/hoist.js +121 -8
- package/dist/ir/host-method-aliases.d.ts +15 -0
- package/dist/ir/host-method-aliases.js +61 -0
- package/dist/ir/host-namespace-reads.d.ts +24 -0
- package/dist/ir/host-namespace-reads.js +151 -0
- package/dist/ir/host-promise-conversions.d.ts +5 -0
- package/dist/ir/host-promise-conversions.js +61 -0
- package/dist/ir/host-template-conversions.d.ts +34 -0
- package/dist/ir/host-template-conversions.js +357 -0
- package/dist/ir/instance-reparenting.d.ts +3 -4
- package/dist/ir/instantiation.d.ts +1 -1
- package/dist/ir/instantiation.js +1 -1
- package/dist/ir/integer-storage.d.ts +19 -9
- package/dist/ir/integer-storage.js +158 -44
- package/dist/ir/integers.d.ts +34 -7
- package/dist/ir/integers.js +240 -7
- package/dist/ir/integrity-restrictions.d.ts +4 -4
- package/dist/ir/integrity-restrictions.js +7 -4
- package/dist/ir/internal-operation-conversions.d.ts +7 -0
- package/dist/ir/internal-operation-conversions.js +195 -0
- package/dist/ir/intrinsic-call-facts.d.ts +40 -0
- package/dist/ir/intrinsic-call-facts.js +176 -0
- package/dist/ir/key-order-observation.d.ts +1 -1
- package/dist/ir/key-order-observation.js +3 -0
- package/dist/ir/lazy-splits.d.ts +20 -0
- package/dist/ir/lazy-splits.js +58 -0
- package/dist/ir/literal-set-membership.d.ts +2 -2
- package/dist/ir/literal-set-membership.js +2 -2
- package/dist/ir/logical-receivers.d.ts +15 -0
- package/dist/ir/logical-receivers.js +98 -0
- package/dist/ir/lower-allocation.js +16 -13
- package/dist/ir/lower-destructuring.js +7 -6
- package/dist/ir/lower-graph.d.ts +4 -4
- package/dist/ir/lower-graph.js +2 -2
- package/dist/ir/lower-invocation.d.ts +2 -2
- package/dist/ir/lower-invocation.js +99 -57
- package/dist/ir/lower-narrow.js +35 -13
- package/dist/ir/lower-operands.d.ts +40 -11
- package/dist/ir/lower-operands.js +206 -87
- package/dist/ir/lower-property.js +31 -8
- package/dist/ir/lower.js +9 -9
- package/dist/ir/merge-conversions.d.ts +18 -0
- package/dist/ir/merge-conversions.js +106 -0
- package/dist/ir/model.d.ts +138 -28
- package/dist/ir/native-accessor-definition.d.ts +104 -0
- package/dist/ir/native-accessor-definition.js +735 -0
- package/dist/ir/native-array-descriptor-snapshot.d.ts +45 -0
- package/dist/ir/native-array-descriptor-snapshot.js +380 -0
- package/dist/ir/native-array-insertion.d.ts +16 -0
- package/dist/ir/native-array-insertion.js +42 -0
- package/dist/ir/native-array-transport.js +37 -3
- package/dist/ir/native-callable-argument.d.ts +38 -0
- package/dist/ir/native-callable-argument.js +128 -0
- package/dist/ir/native-callable-data-flow.d.ts +9 -0
- package/dist/ir/native-callable-data-flow.js +59 -0
- package/dist/ir/native-callable-data-owner.d.ts +45 -0
- package/dist/ir/native-callable-data-owner.js +755 -0
- package/dist/ir/native-callable-data-reads.d.ts +45 -0
- package/dist/ir/native-callable-data-reads.js +282 -0
- package/dist/ir/native-callable-data-slots.d.ts +78 -0
- package/dist/ir/native-callable-data-slots.js +403 -0
- package/dist/ir/native-callable-data-write.d.ts +58 -0
- package/dist/ir/native-callable-data-write.js +254 -0
- package/dist/ir/native-callable-integrity.d.ts +23 -0
- package/dist/ir/native-callable-integrity.js +77 -0
- package/dist/ir/native-callable-own-property.d.ts +42 -0
- package/dist/ir/native-callable-own-property.js +505 -0
- package/dist/ir/native-callable-prototype.d.ts +38 -0
- package/dist/ir/native-callable-prototype.js +307 -0
- package/dist/ir/native-callable-readonly-set.d.ts +25 -0
- package/dist/ir/native-callable-readonly-set.js +238 -0
- package/dist/ir/native-class-accessor.d.ts +3 -3
- package/dist/ir/native-class-accessor.js +3 -3
- package/dist/ir/native-class-construction.js +2 -2
- package/dist/ir/native-constructor-reads.d.ts +15 -0
- package/dist/ir/native-constructor-reads.js +156 -0
- package/dist/ir/native-constructor-static.d.ts +18 -0
- package/dist/ir/native-constructor-static.js +61 -0
- package/dist/ir/native-data-definition.d.ts +43 -0
- package/dist/ir/native-data-definition.js +222 -0
- package/dist/ir/native-document-array-entries.d.ts +15 -0
- package/dist/ir/native-document-array-entries.js +37 -0
- package/dist/ir/native-document-entries.d.ts +21 -0
- package/dist/ir/native-document-entries.js +74 -0
- package/dist/ir/native-entry-field-views.d.ts +18 -0
- package/dist/ir/native-entry-field-views.js +62 -0
- package/dist/ir/native-field-view-domains.d.ts +50 -0
- package/dist/ir/native-field-view-domains.js +325 -0
- package/dist/ir/native-field-view-facts.d.ts +97 -0
- package/dist/ir/native-field-view-facts.js +354 -0
- package/dist/ir/native-fixed-layout.js +1 -1
- package/dist/ir/native-host-construction.d.ts +4 -6
- package/dist/ir/native-host-construction.js +4 -6
- package/dist/ir/native-host-method-reads.d.ts +13 -0
- package/dist/ir/native-host-method-reads.js +53 -0
- package/dist/ir/native-iterator-field-views.d.ts +15 -0
- package/dist/ir/native-iterator-field-views.js +39 -0
- package/dist/ir/native-iterator-receivers.d.ts +8 -0
- package/dist/ir/native-iterator-receivers.js +59 -0
- package/dist/ir/native-key-query.js +5 -2
- package/dist/ir/native-logical-receiver-body.d.ts +8 -0
- package/dist/ir/native-logical-receiver-body.js +23 -0
- package/dist/ir/native-method-frames.d.ts +18 -0
- package/dist/ir/native-method-frames.js +127 -0
- package/dist/ir/native-method-read-source.d.ts +16 -0
- package/dist/ir/native-method-read-source.js +61 -0
- package/dist/ir/native-object-data-slots.d.ts +60 -0
- package/dist/ir/native-object-data-slots.js +493 -0
- package/dist/ir/native-object-sample.d.ts +32 -0
- package/dist/ir/native-object-sample.js +113 -0
- package/dist/ir/native-own-assignment.d.ts +123 -0
- package/dist/ir/native-own-assignment.js +529 -0
- package/dist/ir/native-property-coercibility.d.ts +3 -0
- package/dist/ir/native-property-coercibility.js +10 -0
- package/dist/ir/native-property-key-texts.d.ts +11 -0
- package/dist/ir/native-property-key-texts.js +41 -0
- package/dist/ir/native-property-presence-effects.d.ts +11 -0
- package/dist/ir/native-property-presence-effects.js +19 -0
- package/dist/ir/native-property-presence.d.ts +27 -0
- package/dist/ir/native-property-presence.js +275 -0
- package/dist/ir/native-prototype-calls.d.ts +19 -0
- package/dist/ir/native-prototype-calls.js +53 -0
- package/dist/ir/native-prototype-conversions.d.ts +5 -0
- package/dist/ir/native-prototype-conversions.js +46 -0
- package/dist/ir/native-prototype-presence-demand.d.ts +9 -0
- package/dist/ir/native-prototype-presence-demand.js +58 -0
- package/dist/ir/native-record-index.d.ts +1 -1
- package/dist/ir/native-union-method-targets.d.ts +8 -0
- package/dist/ir/native-union-method-targets.js +69 -0
- package/dist/ir/no-normal-call-completion.d.ts +15 -0
- package/dist/ir/no-normal-call-completion.js +184 -0
- package/dist/ir/non-normal-receiver.d.ts +39 -0
- package/dist/ir/non-normal-receiver.js +253 -0
- package/dist/ir/operation-conversions.d.ts +29 -0
- package/dist/ir/operation-conversions.js +490 -0
- package/dist/ir/operation-index.d.ts +1 -1
- package/dist/ir/presence-proof.d.ts +1 -1
- package/dist/ir/presence-proof.js +1 -0
- package/dist/ir/program-conversions.d.ts +48 -0
- package/dist/ir/program-conversions.js +229 -0
- package/dist/ir/program-facts.d.ts +4 -1
- package/dist/ir/program-facts.js +9 -7
- package/dist/ir/promise-reaction-conversions.d.ts +6 -0
- package/dist/ir/promise-reaction-conversions.js +92 -0
- package/dist/ir/property-read-conversions.d.ts +10 -0
- package/dist/ir/property-read-conversions.js +124 -0
- package/dist/ir/proven-branches.d.ts +2 -1
- package/dist/ir/proven-branches.js +97 -10
- package/dist/ir/publish-conversion-recipes.d.ts +27 -0
- package/dist/ir/publish-conversion-recipes.js +246 -0
- package/dist/ir/publish-native-field-view-facts.d.ts +17 -0
- package/dist/ir/publish-native-field-view-facts.js +119 -0
- package/dist/ir/queries.js +42 -4
- package/dist/ir/read-only-dictionary.d.ts +38 -0
- package/dist/ir/read-only-dictionary.js +281 -0
- package/dist/ir/reflection-demand.d.ts +2 -0
- package/dist/ir/reflection-demand.js +840 -71
- package/dist/ir/shake.d.ts +3 -0
- package/dist/ir/shake.js +39 -15
- package/dist/ir/shared-empty-records.js +1 -1
- package/dist/ir/short-circuit-threading.d.ts +23 -0
- package/dist/ir/short-circuit-threading.js +133 -0
- package/dist/ir/spread-conversions.d.ts +27 -0
- package/dist/ir/spread-conversions.js +134 -0
- package/dist/ir/spread-copy-elision.d.ts +2 -2
- package/dist/ir/spread-copy-elision.js +7 -4
- package/dist/ir/string-layout-reuse.d.ts +9 -8
- package/dist/ir/string-layout-reuse.js +8 -16
- package/dist/ir/string-length-reuse.d.ts +20 -4
- package/dist/ir/string-length-reuse.js +57 -13
- package/dist/ir/transfer.d.ts +5 -5
- package/dist/ir/transfer.js +53 -31
- package/dist/ir/typed-property-access.d.ts +2 -0
- package/dist/ir/typed-property-access.js +21 -8
- package/dist/ir/virtual-call-frames.d.ts +7 -0
- package/dist/ir/virtual-call-frames.js +8 -0
- package/dist/native-signatures.d.ts +45 -0
- package/dist/native-signatures.js +368 -0
- package/dist/plugins/gea/host.d.ts +6 -1
- package/dist/plugins/gea/host.js +30 -1
- package/dist/plugins/gea/lower.js +9 -3
- package/dist/plugins/gea/members.js +1 -1
- package/dist/plugins/gea/plugin.js +2 -1
- package/dist/plugins/gea/prelude.d.ts +1 -1
- package/dist/plugins/gea/prelude.js +1 -1
- package/dist/plugins/gea/reactive-slots.js +6 -6
- package/dist/plugins/gea/render-bridge.js +5 -6
- package/dist/plugins/gea/user-agent-styles.js +1 -1
- package/dist/plugins/installed.d.ts +2 -2
- package/dist/plugins/installed.js +2 -2
- package/dist/plugins/load.js +1 -1
- package/dist/plugins/model.d.ts +21 -36
- package/dist/plugins/webgl/host.d.ts +23 -23
- package/dist/plugins/webgl/host.js +25 -26
- package/dist/plugins/webgl/plugin.d.ts +16 -19
- package/dist/plugins/webgl/plugin.js +16 -23
- package/dist/project-preparation.js +12 -14
- package/dist/projection/abi.js +13 -10
- package/dist/projection/bindings.d.ts +8 -0
- package/dist/projection/bindings.js +36 -5
- package/dist/projection/callee.d.ts +17 -15
- package/dist/projection/callee.js +108 -81
- package/dist/projection/class-property-presence.d.ts +1 -1
- package/dist/projection/class-property-presence.js +1 -1
- package/dist/projection/classes.d.ts +2 -0
- package/dist/projection/classes.js +4 -1
- package/dist/projection/dispatch.d.ts +19 -3
- package/dist/projection/dispatch.js +39 -16
- package/dist/projection/fields.d.ts +14 -2
- package/dist/projection/fields.js +100 -38
- package/dist/projection/function-source.d.ts +5 -0
- package/dist/projection/function-source.js +15 -0
- package/dist/projection/immediate-callees.d.ts +12 -0
- package/dist/projection/immediate-callees.js +36 -0
- package/dist/projection/index-protocols.d.ts +12 -0
- package/dist/projection/index-protocols.js +39 -0
- package/dist/projection/instance-test.d.ts +8 -0
- package/dist/projection/instance-test.js +3 -1
- package/dist/projection/method-values.d.ts +7 -0
- package/dist/projection/method-values.js +29 -0
- package/dist/projection/native-accessor-access.d.ts +26 -0
- package/dist/projection/native-accessor-access.js +18 -0
- package/dist/projection/native-callable-data.d.ts +24 -0
- package/dist/projection/native-callable-data.js +101 -0
- package/dist/projection/native-expando.d.ts +3 -0
- package/dist/projection/native-expando.js +13 -0
- package/dist/projection/native-object-data.d.ts +47 -0
- package/dist/projection/native-object-data.js +203 -0
- package/dist/projection/native-prototype-methods.d.ts +22 -0
- package/dist/projection/native-prototype-methods.js +161 -0
- package/dist/projection/regexp-fields.d.ts +35 -0
- package/dist/projection/regexp-fields.js +80 -0
- package/dist/projection/slots.d.ts +5 -1
- package/dist/projection/slots.js +89 -10
- package/dist/representation/derive.d.ts +5 -7
- package/dist/representation/derive.js +78 -78
- package/dist/representation/difference.js +1 -1
- package/dist/representation/host-abi.d.ts +2 -2
- package/dist/representation/host-abi.js +4 -5
- package/dist/representation/host-templates.d.ts +7 -3
- package/dist/representation/host-templates.js +13 -5
- package/dist/representation/intersection.d.ts +3 -3
- package/dist/representation/intersection.js +3 -3
- package/dist/representation/merge.js +1 -1
- package/dist/representation/model.d.ts +27 -22
- package/dist/representation/model.js +35 -22
- package/dist/representation/native-callable-data-storage.d.ts +85 -0
- package/dist/representation/native-callable-data-storage.js +398 -0
- package/dist/representation/native-data-properties.d.ts +14 -0
- package/dist/representation/native-data-properties.js +52 -0
- package/dist/representation/native-logical-receiver.d.ts +36 -0
- package/dist/representation/native-logical-receiver.js +92 -0
- package/dist/representation/object-shape.d.ts +1 -1
- package/dist/representation/object-shape.js +1 -1
- package/dist/representation/optional.js +2 -2
- package/dist/representation/physical-carrier.d.ts +25 -0
- package/dist/representation/physical-carrier.js +153 -0
- package/dist/representation/policies.d.ts +16 -10
- package/dist/representation/policies.js +5 -1
- package/dist/representation/primitives.js +3 -0
- package/dist/representation/promise-resolution.d.ts +19 -0
- package/dist/representation/promise-resolution.js +50 -0
- package/dist/representation/prototype-domains.d.ts +43 -0
- package/dist/representation/prototype-domains.js +226 -0
- package/dist/representation/proxy-carriers.d.ts +3 -3
- package/dist/representation/proxy-carriers.js +2 -3
- package/dist/representation/publish.d.ts +4 -0
- package/dist/representation/publish.js +73 -42
- package/dist/representation/record-fields.d.ts +2 -2
- package/dist/representation/record-fields.js +2 -2
- package/dist/representation/static-field-cells.d.ts +1 -1
- package/dist/representation/structural-method-abi.d.ts +6 -0
- package/dist/representation/structural-method-abi.js +13 -0
- package/dist/representation/unassigned-binding-cells.d.ts +3 -3
- package/dist/representation/union.js +19 -4
- package/dist/representation/unwritten-record-members.d.ts +6 -6
- package/dist/representation/unwritten-record-members.js +1 -1
- package/dist/representation/value-records.js +77 -5
- package/dist/representation/verify.js +1 -1
- package/dist/representation/well-known-symbols.d.ts +3 -0
- package/dist/representation/well-known-symbols.js +11 -0
- package/dist/semantics/alias-this-field-declaration-transform.js +3 -3
- package/dist/semantics/ambient-type-realization-transform.d.ts +19 -20
- package/dist/semantics/ambient-type-realization-transform.js +20 -12
- package/dist/semantics/ambient.d.ts +13 -13
- package/dist/semantics/ambient.js +12 -12
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +5 -0
- package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +110 -52
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.d.ts +4 -4
- package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +4 -4
- package/dist/semantics/call-invalidated-narrowing.js +2 -2
- package/dist/semantics/callable-origins.d.ts +49 -1
- package/dist/semantics/callable-origins.js +148 -32
- package/dist/semantics/callable-own-data-slots.d.ts +122 -0
- package/dist/semantics/callable-own-data-slots.js +421 -0
- package/dist/semantics/class-alias.d.ts +4 -4
- package/dist/semantics/class-alias.js +4 -4
- package/dist/semantics/class-heritage.d.ts +8 -7
- package/dist/semantics/class-heritage.js +8 -7
- package/dist/semantics/commonjs-wrapper.js +5 -2
- package/dist/semantics/constructor-function-class-source-transform.js +2 -3
- package/dist/semantics/constructor-slot-subclasses.d.ts +1 -1
- package/dist/semantics/constructor-slot-subclasses.js +5 -5
- package/dist/semantics/declaration-overlay-transform.d.ts +9 -12
- package/dist/semantics/declaration-overlay-transform.js +135 -142
- package/dist/semantics/declared-integers.d.ts +24 -0
- package/dist/semantics/declared-integers.js +34 -0
- package/dist/semantics/define-property-source-transform.js +21 -8
- package/dist/semantics/dynamic-fallback.d.ts +1 -1
- package/dist/semantics/dynamic-fallback.js +1 -1
- package/dist/semantics/frontend.d.ts +12 -16
- package/dist/semantics/frontend.js +187 -75
- package/dist/semantics/host-methods.d.ts +3 -3
- package/dist/semantics/host-methods.js +1 -1
- package/dist/semantics/host-protocols.d.ts +3 -3
- package/dist/semantics/host-protocols.js +26 -26
- package/dist/semantics/interface-families.d.ts +2 -2
- package/dist/semantics/interface-families.js +46 -47
- package/dist/semantics/interface-implementors.d.ts +12 -15
- package/dist/semantics/interface-implementors.js +12 -15
- package/dist/semantics/jsdoc-namepath-transform.js +7 -7
- package/dist/semantics/model/operands.d.ts +18 -3
- package/dist/semantics/model/operands.js +41 -0
- package/dist/semantics/model/operations.d.ts +82 -1
- package/dist/semantics/model/selected-signature.d.ts +24 -3
- package/dist/semantics/model/structural-type-table.js +24 -6
- package/dist/semantics/model/structural-types.d.ts +10 -8
- package/dist/semantics/model/structural-types.js +7 -5
- package/dist/semantics/module-resolution.js +3 -2
- package/dist/semantics/native-callable-readonly-set.d.ts +17 -0
- package/dist/semantics/native-callable-readonly-set.js +1 -0
- package/dist/semantics/native-function-signatures.d.ts +14 -0
- package/dist/semantics/native-function-signatures.js +96 -0
- package/dist/semantics/native-object-data-slots.d.ts +72 -0
- package/dist/semantics/native-object-data-slots.js +679 -0
- package/dist/semantics/native-own-assignment.d.ts +62 -0
- package/dist/semantics/native-own-assignment.js +1 -0
- package/dist/semantics/normalize/absent-globals.d.ts +8 -8
- package/dist/semantics/normalize/absent-globals.js +5 -5
- package/dist/semantics/normalize/any-cast-member-call.d.ts +36 -0
- package/dist/semantics/normalize/any-cast-member-call.js +55 -0
- package/dist/semantics/normalize/arguments-objects.d.ts +3 -1
- package/dist/semantics/normalize/arguments-objects.js +1 -1
- package/dist/semantics/normalize/asserted-argument-arms.d.ts +7 -7
- package/dist/semantics/normalize/asserted-arm-absence.d.ts +1 -2
- package/dist/semantics/normalize/asserted-arm-absence.js +1 -2
- package/dist/semantics/normalize/binding-fixpoint.js +3 -3
- package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +2 -2
- package/dist/semantics/normalize/bivariant-slot-parameter.js +6 -6
- package/dist/semantics/normalize/callable-data-write.d.ts +46 -0
- package/dist/semantics/normalize/callable-data-write.js +182 -0
- package/dist/semantics/normalize/census.js +5 -5
- 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 +11 -13
- package/dist/semantics/normalize/collection-bindings.js +60 -33
- package/dist/semantics/normalize/commonjs-module-record.d.ts +7 -4
- package/dist/semantics/normalize/commonjs-module-record.js +93 -4
- package/dist/semantics/normalize/contribution.js +4 -4
- package/dist/semantics/normalize/dead-method-copies.d.ts +5 -5
- package/dist/semantics/normalize/dead-typeof-guards.d.ts +2 -2
- package/dist/semantics/normalize/dead-typeof-guards.js +6 -6
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +22 -13
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +85 -13
- package/dist/semantics/normalize/derived-expression-type.d.ts +129 -91
- package/dist/semantics/normalize/derived-expression-type.js +459 -192
- package/dist/semantics/normalize/field-bindings.d.ts +4 -4
- package/dist/semantics/normalize/field-bindings.js +334 -67
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +2 -2
- package/dist/semantics/normalize/flow/array-element-continuation.js +35 -18
- package/dist/semantics/normalize/flow/callable-array-origins.d.ts +1 -1
- package/dist/semantics/normalize/flow/callable-array-origins.js +3 -3
- package/dist/semantics/normalize/flow/callable-completions.d.ts +2 -2
- package/dist/semantics/normalize/flow/callable-completions.js +2 -2
- package/dist/semantics/normalize/flow/callable-reach.d.ts +19 -6
- package/dist/semantics/normalize/flow/callable-reach.js +755 -289
- package/dist/semantics/normalize/flow/class-family-member-read.js +24 -29
- package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +2 -2
- package/dist/semantics/normalize/flow/collection-value-continuation.js +2 -2
- package/dist/semantics/normalize/flow/component-solver.d.ts +19 -16
- package/dist/semantics/normalize/flow/component-solver.js +138 -69
- package/dist/semantics/normalize/flow/computed-key-set.d.ts +6 -7
- package/dist/semantics/normalize/flow/computed-key-set.js +20 -1
- package/dist/semantics/normalize/flow/export-importers.js +4 -4
- package/dist/semantics/normalize/flow/host-text-sink.d.ts +3 -2
- package/dist/semantics/normalize/flow/host-text-sink.js +4 -3
- package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +3 -2
- package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +2 -2
- package/dist/semantics/normalize/flow/intrinsic-data-definition.js +3 -3
- package/dist/semantics/normalize/flow/invocation-facts.d.ts +3 -2
- package/dist/semantics/normalize/flow/invocation-facts.js +3 -3
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +12 -6
- package/dist/semantics/normalize/flow/member-call-forwarding.js +94 -21
- package/dist/semantics/normalize/flow/model.d.ts +5 -5
- package/dist/semantics/normalize/flow/model.js +11 -11
- package/dist/semantics/normalize/flow/node-path-token.js +3 -3
- package/dist/semantics/normalize/flow/origin-authority.d.ts +3 -3
- package/dist/semantics/normalize/flow/owned-class-receivers.js +8 -7
- package/dist/semantics/normalize/flow/parameter-values.js +6 -6
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +30 -4
- package/dist/semantics/normalize/flow/proof-hypotheses.js +56 -5
- package/dist/semantics/normalize/flow/proof-memo-settlement.d.ts +21 -0
- package/dist/semantics/normalize/flow/proof-memo-settlement.js +32 -0
- 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 +4 -4
- package/dist/semantics/normalize/flow/seeded-origins.js +4 -4
- package/dist/semantics/normalize/flow/source-accessor-descriptor.d.ts +22 -0
- package/dist/semantics/normalize/flow/source-accessor-descriptor.js +210 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.d.ts +33 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.js +238 -0
- package/dist/semantics/normalize/flow/source-callable-readonly-set.d.ts +26 -0
- package/dist/semantics/normalize/flow/source-callable-readonly-set.js +337 -0
- package/dist/semantics/normalize/flow/source-class-data.d.ts +7 -7
- package/dist/semantics/normalize/flow/source-class-data.js +25 -26
- package/dist/semantics/normalize/flow/source-class-static-data.d.ts +2 -2
- package/dist/semantics/normalize/flow/source-class-static-data.js +2 -2
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +15 -0
- package/dist/semantics/normalize/flow/source-commonjs-exports.js +7 -0
- package/dist/semantics/normalize/flow/source-descriptor-protocol.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-descriptor-protocol.js +75 -0
- package/dist/semantics/normalize/flow/source-executing-parameter-values.d.ts +8 -0
- package/dist/semantics/normalize/flow/source-executing-parameter-values.js +93 -0
- package/dist/semantics/normalize/flow/source-global-binding.d.ts +13 -0
- package/dist/semantics/normalize/flow/source-global-binding.js +42 -0
- package/dist/semantics/normalize/flow/source-intrinsic-member-data.d.ts +27 -0
- package/dist/semantics/normalize/flow/source-intrinsic-member-data.js +178 -0
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +1 -1
- package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +31 -11
- package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +7 -3
- package/dist/semantics/normalize/flow/source-invocation-receiver.js +30 -2
- package/dist/semantics/normalize/flow/source-native-class-alias.d.ts +7 -0
- package/dist/semantics/normalize/flow/source-native-class-alias.js +91 -0
- package/dist/semantics/normalize/flow/source-normal-predecessor.d.ts +10 -0
- package/dist/semantics/normalize/flow/source-normal-predecessor.js +90 -0
- package/dist/semantics/normalize/flow/source-property-key.d.ts +3 -0
- package/dist/semantics/normalize/flow/source-property-key.js +7 -0
- package/dist/semantics/normalize/flow/source-read-protocol.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-read-protocol.js +108 -0
- package/dist/semantics/normalize/flow/source-record-data.js +31 -30
- package/dist/semantics/normalize/flow/source-value-session.d.ts +106 -3
- package/dist/semantics/normalize/flow/source-value-session.js +1172 -218
- package/dist/semantics/normalize/flow/standard-prototype-method-source.d.ts +16 -0
- package/dist/semantics/normalize/flow/standard-prototype-method-source.js +64 -0
- package/dist/semantics/normalize/flow/targets.d.ts +13 -14
- package/dist/semantics/normalize/flow/targets.js +20 -23
- package/dist/semantics/normalize/flow/value-flow.d.ts +2 -4
- package/dist/semantics/normalize/flow/value-flow.js +4 -13
- package/dist/semantics/normalize/flow/value-provenance.d.ts +23 -3
- package/dist/semantics/normalize/flow/value-provenance.js +44 -4
- package/dist/semantics/normalize/fresh-dictionary-storage.d.ts +34 -0
- package/dist/semantics/normalize/fresh-dictionary-storage.js +637 -0
- package/dist/semantics/normalize/fresh-indexed-storage.d.ts +43 -0
- package/dist/semantics/normalize/fresh-indexed-storage.js +88 -0
- package/dist/semantics/normalize/fresh-ordinary-object.d.ts +8 -0
- package/dist/semantics/normalize/fresh-ordinary-object.js +27 -0
- package/dist/semantics/normalize/gating.js +2 -2
- package/dist/semantics/normalize/global-host-mutations.js +770 -261
- 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 +2 -2
- package/dist/semantics/normalize/host-mutation-computed-keys.js +8 -0
- package/dist/semantics/normalize/host-mutation-key-reader.d.ts +6 -11
- package/dist/semantics/normalize/host-mutation-key-reader.js +11 -28
- package/dist/semantics/normalize/host-mutation-keys.d.ts +11 -7
- package/dist/semantics/normalize/host-mutation-keys.js +26 -15
- package/dist/semantics/normalize/identities.js +20 -17
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +8 -3
- package/dist/semantics/normalize/implicit-arguments-tuple.js +21 -4
- package/dist/semantics/normalize/installed-global-properties.d.ts +17 -0
- package/dist/semantics/normalize/installed-global-properties.js +214 -0
- package/dist/semantics/normalize/instantiation.js +6 -6
- package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +1 -1
- package/dist/semantics/normalize/intrinsic-property-call.d.ts +6 -1
- package/dist/semantics/normalize/intrinsic-property-call.js +19 -0
- package/dist/semantics/normalize/intrinsic-prototype.d.ts +7 -0
- package/dist/semantics/normalize/intrinsic-prototype.js +10 -0
- package/dist/semantics/normalize/intrinsic-return-identity.d.ts +5 -0
- package/dist/semantics/normalize/intrinsic-return-identity.js +29 -0
- package/dist/semantics/normalize/jsdoc-type-names.js +59 -63
- package/dist/semantics/normalize/keyof.js +3 -3
- package/dist/semantics/normalize/local-bindings.d.ts +4 -4
- package/dist/semantics/normalize/local-bindings.js +68 -62
- package/dist/semantics/normalize/logical-object-truthiness.d.ts +8 -0
- package/dist/semantics/normalize/logical-object-truthiness.js +20 -0
- package/dist/semantics/normalize/merged-declaration.d.ts +3 -3
- package/dist/semantics/normalize/merged-declaration.js +3 -3
- package/dist/semantics/normalize/never-override-result.d.ts +2 -3
- package/dist/semantics/normalize/never-override-result.js +2 -3
- package/dist/semantics/normalize/null-blind-parameter.d.ts +2 -2
- package/dist/semantics/normalize/null-blind-parameter.js +2 -2
- package/dist/semantics/normalize/object-bag-bindings.d.ts +19 -19
- package/dist/semantics/normalize/object-bag-bindings.js +334 -141
- package/dist/semantics/normalize/omitted-stated-parameter.d.ts +8 -8
- package/dist/semantics/normalize/omitted-stated-parameter.js +8 -9
- package/dist/semantics/normalize/override-field-arms.d.ts +3 -3
- package/dist/semantics/normalize/override-field-arms.js +15 -16
- package/dist/semantics/normalize/parameter-bindings.d.ts +13 -12
- package/dist/semantics/normalize/parameter-bindings.js +173 -139
- package/dist/semantics/normalize/parameter-slot.d.ts +9 -10
- package/dist/semantics/normalize/parameter-slot.js +16 -17
- package/dist/semantics/normalize/physical-overload-result.d.ts +8 -8
- package/dist/semantics/normalize/physical-overload-result.js +10 -10
- package/dist/semantics/normalize/producer-context.d.ts +27 -12
- package/dist/semantics/normalize/producers/allocations.js +5 -1
- package/dist/semantics/normalize/producers/bindings.js +8 -7
- package/dist/semantics/normalize/producers/boundary.js +3 -22
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +19 -0
- package/dist/semantics/normalize/producers/cited-value-type.js +38 -0
- package/dist/semantics/normalize/producers/class-lifecycle.js +52 -7
- package/dist/semantics/normalize/producers/computations.js +59 -14
- package/dist/semantics/normalize/producers/control.js +5 -5
- package/dist/semantics/normalize/producers/declaration-lifecycle.js +4 -4
- package/dist/semantics/normalize/producers/destructuring.js +10 -5
- package/dist/semantics/normalize/producers/erasure.d.ts +9 -0
- package/dist/semantics/normalize/producers/erasure.js +22 -0
- package/dist/semantics/normalize/producers/invocations.d.ts +1 -1
- package/dist/semantics/normalize/producers/invocations.js +210 -55
- package/dist/semantics/normalize/producers/logical-merge-type.d.ts +2 -2
- package/dist/semantics/normalize/producers/logical-merge-type.js +12 -12
- package/dist/semantics/normalize/producers/native-callable-readonly-set.d.ts +6 -0
- package/dist/semantics/normalize/producers/native-callable-readonly-set.js +24 -0
- package/dist/semantics/normalize/producers/native-own-assignment.d.ts +14 -0
- package/dist/semantics/normalize/producers/native-own-assignment.js +153 -0
- package/dist/semantics/normalize/producers/properties.js +153 -20
- package/dist/semantics/normalize/producers/protocol.js +4 -4
- package/dist/semantics/normalize/producers/references.js +21 -19
- package/dist/semantics/normalize/producers/shared.d.ts +1 -1
- package/dist/semantics/normalize/producers/shared.js +59 -58
- package/dist/semantics/normalize/producers/spread-arguments.js +7 -3
- package/dist/semantics/normalize/producers/tuple-spread.d.ts +2 -2
- package/dist/semantics/normalize/producers/tuple-spread.js +5 -5
- package/dist/semantics/normalize/property-key-domain.d.ts +6 -6
- package/dist/semantics/normalize/property-key-domain.js +7 -7
- package/dist/semantics/normalize/reachability.d.ts +6 -7
- package/dist/semantics/normalize/reachability.js +60 -62
- package/dist/semantics/normalize/record-home-arms.js +2 -3
- 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 +4 -5
- package/dist/semantics/normalize/return-bindings.d.ts +19 -9
- package/dist/semantics/normalize/return-bindings.js +96 -42
- 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 +4 -5
- package/dist/semantics/normalize/shared-array-storage.js +7 -8
- package/dist/semantics/normalize/sloppy-absence.d.ts +6 -3
- package/dist/semantics/normalize/sloppy-absence.js +7 -3
- package/dist/semantics/normalize/source-object-prototype-absence.d.ts +7 -0
- package/dist/semantics/normalize/source-object-prototype-absence.js +19 -0
- package/dist/semantics/normalize/specialization.d.ts +10 -10
- package/dist/semantics/normalize/specialization.js +107 -112
- package/dist/semantics/normalize/specialized-source-frames.d.ts +11 -0
- package/dist/semantics/normalize/specialized-source-frames.js +41 -0
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +34 -0
- package/dist/semantics/normalize/structural-any-binding-consumer.js +208 -0
- package/dist/semantics/normalize/structural-array-element.d.ts +5 -5
- package/dist/semantics/normalize/structural-array-element.js +40 -39
- package/dist/semantics/normalize/structural-array-read.js +3 -3
- package/dist/semantics/normalize/structural-callable.d.ts +15 -1
- package/dist/semantics/normalize/structural-callable.js +35 -3
- package/dist/semantics/normalize/structural-creation-order.d.ts +2 -2
- package/dist/semantics/normalize/structural-declarations.d.ts +22 -21
- package/dist/semantics/normalize/structural-declarations.js +52 -43
- package/dist/semantics/normalize/structural-declared-body.js +10 -11
- package/dist/semantics/normalize/structural-indexed-access.js +2 -2
- package/dist/semantics/normalize/structural-instantiated-member.d.ts +9 -10
- package/dist/semantics/normalize/structural-instantiated-member.js +43 -30
- package/dist/semantics/normalize/structural-joins.d.ts +4 -16
- package/dist/semantics/normalize/structural-joins.js +5 -65
- package/dist/semantics/normalize/structural-layout-relevance.d.ts +5 -5
- package/dist/semantics/normalize/structural-layout-relevance.js +22 -23
- package/dist/semantics/normalize/structural-layout-type.d.ts +1 -1
- package/dist/semantics/normalize/structural-layout-type.js +140 -107
- package/dist/semantics/normalize/structural-local-union.d.ts +1 -1
- package/dist/semantics/normalize/structural-local-union.js +38 -12
- package/dist/semantics/normalize/structural-mutable-field.d.ts +9 -0
- package/dist/semantics/normalize/structural-mutable-field.js +152 -0
- package/dist/semantics/normalize/structural-parts.d.ts +6 -0
- package/dist/semantics/normalize/structural-parts.js +35 -32
- package/dist/semantics/normalize/structural-receiver.d.ts +3 -3
- package/dist/semantics/normalize/structural-receiver.js +12 -13
- package/dist/semantics/normalize/structural-self-reference.d.ts +12 -11
- package/dist/semantics/normalize/structural-self-reference.js +24 -25
- package/dist/semantics/normalize/structural.d.ts +15 -3
- package/dist/semantics/normalize/structural.js +440 -201
- package/dist/semantics/normalize/suppressed-write-arms.d.ts +10 -11
- package/dist/semantics/normalize/symbol-keyed-this-slots.d.ts +6 -6
- package/dist/semantics/normalize/symbol-keyed-this-slots.js +4 -4
- package/dist/semantics/normalize/unresolvable-names.d.ts +2 -3
- package/dist/semantics/normalize/unresolvable-names.js +2 -2
- package/dist/semantics/normalize/unshared-array-result.d.ts +4 -4
- package/dist/semantics/normalize/unshared-array-result.js +4 -4
- package/dist/semantics/package-sources.js +2 -3
- package/dist/semantics/program.d.ts +10 -13
- package/dist/semantics/program.js +80 -26
- package/dist/semantics/property-key.d.ts +9 -0
- package/dist/semantics/property-key.js +25 -0
- package/dist/semantics/prototype-object-class-source-transform.js +2 -2
- 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 +6 -1
- package/dist/semantics/shared-declaration-files.js +2 -2
- package/dist/semantics/source-transform-protocol.d.ts +26 -0
- package/dist/semantics/source-transform-protocol.js +1 -0
- package/dist/semantics/stable-checker.js +9 -13
- package/dist/semantics/subclass-member-overlay-transform.d.ts +2 -2
- package/dist/semantics/subclass-member-overlay-transform.js +89 -88
- package/dist/semantics/this-constructor-source-transform.js +2 -2
- package/dist/semantics/unchecked-guard-argument-copies.d.ts +3 -3
- package/dist/semantics/unchecked-write-member-declarations.d.ts +9 -11
- package/dist/semantics/unchecked-write-member-declarations.js +11 -13
- package/dist/semantics/uninstantiable-classes.d.ts +1 -1
- package/dist/semantics/uninstantiable-classes.js +1 -1
- package/dist/targets/cpp/balanced-units.d.ts +1 -1
- package/dist/targets/cpp/balanced-units.js +1 -1
- package/dist/targets/cpp/borrowed-arm-projections.d.ts +2 -3
- package/dist/targets/cpp/borrowed-arm-projections.js +2 -3
- package/dist/targets/cpp/borrowed-call-entry.js +3 -3
- package/dist/targets/cpp/captures.d.ts +2 -2
- package/dist/targets/cpp/captures.js +4 -4
- package/dist/targets/cpp/char-code-buffers.d.ts +1 -1
- package/dist/targets/cpp/char-code-buffers.js +4 -1
- package/dist/targets/cpp/class-layout.d.ts +7 -17
- package/dist/targets/cpp/class-layout.js +6 -13
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +1 -1
- package/dist/targets/cpp/class-properties/computed-method-value.js +5 -27
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +49 -59
- package/dist/targets/cpp/class-properties/emit-class-properties.js +68 -232
- package/dist/targets/cpp/class-properties/native-method-read.d.ts +5 -0
- package/dist/targets/cpp/class-properties/native-method-read.js +60 -0
- package/dist/targets/cpp/class-properties/native-prototype.d.ts +3 -1
- package/dist/targets/cpp/class-properties/native-prototype.js +5 -6
- package/dist/targets/cpp/class-ref-transport.d.ts +1 -11
- package/dist/targets/cpp/class-ref-transport.js +1 -9
- package/dist/targets/cpp/conversions.js +633 -252
- package/dist/targets/cpp/coroutine-bodies.d.ts +1 -97
- package/dist/targets/cpp/coroutine-bodies.js +1 -187
- package/dist/targets/cpp/document.js +1 -1
- package/dist/targets/cpp/emit-allocation.d.ts +0 -38
- package/dist/targets/cpp/emit-allocation.js +63 -88
- package/dist/targets/cpp/emit-array-view.d.ts +7 -0
- package/dist/targets/cpp/emit-array-view.js +47 -0
- package/dist/targets/cpp/emit-arrays.d.ts +9 -52
- package/dist/targets/cpp/emit-arrays.js +177 -113
- package/dist/targets/cpp/emit-binding-reference.d.ts +10 -0
- package/dist/targets/cpp/emit-binding-reference.js +19 -1
- package/dist/targets/cpp/emit-bindings.js +19 -24
- package/dist/targets/cpp/emit-buffers.d.ts +8 -4
- package/dist/targets/cpp/emit-buffers.js +88 -47
- package/dist/targets/cpp/emit-callable-view.d.ts +6 -0
- package/dist/targets/cpp/emit-callable-view.js +133 -0
- package/dist/targets/cpp/emit-callable.d.ts +11 -1
- package/dist/targets/cpp/emit-callable.js +225 -266
- package/dist/targets/cpp/emit-carrier-members.d.ts +2 -2
- package/dist/targets/cpp/emit-carrier-members.js +42 -35
- package/dist/targets/cpp/emit-certified-conversion.d.ts +7 -0
- package/dist/targets/cpp/emit-certified-conversion.js +27 -0
- package/dist/targets/cpp/emit-context.d.ts +123 -64
- package/dist/targets/cpp/emit-context.js +147 -44
- package/dist/targets/cpp/emit-descriptor-snapshot.d.ts +10 -0
- package/dist/targets/cpp/emit-descriptor-snapshot.js +60 -0
- package/dist/targets/cpp/emit-dictionary-view.d.ts +6 -0
- package/dist/targets/cpp/emit-dictionary-view.js +102 -0
- package/dist/targets/cpp/emit-document-record-view.d.ts +3 -0
- package/dist/targets/cpp/emit-document-record-view.js +104 -0
- package/dist/targets/cpp/emit-dynamic-properties.d.ts +42 -17
- package/dist/targets/cpp/emit-dynamic-properties.js +118 -72
- package/dist/targets/cpp/emit-equality.d.ts +2 -1
- package/dist/targets/cpp/emit-equality.js +65 -45
- package/dist/targets/cpp/emit-exceptions.js +1 -1
- package/dist/targets/cpp/emit-in.js +22 -11
- package/dist/targets/cpp/emit-instanceof.js +15 -14
- package/dist/targets/cpp/emit-integers.d.ts +40 -3
- package/dist/targets/cpp/emit-integers.js +76 -5
- package/dist/targets/cpp/emit-iterable-object-view.d.ts +2 -0
- package/dist/targets/cpp/emit-iterable-object-view.js +15 -11
- package/dist/targets/cpp/emit-iterator-object-view.d.ts +2 -0
- package/dist/targets/cpp/emit-iterator-object-view.js +24 -16
- package/dist/targets/cpp/emit-iterator.d.ts +2 -0
- package/dist/targets/cpp/emit-iterator.js +115 -43
- package/dist/targets/cpp/emit-json.js +6 -6
- package/dist/targets/cpp/emit-jsx.js +2 -2
- package/dist/targets/cpp/emit-live-field-view.d.ts +26 -0
- package/dist/targets/cpp/emit-live-field-view.js +50 -0
- package/dist/targets/cpp/emit-narrowing.d.ts +60 -139
- package/dist/targets/cpp/emit-narrowing.js +715 -624
- package/dist/targets/cpp/emit-native-accessor-definition.d.ts +10 -0
- package/dist/targets/cpp/emit-native-accessor-definition.js +94 -0
- package/dist/targets/cpp/emit-native-callable-data.d.ts +23 -0
- package/dist/targets/cpp/emit-native-callable-data.js +117 -0
- package/dist/targets/cpp/emit-native-document-entry.d.ts +4 -0
- package/dist/targets/cpp/emit-native-document-entry.js +52 -0
- package/dist/targets/cpp/emit-native-field-view.d.ts +26 -0
- package/dist/targets/cpp/emit-native-field-view.js +235 -0
- package/dist/targets/cpp/emit-native-method.d.ts +16 -0
- package/dist/targets/cpp/emit-native-method.js +90 -0
- package/dist/targets/cpp/emit-native-object-data.d.ts +7 -0
- package/dist/targets/cpp/emit-native-object-data.js +66 -0
- package/dist/targets/cpp/emit-native-object-sample.d.ts +8 -0
- package/dist/targets/cpp/emit-native-object-sample.js +34 -0
- package/dist/targets/cpp/emit-native-own-assignment.d.ts +7 -0
- package/dist/targets/cpp/emit-native-own-assignment.js +119 -0
- package/dist/targets/cpp/emit-native-selection.d.ts +2 -2
- package/dist/targets/cpp/emit-native-selection.js +14 -5
- package/dist/targets/cpp/emit-number-storage.d.ts +2 -0
- package/dist/targets/cpp/emit-number-storage.js +1 -0
- package/dist/targets/cpp/emit-presence.d.ts +3 -4
- package/dist/targets/cpp/emit-presence.js +43 -21
- package/dist/targets/cpp/emit-properties.js +224 -111
- package/dist/targets/cpp/emit-protocol-iterator.d.ts +2 -0
- package/dist/targets/cpp/emit-protocol-iterator.js +45 -23
- package/dist/targets/cpp/emit-record-view.d.ts +5 -10
- package/dist/targets/cpp/emit-record-view.js +223 -269
- package/dist/targets/cpp/emit-return.js +33 -8
- package/dist/targets/cpp/emit-scopes.d.ts +2 -2
- package/dist/targets/cpp/emit-sum-widening.js +13 -5
- package/dist/targets/cpp/emit-tonumber.d.ts +1 -1
- package/dist/targets/cpp/emit-tonumber.js +3 -3
- package/dist/targets/cpp/emit-tostring.d.ts +20 -2
- package/dist/targets/cpp/emit-tostring.js +131 -28
- package/dist/targets/cpp/emit-typeof.d.ts +4 -0
- package/dist/targets/cpp/emit-typeof.js +29 -1
- package/dist/targets/cpp/emit-union-properties.d.ts +6 -23
- package/dist/targets/cpp/emit-union-properties.js +136 -237
- package/dist/targets/cpp/emit.d.ts +4 -1
- package/dist/targets/cpp/emit.js +336 -119
- package/dist/targets/cpp/error-types.d.ts +1 -3
- package/dist/targets/cpp/error-types.js +1 -2
- package/dist/targets/cpp/evaluated-once.d.ts +4 -4
- package/dist/targets/cpp/evaluated-once.js +5 -5
- package/dist/targets/cpp/function-source-reads.d.ts +2 -15
- package/dist/targets/cpp/function-source-reads.js +3 -38
- package/dist/targets/cpp/host/core-globals.d.ts +5 -0
- package/dist/targets/cpp/host/core-globals.js +10 -0
- package/dist/targets/cpp/host/emit-host-arity.js +1 -1
- package/dist/targets/cpp/host/emit-host-invoke.js +73 -23
- package/dist/targets/cpp/host/emit-host-object.d.ts +2 -1
- package/dist/targets/cpp/host/emit-host-object.js +329 -146
- package/dist/targets/cpp/host/emit-host-properties.js +4 -6
- package/dist/targets/cpp/host/emit-host-reflect.js +29 -5
- package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
- package/dist/targets/cpp/host/emit-host-value.js +2 -2
- package/dist/targets/cpp/host/host-members.d.ts +11 -0
- package/dist/targets/cpp/host/host-members.js +27 -5
- package/dist/targets/cpp/host/host-method-aliases.d.ts +1 -30
- package/dist/targets/cpp/host/host-method-aliases.js +1 -76
- package/dist/targets/cpp/host/native-protocols.js +1 -1
- package/dist/targets/cpp/host/object-protocol.d.ts +1 -1
- package/dist/targets/cpp/host/object-protocol.js +24 -24
- package/dist/targets/cpp/host-namespace-reads.d.ts +1 -83
- package/dist/targets/cpp/host-namespace-reads.js +1 -113
- package/dist/targets/cpp/manifest/capabilities.js +33 -33
- package/dist/targets/cpp/manifest.d.ts +5 -0
- package/dist/targets/cpp/manifest.js +38 -14
- package/dist/targets/cpp/native-collection-base.js +7 -6
- package/dist/targets/cpp/native-debug-source.d.ts +15 -0
- package/dist/targets/cpp/native-debug-source.js +21 -0
- package/dist/targets/cpp/native-error-base.d.ts +1 -1
- package/dist/targets/cpp/native-error-base.js +1 -1
- package/dist/targets/cpp/native-narrowing-transport.d.ts +2 -0
- package/dist/targets/cpp/native-narrowing-transport.js +25 -5
- package/dist/targets/cpp/native-view-targets.d.ts +3 -0
- package/dist/targets/cpp/native-view-targets.js +5 -0
- package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +3 -33
- package/dist/targets/cpp/prototype/emit-prototype-array.js +40 -22
- package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +1 -58
- package/dist/targets/cpp/prototype/emit-prototype-date.js +14 -97
- package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +20 -0
- package/dist/targets/cpp/prototype/emit-prototype-error.js +2 -2
- package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +3 -27
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +60 -52
- package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +1 -41
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +4 -43
- package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +2 -13
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +10 -58
- package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +4 -25
- package/dist/targets/cpp/prototype/emit-prototype-regexp.js +16 -81
- package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +1 -1
- package/dist/targets/cpp/prototype/emit-prototype-string.js +17 -28
- package/dist/targets/cpp/prototype/prototype-method-reads.js +4 -80
- package/dist/targets/cpp/reactive-dependencies.d.ts +12 -6
- package/dist/targets/cpp/reactive-dependencies.js +62 -42
- package/dist/targets/cpp/reactive-origins.js +12 -0
- package/dist/targets/cpp/records.d.ts +133 -14
- package/dist/targets/cpp/records.js +345 -153
- package/dist/targets/cpp/regexp-types.d.ts +1 -26
- package/dist/targets/cpp/regexp-types.js +4 -29
- package/dist/targets/cpp/segment-scopes.d.ts +30 -0
- package/dist/targets/cpp/segment-scopes.js +294 -0
- package/dist/targets/cpp/translation-unit.d.ts +21 -2
- package/dist/targets/cpp/translation-unit.js +121 -276
- package/dist/targets/cpp/types.d.ts +8 -3
- package/dist/targets/cpp/types.js +30 -6
- package/dist/targets/cpp/virtual-callees.d.ts +18 -0
- package/dist/targets/cpp/virtual-callees.js +27 -0
- package/dist/targets/cpp/virtual-methods.d.ts +7 -7
- package/dist/targets/cpp/virtual-methods.js +213 -58
- package/package.json +8 -3
- package/src/targets/cpp/runtime/gea_dictionary_view.h +204 -0
- package/src/targets/cpp/runtime/gea_document_view.h +845 -0
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +66 -23
- package/src/targets/cpp/runtime/gea_eval.h +6 -6
- package/src/targets/cpp/runtime/gea_runtime.h +7587 -1166
- package/dist/targets/cpp/direct-call-receivers.d.ts +0 -37
- package/dist/targets/cpp/direct-call-receivers.js +0 -79
|
@@ -0,0 +1,1331 @@
|
|
|
1
|
+
import { operationOfResult } from '../../identity/ids.js';
|
|
2
|
+
import { classFamilyOverridesOf } from '../../projection/dispatch.js';
|
|
3
|
+
import { classMemberOf } from '../../projection/fields.js';
|
|
4
|
+
import { allOperationsOf } from '../model.js';
|
|
5
|
+
const top = 'TOP';
|
|
6
|
+
const shared = 'SHARED';
|
|
7
|
+
const allFields = '#';
|
|
8
|
+
const unknownField = '*';
|
|
9
|
+
/** Monotone set-constraint solver: nodes hold sets of abstract objects; edges and watchers propagate. */
|
|
10
|
+
class PointsTo {
|
|
11
|
+
sets = new Map();
|
|
12
|
+
edges = new Map();
|
|
13
|
+
watchers = new Map();
|
|
14
|
+
queue = [];
|
|
15
|
+
of(node) {
|
|
16
|
+
return this.sets.get(node) ?? new Set();
|
|
17
|
+
}
|
|
18
|
+
add(node, object) {
|
|
19
|
+
let set = this.sets.get(node);
|
|
20
|
+
if (!set)
|
|
21
|
+
this.sets.set(node, (set = new Set()));
|
|
22
|
+
if (set.has(object))
|
|
23
|
+
return;
|
|
24
|
+
set.add(object);
|
|
25
|
+
this.queue.push([node, object]);
|
|
26
|
+
}
|
|
27
|
+
copy(from, to) {
|
|
28
|
+
if (from === to)
|
|
29
|
+
return;
|
|
30
|
+
let targets = this.edges.get(from);
|
|
31
|
+
if (!targets)
|
|
32
|
+
this.edges.set(from, (targets = new Set()));
|
|
33
|
+
if (targets.has(to))
|
|
34
|
+
return;
|
|
35
|
+
targets.add(to);
|
|
36
|
+
for (const object of this.of(from))
|
|
37
|
+
this.add(to, object);
|
|
38
|
+
}
|
|
39
|
+
on(node, watcher) {
|
|
40
|
+
let list = this.watchers.get(node);
|
|
41
|
+
if (!list)
|
|
42
|
+
this.watchers.set(node, (list = []));
|
|
43
|
+
list.push(watcher);
|
|
44
|
+
for (const object of [...this.of(node)])
|
|
45
|
+
watcher(object);
|
|
46
|
+
}
|
|
47
|
+
/** Whether constraints were added since the last `solve`. */
|
|
48
|
+
get busy() {
|
|
49
|
+
return this.queue.length > 0;
|
|
50
|
+
}
|
|
51
|
+
solve() {
|
|
52
|
+
for (let next = this.queue.pop(); next; next = this.queue.pop()) {
|
|
53
|
+
const [node, object] = next;
|
|
54
|
+
for (const target of this.edges.get(node) ?? [])
|
|
55
|
+
this.add(target, object);
|
|
56
|
+
for (const watcher of this.watchers.get(node) ?? [])
|
|
57
|
+
watcher(object);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const valueNode = (value) => `v|${value}`;
|
|
62
|
+
const cellNode = (declaration) => `d|${declaration}`;
|
|
63
|
+
const parameterNode = (functionId, ordinal) => `p|${functionId}|${ordinal}`;
|
|
64
|
+
const receiverNode = (functionId) => `t|${functionId}`;
|
|
65
|
+
const returnNode = (functionId) => `r|${functionId}`;
|
|
66
|
+
const fieldNode = (object, key) => `f|${object}|${key}`;
|
|
67
|
+
const functionObject = (functionId) => `F|${functionId}`;
|
|
68
|
+
const functionOf = (object) => (object.startsWith('F|') ? object.slice(2) : null);
|
|
69
|
+
/** The carrier under any presence or borrow wrapper: what a member read on the value dispatches on. */
|
|
70
|
+
const carrierOf = (representation) => representation.kind === 'optional'
|
|
71
|
+
? carrierOf(representation.payload)
|
|
72
|
+
: representation.kind === 'borrowed-ref'
|
|
73
|
+
? carrierOf(representation.referent)
|
|
74
|
+
: representation;
|
|
75
|
+
const arrayReads = new Set([
|
|
76
|
+
'at',
|
|
77
|
+
'concat',
|
|
78
|
+
'entries',
|
|
79
|
+
'every',
|
|
80
|
+
'filter',
|
|
81
|
+
'find',
|
|
82
|
+
'findIndex',
|
|
83
|
+
'findLast',
|
|
84
|
+
'findLastIndex',
|
|
85
|
+
'flat',
|
|
86
|
+
'flatMap',
|
|
87
|
+
'forEach',
|
|
88
|
+
'includes',
|
|
89
|
+
'indexOf',
|
|
90
|
+
'join',
|
|
91
|
+
'keys',
|
|
92
|
+
'lastIndexOf',
|
|
93
|
+
'map',
|
|
94
|
+
'reduce',
|
|
95
|
+
'reduceRight',
|
|
96
|
+
'slice',
|
|
97
|
+
'some',
|
|
98
|
+
'toLocaleString',
|
|
99
|
+
'toReversed',
|
|
100
|
+
'toSorted',
|
|
101
|
+
'toSpliced',
|
|
102
|
+
'toString',
|
|
103
|
+
'values',
|
|
104
|
+
'with'
|
|
105
|
+
]);
|
|
106
|
+
const arrayWrites = new Set(['copyWithin', 'fill', 'pop', 'push', 'reverse', 'set', 'shift', 'sort', 'splice', 'unshift']);
|
|
107
|
+
/** A typed-array view of the same buffer: its result aliases the receiver rather than copying it. */
|
|
108
|
+
const aliasingReads = new Set(['subarray']);
|
|
109
|
+
/**
|
|
110
|
+
* Reads whose result is a NEW array holding elements, never an element
|
|
111
|
+
* itself. Modelled as "may be any element" like `at` or `find`, `items.slice()`
|
|
112
|
+
* looked like an object from before the region, and sorting the leaf's own
|
|
113
|
+
* copy was refused as a write to shared state.
|
|
114
|
+
*/
|
|
115
|
+
const arrayResultAllocatingReads = new Set([
|
|
116
|
+
'concat',
|
|
117
|
+
'filter',
|
|
118
|
+
'flat',
|
|
119
|
+
'flatMap',
|
|
120
|
+
'map',
|
|
121
|
+
'slice',
|
|
122
|
+
'toReversed',
|
|
123
|
+
'toSorted',
|
|
124
|
+
'toSpliced',
|
|
125
|
+
'with'
|
|
126
|
+
]);
|
|
127
|
+
const collectionReads = new Set(['entries', 'forEach', 'get', 'has', 'keys', 'values']);
|
|
128
|
+
const collectionWrites = new Set(['add', 'clear', 'delete', 'set']);
|
|
129
|
+
/**
|
|
130
|
+
* Host members with no effect but their result, and whose result depends on
|
|
131
|
+
* their arguments alone. `Math.random` is the one `Math` member that is not:
|
|
132
|
+
* its answer depends on how many draws other tasks made first.
|
|
133
|
+
*/
|
|
134
|
+
const pureHostMember = (protocol, member) => {
|
|
135
|
+
if (protocol === 'Math')
|
|
136
|
+
return member !== 'random';
|
|
137
|
+
if (protocol === 'NumberConstructor' || protocol === 'Number')
|
|
138
|
+
return ['isFinite', 'isInteger', 'isNaN', 'isSafeInteger', 'parseFloat', 'parseInt'].includes(member);
|
|
139
|
+
if (protocol === 'StringConstructor' || protocol === 'String')
|
|
140
|
+
return ['fromCharCode', 'fromCodePoint'].includes(member);
|
|
141
|
+
if (protocol === 'ArrayConstructor' || protocol === 'Array')
|
|
142
|
+
return ['from', 'isArray', 'of'].includes(member);
|
|
143
|
+
if (protocol === 'ObjectConstructor' || protocol === 'Object')
|
|
144
|
+
return ['entries', 'keys', 'values'].includes(member);
|
|
145
|
+
return false;
|
|
146
|
+
};
|
|
147
|
+
const hostDetail = (protocol, member) => protocol === 'Console'
|
|
148
|
+
? `calls console.${member}, whose output order would depend on which thread ran first`
|
|
149
|
+
: protocol === 'Math' && member === 'random'
|
|
150
|
+
? 'calls Math.random, whose answer depends on how many draws other tasks made first'
|
|
151
|
+
: `calls ${protocol}.${member}, which is not known to be free of shared effects`;
|
|
152
|
+
/** The host function or external a binding renders as, or `null` for a program binding. */
|
|
153
|
+
const hostNameOf = (placement) => {
|
|
154
|
+
const storage = placement?.storage;
|
|
155
|
+
if (!storage)
|
|
156
|
+
return null;
|
|
157
|
+
if (storage.kind === 'host-function')
|
|
158
|
+
return storage.emit;
|
|
159
|
+
if (storage.kind === 'external' || storage.kind === 'absent' || storage.kind === 'host-class')
|
|
160
|
+
return storage.linkageName;
|
|
161
|
+
return null;
|
|
162
|
+
};
|
|
163
|
+
const errorProtocol = (protocol) => /^[A-Za-z]*ErrorConstructor$/.test(protocol);
|
|
164
|
+
const hostErrorClasses = /^(Eval|Range|Reference|Syntax|Type|URI)?Error$/;
|
|
165
|
+
/**
|
|
166
|
+
* Operations that only move a value: a boxed one passes through them without
|
|
167
|
+
* any of its dynamic operations running. A thrown value is boxed into the
|
|
168
|
+
* runtime's exception carrier on its way out, and that is all `throw` does.
|
|
169
|
+
*/
|
|
170
|
+
const transportKinds = new Set(['throw', 'return', 'phi', 'binding-write', 'binding-read', 'convert']);
|
|
171
|
+
const operationsOf = (body) => body.blockOrder.flatMap((id) => {
|
|
172
|
+
const block = body.blocks.get(id);
|
|
173
|
+
return block ? allOperationsOf(block) : [];
|
|
174
|
+
});
|
|
175
|
+
const resultsOf = (operation) => ('result' in operation && operation.result ? [operation.result.id] : []);
|
|
176
|
+
const programOf = (input) => {
|
|
177
|
+
const byFunction = new Map();
|
|
178
|
+
const definitions = new Map();
|
|
179
|
+
const owners = new Map();
|
|
180
|
+
const writers = new Map();
|
|
181
|
+
for (const body of input.bodies.values()) {
|
|
182
|
+
const list = byFunction.get(body.sourceOwner) ?? [];
|
|
183
|
+
list.push(body);
|
|
184
|
+
byFunction.set(body.sourceOwner, list);
|
|
185
|
+
for (const operation of operationsOf(body)) {
|
|
186
|
+
for (const value of resultsOf(operation)) {
|
|
187
|
+
definitions.set(value, operation);
|
|
188
|
+
owners.set(value, body);
|
|
189
|
+
}
|
|
190
|
+
if (operation.kind === 'binding-write') {
|
|
191
|
+
const set = writers.get(operation.declaration) ?? new Set();
|
|
192
|
+
set.add(body);
|
|
193
|
+
writers.set(operation.declaration, set);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// A construct target names the class's source constructor; a generic class
|
|
198
|
+
// has one physical copy per layout (`373@0`, `373@1`). The copy a site enters
|
|
199
|
+
// is not on the proof, so every copy is entered -- a superset, which is the
|
|
200
|
+
// safe direction for both analyses.
|
|
201
|
+
const bodiesOf = (functionId) => {
|
|
202
|
+
const exact = byFunction.get(functionId);
|
|
203
|
+
if (exact)
|
|
204
|
+
return exact;
|
|
205
|
+
return [...byFunction.entries()].filter(([owner]) => owner.startsWith(`${functionId}@`)).flatMap(([, bodies]) => bodies);
|
|
206
|
+
};
|
|
207
|
+
const externalOf = (operation) => operation.kind === 'binding-read' ? hostNameOf(input.placements.get(operation.declaration)) : null;
|
|
208
|
+
const calleeExternal = (call) => {
|
|
209
|
+
const definition = definitions.get(call.callee.value);
|
|
210
|
+
return definition ? externalOf(definition) : null;
|
|
211
|
+
};
|
|
212
|
+
const builtinOf = (call) => {
|
|
213
|
+
const definition = definitions.get(call.callee.value);
|
|
214
|
+
if (!definition || definition.kind !== 'get')
|
|
215
|
+
return null;
|
|
216
|
+
const key = definitions.get(definition.key.value);
|
|
217
|
+
if (!key || key.kind !== 'constant' || key.literal !== 'string')
|
|
218
|
+
return null;
|
|
219
|
+
const receiver = carrierOf(definition.receiver.representation);
|
|
220
|
+
const member = key.text;
|
|
221
|
+
switch (receiver.kind) {
|
|
222
|
+
case 'native-handle':
|
|
223
|
+
return { kind: 'host', protocol: receiver.native ?? receiver.protocol, member };
|
|
224
|
+
case 'array-object':
|
|
225
|
+
case 'typed-array':
|
|
226
|
+
return arrayReads.has(member) || arrayWrites.has(member) || aliasingReads.has(member)
|
|
227
|
+
? { kind: 'method', carrier: receiver.kind, member, receiver: definition.receiver }
|
|
228
|
+
: null;
|
|
229
|
+
case 'keyed-collection':
|
|
230
|
+
return collectionReads.has(member) || collectionWrites.has(member)
|
|
231
|
+
? { kind: 'method', carrier: receiver.kind, member, receiver: definition.receiver }
|
|
232
|
+
: null;
|
|
233
|
+
case 'string':
|
|
234
|
+
return { kind: 'method', carrier: 'string', member, receiver: definition.receiver };
|
|
235
|
+
default:
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const classByConstructor = new Map();
|
|
240
|
+
for (const layout of input.classes.values())
|
|
241
|
+
if (layout.constructor)
|
|
242
|
+
classByConstructor.set(layout.constructor, layout);
|
|
243
|
+
const layoutOfConstructor = (functionId) => classByConstructor.get(functionId) ?? classByConstructor.get(functionId.replace(/@[^|]*$/, ''));
|
|
244
|
+
/** The class and its bases, or `null` when one of them is a host class whose construction is not program code. */
|
|
245
|
+
const chainOf = (layout) => {
|
|
246
|
+
const chain = [];
|
|
247
|
+
for (let current = layout; current; current = current.base ? input.classes.get(current.base) : undefined) {
|
|
248
|
+
if (current.nativeBase !== null) {
|
|
249
|
+
// An `Error` subclass: the base is the runtime's own error record,
|
|
250
|
+
// whose construction reads its arguments and touches nothing shared.
|
|
251
|
+
if (!errorProtocol(current.nativeBase.protocol))
|
|
252
|
+
return null;
|
|
253
|
+
chain.push(current);
|
|
254
|
+
return chain;
|
|
255
|
+
}
|
|
256
|
+
chain.push(current);
|
|
257
|
+
if (current.base && !input.classes.has(current.base))
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
return chain;
|
|
261
|
+
};
|
|
262
|
+
const firstConstructor = (chain) => {
|
|
263
|
+
const explicit = chain.find((layout) => layout.constructor !== null);
|
|
264
|
+
return explicit?.constructor ? [explicit.constructor] : [];
|
|
265
|
+
};
|
|
266
|
+
const constructionOf = (operation) => {
|
|
267
|
+
if (operation.target.kind === 'open')
|
|
268
|
+
return null;
|
|
269
|
+
const targets = operation.target.kind === 'exact' ? [operation.target.target] : operation.target.targets;
|
|
270
|
+
const constructors = [];
|
|
271
|
+
const initializers = [];
|
|
272
|
+
for (const target of targets) {
|
|
273
|
+
const layout = target.kind === 'function' ? layoutOfConstructor(target.functionId) : input.classes.get(target.classDeclaration);
|
|
274
|
+
if (!layout) {
|
|
275
|
+
if (target.kind !== 'function')
|
|
276
|
+
return null;
|
|
277
|
+
constructors.push(target.functionId);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const chain = chainOf(layout);
|
|
281
|
+
if (!chain)
|
|
282
|
+
return null;
|
|
283
|
+
for (const member of chain)
|
|
284
|
+
for (const field of member.fields)
|
|
285
|
+
if (field.initializer)
|
|
286
|
+
initializers.push({ key: field.key, functionId: field.initializer });
|
|
287
|
+
constructors.push(...(target.kind === 'function' ? [target.functionId] : firstConstructor(chain)));
|
|
288
|
+
}
|
|
289
|
+
return { constructors, initializers };
|
|
290
|
+
};
|
|
291
|
+
const superConstructorOf = (body) => {
|
|
292
|
+
const layout = layoutOfConstructor(body.sourceOwner);
|
|
293
|
+
if (layout && !layout.base && layout.nativeBase && errorProtocol(layout.nativeBase.protocol))
|
|
294
|
+
return [];
|
|
295
|
+
if (!layout || !layout.base)
|
|
296
|
+
return null;
|
|
297
|
+
const base = input.classes.get(layout.base);
|
|
298
|
+
const chain = base ? chainOf(base) : null;
|
|
299
|
+
return chain ? firstConstructor(chain) : null;
|
|
300
|
+
};
|
|
301
|
+
const constructsHostError = (operation) => {
|
|
302
|
+
const callee = definitions.get(operation.callee.value);
|
|
303
|
+
const storage = callee?.kind === 'binding-read' ? input.placements.get(callee.declaration)?.storage : undefined;
|
|
304
|
+
return storage?.kind === 'host-class' && hostErrorClasses.test(storage.linkageName);
|
|
305
|
+
};
|
|
306
|
+
return {
|
|
307
|
+
constructionOf,
|
|
308
|
+
superConstructorOf,
|
|
309
|
+
constructsHostError,
|
|
310
|
+
bodiesOf,
|
|
311
|
+
definitionOf: (value) => definitions.get(value),
|
|
312
|
+
bodyOfValue: (value) => owners.get(value),
|
|
313
|
+
targetProofOf: (operation) => {
|
|
314
|
+
if (operation.lineage === null)
|
|
315
|
+
return null;
|
|
316
|
+
const semantic = input.graph.operations.get(operationOfResult(operation.lineage));
|
|
317
|
+
return semantic && semantic.family === 'invocation' ? semantic.target : null;
|
|
318
|
+
},
|
|
319
|
+
regionEntryCall: (operation) => operation.kind === 'call' && input.entries.has(calleeExternal(operation) ?? ''),
|
|
320
|
+
externalOf,
|
|
321
|
+
builtinOf,
|
|
322
|
+
writersOf: (declaration) => writers.get(declaration) ?? new Set()
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
const proofFunctions = (proof) => {
|
|
326
|
+
if (!proof || proof.kind === 'open')
|
|
327
|
+
return [];
|
|
328
|
+
const targets = proof.kind === 'exact' ? [proof.target] : proof.targets;
|
|
329
|
+
return targets.flatMap((target) => (target.kind === 'function' ? [target.functionId] : []));
|
|
330
|
+
};
|
|
331
|
+
/** The functions a call's own sealed facts name, without asking any points-to set. */
|
|
332
|
+
const statedCallees = (call, program) => {
|
|
333
|
+
const named = new Set();
|
|
334
|
+
if (call.closedCallee) {
|
|
335
|
+
if (call.closedCallee.kind === 'exact')
|
|
336
|
+
named.add(call.closedCallee.functionId);
|
|
337
|
+
else
|
|
338
|
+
for (const id of call.closedCallee.functionIds)
|
|
339
|
+
named.add(id);
|
|
340
|
+
}
|
|
341
|
+
if (call.target?.kind === 'direct')
|
|
342
|
+
named.add(call.target.functionId);
|
|
343
|
+
for (const member of call.family ?? [])
|
|
344
|
+
named.add(member.functionId);
|
|
345
|
+
for (const id of proofFunctions(program.targetProofOf(call)))
|
|
346
|
+
named.add(id);
|
|
347
|
+
return [...named];
|
|
348
|
+
};
|
|
349
|
+
const fieldKeyOf = (program, key) => {
|
|
350
|
+
const definition = program.definitionOf(key.value);
|
|
351
|
+
return definition?.kind === 'constant' && (definition.literal === 'string' || definition.literal === 'number')
|
|
352
|
+
? definition.text
|
|
353
|
+
: unknownField;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* The whole-program analysis. Its only consumer asks which functions a value
|
|
357
|
+
* can be, so everything it cannot follow is `TOP` -- an unknown object -- and
|
|
358
|
+
* everything handed to code it cannot see escapes, which makes `TOP` stand for
|
|
359
|
+
* the escaped set too.
|
|
360
|
+
*/
|
|
361
|
+
const globalPointsTo = (input, program) => {
|
|
362
|
+
const solver = new PointsTo();
|
|
363
|
+
const escaped = 'ESC';
|
|
364
|
+
const store = (receiver, key, value) => solver.on(receiver, (object) => {
|
|
365
|
+
if (object === top)
|
|
366
|
+
return solver.copy(value, escaped);
|
|
367
|
+
solver.copy(value, fieldNode(object, key));
|
|
368
|
+
solver.copy(value, fieldNode(object, allFields));
|
|
369
|
+
});
|
|
370
|
+
const load = (receiver, key, result) => solver.on(receiver, (object) => {
|
|
371
|
+
if (object === top) {
|
|
372
|
+
solver.add(result, top);
|
|
373
|
+
return solver.copy(escaped, result);
|
|
374
|
+
}
|
|
375
|
+
if (key === allFields)
|
|
376
|
+
return solver.copy(fieldNode(object, allFields), result);
|
|
377
|
+
solver.copy(fieldNode(object, key), result);
|
|
378
|
+
solver.copy(fieldNode(object, unknownField), result);
|
|
379
|
+
});
|
|
380
|
+
const enter = (functionId, call) => {
|
|
381
|
+
call.args.forEach((argument, ordinal) => solver.copy(argument, parameterNode(functionId, call.spread ? '*' : ordinal)));
|
|
382
|
+
if (call.spread && call.args[0])
|
|
383
|
+
load(call.args[0], allFields, parameterNode(functionId, '*'));
|
|
384
|
+
if (call.receiver)
|
|
385
|
+
solver.copy(call.receiver, receiverNode(functionId));
|
|
386
|
+
if (call.result)
|
|
387
|
+
solver.copy(returnNode(functionId), call.result);
|
|
388
|
+
};
|
|
389
|
+
solver.on(escaped, (object) => {
|
|
390
|
+
const functionId = functionOf(object);
|
|
391
|
+
if (functionId) {
|
|
392
|
+
solver.add(parameterNode(functionId, '*'), top);
|
|
393
|
+
solver.copy(escaped, parameterNode(functionId, '*'));
|
|
394
|
+
solver.add(receiverNode(functionId), top);
|
|
395
|
+
solver.copy(returnNode(functionId), escaped);
|
|
396
|
+
}
|
|
397
|
+
if (object === top)
|
|
398
|
+
return;
|
|
399
|
+
solver.add(fieldNode(object, unknownField), top);
|
|
400
|
+
solver.copy(escaped, fieldNode(object, unknownField));
|
|
401
|
+
solver.copy(fieldNode(object, allFields), escaped);
|
|
402
|
+
});
|
|
403
|
+
for (const body of input.bodies.values()) {
|
|
404
|
+
const self = body.sourceOwner;
|
|
405
|
+
for (const operation of operationsOf(body)) {
|
|
406
|
+
const result = resultsOf(operation)[0];
|
|
407
|
+
const out = result === undefined ? null : valueNode(result);
|
|
408
|
+
const fresh = () => {
|
|
409
|
+
if (out && result !== undefined)
|
|
410
|
+
solver.add(out, `O|${result}`);
|
|
411
|
+
};
|
|
412
|
+
switch (operation.kind) {
|
|
413
|
+
case 'parameter':
|
|
414
|
+
solver.copy(parameterNode(self, operation.ordinal), out);
|
|
415
|
+
solver.copy(parameterNode(self, '*'), out);
|
|
416
|
+
break;
|
|
417
|
+
case 'receiver':
|
|
418
|
+
solver.copy(receiverNode(self), out);
|
|
419
|
+
break;
|
|
420
|
+
case 'binding-read':
|
|
421
|
+
if (hostNameOf(input.placements.get(operation.declaration)) !== null)
|
|
422
|
+
solver.add(out, top);
|
|
423
|
+
else
|
|
424
|
+
solver.copy(cellNode(operation.declaration), out);
|
|
425
|
+
if (operation.closedCallable)
|
|
426
|
+
for (const id of operation.closedCallable.kind === 'exact'
|
|
427
|
+
? [operation.closedCallable.functionId]
|
|
428
|
+
: operation.closedCallable.functionIds)
|
|
429
|
+
solver.add(out, functionObject(id));
|
|
430
|
+
break;
|
|
431
|
+
case 'binding-write':
|
|
432
|
+
solver.copy(valueNode(operation.value.value), cellNode(operation.declaration));
|
|
433
|
+
break;
|
|
434
|
+
case 'phi':
|
|
435
|
+
for (const incoming of operation.incoming)
|
|
436
|
+
solver.copy(valueNode(incoming.value.value), out);
|
|
437
|
+
break;
|
|
438
|
+
case 'convert':
|
|
439
|
+
case 'merge-live-arm-rebuild':
|
|
440
|
+
solver.copy(valueNode(operation.source.value), out);
|
|
441
|
+
break;
|
|
442
|
+
case 'compute':
|
|
443
|
+
if (operation.form.startsWith('require-') && operation.operands[0])
|
|
444
|
+
solver.copy(valueNode(operation.operands[0].value), out);
|
|
445
|
+
break;
|
|
446
|
+
case 'allocate-callable':
|
|
447
|
+
solver.add(out, functionObject(operation.functionId));
|
|
448
|
+
break;
|
|
449
|
+
case 'allocate-array-object':
|
|
450
|
+
fresh();
|
|
451
|
+
for (const element of operation.elements) {
|
|
452
|
+
if (element.kind === 'element')
|
|
453
|
+
store(out, unknownField, valueNode(element.value.value));
|
|
454
|
+
else if (element.kind === 'spread') {
|
|
455
|
+
const spread = `${out}|spread`;
|
|
456
|
+
load(valueNode(element.value.value), allFields, spread);
|
|
457
|
+
store(out, unknownField, spread);
|
|
458
|
+
}
|
|
459
|
+
else if (element.kind === 'gather')
|
|
460
|
+
store(out, unknownField, valueNode(element.iterator.value));
|
|
461
|
+
}
|
|
462
|
+
break;
|
|
463
|
+
case 'allocate-record':
|
|
464
|
+
fresh();
|
|
465
|
+
for (const field of operation.fields)
|
|
466
|
+
store(out, field.key, valueNode(field.value.value));
|
|
467
|
+
break;
|
|
468
|
+
case 'allocate-ordinary-object':
|
|
469
|
+
case 'allocate-constructor':
|
|
470
|
+
case 'allocate-template-object':
|
|
471
|
+
case 'allocate-regexp':
|
|
472
|
+
case 'own-property-keys':
|
|
473
|
+
fresh();
|
|
474
|
+
break;
|
|
475
|
+
case 'get':
|
|
476
|
+
load(valueNode(operation.receiver.value), fieldKeyOf(program, operation.key) === unknownField ? allFields : fieldKeyOf(program, operation.key), out);
|
|
477
|
+
if (operation.closedCallable)
|
|
478
|
+
for (const id of operation.closedCallable.kind === 'exact'
|
|
479
|
+
? [operation.closedCallable.functionId]
|
|
480
|
+
: operation.closedCallable.functionIds)
|
|
481
|
+
solver.add(out, functionObject(id));
|
|
482
|
+
break;
|
|
483
|
+
case 'set':
|
|
484
|
+
case 'define-own-property':
|
|
485
|
+
store(valueNode(operation.receiver.value), fieldKeyOf(program, operation.key), valueNode(operation.value.value));
|
|
486
|
+
// The lowered result is the receiver for a definition and the value
|
|
487
|
+
// for an assignment; holding both is the superset either way.
|
|
488
|
+
if (out) {
|
|
489
|
+
solver.copy(valueNode(operation.value.value), out);
|
|
490
|
+
solver.copy(valueNode(operation.receiver.value), out);
|
|
491
|
+
}
|
|
492
|
+
break;
|
|
493
|
+
case 'spread-copy': {
|
|
494
|
+
const spread = `${valueNode(operation.receiver.value)}|spread`;
|
|
495
|
+
load(valueNode(operation.source.value), allFields, spread);
|
|
496
|
+
store(valueNode(operation.receiver.value), unknownField, spread);
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
case 'get-iterator':
|
|
500
|
+
fresh();
|
|
501
|
+
load(valueNode(operation.receiver.value), allFields, fieldNode(`O|${result}`, unknownField));
|
|
502
|
+
break;
|
|
503
|
+
case 'iterator-next':
|
|
504
|
+
load(valueNode(operation.iterator.value), allFields, out);
|
|
505
|
+
break;
|
|
506
|
+
case 'return':
|
|
507
|
+
if (operation.value)
|
|
508
|
+
solver.copy(valueNode(operation.value.value), returnNode(self));
|
|
509
|
+
break;
|
|
510
|
+
case 'throw':
|
|
511
|
+
solver.copy(valueNode(operation.value.value), escaped);
|
|
512
|
+
break;
|
|
513
|
+
case 'construct': {
|
|
514
|
+
const args = operation.arguments.map((argument) => valueNode(argument.value));
|
|
515
|
+
const targets = proofFunctions(operation.target);
|
|
516
|
+
if (operation.target.kind === 'open' || operation.hostFrame) {
|
|
517
|
+
for (const argument of args)
|
|
518
|
+
solver.copy(argument, escaped);
|
|
519
|
+
fresh();
|
|
520
|
+
if (operation.target.kind === 'open') {
|
|
521
|
+
solver.add(out, top);
|
|
522
|
+
solver.copy(escaped, out);
|
|
523
|
+
}
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
fresh();
|
|
527
|
+
const construction = program.constructionOf(operation);
|
|
528
|
+
if (!construction) {
|
|
529
|
+
for (const argument of args)
|
|
530
|
+
solver.copy(argument, escaped);
|
|
531
|
+
for (const id of targets)
|
|
532
|
+
for (const callee of program.bodiesOf(id))
|
|
533
|
+
enter(callee.sourceOwner, { args, receiver: out, spread: false, result: null });
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
for (const id of construction.constructors)
|
|
537
|
+
for (const callee of program.bodiesOf(id))
|
|
538
|
+
enter(callee.sourceOwner, { args, receiver: out, spread: false, result: null });
|
|
539
|
+
for (const initializer of construction.initializers) {
|
|
540
|
+
const value = `${out}|field|${initializer.key}`;
|
|
541
|
+
for (const callee of program.bodiesOf(initializer.functionId))
|
|
542
|
+
enter(callee.sourceOwner, { args: [], receiver: out, spread: false, result: value });
|
|
543
|
+
store(out, initializer.key, value);
|
|
544
|
+
}
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
case 'super-initialize': {
|
|
548
|
+
const args = operation.arguments.map((argument) => valueNode(argument.value));
|
|
549
|
+
const constructors = program.superConstructorOf(body);
|
|
550
|
+
if (!constructors) {
|
|
551
|
+
for (const argument of args)
|
|
552
|
+
solver.copy(argument, escaped);
|
|
553
|
+
break;
|
|
554
|
+
}
|
|
555
|
+
for (const id of constructors)
|
|
556
|
+
for (const callee of program.bodiesOf(id))
|
|
557
|
+
enter(callee.sourceOwner, { args, receiver: receiverNode(self), spread: false, result: null });
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
case 'call': {
|
|
561
|
+
const args = operation.arguments.map((argument) => valueNode(argument.value));
|
|
562
|
+
const receiver = operation.receiver ? valueNode(operation.receiver.value) : null;
|
|
563
|
+
const spread = operation.argumentsAreSpread === true;
|
|
564
|
+
if (program.regionEntryCall(operation)) {
|
|
565
|
+
// `tasks(count, body)`: the body is called with a number and its
|
|
566
|
+
// result is read as a boolean; nothing else crosses.
|
|
567
|
+
if (args[1])
|
|
568
|
+
solver.on(args[1], (object) => {
|
|
569
|
+
const functionId = functionOf(object);
|
|
570
|
+
if (functionId)
|
|
571
|
+
for (const callee of program.bodiesOf(functionId))
|
|
572
|
+
enter(callee.sourceOwner, { args: [], receiver: null, spread: false, result: null });
|
|
573
|
+
else if (object === top)
|
|
574
|
+
solver.copy(args[1], escaped);
|
|
575
|
+
});
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
const builtin = program.builtinOf(operation);
|
|
579
|
+
if (builtin && builtin.kind === 'method') {
|
|
580
|
+
const self = valueNode(builtin.receiver.value);
|
|
581
|
+
const elements = `${out ?? valueNode(`${String(operation.lineage)}|call`)}|elements`;
|
|
582
|
+
load(self, allFields, elements);
|
|
583
|
+
for (const argument of args) {
|
|
584
|
+
store(self, unknownField, argument);
|
|
585
|
+
load(argument, allFields, elements);
|
|
586
|
+
solver.copy(argument, elements);
|
|
587
|
+
solver.on(argument, (object) => {
|
|
588
|
+
const functionId = functionOf(object);
|
|
589
|
+
if (!functionId)
|
|
590
|
+
return;
|
|
591
|
+
for (const callee of program.bodiesOf(functionId)) {
|
|
592
|
+
const id = callee.sourceOwner;
|
|
593
|
+
solver.copy(elements, parameterNode(id, '*'));
|
|
594
|
+
solver.copy(returnNode(id), elements);
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
if (out) {
|
|
599
|
+
fresh();
|
|
600
|
+
solver.copy(elements, out);
|
|
601
|
+
solver.copy(elements, fieldNode(`O|${result}`, unknownField));
|
|
602
|
+
solver.copy(elements, fieldNode(`O|${result}`, allFields));
|
|
603
|
+
}
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
const unknown = () => {
|
|
607
|
+
for (const argument of args)
|
|
608
|
+
solver.copy(argument, escaped);
|
|
609
|
+
if (receiver)
|
|
610
|
+
solver.copy(receiver, escaped);
|
|
611
|
+
if (out) {
|
|
612
|
+
solver.add(out, top);
|
|
613
|
+
solver.copy(escaped, out);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
if (builtin && builtin.kind === 'host') {
|
|
617
|
+
if (!pureHostMember(builtin.protocol, builtin.member))
|
|
618
|
+
unknown();
|
|
619
|
+
else if (out) {
|
|
620
|
+
fresh();
|
|
621
|
+
for (const argument of args)
|
|
622
|
+
load(argument, allFields, fieldNode(`O|${result}`, allFields));
|
|
623
|
+
}
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
const stated = statedCallees(operation, program);
|
|
627
|
+
if (stated.length > 0) {
|
|
628
|
+
for (const id of stated)
|
|
629
|
+
for (const callee of program.bodiesOf(id))
|
|
630
|
+
enter(callee.sourceOwner, { args, receiver, spread, result: out });
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
solver.on(valueNode(operation.callee.value), (object) => {
|
|
634
|
+
const functionId = functionOf(object);
|
|
635
|
+
if (functionId)
|
|
636
|
+
for (const callee of program.bodiesOf(functionId))
|
|
637
|
+
enter(callee.sourceOwner, { args, receiver, spread, result: out });
|
|
638
|
+
else if (object === top)
|
|
639
|
+
unknown();
|
|
640
|
+
});
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
case 'bind-callable':
|
|
644
|
+
case 'global-this':
|
|
645
|
+
case 'unresolvable-reference':
|
|
646
|
+
case 'commonjs-require':
|
|
647
|
+
case 'commonjs-binding':
|
|
648
|
+
case 'catch-binding':
|
|
649
|
+
case 'await':
|
|
650
|
+
case 'yield':
|
|
651
|
+
case 'allocate-proxy':
|
|
652
|
+
case 'proxy-part':
|
|
653
|
+
case 'element':
|
|
654
|
+
for (const operand of operandValues(operation))
|
|
655
|
+
solver.copy(valueNode(operand), escaped);
|
|
656
|
+
if (out) {
|
|
657
|
+
solver.add(out, top);
|
|
658
|
+
solver.copy(escaped, out);
|
|
659
|
+
}
|
|
660
|
+
break;
|
|
661
|
+
default:
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
solver.solve();
|
|
667
|
+
return solver;
|
|
668
|
+
};
|
|
669
|
+
/** Every SSA value an operation reads, for the operations the analyses only need to treat as escaping. */
|
|
670
|
+
const operandValues = (operation) => {
|
|
671
|
+
const values = [];
|
|
672
|
+
const visit = (value) => {
|
|
673
|
+
if (!value || typeof value !== 'object')
|
|
674
|
+
return;
|
|
675
|
+
if (Array.isArray(value))
|
|
676
|
+
return value.forEach(visit);
|
|
677
|
+
const record = value;
|
|
678
|
+
if (typeof record['value'] === 'string' && 'representation' in record) {
|
|
679
|
+
values.push(record['value']);
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
for (const [key, item] of Object.entries(record))
|
|
683
|
+
if (key !== 'result')
|
|
684
|
+
visit(item);
|
|
685
|
+
};
|
|
686
|
+
visit(operation);
|
|
687
|
+
return values;
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* One region instance, under an assumption about which captured bindings are
|
|
691
|
+
* the region's own (`localCaptures`): a binding a closure captured from a frame
|
|
692
|
+
* the region itself activated is that task's, not shared.
|
|
693
|
+
*/
|
|
694
|
+
const runRegion = (input, program, global, entry, localCaptures) => {
|
|
695
|
+
const solver = new PointsTo();
|
|
696
|
+
const refusals = [];
|
|
697
|
+
const refused = new Set();
|
|
698
|
+
const entries = new Map();
|
|
699
|
+
const entered = new Set();
|
|
700
|
+
const closureSites = new Map();
|
|
701
|
+
const disjointWrites = [];
|
|
702
|
+
const contentReads = [];
|
|
703
|
+
const entryId = entry.sourceOwner;
|
|
704
|
+
const refuse = (body, operation, detail) => {
|
|
705
|
+
const key = `${body.sourceOwner}|${detail}`;
|
|
706
|
+
if (refused.has(key))
|
|
707
|
+
return;
|
|
708
|
+
refused.add(key);
|
|
709
|
+
refusals.push({ owner: String(body.sourceOwner), site: operation, detail });
|
|
710
|
+
};
|
|
711
|
+
const store = (receiver, key, value) => solver.on(receiver, (object) => {
|
|
712
|
+
if (object === shared)
|
|
713
|
+
return;
|
|
714
|
+
solver.copy(value, fieldNode(object, key));
|
|
715
|
+
solver.copy(value, fieldNode(object, allFields));
|
|
716
|
+
});
|
|
717
|
+
const load = (receiver, key, result) => solver.on(receiver, (object) => {
|
|
718
|
+
if (object === shared)
|
|
719
|
+
return solver.add(result, shared);
|
|
720
|
+
if (key === allFields)
|
|
721
|
+
return solver.copy(fieldNode(object, allFields), result);
|
|
722
|
+
solver.copy(fieldNode(object, key), result);
|
|
723
|
+
solver.copy(fieldNode(object, unknownField), result);
|
|
724
|
+
});
|
|
725
|
+
// Checks that read the solved sets, run once nothing more can be added. An
|
|
726
|
+
// empty set at a write or a call is a value the analysis lost track of, and
|
|
727
|
+
// is refused as such rather than read as "touches nothing".
|
|
728
|
+
const writeChecks = [];
|
|
729
|
+
const callChecks = [];
|
|
730
|
+
// Enumerating an object's keys can settle its creation order into the
|
|
731
|
+
// object itself (a pending key order becomes a log), which is a write.
|
|
732
|
+
const enumerations = [];
|
|
733
|
+
const settlers = [];
|
|
734
|
+
/** A write whose target may be an object that existed before the region is the race this family exists to refuse. */
|
|
735
|
+
const requireLocal = (body, operation, receiver, what) => {
|
|
736
|
+
writeChecks.push({ body, operation, value: receiver.value, what });
|
|
737
|
+
};
|
|
738
|
+
const globalFunctions = (value) => {
|
|
739
|
+
const functions = [];
|
|
740
|
+
let unknown = false;
|
|
741
|
+
for (const object of global.of(valueNode(value))) {
|
|
742
|
+
const functionId = functionOf(object);
|
|
743
|
+
if (functionId)
|
|
744
|
+
functions.push(functionId);
|
|
745
|
+
else if (object === top)
|
|
746
|
+
unknown = true;
|
|
747
|
+
}
|
|
748
|
+
return { functions, unknown };
|
|
749
|
+
};
|
|
750
|
+
const enter = (functionId, how, call) => {
|
|
751
|
+
for (const callee of program.bodiesOf(functionId)) {
|
|
752
|
+
const id = callee.sourceOwner;
|
|
753
|
+
const list = entries.get(id) ?? [];
|
|
754
|
+
if (!list.some((seen) => seen.kind === how.kind && (seen.kind === 'outside' || (how.kind === 'closure' && seen.allocator === how.allocator))))
|
|
755
|
+
list.push(how);
|
|
756
|
+
entries.set(id, list);
|
|
757
|
+
call.args.forEach((argument, ordinal) => solver.copy(argument, parameterNode(id, call.spread ? '*' : ordinal)));
|
|
758
|
+
if (call.spread && call.args[0])
|
|
759
|
+
load(call.args[0], allFields, parameterNode(id, '*'));
|
|
760
|
+
if (call.receiver)
|
|
761
|
+
solver.copy(call.receiver, receiverNode(id));
|
|
762
|
+
if (call.result)
|
|
763
|
+
solver.copy(returnNode(id), call.result);
|
|
764
|
+
if (!entered.has(id)) {
|
|
765
|
+
entered.add(id);
|
|
766
|
+
visit(callee);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
/** Enters every function a callee value can be, or refuses the call when one of them cannot be named. */
|
|
771
|
+
const callValue = (body, operation, callee, call) => solver.on(valueNode(callee), (object) => {
|
|
772
|
+
const site = closureSites.get(object);
|
|
773
|
+
if (site)
|
|
774
|
+
return enter(site.functionId, { kind: 'closure', allocator: site.allocator }, call);
|
|
775
|
+
if (object !== shared)
|
|
776
|
+
return;
|
|
777
|
+
const resolved = globalFunctions(callee);
|
|
778
|
+
if (resolved.unknown)
|
|
779
|
+
return refuse(body, operation, 'calls a function value the compiler cannot trace to its definitions');
|
|
780
|
+
for (const functionId of resolved.functions)
|
|
781
|
+
enter(functionId, { kind: 'outside' }, call);
|
|
782
|
+
});
|
|
783
|
+
const visit = (body) => {
|
|
784
|
+
if (body.generator || body.async) {
|
|
785
|
+
const first = operationsOf(body)[0];
|
|
786
|
+
if (first)
|
|
787
|
+
refuse(body, first, 'calls a generator or async function, whose suspension the parallel runtime does not support');
|
|
788
|
+
}
|
|
789
|
+
const self = body.sourceOwner;
|
|
790
|
+
const local = localCaptures.get(self) ?? new Set();
|
|
791
|
+
const captured = new Set(body.facts?.capturedDeclarations ?? []);
|
|
792
|
+
const ownsCell = (declaration) => {
|
|
793
|
+
const placement = input.placements.get(declaration);
|
|
794
|
+
if (placement?.storage.kind === 'local' && placement.storage.owner === self && !captured.has(declaration))
|
|
795
|
+
return true;
|
|
796
|
+
return local.has(declaration);
|
|
797
|
+
};
|
|
798
|
+
for (const operation of operationsOf(body)) {
|
|
799
|
+
const result = resultsOf(operation)[0];
|
|
800
|
+
const out = result === undefined ? null : valueNode(result);
|
|
801
|
+
const fresh = () => {
|
|
802
|
+
if (out && result !== undefined)
|
|
803
|
+
solver.add(out, `L|${result}`);
|
|
804
|
+
};
|
|
805
|
+
if (!transportKinds.has(operation.kind))
|
|
806
|
+
for (const operand of operandValues(operation)) {
|
|
807
|
+
const definition = program.definitionOf(operand);
|
|
808
|
+
const representation = definition && 'result' in definition && definition.result ? definition.result.representation : null;
|
|
809
|
+
if (representation?.kind === 'dynamic')
|
|
810
|
+
refuse(body, operation, 'handles a dynamically typed value, whose operations the compiler cannot prove free of shared effects');
|
|
811
|
+
}
|
|
812
|
+
switch (operation.kind) {
|
|
813
|
+
case 'parameter':
|
|
814
|
+
if (body === entry)
|
|
815
|
+
break;
|
|
816
|
+
solver.copy(parameterNode(self, operation.ordinal), out);
|
|
817
|
+
solver.copy(parameterNode(self, '*'), out);
|
|
818
|
+
break;
|
|
819
|
+
case 'receiver':
|
|
820
|
+
solver.copy(receiverNode(self), out);
|
|
821
|
+
break;
|
|
822
|
+
case 'binding-read': {
|
|
823
|
+
const external = program.externalOf(operation);
|
|
824
|
+
if (external !== null) {
|
|
825
|
+
solver.add(out, shared);
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
828
|
+
if (ownsCell(operation.declaration))
|
|
829
|
+
solver.copy(cellNode(operation.declaration), out);
|
|
830
|
+
else
|
|
831
|
+
solver.add(out, shared);
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
case 'binding-write':
|
|
835
|
+
if (ownsCell(operation.declaration))
|
|
836
|
+
solver.copy(valueNode(operation.value.value), cellNode(operation.declaration));
|
|
837
|
+
else
|
|
838
|
+
refuse(body, operation, `assigns \`${declarationName(input, operation.declaration)}\`, a variable that existed before the parallel region`);
|
|
839
|
+
break;
|
|
840
|
+
case 'binding-renew':
|
|
841
|
+
if (!ownsCell(operation.declaration))
|
|
842
|
+
refuse(body, operation, 'renews a binding that existed before the parallel region');
|
|
843
|
+
break;
|
|
844
|
+
case 'phi':
|
|
845
|
+
for (const incoming of operation.incoming)
|
|
846
|
+
solver.copy(valueNode(incoming.value.value), out);
|
|
847
|
+
break;
|
|
848
|
+
case 'convert':
|
|
849
|
+
case 'merge-live-arm-rebuild':
|
|
850
|
+
solver.copy(valueNode(operation.source.value), out);
|
|
851
|
+
contentReads.push({ body, operation, operand: operation.source.value });
|
|
852
|
+
break;
|
|
853
|
+
case 'compute':
|
|
854
|
+
if (operation.form.startsWith('require-') && operation.operands[0])
|
|
855
|
+
solver.copy(valueNode(operation.operands[0].value), out);
|
|
856
|
+
if (operation.form === 'binary' || operation.form === 'template' || operation.form === 'unary' || operation.form === 'update')
|
|
857
|
+
for (const operand of operation.operands) {
|
|
858
|
+
const kind = carrierOf(operand.representation).kind;
|
|
859
|
+
if (kind === 'class-ref' || kind === 'record' || kind === 'native-record-ref' || kind === 'native-handle')
|
|
860
|
+
refuse(body, operation, 'converts an object to a primitive, which may run a method the compiler does not trace');
|
|
861
|
+
}
|
|
862
|
+
break;
|
|
863
|
+
case 'test':
|
|
864
|
+
case 'constant':
|
|
865
|
+
case 'has-property':
|
|
866
|
+
case 'jump':
|
|
867
|
+
case 'branch':
|
|
868
|
+
case 'switch':
|
|
869
|
+
case 'iterator-done':
|
|
870
|
+
case 'iterator-close':
|
|
871
|
+
if (operation.kind === 'has-property')
|
|
872
|
+
contentReads.push({ body, operation, operand: operation.receiver.value });
|
|
873
|
+
break;
|
|
874
|
+
case 'allocate-callable':
|
|
875
|
+
fresh();
|
|
876
|
+
if (out && result !== undefined)
|
|
877
|
+
closureSites.set(`L|${result}`, { functionId: operation.functionId, allocator: body });
|
|
878
|
+
break;
|
|
879
|
+
case 'allocate-array-object':
|
|
880
|
+
fresh();
|
|
881
|
+
for (const element of operation.elements) {
|
|
882
|
+
if (element.kind === 'element')
|
|
883
|
+
store(out, unknownField, valueNode(element.value.value));
|
|
884
|
+
else if (element.kind === 'spread') {
|
|
885
|
+
const spread = `${out}|spread`;
|
|
886
|
+
load(valueNode(element.value.value), allFields, spread);
|
|
887
|
+
store(out, unknownField, spread);
|
|
888
|
+
contentReads.push({ body, operation, operand: element.value.value });
|
|
889
|
+
}
|
|
890
|
+
else if (element.kind === 'gather')
|
|
891
|
+
refuse(body, operation, 'drains a dynamic iterator');
|
|
892
|
+
}
|
|
893
|
+
break;
|
|
894
|
+
case 'allocate-record':
|
|
895
|
+
fresh();
|
|
896
|
+
for (const field of operation.fields)
|
|
897
|
+
store(out, field.key, valueNode(field.value.value));
|
|
898
|
+
break;
|
|
899
|
+
case 'allocate-ordinary-object':
|
|
900
|
+
case 'own-property-keys':
|
|
901
|
+
fresh();
|
|
902
|
+
if (operation.kind === 'own-property-keys') {
|
|
903
|
+
contentReads.push({ body, operation, operand: operation.receiver.value });
|
|
904
|
+
enumerations.push({ body, operation, value: operation.receiver.value });
|
|
905
|
+
}
|
|
906
|
+
break;
|
|
907
|
+
case 'allocate-regexp':
|
|
908
|
+
refuse(body, operation, 'uses a regular expression, whose lastIndex and match cache are shared state');
|
|
909
|
+
break;
|
|
910
|
+
case 'get': {
|
|
911
|
+
const key = fieldKeyOf(program, operation.key);
|
|
912
|
+
load(valueNode(operation.receiver.value), key === unknownField ? allFields : key, out);
|
|
913
|
+
if (key !== 'length')
|
|
914
|
+
contentReads.push({ body, operation, operand: operation.receiver.value });
|
|
915
|
+
if (key !== unknownField) {
|
|
916
|
+
const accessor = accessorOf(input, operation.receiver.representation, key, 'get');
|
|
917
|
+
if (accessor === 'family')
|
|
918
|
+
refuse(body, operation, `reads \`${key}\` through an accessor some subclass overrides`);
|
|
919
|
+
else if (accessor)
|
|
920
|
+
enter(accessor, { kind: 'outside' }, { args: [], receiver: valueNode(operation.receiver.value), spread: false, result: out });
|
|
921
|
+
}
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
case 'set':
|
|
925
|
+
case 'define-own-property': {
|
|
926
|
+
const key = fieldKeyOf(program, operation.key);
|
|
927
|
+
const setter = key === unknownField ? null : accessorOf(input, operation.receiver.representation, key, 'set');
|
|
928
|
+
if (setter === 'family')
|
|
929
|
+
refuse(body, operation, `writes \`${key}\` through an accessor some subclass overrides`);
|
|
930
|
+
else if (setter)
|
|
931
|
+
enter(setter, { kind: 'outside' }, { args: [valueNode(operation.value.value)], receiver: valueNode(operation.receiver.value), spread: false, result: null });
|
|
932
|
+
else if (operation.kind === 'set' && isDisjointSlotWrite(program, body, entry, operation)) {
|
|
933
|
+
disjointWrites.push({ body, operation, receiver: operation.receiver.value });
|
|
934
|
+
solver.on(valueNode(operation.receiver.value), (object) => {
|
|
935
|
+
if (object !== shared)
|
|
936
|
+
store(valueNode(operation.receiver.value), key, valueNode(operation.value.value));
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
requireLocal(body, operation, operation.receiver, 'writes to');
|
|
941
|
+
store(valueNode(operation.receiver.value), key, valueNode(operation.value.value));
|
|
942
|
+
}
|
|
943
|
+
if (out) {
|
|
944
|
+
solver.copy(valueNode(operation.value.value), out);
|
|
945
|
+
solver.copy(valueNode(operation.receiver.value), out);
|
|
946
|
+
}
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
case 'delete':
|
|
950
|
+
requireLocal(body, operation, operation.receiver, 'deletes a property of');
|
|
951
|
+
break;
|
|
952
|
+
case 'spread-copy': {
|
|
953
|
+
requireLocal(body, operation, operation.receiver, 'writes to');
|
|
954
|
+
const spread = `${valueNode(operation.receiver.value)}|spread`;
|
|
955
|
+
load(valueNode(operation.source.value), allFields, spread);
|
|
956
|
+
store(valueNode(operation.receiver.value), unknownField, spread);
|
|
957
|
+
contentReads.push({ body, operation, operand: operation.source.value });
|
|
958
|
+
enumerations.push({ body, operation, value: operation.source.value });
|
|
959
|
+
break;
|
|
960
|
+
}
|
|
961
|
+
case 'get-iterator': {
|
|
962
|
+
const kind = carrierOf(operation.receiver.representation).kind;
|
|
963
|
+
if (operation.protocol === 'enumerate')
|
|
964
|
+
enumerations.push({ body, operation, value: operation.receiver.value });
|
|
965
|
+
else if (operation.method || !['array-object', 'typed-array', 'string', 'keyed-collection', 'iterator'].includes(kind))
|
|
966
|
+
refuse(body, operation, 'iterates an object whose iterator the compiler does not trace');
|
|
967
|
+
fresh();
|
|
968
|
+
load(valueNode(operation.receiver.value), allFields, fieldNode(`L|${result}`, unknownField));
|
|
969
|
+
contentReads.push({ body, operation, operand: operation.receiver.value });
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
972
|
+
case 'iterator-next':
|
|
973
|
+
load(valueNode(operation.iterator.value), allFields, out);
|
|
974
|
+
break;
|
|
975
|
+
case 'return':
|
|
976
|
+
if (operation.value)
|
|
977
|
+
solver.copy(valueNode(operation.value.value), returnNode(self));
|
|
978
|
+
break;
|
|
979
|
+
case 'throw':
|
|
980
|
+
break;
|
|
981
|
+
case 'catch-binding':
|
|
982
|
+
solver.add(out, shared);
|
|
983
|
+
break;
|
|
984
|
+
case 'construct': {
|
|
985
|
+
const args = operation.arguments.map((argument) => valueNode(argument.value));
|
|
986
|
+
fresh();
|
|
987
|
+
if (operation.hostFrame || program.constructsHostError(operation)) {
|
|
988
|
+
for (const argument of operation.arguments)
|
|
989
|
+
contentReads.push({ body, operation, operand: argument.value });
|
|
990
|
+
const fields = fieldNode(`L|${result}`, unknownField);
|
|
991
|
+
for (const argument of args) {
|
|
992
|
+
solver.copy(argument, fields);
|
|
993
|
+
load(argument, allFields, fields);
|
|
994
|
+
}
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
const construction = program.constructionOf(operation);
|
|
998
|
+
if (!construction) {
|
|
999
|
+
refuse(body, operation, 'constructs an object whose constructor the compiler cannot name');
|
|
1000
|
+
break;
|
|
1001
|
+
}
|
|
1002
|
+
for (const id of construction.constructors)
|
|
1003
|
+
enter(id, { kind: 'outside' }, { args, receiver: out, spread: false, result: null });
|
|
1004
|
+
for (const initializer of construction.initializers) {
|
|
1005
|
+
const value = `${out}|field|${initializer.key}`;
|
|
1006
|
+
enter(initializer.functionId, { kind: 'outside' }, { args: [], receiver: out, spread: false, result: value });
|
|
1007
|
+
store(out, initializer.key, value);
|
|
1008
|
+
}
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
case 'super-initialize': {
|
|
1012
|
+
const constructors = program.superConstructorOf(body);
|
|
1013
|
+
if (!constructors) {
|
|
1014
|
+
refuse(body, operation, 'calls a base constructor the compiler cannot name');
|
|
1015
|
+
break;
|
|
1016
|
+
}
|
|
1017
|
+
const args = operation.arguments.map((argument) => valueNode(argument.value));
|
|
1018
|
+
for (const id of constructors)
|
|
1019
|
+
enter(id, { kind: 'outside' }, { args, receiver: receiverNode(self), spread: false, result: null });
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
case 'call':
|
|
1023
|
+
visitCall(body, operation, out, result);
|
|
1024
|
+
break;
|
|
1025
|
+
default:
|
|
1026
|
+
refuse(body, operation, `performs \`${operation.kind}\`, which a parallel region does not support`);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
const visitCall = (body, operation, out, result) => {
|
|
1031
|
+
const args = operation.arguments.map((argument) => valueNode(argument.value));
|
|
1032
|
+
const receiver = operation.receiver ? valueNode(operation.receiver.value) : null;
|
|
1033
|
+
const spread = operation.argumentsAreSpread === true;
|
|
1034
|
+
const call = { args, receiver, spread, result: out };
|
|
1035
|
+
if (program.regionEntryCall(operation)) {
|
|
1036
|
+
// A region inside a region runs inline, in index order, on the thread
|
|
1037
|
+
// that reached it: its body is one more callee of this one.
|
|
1038
|
+
const body1 = operation.arguments[1];
|
|
1039
|
+
if (body1) {
|
|
1040
|
+
callChecks.push({ body, operation, value: body1.value, what: 'runs a region body the compiler cannot name' });
|
|
1041
|
+
callValue(body, operation, body1.value, { args: [], receiver: null, spread: false, result: null });
|
|
1042
|
+
}
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
const external = program.definitionOf(operation.callee.value);
|
|
1046
|
+
const externalName = external ? program.externalOf(external) : null;
|
|
1047
|
+
if (externalName !== null)
|
|
1048
|
+
return refuse(body, operation, `calls host function ${externalName}, which is not known to be free of shared effects`);
|
|
1049
|
+
const builtin = program.builtinOf(operation);
|
|
1050
|
+
if (builtin?.kind === 'host') {
|
|
1051
|
+
if (!pureHostMember(builtin.protocol, builtin.member))
|
|
1052
|
+
return refuse(body, operation, hostDetail(builtin.protocol, builtin.member));
|
|
1053
|
+
for (const argument of operation.arguments)
|
|
1054
|
+
contentReads.push({ body, operation, operand: argument.value });
|
|
1055
|
+
if (builtin.protocol === 'ObjectConstructor' || builtin.protocol === 'Object')
|
|
1056
|
+
for (const argument of operation.arguments)
|
|
1057
|
+
enumerations.push({ body, operation, value: argument.value });
|
|
1058
|
+
if (out && result !== undefined) {
|
|
1059
|
+
solver.add(out, `L|${result}`);
|
|
1060
|
+
for (const argument of args)
|
|
1061
|
+
load(argument, allFields, fieldNode(`L|${result}`, unknownField));
|
|
1062
|
+
}
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
if (builtin?.kind === 'method') {
|
|
1066
|
+
const self = valueNode(builtin.receiver.value);
|
|
1067
|
+
const writes = builtin.carrier === 'keyed-collection' ? collectionWrites.has(builtin.member) : arrayWrites.has(builtin.member);
|
|
1068
|
+
if (writes && builtin.carrier !== 'string')
|
|
1069
|
+
requireLocal(body, operation, builtin.receiver, `calls ${builtin.member} on`);
|
|
1070
|
+
contentReads.push({ body, operation, operand: builtin.receiver.value });
|
|
1071
|
+
for (const argument of operation.arguments)
|
|
1072
|
+
contentReads.push({ body, operation, operand: argument.value });
|
|
1073
|
+
const elements = `${out ?? valueNode(`${String(operation.lineage)}|call`)}|elements`;
|
|
1074
|
+
load(self, allFields, elements);
|
|
1075
|
+
for (const argument of args) {
|
|
1076
|
+
if (writes)
|
|
1077
|
+
store(self, unknownField, argument);
|
|
1078
|
+
load(argument, allFields, elements);
|
|
1079
|
+
solver.copy(argument, elements);
|
|
1080
|
+
}
|
|
1081
|
+
if (aliasingReads.has(builtin.member) && out)
|
|
1082
|
+
solver.copy(self, out);
|
|
1083
|
+
else if (out && result !== undefined) {
|
|
1084
|
+
solver.add(out, `L|${result}`);
|
|
1085
|
+
if (builtin.carrier === 'string' || !arrayResultAllocatingReads.has(builtin.member))
|
|
1086
|
+
solver.copy(elements, out);
|
|
1087
|
+
solver.copy(elements, fieldNode(`L|${result}`, unknownField));
|
|
1088
|
+
solver.copy(elements, fieldNode(`L|${result}`, allFields));
|
|
1089
|
+
}
|
|
1090
|
+
// A callback argument is called with elements, indexes and its own
|
|
1091
|
+
// results (`reduce`'s accumulator): every parameter may hold any of them.
|
|
1092
|
+
operation.arguments.forEach((argument) => {
|
|
1093
|
+
if (!isCallableCarrier(argument.representation))
|
|
1094
|
+
return;
|
|
1095
|
+
callChecks.push({ body, operation, value: argument.value, what: `passes ${builtin.member} a callback the compiler cannot name` });
|
|
1096
|
+
solver.on(valueNode(argument.value), (object) => {
|
|
1097
|
+
const site = closureSites.get(object);
|
|
1098
|
+
const functions = site ? [site.functionId] : object === shared ? globalFunctions(argument.value).functions : [];
|
|
1099
|
+
if (object === shared && globalFunctions(argument.value).unknown)
|
|
1100
|
+
return refuse(body, operation, `passes ${builtin.member} a callback the compiler cannot trace to its definitions`);
|
|
1101
|
+
const how = site ? { kind: 'closure', allocator: site.allocator } : { kind: 'outside' };
|
|
1102
|
+
for (const functionId of functions) {
|
|
1103
|
+
enter(functionId, how, { args: [], receiver: null, spread: false, result: elements });
|
|
1104
|
+
for (const callee of program.bodiesOf(functionId))
|
|
1105
|
+
solver.copy(elements, parameterNode(callee.sourceOwner, '*'));
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
const stated = statedCallees(operation, program);
|
|
1112
|
+
if (stated.length > 0) {
|
|
1113
|
+
// A closure the region allocated keeps its own captures when the sealed
|
|
1114
|
+
// facts name it too: the local entry is the more precise of the two.
|
|
1115
|
+
const callee = valueNode(operation.callee.value);
|
|
1116
|
+
solver.on(callee, (object) => {
|
|
1117
|
+
const site = closureSites.get(object);
|
|
1118
|
+
if (site && stated.includes(site.functionId))
|
|
1119
|
+
enter(site.functionId, { kind: 'closure', allocator: site.allocator }, call);
|
|
1120
|
+
});
|
|
1121
|
+
let outside = false;
|
|
1122
|
+
settlers.push(() => {
|
|
1123
|
+
if (outside)
|
|
1124
|
+
return;
|
|
1125
|
+
const objects = [...solver.of(callee)];
|
|
1126
|
+
if (objects.length > 0 && objects.every((object) => closureSites.has(object)))
|
|
1127
|
+
return;
|
|
1128
|
+
outside = true;
|
|
1129
|
+
for (const id of stated)
|
|
1130
|
+
enter(id, { kind: 'outside' }, call);
|
|
1131
|
+
});
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
if (operation.target?.kind === 'virtual' || operation.target?.kind === 'union-arm')
|
|
1135
|
+
return refuse(body, operation, 'calls a method whose implementation the compiler cannot name');
|
|
1136
|
+
callChecks.push({ body, operation, value: operation.callee.value, what: 'calls a function the compiler cannot name' });
|
|
1137
|
+
callValue(body, operation, operation.callee.value, call);
|
|
1138
|
+
};
|
|
1139
|
+
enter(entryId, { kind: 'outside' }, { args: [], receiver: null, spread: false, result: null });
|
|
1140
|
+
do {
|
|
1141
|
+
solver.solve();
|
|
1142
|
+
for (const settle of settlers)
|
|
1143
|
+
settle();
|
|
1144
|
+
} while (solver.busy);
|
|
1145
|
+
for (const check of writeChecks) {
|
|
1146
|
+
const objects = solver.of(valueNode(check.value));
|
|
1147
|
+
if (objects.size === 0)
|
|
1148
|
+
refuse(check.body, check.operation, `${check.what} an object the compiler cannot trace`);
|
|
1149
|
+
else if (objects.has(shared))
|
|
1150
|
+
refuse(check.body, check.operation, `${check.what} an object that existed before the parallel region`);
|
|
1151
|
+
}
|
|
1152
|
+
for (const check of callChecks)
|
|
1153
|
+
if (solver.of(valueNode(check.value)).size === 0)
|
|
1154
|
+
refuse(check.body, check.operation, check.what);
|
|
1155
|
+
for (const check of enumerations) {
|
|
1156
|
+
const objects = solver.of(valueNode(check.value));
|
|
1157
|
+
if (objects.size === 0 || objects.has(shared))
|
|
1158
|
+
refuse(check.body, check.operation, 'enumerates the keys of an object that existed before the parallel region');
|
|
1159
|
+
}
|
|
1160
|
+
// The disjoint-slot write is sound only if no task reads the array another
|
|
1161
|
+
// task is filling: the slots a write may target, against every read the
|
|
1162
|
+
// region makes of a pre-existing object.
|
|
1163
|
+
const targets = new Set();
|
|
1164
|
+
for (const write of disjointWrites)
|
|
1165
|
+
for (const object of global.of(valueNode(write.receiver)))
|
|
1166
|
+
targets.add(object);
|
|
1167
|
+
if (targets.has(top))
|
|
1168
|
+
for (const write of disjointWrites)
|
|
1169
|
+
refuse(write.body, write.operation, 'writes a task-indexed slot of an array the compiler cannot trace');
|
|
1170
|
+
const writeReceivers = new Set(disjointWrites.map((write) => write.receiver));
|
|
1171
|
+
const escapedObjects = global.of('ESC');
|
|
1172
|
+
const targetEscaped = [...targets].some((object) => escapedObjects.has(object));
|
|
1173
|
+
if (targets.size > 0)
|
|
1174
|
+
for (const read of contentReads) {
|
|
1175
|
+
const region = solver.of(valueNode(read.operand));
|
|
1176
|
+
if (writeReceivers.has(read.operand) || (region.size > 0 && !region.has(shared)))
|
|
1177
|
+
continue;
|
|
1178
|
+
const objects = global.of(valueNode(read.operand));
|
|
1179
|
+
// `TOP` is an object only code the analysis cannot see holds, and such
|
|
1180
|
+
// code can only have been handed an escaped one.
|
|
1181
|
+
if ([...objects].some((object) => (object === top ? targetEscaped : targets.has(object))))
|
|
1182
|
+
refuse(read.body, read.operation, 'reads an array whose slots the tasks of this region are writing');
|
|
1183
|
+
}
|
|
1184
|
+
return { refusals, entries };
|
|
1185
|
+
};
|
|
1186
|
+
const isCallableCarrier = (representation) => {
|
|
1187
|
+
const kind = carrierOf(representation).kind;
|
|
1188
|
+
return kind === 'function' || kind === 'function-family' || kind === 'function-value-dispatch' || kind === 'function-value-family';
|
|
1189
|
+
};
|
|
1190
|
+
/**
|
|
1191
|
+
* `slots[index] = value` in the region entry itself, where `index` is the
|
|
1192
|
+
* entry's own task index: a binding written once, from the entry's first
|
|
1193
|
+
* parameter, and never again anywhere. Distinct tasks have distinct indexes,
|
|
1194
|
+
* so no two tasks ever write one slot; the runtime refuses a write that would
|
|
1195
|
+
* grow the array, which is what keeps every other slot where it is.
|
|
1196
|
+
*/
|
|
1197
|
+
const isDisjointSlotWrite = (program, body, entry, operation) => {
|
|
1198
|
+
if (body !== entry)
|
|
1199
|
+
return false;
|
|
1200
|
+
if (carrierOf(operation.receiver.representation).kind !== 'array-object')
|
|
1201
|
+
return false;
|
|
1202
|
+
const key = program.definitionOf(operation.key.value);
|
|
1203
|
+
if (!key || key.kind !== 'binding-read')
|
|
1204
|
+
return false;
|
|
1205
|
+
const writers = program.writersOf(key.declaration);
|
|
1206
|
+
if (writers.size !== 1 || !writers.has(entry))
|
|
1207
|
+
return false;
|
|
1208
|
+
const writes = operationsOf(entry).filter((site) => site.kind === 'binding-write' && site.declaration === key.declaration);
|
|
1209
|
+
if (writes.length !== 1 || writes[0].kind !== 'binding-write')
|
|
1210
|
+
return false;
|
|
1211
|
+
const value = program.definitionOf(writes[0].value.value);
|
|
1212
|
+
return value?.kind === 'parameter' && value.ordinal === 0 && program.bodyOfValue(writes[0].value.value) === entry;
|
|
1213
|
+
};
|
|
1214
|
+
/**
|
|
1215
|
+
* The accessor a constant-key member access on a class instance runs, when the
|
|
1216
|
+
* key names one: `null` for a plain field or method. An accessor some subclass
|
|
1217
|
+
* overrides answers `'family'`, which the caller refuses rather than guess at.
|
|
1218
|
+
*/
|
|
1219
|
+
const accessorOf = (input, receiver, key, internal) => {
|
|
1220
|
+
const carrier = carrierOf(receiver);
|
|
1221
|
+
if (carrier.kind !== 'class-ref')
|
|
1222
|
+
return null;
|
|
1223
|
+
const member = classMemberOf(input.classes, carrier.declaration, key);
|
|
1224
|
+
if (member?.kind !== 'accessor')
|
|
1225
|
+
return null;
|
|
1226
|
+
if (classFamilyOverridesOf(input.classes, carrier.declaration, key).length > 0)
|
|
1227
|
+
return 'family';
|
|
1228
|
+
return (internal === 'get' ? member.accessor.getter : member.accessor.setter) ?? 'family';
|
|
1229
|
+
};
|
|
1230
|
+
const declarationName = (input, declaration) => {
|
|
1231
|
+
const placement = input.placements.get(declaration);
|
|
1232
|
+
if (placement?.storage.kind === 'external')
|
|
1233
|
+
return placement.storage.linkageName;
|
|
1234
|
+
return input.nameOfDeclaration?.(declaration) ?? String(declaration);
|
|
1235
|
+
};
|
|
1236
|
+
/**
|
|
1237
|
+
* Every refusal the program's parallel regions earn, or none for a program
|
|
1238
|
+
* that has no region entry -- the overwhelmingly common case, which costs one
|
|
1239
|
+
* scan for the entry call.
|
|
1240
|
+
*/
|
|
1241
|
+
export const parallelRegionRefusalsOf = (input) => {
|
|
1242
|
+
if (input.entries.size === 0)
|
|
1243
|
+
return [];
|
|
1244
|
+
const program = programOf(input);
|
|
1245
|
+
const sites = [];
|
|
1246
|
+
for (const body of input.bodies.values())
|
|
1247
|
+
for (const operation of operationsOf(body))
|
|
1248
|
+
if (operation.kind === 'call' && program.regionEntryCall(operation))
|
|
1249
|
+
sites.push({ body, operation });
|
|
1250
|
+
if (sites.length === 0)
|
|
1251
|
+
return [];
|
|
1252
|
+
const global = globalPointsTo(input, program);
|
|
1253
|
+
const refusals = [];
|
|
1254
|
+
const regionEntries = new Set();
|
|
1255
|
+
for (const site of sites) {
|
|
1256
|
+
const argument = site.operation.arguments[1];
|
|
1257
|
+
if (!argument)
|
|
1258
|
+
continue;
|
|
1259
|
+
for (const object of global.of(valueNode(argument.value))) {
|
|
1260
|
+
const functionId = functionOf(object);
|
|
1261
|
+
if (functionId)
|
|
1262
|
+
for (const body of program.bodiesOf(functionId))
|
|
1263
|
+
regionEntries.add(body);
|
|
1264
|
+
else if (object === top)
|
|
1265
|
+
refusals.push({
|
|
1266
|
+
owner: String(site.body.sourceOwner),
|
|
1267
|
+
site: site.operation,
|
|
1268
|
+
detail: 'runs a region body the compiler cannot trace to its definition'
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
for (const entry of regionEntries)
|
|
1273
|
+
refusals.push(...certifyRegion(input, program, global, entry));
|
|
1274
|
+
return refusals;
|
|
1275
|
+
};
|
|
1276
|
+
/**
|
|
1277
|
+
* Runs the region instance to a fixed point of its own capture assumption.
|
|
1278
|
+
* The pessimistic start (no capture is the region's) is always sound; each
|
|
1279
|
+
* round admits the captures every observed entry proves local, and a round
|
|
1280
|
+
* that changes nothing is the answer. A run that never settles falls back to
|
|
1281
|
+
* the pessimistic one.
|
|
1282
|
+
*/
|
|
1283
|
+
const certifyRegion = (input, program, global, entry) => {
|
|
1284
|
+
const pessimistic = runRegion(input, program, global, entry, new Map());
|
|
1285
|
+
let assumption = new Map();
|
|
1286
|
+
let run = pessimistic;
|
|
1287
|
+
for (let round = 0; round < 8; round++) {
|
|
1288
|
+
const next = localCapturesOf(input, program, run.entries, assumption);
|
|
1289
|
+
if (sameAssumption(next, assumption))
|
|
1290
|
+
return run.refusals;
|
|
1291
|
+
assumption = next;
|
|
1292
|
+
run = runRegion(input, program, global, entry, assumption);
|
|
1293
|
+
}
|
|
1294
|
+
return pessimistic.refusals;
|
|
1295
|
+
};
|
|
1296
|
+
const localCapturesOf = (input, program, entries, previous) => {
|
|
1297
|
+
const next = new Map();
|
|
1298
|
+
for (const [functionId, list] of entries) {
|
|
1299
|
+
const bodies = program.bodiesOf(functionId);
|
|
1300
|
+
const captured = new Set(bodies.flatMap((body) => body.facts?.capturedDeclarations ?? []));
|
|
1301
|
+
const admittedPerEntry = [];
|
|
1302
|
+
for (const how of list) {
|
|
1303
|
+
const admitted = new Set();
|
|
1304
|
+
if (how.kind === 'closure') {
|
|
1305
|
+
const allocator = how.allocator.sourceOwner;
|
|
1306
|
+
const allocatorLocal = previous.get(allocator) ?? new Set();
|
|
1307
|
+
const allocatorCaptured = new Set(how.allocator.facts?.capturedDeclarations ?? []);
|
|
1308
|
+
for (const declaration of captured) {
|
|
1309
|
+
const placement = input.placements.get(declaration);
|
|
1310
|
+
const ownedByAllocator = placement?.storage.kind === 'local' && placement.storage.owner === allocator && !allocatorCaptured.has(declaration);
|
|
1311
|
+
if (ownedByAllocator || allocatorLocal.has(declaration))
|
|
1312
|
+
admitted.add(declaration);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
admittedPerEntry.push(admitted);
|
|
1316
|
+
}
|
|
1317
|
+
const [first, ...rest] = admittedPerEntry;
|
|
1318
|
+
next.set(functionId, new Set([...(first ?? [])].filter((declaration) => rest.every((admitted) => admitted.has(declaration)))));
|
|
1319
|
+
}
|
|
1320
|
+
return next;
|
|
1321
|
+
};
|
|
1322
|
+
const sameAssumption = (left, right) => {
|
|
1323
|
+
const keys = new Set([...left.keys(), ...right.keys()]);
|
|
1324
|
+
for (const key of keys) {
|
|
1325
|
+
const a = left.get(key) ?? new Set();
|
|
1326
|
+
const b = right.get(key) ?? new Set();
|
|
1327
|
+
if (a.size !== b.size || [...a].some((declaration) => !b.has(declaration)))
|
|
1328
|
+
return false;
|
|
1329
|
+
}
|
|
1330
|
+
return true;
|
|
1331
|
+
};
|