@scriptc/compiler 0.4.7 → 0.4.8
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/ambient/node-fallback/child_process.d.ts +71 -22
- package/ambient/node-fallback/crypto.d.ts +15 -7
- package/ambient/node-fallback/events.d.ts +23 -5
- package/ambient/node-fallback/fs.d.ts +3 -2
- package/ambient/node-fallback/http.d.ts +23 -17
- package/ambient/node-fallback/https.d.ts +5 -2
- package/ambient/node-fallback/net.d.ts +6 -0
- package/ambient/node-fallback/os.d.ts +11 -1
- package/ambient/node-fallback/path-posix.d.ts +6 -0
- package/ambient/node-fallback/path-win32.d.ts +5 -0
- package/ambient/node-fallback/path.d.ts +2 -0
- package/ambient/node-fallback/zlib.d.ts +31 -2
- package/ambient/scriptc-node-fallback.d.ts +37 -7
- package/ambient/scriptc.d.ts +7 -2
- package/dist/backend/executable-features.js +11 -3
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/library-pack.d.ts +6 -0
- package/dist/backend/library-pack.js +17 -6
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/library-pack.test.d.ts +1 -0
- package/dist/backend/library-pack.test.js +28 -0
- package/dist/backend/library-pack.test.js.map +1 -0
- package/dist/backend/linker.d.ts +9 -2
- package/dist/backend/linker.js +190 -32
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +8 -4
- package/dist/backend/lld.js +19 -13
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +3 -1
- package/dist/backend/lld.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -2
- package/dist/backend/llvm/alloc.js +172 -36
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +69 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/arenas.d.ts +17 -4
- package/dist/backend/llvm/arenas.js +105 -10
- package/dist/backend/llvm/arenas.js.map +1 -1
- package/dist/backend/llvm/arenas.test.js +229 -0
- package/dist/backend/llvm/arenas.test.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.js +10 -1
- package/dist/backend/llvm/bytes-alias.js.map +1 -1
- package/dist/backend/llvm/bytes-headers.js +6 -0
- package/dist/backend/llvm/bytes-headers.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.js +10 -0
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -9
- package/dist/backend/llvm/classes.js +142 -37
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +42 -0
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
- package/dist/backend/llvm/cpu-dispatch.js +31 -7
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +12 -3
- package/dist/backend/llvm/dyn.js +31 -7
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +67 -4
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +90 -39
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.d.ts +1 -0
- package/dist/backend/llvm/emit-module.test.js +52 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -0
- package/dist/backend/llvm/emit-statements.js +99 -15
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +113 -8
- package/dist/backend/llvm/emitter.js +438 -67
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +31 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +19 -1
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +16 -1
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +18 -2
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +31 -10
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +31 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +1 -1
- package/dist/backend/llvm/expr-records.js +124 -56
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +17 -0
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/js-groups.d.ts +21 -0
- package/dist/backend/llvm/js-groups.js +277 -0
- package/dist/backend/llvm/js-groups.js.map +1 -0
- package/dist/backend/llvm/js-ic.d.ts +19 -1
- package/dist/backend/llvm/js-ic.js +96 -23
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +132 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +33 -6
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +44 -3
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +69 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +32 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-state.js +7 -2
- package/dist/backend/llvm/loop-state.js.map +1 -1
- package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
- package/dist/backend/llvm/map-entry-fusion.js +3 -3
- package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +6 -6
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +7 -6
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.test.js +4 -1
- package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
- package/dist/backend/llvm/receivers.js +3 -0
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
- package/dist/backend/llvm/record-entry-fusion.js +217 -0
- package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
- package/dist/backend/llvm/record-results.d.ts +5 -2
- package/dist/backend/llvm/record-results.js +13 -12
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/record-views.js +12 -6
- package/dist/backend/llvm/record-views.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +1 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +3 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-ir.js +1 -0
- package/dist/backend/llvm/region-ir.js.map +1 -1
- package/dist/backend/llvm/region-sites.d.ts +18 -0
- package/dist/backend/llvm/region-sites.js +79 -1
- package/dist/backend/llvm/region-sites.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +53 -6
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +33 -3
- package/dist/backend/llvm/shapes.js +183 -13
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +1 -2
- package/dist/backend/llvm/stack-objects.js +8 -5
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +12 -0
- package/dist/backend/llvm/walkers.js +46 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +12 -2
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +13 -0
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +48 -8
- package/dist/backend/native/executable.js +55 -13
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/helper-identity-record.d.ts +11 -0
- package/dist/backend/native/helper-identity-record.js +76 -0
- package/dist/backend/native/helper-identity-record.js.map +1 -0
- package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
- package/dist/backend/native/helper-identity-record.test.js +101 -0
- package/dist/backend/native/helper-identity-record.test.js.map +1 -0
- package/dist/backend/native/library.js +9 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +4 -1
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +13 -10
- package/dist/backend/native-codegen-core.js +26 -13
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.js +27 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +110 -14
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +37 -8
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/runtime-pack-core.d.ts +17 -2
- package/dist/backend/runtime-pack-core.js +18 -3
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +211 -2
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/tree-classes.d.ts +42 -0
- package/dist/backend/tree-classes.js +723 -0
- package/dist/backend/tree-classes.js.map +1 -0
- package/dist/backend/tree-classes.test.d.ts +1 -0
- package/dist/backend/tree-classes.test.js +338 -0
- package/dist/backend/tree-classes.test.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +5 -1
- package/dist/backend/vendor-archives.js +51 -7
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +25 -4
- package/dist/backend/vendor-inputs.js +68 -4
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +35 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +1 -1
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.js +2 -2
- package/dist/coverage/report.js +47 -0
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/diagnostics/codes.d.ts +8 -0
- package/dist/diagnostics/codes.js +8 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +27 -9
- package/dist/diagnostics/diagnostic.js +60 -19
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +18 -0
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +21 -2
- package/dist/executable/executable-cache.js +21 -1
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +123 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +199 -248
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +200 -18
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +4 -0
- package/dist/frontend/builtin-modules.js +10 -0
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/early-errors.d.ts +12 -2
- package/dist/frontend/early-errors.js +535 -4
- package/dist/frontend/early-errors.js.map +1 -1
- package/dist/frontend/early-errors.test.js +165 -0
- package/dist/frontend/early-errors.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +65 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
- package/dist/frontend/jsx-opinion-sites.test.js +86 -0
- package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
- package/dist/frontend/lib-exports.d.ts +23 -4
- package/dist/frontend/lib-exports.js +98 -26
- package/dist/frontend/lib-exports.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.js +21 -3
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/buffers.d.ts +8 -0
- package/dist/frontend/lowering/buffers.js +43 -0
- package/dist/frontend/lowering/buffers.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.js +4 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
- package/dist/frontend/lowering/builtin-namespaces.js +24 -3
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
- package/dist/frontend/lowering/builtin-statics.js +407 -0
- package/dist/frontend/lowering/builtin-statics.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
- package/dist/frontend/lowering/builtins/arguments.js +12 -0
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
- package/dist/frontend/lowering/builtins/atomics.js +87 -1
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.js +2 -2
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
- package/dist/frontend/lowering/builtins/child-process.js +560 -27
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
- package/dist/frontend/lowering/builtins/compression.js +41 -21
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +7 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +28 -2
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +4 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +3 -1
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
- package/dist/frontend/lowering/builtins/numbers.js +10 -2
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +6 -3
- package/dist/frontend/lowering/builtins/operating-system.js +96 -16
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +2 -2
- package/dist/frontend/lowering/builtins/process.js +103 -8
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +169 -8
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.js +6 -2
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
- package/dist/frontend/lowering/builtins/readline.js +180 -36
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +35 -12
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/webassembly.js +2 -0
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +10 -0
- package/dist/frontend/lowering/call-arguments.js +37 -2
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +10 -0
- package/dist/frontend/lowering/call-signatures.js +103 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +14 -2
- package/dist/frontend/lowering/class-construction.js +99 -5
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +9 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1283 -1030
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +20 -15
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +20 -1
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +21 -4
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +9 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +8 -0
- package/dist/frontend/lowering/coercions/state.js +17 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +20 -5
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +10 -1
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
- package/dist/frontend/lowering/coercions/unions.js +54 -10
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
- package/dist/frontend/lowering/constructor-returns.js +284 -58
- package/dist/frontend/lowering/constructor-returns.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +156 -62
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +21 -3
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.js +139 -3
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
- package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
- package/dist/frontend/lowering/containers/array-iteration.js +24 -7
- package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +14 -11
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
- package/dist/frontend/lowering/containers/bytes.js +446 -86
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +5 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +21 -12
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +52 -17
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
- package/dist/frontend/lowering/crypto-tables.js +5 -5
- package/dist/frontend/lowering/dispatch-sites.js +3 -0
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
- package/dist/frontend/lowering/divergences.d.ts +40 -0
- package/dist/frontend/lowering/divergences.js +239 -20
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/effect-free.d.ts +12 -0
- package/dist/frontend/lowering/effect-free.js +44 -0
- package/dist/frontend/lowering/effect-free.js.map +1 -0
- package/dist/frontend/lowering/expressions/array-literals.d.ts +10 -0
- package/dist/frontend/lowering/expressions/array-literals.js +62 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +115 -5
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +151 -7
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +31 -2
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
- package/dist/frontend/lowering/expressions/narrowing.js +175 -22
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +173 -11
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +5 -1
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +8 -0
- package/dist/frontend/lowering/expressions/property-access.js +379 -109
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +237 -7
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +8 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
- package/dist/frontend/lowering/expressions/union-fields.js +103 -13
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +74 -55
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +37 -10
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/general-streams.js +5 -0
- package/dist/frontend/lowering/general-streams.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
- package/dist/frontend/lowering/generator-delegation.js +301 -118
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +27 -1
- package/dist/frontend/lowering/generic-functions.js +432 -18
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-function-values.d.ts +25 -0
- package/dist/frontend/lowering/global-function-values.js +193 -0
- package/dist/frontend/lowering/global-function-values.js.map +1 -0
- package/dist/frontend/lowering/global-values.d.ts +6 -4
- package/dist/frontend/lowering/global-values.js +24 -10
- package/dist/frontend/lowering/global-values.js.map +1 -1
- package/dist/frontend/lowering/host-global-values.d.ts +31 -0
- package/dist/frontend/lowering/host-global-values.js +121 -0
- package/dist/frontend/lowering/host-global-values.js.map +1 -0
- package/dist/frontend/lowering/host-globals.d.ts +74 -0
- package/dist/frontend/lowering/host-globals.js +344 -0
- package/dist/frontend/lowering/host-globals.js.map +1 -0
- package/dist/frontend/lowering/http2-constants.js +1 -1
- package/dist/frontend/lowering/iterator-adapters.js +46 -17
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
- package/dist/frontend/lowering/iterator-prototype.js +160 -0
- package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.js +43 -22
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +1 -0
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +11 -3
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +30 -15
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
- package/dist/frontend/lowering/lower-async-iteration.js +15 -0
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.js +11 -1
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +25 -0
- package/dist/frontend/lowering/lower-calls.js +929 -227
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.js +59 -16
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +20 -0
- package/dist/frontend/lowering/lower-classes.js +468 -44
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -2
- package/dist/frontend/lowering/lower-event-emitter.js +253 -83
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
- package/dist/frontend/lowering/lower-exprs.js +71 -20
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +25 -6
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +57 -10
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
- package/dist/frontend/lowering/lower-global-value.js +14 -5
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
- package/dist/frontend/lowering/lower-inspect.js +638 -64
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +48 -2
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +18 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.js +16 -6
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +303 -87
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +45 -0
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +14 -11
- package/dist/frontend/lowering/lower-stmts.js +270 -52
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +110 -27
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lower-url.js +6 -3
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +227 -21
- package/dist/frontend/lowering/lowerer.js +651 -92
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +18 -0
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
- package/dist/frontend/lowering/lowering-facts.js +323 -0
- package/dist/frontend/lowering/lowering-facts.js.map +1 -0
- package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
- package/dist/frontend/lowering/lowering-facts.test.js +100 -0
- package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
- package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
- package/dist/frontend/lowering/nan-coded-reads.js +112 -9
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
- package/dist/frontend/lowering/optional-arguments.js +26 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.d.ts +0 -3
- package/dist/frontend/lowering/partial-assertions.js +9 -15
- package/dist/frontend/lowering/partial-assertions.js.map +1 -1
- package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
- package/dist/frontend/lowering/primitive-throws.js +241 -0
- package/dist/frontend/lowering/primitive-throws.js.map +1 -0
- package/dist/frontend/lowering/primitive-wrappers.js +1 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
- package/dist/frontend/lowering/record-inherited.d.ts +17 -1
- package/dist/frontend/lowering/record-inherited.js +16 -2
- package/dist/frontend/lowering/record-inherited.js.map +1 -1
- package/dist/frontend/lowering/record-links.d.ts +73 -0
- package/dist/frontend/lowering/record-links.js +797 -0
- package/dist/frontend/lowering/record-links.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
- package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
- package/dist/frontend/lowering/runtime-optional-report.js +300 -0
- package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +3 -1
- package/dist/frontend/lowering/static-typeof.js +6 -1
- package/dist/frontend/lowering/static-typeof.js.map +1 -1
- package/dist/frontend/lowering/strict-mode.d.ts +1 -5
- package/dist/frontend/lowering/strict-mode.js +4 -30
- package/dist/frontend/lowering/strict-mode.js.map +1 -1
- package/dist/frontend/lowering/structural-instances.d.ts +7 -0
- package/dist/frontend/lowering/structural-instances.js +23 -0
- package/dist/frontend/lowering/structural-instances.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +15 -1
- package/dist/frontend/lowering/surfaces.js +78 -10
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +13 -1
- package/dist/frontend/lowering/union-retag.js +55 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +51 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +8 -0
- package/dist/frontend/lowering/unit-journal.js +14 -0
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +36 -1
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/zlib-constants.js +3 -2
- package/dist/frontend/lowering/zlib-constants.js.map +1 -1
- package/dist/frontend/npm-static.js +78 -9
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm-static.test.js +95 -2
- package/dist/frontend/npm-static.test.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +5 -4
- package/dist/frontend/pipeline.js +94 -31
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +68 -11
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program.d.ts +62 -2
- package/dist/frontend/program.js +695 -422
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +37 -1
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/services-node.d.ts +7 -0
- package/dist/frontend/services-node.js +32 -1
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services-node.test.js +51 -0
- package/dist/frontend/services-node.test.js.map +1 -1
- package/dist/frontend/shape-inference/overlay.js +68 -2
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- package/dist/frontend/tier-analysis.d.ts +9 -0
- package/dist/frontend/tier-analysis.js +1 -0
- package/dist/frontend/tier-analysis.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +57 -3
- package/dist/frontend/tsc-codes.js +935 -150
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/tsc-codes.test.js +221 -12
- package/dist/frontend/tsc-codes.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +91 -9
- package/dist/frontend/type-mapper.js +622 -181
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +80 -15
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +60 -0
- package/dist/index.test.js.map +1 -0
- package/dist/ir/builtin-effects.js +43 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +242 -16
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +3 -2
- package/dist/ir/callback-specialization.js +35 -25
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/capture-values.d.ts +8 -4
- package/dist/ir/capture-values.js +9 -6
- package/dist/ir/capture-values.js.map +1 -1
- package/dist/ir/char-unit-locals.d.ts +6 -2
- package/dist/ir/char-unit-locals.js +11 -2
- package/dist/ir/char-unit-locals.js.map +1 -1
- package/dist/ir/class-key-index.d.ts +18 -0
- package/dist/ir/class-key-index.js +29 -0
- package/dist/ir/class-key-index.js.map +1 -0
- package/dist/ir/class-key-index.test.d.ts +1 -0
- package/dist/ir/class-key-index.test.js +25 -0
- package/dist/ir/class-key-index.test.js.map +1 -0
- package/dist/ir/codec.generated.d.ts +1 -1
- package/dist/ir/codec.generated.js +724 -648
- package/dist/ir/codec.generated.js.map +1 -1
- package/dist/ir/constant-globals.d.ts +5 -2
- package/dist/ir/constant-globals.js +25 -27
- package/dist/ir/constant-globals.js.map +1 -1
- package/dist/ir/expression-inlining.d.ts +4 -2
- package/dist/ir/expression-inlining.js +8 -2
- package/dist/ir/expression-inlining.js.map +1 -1
- package/dist/ir/field-values.d.ts +5 -2
- package/dist/ir/field-values.js +32 -21
- package/dist/ir/field-values.js.map +1 -1
- package/dist/ir/fields.generated.d.ts +11 -2
- package/dist/ir/fields.generated.js +8 -0
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/final-fields.js +1 -1
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.d.ts +5 -4
- package/dist/ir/function-references.js +7 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +7 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/init-only-globals.d.ts +4 -2
- package/dist/ir/init-only-globals.js +17 -18
- package/dist/ir/init-only-globals.js.map +1 -1
- package/dist/ir/inline-array-views.js +1 -0
- package/dist/ir/inline-array-views.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/ir.d.ts +59 -4
- package/dist/ir/ir.js +7 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-groups.d.ts +51 -0
- package/dist/ir/js-groups.js +394 -0
- package/dist/ir/js-groups.js.map +1 -0
- package/dist/ir/js-groups.test.d.ts +1 -0
- package/dist/ir/js-groups.test.js +555 -0
- package/dist/ir/js-groups.test.js.map +1 -0
- package/dist/ir/js-ic.js +30 -5
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +27 -1
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/node-index.d.ts +23 -6
- package/dist/ir/node-index.js +126 -49
- package/dist/ir/node-index.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +4 -2
- package/dist/ir/numeric-call-specialization.js +40 -26
- package/dist/ir/numeric-call-specialization.js.map +1 -1
- package/dist/ir/paired-while-loops.d.ts +4 -2
- package/dist/ir/paired-while-loops.js +8 -2
- package/dist/ir/paired-while-loops.js.map +1 -1
- package/dist/ir/parameter-versions.d.ts +13 -4
- package/dist/ir/parameter-versions.js +63 -42
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/property-bags.d.ts +4 -2
- package/dist/ir/property-bags.js +22 -17
- package/dist/ir/property-bags.js.map +1 -1
- package/dist/ir/row-pairs.d.ts +4 -2
- package/dist/ir/row-pairs.js +12 -11
- package/dist/ir/row-pairs.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +87 -12
- package/dist/ir/runtime-features.js +263 -160
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +109 -139
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/runtime-jam-loops.d.ts +35 -0
- package/dist/ir/runtime-jam-loops.js +604 -0
- package/dist/ir/runtime-jam-loops.js.map +1 -0
- package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
- package/dist/ir/runtime-jam-loops.test.js +565 -0
- package/dist/ir/runtime-jam-loops.test.js.map +1 -0
- package/dist/ir/saturating-loop-jams.d.ts +4 -2
- package/dist/ir/saturating-loop-jams.js +11 -10
- package/dist/ir/saturating-loop-jams.js.map +1 -1
- package/dist/ir/scalar-records.d.ts +5 -2
- package/dist/ir/scalar-records.js +12 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/self-captures.d.ts +4 -2
- package/dist/ir/self-captures.js +32 -27
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/serialize.d.ts +6 -1
- package/dist/ir/serialize.js +87 -23
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +26 -0
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/tiers.js +1 -0
- package/dist/ir/tiers.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/typed-argument-clones.d.ts +30 -0
- package/dist/ir/typed-argument-clones.js +789 -0
- package/dist/ir/typed-argument-clones.js.map +1 -0
- package/dist/ir/union-arm-loops.d.ts +3 -0
- package/dist/ir/union-arm-loops.js +373 -0
- package/dist/ir/union-arm-loops.js.map +1 -0
- package/dist/ir/union-arm-loops.test.d.ts +1 -0
- package/dist/ir/union-arm-loops.test.js +230 -0
- package/dist/ir/union-arm-loops.test.js.map +1 -0
- package/dist/ir/validate.js +88 -18
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/compiler-self-identity.d.ts +8 -2
- package/dist/library/compiler-self-identity.js +92 -18
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.js +150 -3
- package/dist/library/compiler-self-identity.test.js.map +1 -1
- package/dist/library/int-infer.d.ts +5 -0
- package/dist/library/int-infer.js +15 -3
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.d.ts +4 -0
- package/dist/library/library-cache.js +2 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +26 -0
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/prepare.js +99 -31
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cache.d.ts +7 -0
- package/dist/native/cache.js +47 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +13 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +1 -1
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +18 -3
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache-open.test.js +31 -5
- package/dist/native/executable-cache-open.test.js.map +1 -1
- package/dist/native/executable-cache.d.ts +6 -1
- package/dist/native/executable-cache.js +7 -1
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.d.ts +3 -0
- package/dist/native/prepare.js +43 -26
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +25 -3
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/sanitizer.js +10 -1
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +7 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +12 -0
- package/dist/node-islands/boundary.js +38 -6
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.d.ts +1 -0
- package/dist/node-islands/boundary.test.js +76 -0
- package/dist/node-islands/boundary.test.js.map +1 -0
- package/dist/node-islands/detect.d.ts +9 -0
- package/dist/node-islands/detect.js +110 -0
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +24 -0
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/graph-islands.d.ts +40 -0
- package/dist/node-islands/graph-islands.js +128 -0
- package/dist/node-islands/graph-islands.js.map +1 -0
- package/dist/node-islands/growth.d.ts +57 -0
- package/dist/node-islands/growth.js +205 -0
- package/dist/node-islands/growth.js.map +1 -0
- package/dist/node-islands/report.d.ts +12 -0
- package/dist/node-islands/report.js +28 -0
- package/dist/node-islands/report.js.map +1 -1
- package/dist/node-islands/report.test.js +2 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +5 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +11 -2
- package/dist/node-islands/scan.js +61 -9
- package/dist/node-islands/scan.js.map +1 -1
- package/dist/wasm/translate.js +11 -5
- package/dist/wasm/translate.js.map +1 -1
- package/dist/wasm/translate.test.js +35 -0
- package/dist/wasm/translate.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +184 -117
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
import { BOOL, DYN, F64, VOID, typeKey, } from "./ir.js";
|
|
2
|
+
import { numLit, strLit, varRef } from "./build.js";
|
|
3
|
+
import { everyStmtList, mapExprChildren, mapStmtChildren, transformStmtList } from "./traverse.js";
|
|
4
|
+
import { reparseExpr, reparseStmt } from "./serialize.js";
|
|
5
|
+
import {} from "./node-index.js";
|
|
6
|
+
/** Largest body (IR nodes) a clone is made from. */
|
|
7
|
+
const MAX_FUNCTION_NODES = 300;
|
|
8
|
+
/** Clones of one function: one per parameter and argument type. */
|
|
9
|
+
const MAX_CLONES_PER_FUNCTION = 4;
|
|
10
|
+
/** Module-wide cloned nodes: at least this many, or this share of the module. */
|
|
11
|
+
const MIN_CLONED_NODES = 4000;
|
|
12
|
+
const CLONED_NODE_FRACTION = 0.05;
|
|
13
|
+
/** The dynamic operations that read a value's properties without retaining
|
|
14
|
+
* it or observing its identity, so a capsule built for them is
|
|
15
|
+
* interchangeable with the one the caller passed. */
|
|
16
|
+
const PROPERTY_OBSERVERS = new Set(["dyn.in", "dyn.hasKeyComputed"]);
|
|
17
|
+
/** The conversion calls that wrap a static value before a dynamic store. */
|
|
18
|
+
const STORE_CONVERSIONS = new Set([
|
|
19
|
+
"js.fromF64",
|
|
20
|
+
"js.fromStr",
|
|
21
|
+
"js.fromBool",
|
|
22
|
+
"js.fromBigInt",
|
|
23
|
+
]);
|
|
24
|
+
/** Thrown when the parameter's uses do not fit a clone; a clone that hits
|
|
25
|
+
* one is not made. */
|
|
26
|
+
const NOT_A_CLONE = Symbol("not a clone");
|
|
27
|
+
function reject() {
|
|
28
|
+
throw NOT_A_CLONE;
|
|
29
|
+
}
|
|
30
|
+
function countNodes(fn, index) {
|
|
31
|
+
const recorded = index?.nodeCount(fn);
|
|
32
|
+
if (recorded !== undefined)
|
|
33
|
+
return recorded;
|
|
34
|
+
let count = 0;
|
|
35
|
+
everyStmtList(fn.body, {
|
|
36
|
+
stmt: () => ++count <= MAX_FUNCTION_NODES,
|
|
37
|
+
expr: () => ++count <= MAX_FUNCTION_NODES,
|
|
38
|
+
});
|
|
39
|
+
return count;
|
|
40
|
+
}
|
|
41
|
+
/** The single parameter a dynamic operation reaches through its operand, or
|
|
42
|
+
* null when the operand names none or several. */
|
|
43
|
+
function operandParam(operand, params) {
|
|
44
|
+
let found = null;
|
|
45
|
+
let several = false;
|
|
46
|
+
const visit = (node) => {
|
|
47
|
+
if (node.kind !== "varRef")
|
|
48
|
+
return;
|
|
49
|
+
const index = params.get(node.localId);
|
|
50
|
+
if (index === undefined)
|
|
51
|
+
return;
|
|
52
|
+
if (found === null)
|
|
53
|
+
found = index;
|
|
54
|
+
else if (found !== index)
|
|
55
|
+
several = true;
|
|
56
|
+
};
|
|
57
|
+
walkExpr(operand, visit);
|
|
58
|
+
return several ? null : found;
|
|
59
|
+
}
|
|
60
|
+
/** Calls `visit` on `node` and every expression below it. */
|
|
61
|
+
function walkExpr(node, visit) {
|
|
62
|
+
visit(node);
|
|
63
|
+
mapExprChildren(node, (child) => {
|
|
64
|
+
walkExpr(child, visit);
|
|
65
|
+
return child;
|
|
66
|
+
}, (statement) => {
|
|
67
|
+
walkStmt(statement, visit);
|
|
68
|
+
return statement;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function walkStmt(node, visit) {
|
|
72
|
+
mapStmtChildren(node, (child) => {
|
|
73
|
+
walkExpr(child, visit);
|
|
74
|
+
return child;
|
|
75
|
+
}, (child) => {
|
|
76
|
+
walkStmt(child, visit);
|
|
77
|
+
return child;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/** The key a dynamic operation reads: a constant the helper names, the
|
|
81
|
+
* parameter it passes, or null. */
|
|
82
|
+
function keyOperand(key, params) {
|
|
83
|
+
if (!key)
|
|
84
|
+
return null;
|
|
85
|
+
if (key.kind === "strLit")
|
|
86
|
+
return { literal: key.value };
|
|
87
|
+
return operandParam(key, params);
|
|
88
|
+
}
|
|
89
|
+
/** What `fn` does, when it is one of the dynamic object helpers the
|
|
90
|
+
* frontend emits for a `dyn` receiver (`%dyn.class.*`). The operation is
|
|
91
|
+
* read from the helper's own generic tail — the last dynamic property
|
|
92
|
+
* operation in its body — and its receiver, key and value from the
|
|
93
|
+
* parameters those operands reach, never from the helper's name, because
|
|
94
|
+
* the same name carries different operations in different modules. */
|
|
95
|
+
function propertyOp(fn) {
|
|
96
|
+
if (!fn.name.startsWith("%dyn.class."))
|
|
97
|
+
return null;
|
|
98
|
+
if (fn.captures !== undefined || fn.classCaptures?.length)
|
|
99
|
+
return null;
|
|
100
|
+
const params = new Map(fn.params.map((param, index) => [param.localId, index]));
|
|
101
|
+
let found = null;
|
|
102
|
+
const consider = (node) => {
|
|
103
|
+
const op = operationOf(node, params);
|
|
104
|
+
if (op)
|
|
105
|
+
found = op;
|
|
106
|
+
};
|
|
107
|
+
for (const statement of fn.body)
|
|
108
|
+
walkStmt(statement, consider);
|
|
109
|
+
return found;
|
|
110
|
+
}
|
|
111
|
+
function operationOf(node, params) {
|
|
112
|
+
if (node.kind === "dynKeyGet") {
|
|
113
|
+
const receiver = operandParam(node.value, params);
|
|
114
|
+
if (receiver === null)
|
|
115
|
+
return null;
|
|
116
|
+
const key = keyOperand(node.key, params);
|
|
117
|
+
return key === null ? null : { kind: "get", receiver, key, loc: node.loc };
|
|
118
|
+
}
|
|
119
|
+
if (node.kind !== "libCall")
|
|
120
|
+
return null;
|
|
121
|
+
const args = node.args;
|
|
122
|
+
const receiver = args[0] === undefined ? null : operandParam(args[0], params);
|
|
123
|
+
if (receiver === null)
|
|
124
|
+
return null;
|
|
125
|
+
if (node.fn === "dyn.keySet" || node.fn === "dyn.keySetComputed") {
|
|
126
|
+
const key = keyOperand(args[1], params);
|
|
127
|
+
const value = args[2] === undefined ? null : operandParam(args[2], params);
|
|
128
|
+
if (key === null || value === null)
|
|
129
|
+
return null;
|
|
130
|
+
return { kind: "set", receiver, key, value, loc: node.loc };
|
|
131
|
+
}
|
|
132
|
+
if (node.fn === "dyn.in" || node.fn === "dyn.hasKeyComputed" || node.fn === "dyn.hasOwnComputed")
|
|
133
|
+
return { kind: "has", receiver, key: keyOperand(args[1], params), loc: node.loc };
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
/** The record shapes a partial record assertion names: a value asserted to
|
|
137
|
+
* one may lack fields the shape declares (`{ hits: 1 } as Stats`), and the
|
|
138
|
+
* runtime answers a partial view whose absent fields a typed read throws on
|
|
139
|
+
* (record-views.ts). The helper's read of such a field is a dynamic read,
|
|
140
|
+
* which answers undefined as JavaScript does, so a clone — whose read is a
|
|
141
|
+
* typed one — would change the program's answer. Calls that pass one of
|
|
142
|
+
* these shapes keep the original function. */
|
|
143
|
+
function partialAssertionTargets(mod) {
|
|
144
|
+
const targets = new Set();
|
|
145
|
+
for (const fn of mod.functions)
|
|
146
|
+
everyStmtList(fn.body, {
|
|
147
|
+
stmt: () => true,
|
|
148
|
+
expr: (expr) => {
|
|
149
|
+
if (expr.kind === "dynCheck" && expr.partialView === true && expr.type.kind === "record")
|
|
150
|
+
targets.add(expr.type.shapeId);
|
|
151
|
+
return true;
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
return targets;
|
|
155
|
+
}
|
|
156
|
+
/** The helper bodies' shapes, by helper name. */
|
|
157
|
+
function helperOperations(mod) {
|
|
158
|
+
const ops = new Map();
|
|
159
|
+
for (const fn of mod.functions) {
|
|
160
|
+
const op = propertyOp(fn);
|
|
161
|
+
if (op)
|
|
162
|
+
ops.set(fn.name, op);
|
|
163
|
+
}
|
|
164
|
+
return ops;
|
|
165
|
+
}
|
|
166
|
+
/** The locals that hold the parameter `paramIndex` and nothing else: the
|
|
167
|
+
* parameter itself and every local whose every definition copies one of
|
|
168
|
+
* them. A cast that lowers to a plain copy (`const r = x as any`) is one of
|
|
169
|
+
* these; a local written by anything else is not. Null when the parameter
|
|
170
|
+
* or a copy can be observed through a closure. */
|
|
171
|
+
function receiverLocals(fn, paramIndex) {
|
|
172
|
+
const param = fn.params[paramIndex];
|
|
173
|
+
const types = new Map(fn.locals.map((local) => [local.id, local]));
|
|
174
|
+
const definitions = new Map();
|
|
175
|
+
const otherWrites = new Set();
|
|
176
|
+
const captured = new Set();
|
|
177
|
+
const note = (id, value) => {
|
|
178
|
+
if (value === null) {
|
|
179
|
+
otherWrites.add(id);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const list = definitions.get(id);
|
|
183
|
+
if (list === undefined)
|
|
184
|
+
definitions.set(id, [value]);
|
|
185
|
+
else
|
|
186
|
+
list.push(value);
|
|
187
|
+
};
|
|
188
|
+
for (const statement of fn.body) {
|
|
189
|
+
walkStmt(statement, (node) => {
|
|
190
|
+
if (node.kind !== "closure")
|
|
191
|
+
return;
|
|
192
|
+
for (const id of node.captures)
|
|
193
|
+
captured.add(id);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// A write can sit at any depth of an expression, so every expression
|
|
197
|
+
// below a statement is walked: an assignment the clone would leave in
|
|
198
|
+
// place stores a dynamic value into the record-typed local.
|
|
199
|
+
const scanExpr = (node) => {
|
|
200
|
+
if (node.kind === "assignExpr" || node.kind === "incDec")
|
|
201
|
+
note(node.localId, null);
|
|
202
|
+
mapExprChildren(node, (child) => {
|
|
203
|
+
scanExpr(child);
|
|
204
|
+
return child;
|
|
205
|
+
}, (child) => {
|
|
206
|
+
scan(child);
|
|
207
|
+
return child;
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
const scan = (statement) => {
|
|
211
|
+
if (statement.kind === "varDecl")
|
|
212
|
+
note(statement.localId, statement.init);
|
|
213
|
+
else if (statement.kind === "assign")
|
|
214
|
+
note(statement.localId, statement.value);
|
|
215
|
+
else if (statement.kind === "forOf")
|
|
216
|
+
note(statement.localId, null);
|
|
217
|
+
else if (statement.kind === "tryCatch" && statement.catchLocalId !== null)
|
|
218
|
+
note(statement.catchLocalId, null);
|
|
219
|
+
mapStmtChildren(statement, (child) => {
|
|
220
|
+
scanExpr(child);
|
|
221
|
+
return child;
|
|
222
|
+
}, (child) => {
|
|
223
|
+
scan(child);
|
|
224
|
+
return child;
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
for (const statement of fn.body)
|
|
228
|
+
scan(statement);
|
|
229
|
+
const members = new Set([param.localId]);
|
|
230
|
+
for (let changed = true; changed;) {
|
|
231
|
+
changed = false;
|
|
232
|
+
for (const [id, list] of definitions) {
|
|
233
|
+
if (members.has(id) || otherWrites.has(id))
|
|
234
|
+
continue;
|
|
235
|
+
const local = types.get(id);
|
|
236
|
+
if (!local || local.type.kind !== "dyn" || local.boxed)
|
|
237
|
+
continue;
|
|
238
|
+
if (!list.length)
|
|
239
|
+
continue;
|
|
240
|
+
if (list.every((value) => value.kind === "varRef" && members.has(value.localId))) {
|
|
241
|
+
members.add(id);
|
|
242
|
+
changed = true;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const paramLocal = types.get(param.localId);
|
|
247
|
+
if (paramLocal?.boxed)
|
|
248
|
+
return null;
|
|
249
|
+
// A parameter that is ever written holds something other than the
|
|
250
|
+
// caller's value by then, so no typed use of it is exact.
|
|
251
|
+
if (otherWrites.has(param.localId) || definitions.has(param.localId))
|
|
252
|
+
return null;
|
|
253
|
+
for (const id of members)
|
|
254
|
+
if (captured.has(id))
|
|
255
|
+
return null;
|
|
256
|
+
return members;
|
|
257
|
+
}
|
|
258
|
+
/** The key a write's source range is listed under in
|
|
259
|
+
* IrModule.sloppyDynWrites. */
|
|
260
|
+
function writeKey(loc) {
|
|
261
|
+
return `${loc.file}\0${loc.start}\0${loc.end}`;
|
|
262
|
+
}
|
|
263
|
+
/** A clone of `origin` in which parameter `paramIndex` is `type`, its
|
|
264
|
+
* dynamic property operations rewritten to typed record operations and
|
|
265
|
+
* every other use taking a capsule built in place. Null when no operation
|
|
266
|
+
* can be rewritten or a use of the parameter is not one the clone keeps
|
|
267
|
+
* exact. */
|
|
268
|
+
function buildClone(context, origin, paramIndex, type) {
|
|
269
|
+
const members = receiverLocals(origin, paramIndex);
|
|
270
|
+
if (members === null)
|
|
271
|
+
return null;
|
|
272
|
+
const declared = context.records.get(type.shapeId);
|
|
273
|
+
if (!declared || declared.tuple)
|
|
274
|
+
return null;
|
|
275
|
+
const shape = declared;
|
|
276
|
+
const extras = [];
|
|
277
|
+
let rewritten = 0;
|
|
278
|
+
const local = (name, localType, loc) => {
|
|
279
|
+
const id = `${name}.${origin.locals.length + extras.length}`;
|
|
280
|
+
extras.push({ id, name, type: localType, mutable: false });
|
|
281
|
+
return varRef(id, localType, loc);
|
|
282
|
+
};
|
|
283
|
+
const capsule = (value, loc) => ({
|
|
284
|
+
kind: "dynFrom",
|
|
285
|
+
value,
|
|
286
|
+
type: DYN,
|
|
287
|
+
liveRef: true,
|
|
288
|
+
loc,
|
|
289
|
+
});
|
|
290
|
+
const typed = (ref) => ({ ...ref, type });
|
|
291
|
+
function field(name) {
|
|
292
|
+
return shape.fields.find((candidate) => candidate.name === name);
|
|
293
|
+
}
|
|
294
|
+
function recordGet(receiver, declared) {
|
|
295
|
+
return {
|
|
296
|
+
kind: "recordGet",
|
|
297
|
+
obj: receiver,
|
|
298
|
+
shapeId: shape.id,
|
|
299
|
+
field: declared.name,
|
|
300
|
+
type: declared.type,
|
|
301
|
+
loc: receiver.loc,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/** The record write, behind the frozen-bit test when the shape has values
|
|
305
|
+
* that can be frozen. A frozen record takes no write: strict-mode code
|
|
306
|
+
* throws Node's TypeError, as the dynamic write this replaces does, and
|
|
307
|
+
* sloppy-mode code leaves the record unchanged. */
|
|
308
|
+
function recordStore(receiver, declared, value, loc, sloppy) {
|
|
309
|
+
const store = (obj, stored) => ({
|
|
310
|
+
kind: "recordSet",
|
|
311
|
+
obj,
|
|
312
|
+
shapeId: shape.id,
|
|
313
|
+
field: declared.name,
|
|
314
|
+
value: stored,
|
|
315
|
+
loc,
|
|
316
|
+
});
|
|
317
|
+
if (!shape.freezable)
|
|
318
|
+
return store(receiver, value);
|
|
319
|
+
const receiverSlot = local("%typedReceiver", receiver.type, loc);
|
|
320
|
+
const valueSlot = local("%typedValue", value.type, loc);
|
|
321
|
+
const receiverRef = varRef(receiverSlot.localId, receiver.type, loc);
|
|
322
|
+
const refused = sloppy
|
|
323
|
+
? []
|
|
324
|
+
: [
|
|
325
|
+
{
|
|
326
|
+
kind: "exprStmt",
|
|
327
|
+
expr: {
|
|
328
|
+
kind: "libCall",
|
|
329
|
+
fn: "record.throwFrozen",
|
|
330
|
+
args: [strLit(declared.name, loc), strLit("#<Object>", loc), numLit(0, loc)],
|
|
331
|
+
type: VOID,
|
|
332
|
+
loc,
|
|
333
|
+
},
|
|
334
|
+
loc,
|
|
335
|
+
},
|
|
336
|
+
];
|
|
337
|
+
return {
|
|
338
|
+
kind: "block",
|
|
339
|
+
body: [
|
|
340
|
+
{ kind: "varDecl", localId: receiverSlot.localId, init: receiver, loc },
|
|
341
|
+
{ kind: "varDecl", localId: valueSlot.localId, init: value, loc },
|
|
342
|
+
{
|
|
343
|
+
kind: "if",
|
|
344
|
+
cond: { kind: "libCall", fn: "record.isFrozen", args: [receiverRef], type: BOOL, loc },
|
|
345
|
+
then: refused,
|
|
346
|
+
else_: [store(receiverRef, varRef(valueSlot.localId, value.type, loc))],
|
|
347
|
+
loc,
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
loc,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
/** The static value a dynamic store carries, when the store's argument is
|
|
354
|
+
* a conversion of one. */
|
|
355
|
+
function storedValue(arg) {
|
|
356
|
+
if (arg.kind === "dynFrom")
|
|
357
|
+
return arg.value;
|
|
358
|
+
if (arg.kind === "libCall" && STORE_CONVERSIONS.has(arg.fn))
|
|
359
|
+
return arg.args[0] ?? null;
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
/** A call the rewrite leaves dynamic, on a capsule of the typed
|
|
363
|
+
* receiver — the operation exactly as it runs today. */
|
|
364
|
+
function genericCall(call, op, receiver) {
|
|
365
|
+
return {
|
|
366
|
+
...call,
|
|
367
|
+
args: call.args.map((arg, index) => index === op.receiver ? capsule(receiver, call.loc) : rewriteExpr(arg, call)),
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function rewriteStore(call, op) {
|
|
371
|
+
const recv = call.args[op.receiver];
|
|
372
|
+
const receiver = typed(recv);
|
|
373
|
+
const loc = call.loc;
|
|
374
|
+
const sloppy = context.sloppyWrites.has(writeKey(op.loc));
|
|
375
|
+
const fallback = () => ({
|
|
376
|
+
kind: "exprStmt",
|
|
377
|
+
expr: genericCall(call, op, receiver),
|
|
378
|
+
loc,
|
|
379
|
+
});
|
|
380
|
+
const valueArg = op.value === undefined ? undefined : call.args[op.value];
|
|
381
|
+
const stored = valueArg === undefined ? null : storedValue(valueArg);
|
|
382
|
+
if (stored === null || op.key === null)
|
|
383
|
+
return fallback();
|
|
384
|
+
// The value is rewritten before the arms are chosen: a read of the
|
|
385
|
+
// receiver inside it becomes a typed read, so the arm's field type is
|
|
386
|
+
// the type the store moves.
|
|
387
|
+
const value = rewriteExpr(stored, null);
|
|
388
|
+
const keyArg = typeof op.key === "number" ? call.args[op.key] : undefined;
|
|
389
|
+
const literal = typeof op.key === "object" ? op.key.literal : keyArg?.kind === "strLit" ? keyArg.value : null;
|
|
390
|
+
/** Fields a store of `value` can take: the ones whose type it holds. */
|
|
391
|
+
const fits = (declared) => typeKey(declared.type) === typeKey(value.type);
|
|
392
|
+
if (literal !== null) {
|
|
393
|
+
const declared = field(literal);
|
|
394
|
+
if (!declared || !fits(declared))
|
|
395
|
+
return fallback();
|
|
396
|
+
rewritten++;
|
|
397
|
+
return recordStore(receiver, declared, value, loc, sloppy);
|
|
398
|
+
}
|
|
399
|
+
if (!keyArg || keyArg.kind !== "varRef" || keyArg.type.kind !== "string")
|
|
400
|
+
return fallback();
|
|
401
|
+
const arms = shape.fields.filter(fits);
|
|
402
|
+
if (!arms.length)
|
|
403
|
+
return fallback();
|
|
404
|
+
rewritten += arms.length;
|
|
405
|
+
let chain = fallback();
|
|
406
|
+
for (let index = arms.length - 1; index >= 0; index--) {
|
|
407
|
+
const declared = arms[index];
|
|
408
|
+
chain = {
|
|
409
|
+
kind: "if",
|
|
410
|
+
cond: {
|
|
411
|
+
kind: "strEq",
|
|
412
|
+
negated: false,
|
|
413
|
+
left: reparseExpr(keyArg),
|
|
414
|
+
right: strLit(declared.name, loc),
|
|
415
|
+
type: BOOL,
|
|
416
|
+
loc,
|
|
417
|
+
},
|
|
418
|
+
then: [recordStore(receiver, declared, reparseExpr(value), loc, sloppy)],
|
|
419
|
+
else_: [chain],
|
|
420
|
+
loc,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
return chain;
|
|
424
|
+
}
|
|
425
|
+
function rewriteLoad(call, op, parent) {
|
|
426
|
+
const recv = call.args[op.receiver];
|
|
427
|
+
const receiver = typed(recv);
|
|
428
|
+
const loc = call.loc;
|
|
429
|
+
const fallback = () => genericCall(call, op, receiver);
|
|
430
|
+
// Only a number read is rewritten: the view the caller reads through is
|
|
431
|
+
// the `js.toF64` conversion around this call.
|
|
432
|
+
const wrapped = parent !== null &&
|
|
433
|
+
parent.kind === "libCall" &&
|
|
434
|
+
parent.fn === "js.toF64" &&
|
|
435
|
+
parent.args.length === 1 &&
|
|
436
|
+
parent.args[0] === call;
|
|
437
|
+
if (!wrapped || op.key === null)
|
|
438
|
+
return fallback();
|
|
439
|
+
const keyArg = typeof op.key === "number" ? call.args[op.key] : undefined;
|
|
440
|
+
const literal = typeof op.key === "object" ? op.key.literal : keyArg?.kind === "strLit" ? keyArg.value : null;
|
|
441
|
+
if (literal !== null) {
|
|
442
|
+
const declared = field(literal);
|
|
443
|
+
if (!declared || typeKey(declared.type) !== typeKey(F64))
|
|
444
|
+
return fallback();
|
|
445
|
+
rewritten++;
|
|
446
|
+
return recordGet(receiver, declared);
|
|
447
|
+
}
|
|
448
|
+
if (!keyArg || keyArg.kind !== "varRef" || keyArg.type.kind !== "string")
|
|
449
|
+
return fallback();
|
|
450
|
+
const arms = shape.fields.filter((declared) => typeKey(declared.type) === typeKey(F64));
|
|
451
|
+
if (!arms.length)
|
|
452
|
+
return fallback();
|
|
453
|
+
rewritten += arms.length;
|
|
454
|
+
let result = {
|
|
455
|
+
kind: "libCall",
|
|
456
|
+
fn: "js.toF64",
|
|
457
|
+
args: [fallback()],
|
|
458
|
+
type: F64,
|
|
459
|
+
loc,
|
|
460
|
+
};
|
|
461
|
+
for (let index = arms.length - 1; index >= 0; index--) {
|
|
462
|
+
const declared = arms[index];
|
|
463
|
+
result = {
|
|
464
|
+
kind: "ternary",
|
|
465
|
+
cond: {
|
|
466
|
+
kind: "strEq",
|
|
467
|
+
negated: false,
|
|
468
|
+
left: reparseExpr(keyArg),
|
|
469
|
+
right: strLit(declared.name, loc),
|
|
470
|
+
type: BOOL,
|
|
471
|
+
loc,
|
|
472
|
+
},
|
|
473
|
+
then: recordGet(reparseExpr(receiver), declared),
|
|
474
|
+
else_: result,
|
|
475
|
+
type: F64,
|
|
476
|
+
loc,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
return result;
|
|
480
|
+
}
|
|
481
|
+
/** The receiver as the operand of a local that keeps the type it copies:
|
|
482
|
+
* a typed local takes the typed receiver, a dynamic one a capsule. */
|
|
483
|
+
function copyInto(ref, target) {
|
|
484
|
+
const value = typed(ref);
|
|
485
|
+
if (typeKey(target) === typeKey(value.type))
|
|
486
|
+
return value;
|
|
487
|
+
if (target.kind === "dyn")
|
|
488
|
+
return capsule(value, ref.loc);
|
|
489
|
+
return reject();
|
|
490
|
+
}
|
|
491
|
+
/** The declared type of a local of the origin or of the clone's extras.
|
|
492
|
+
* A local that holds the parameter carries the caller's type in the
|
|
493
|
+
* clone, whether it is the parameter or a copy of it. */
|
|
494
|
+
function localType(id) {
|
|
495
|
+
if (members.has(id))
|
|
496
|
+
return type;
|
|
497
|
+
const extra = extras.find((candidate) => candidate.id === id);
|
|
498
|
+
if (extra !== undefined)
|
|
499
|
+
return extra.type;
|
|
500
|
+
return origin.locals.find((candidate) => candidate.id === id)?.type ?? null;
|
|
501
|
+
}
|
|
502
|
+
function memberUse(ref, parent) {
|
|
503
|
+
if (parent === null)
|
|
504
|
+
reject();
|
|
505
|
+
const value = typed(ref);
|
|
506
|
+
if (parent.kind === "varDecl" && parent.init === ref) {
|
|
507
|
+
const target = localType(parent.localId);
|
|
508
|
+
return target === null ? reject() : copyInto(ref, target);
|
|
509
|
+
}
|
|
510
|
+
if (parent.kind === "assign" && parent.value === ref) {
|
|
511
|
+
const target = localType(parent.localId);
|
|
512
|
+
return target === null ? reject() : copyInto(ref, target);
|
|
513
|
+
}
|
|
514
|
+
if (parent.kind === "libCall" && PROPERTY_OBSERVERS.has(parent.fn) && parent.args[0] === ref)
|
|
515
|
+
return capsule(value, ref.loc);
|
|
516
|
+
if (parent.kind === "dynTest" && parent.value === ref)
|
|
517
|
+
return capsule(value, ref.loc);
|
|
518
|
+
if (parent.kind === "toBool" && parent.operand === ref)
|
|
519
|
+
return capsule(value, ref.loc);
|
|
520
|
+
if (parent.kind === "dynKeyGet" && parent.value === ref)
|
|
521
|
+
return capsule(value, ref.loc);
|
|
522
|
+
return reject();
|
|
523
|
+
}
|
|
524
|
+
function rewriteExpr(expr, parent) {
|
|
525
|
+
if (expr.kind === "varRef" && members.has(expr.localId))
|
|
526
|
+
return memberUse(expr, parent);
|
|
527
|
+
if (expr.kind === "libCall" && expr.fn === "js.toF64" && expr.args.length === 1) {
|
|
528
|
+
// A number read the rewrite turned into a typed field read is f64
|
|
529
|
+
// already: the conversion that wrapped the dynamic read is elided.
|
|
530
|
+
const inner = rewriteExpr(expr.args[0], expr);
|
|
531
|
+
if (inner === expr.args[0])
|
|
532
|
+
return expr;
|
|
533
|
+
return inner.type.kind === "f64" ? inner : { ...expr, args: [inner] };
|
|
534
|
+
}
|
|
535
|
+
if (expr.kind === "call") {
|
|
536
|
+
const op = context.helpers.get(expr.callee);
|
|
537
|
+
const recv = op ? expr.args[op.receiver] : undefined;
|
|
538
|
+
if (op && recv?.kind === "varRef" && members.has(recv.localId) && op.kind !== "set")
|
|
539
|
+
return rewriteLoad(expr, op, parent);
|
|
540
|
+
}
|
|
541
|
+
const next = mapExprChildren(expr, (child) => rewriteExpr(child, expr), (statement) => rewriteStmt(statement));
|
|
542
|
+
return next === expr ? reparseExpr(expr) : next;
|
|
543
|
+
}
|
|
544
|
+
/** The expression a sequence's hoisted local was initialised with, put in
|
|
545
|
+
* place of every reference to that local. */
|
|
546
|
+
function substitute(expr, hoists) {
|
|
547
|
+
if (expr.kind === "varRef") {
|
|
548
|
+
const init = hoists.get(expr.localId);
|
|
549
|
+
if (init !== undefined)
|
|
550
|
+
return reparseExpr(init);
|
|
551
|
+
}
|
|
552
|
+
return mapExprChildren(expr, (child) => substitute(child, hoists), (statement) => statement);
|
|
553
|
+
}
|
|
554
|
+
/** A keyed write lowered as a sequence of hoisted operands followed by the
|
|
555
|
+
* dynamic set call, rewritten with those operands put back in place. */
|
|
556
|
+
function storeStatement(statement) {
|
|
557
|
+
if (statement.kind !== "exprStmt" || statement.expr.kind !== "seqExpr")
|
|
558
|
+
return null;
|
|
559
|
+
const sequence = statement.expr;
|
|
560
|
+
if (sequence.generatorDelegate !== undefined || sequence.diverges !== undefined)
|
|
561
|
+
return null;
|
|
562
|
+
const last = sequence.stmts[sequence.stmts.length - 1];
|
|
563
|
+
if (!last || last.kind !== "exprStmt" || last.expr.kind !== "call")
|
|
564
|
+
return null;
|
|
565
|
+
const call = last.expr;
|
|
566
|
+
const op = context.helpers.get(call.callee);
|
|
567
|
+
if (!op || op.kind !== "set")
|
|
568
|
+
return null;
|
|
569
|
+
const hoists = new Map();
|
|
570
|
+
for (const hoisted of sequence.stmts.slice(0, -1))
|
|
571
|
+
if (hoisted.kind === "varDecl" && hoisted.init !== null)
|
|
572
|
+
hoists.set(hoisted.localId, hoisted.init);
|
|
573
|
+
const resolved = {
|
|
574
|
+
...call,
|
|
575
|
+
args: call.args.map((arg) => substitute(arg, hoists)),
|
|
576
|
+
};
|
|
577
|
+
const recv = resolved.args[op.receiver];
|
|
578
|
+
if (!recv || recv.kind !== "varRef" || !members.has(recv.localId))
|
|
579
|
+
return null;
|
|
580
|
+
return rewriteStore(resolved, op);
|
|
581
|
+
}
|
|
582
|
+
function rewriteStmt(statement) {
|
|
583
|
+
const store = storeStatement(statement);
|
|
584
|
+
if (store !== null)
|
|
585
|
+
return store;
|
|
586
|
+
if (statement.kind === "exprStmt" && statement.expr.kind === "call") {
|
|
587
|
+
const op = context.helpers.get(statement.expr.callee);
|
|
588
|
+
const recv = op ? statement.expr.args[op.receiver] : undefined;
|
|
589
|
+
if (op?.kind === "set" && recv?.kind === "varRef" && members.has(recv.localId))
|
|
590
|
+
return rewriteStore(statement.expr, op);
|
|
591
|
+
}
|
|
592
|
+
const next = mapStmtChildren(statement, (child) => rewriteExpr(child, statement), (child) => rewriteStmt(child));
|
|
593
|
+
return next === statement ? reparseStmt(statement) : next;
|
|
594
|
+
}
|
|
595
|
+
let body;
|
|
596
|
+
try {
|
|
597
|
+
body = origin.body.map((statement) => rewriteStmt(statement));
|
|
598
|
+
}
|
|
599
|
+
catch (error) {
|
|
600
|
+
if (error === NOT_A_CLONE)
|
|
601
|
+
return null;
|
|
602
|
+
throw error;
|
|
603
|
+
}
|
|
604
|
+
if (!rewritten || !body.length)
|
|
605
|
+
return null;
|
|
606
|
+
const { ownsPrototype: _ownsPrototype, ...implementation } = origin;
|
|
607
|
+
return {
|
|
608
|
+
...implementation,
|
|
609
|
+
name: "",
|
|
610
|
+
params: origin.params.map((candidate, index) => index === paramIndex ? { ...candidate, type } : candidate),
|
|
611
|
+
locals: [
|
|
612
|
+
...origin.locals.map((candidate) => members.has(candidate.id) ? { ...candidate, type } : candidate),
|
|
613
|
+
...extras,
|
|
614
|
+
],
|
|
615
|
+
body,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
/** Direct calls that pass a statically typed record to an `unknown`
|
|
619
|
+
* parameter call a clone of the callee in which the parameter carries the
|
|
620
|
+
* caller's type while its body uses the parameter only through property
|
|
621
|
+
* operations.
|
|
622
|
+
*
|
|
623
|
+
* A callee qualifies when the parameter and every local that copies it (a
|
|
624
|
+
* cast to `any` or to a record view lowers to a copy) is used only as the
|
|
625
|
+
* receiver of dynamic property reads and writes, an `in` operand, a
|
|
626
|
+
* `typeof` operand or a truthiness test — never stored, returned, compared,
|
|
627
|
+
* passed on, captured, spread or enumerated — and the callee is an ordinary
|
|
628
|
+
* function of at most MAX_FUNCTION_NODES nodes with no captures.
|
|
629
|
+
*
|
|
630
|
+
* Inside the clone the receiver is the caller's record type: a read or write
|
|
631
|
+
* whose key the clone knows compiles to a typed field access, and a keyed
|
|
632
|
+
* operation compares the key against the shape's declared field names and
|
|
633
|
+
* takes the typed field arm when one matches, updating the value type it was
|
|
634
|
+
* given. Every other key, and every operation on a shape that has no such
|
|
635
|
+
* field, takes the operation exactly as it runs today, on a capsule built at
|
|
636
|
+
* that point. A write to a shape whose values can be frozen tests the frozen
|
|
637
|
+
* bit first: a frozen record takes the TypeError the dynamic operation
|
|
638
|
+
* throws in strict-mode code, and is left unchanged in sloppy-mode code.
|
|
639
|
+
* Calls that do not qualify keep the original function.
|
|
640
|
+
*
|
|
641
|
+
* Code growth is bounded: at most MAX_CLONES_PER_FUNCTION clones per
|
|
642
|
+
* function and MIN_CLONED_NODES (or CLONED_NODE_FRACTION of the module) of
|
|
643
|
+
* cloned nodes module-wide. `symbolName` spells names after mangling, and
|
|
644
|
+
* `index`, an index of `mod`, gives node counts without walking bodies. */
|
|
645
|
+
export function specializeTypedArguments(mod, symbolName = (name) => name, index) {
|
|
646
|
+
const functions = new Map(mod.functions.map((fn) => [fn.name, fn]));
|
|
647
|
+
const context = {
|
|
648
|
+
helpers: helperOperations(mod),
|
|
649
|
+
records: new Map((mod.records ?? []).map((shape) => [shape.id, shape])),
|
|
650
|
+
sloppyWrites: new Set(mod.sloppyDynWrites ?? []),
|
|
651
|
+
};
|
|
652
|
+
if (!context.helpers.size || !context.records.size)
|
|
653
|
+
return mod;
|
|
654
|
+
let moduleNodes = 0;
|
|
655
|
+
for (const fn of mod.functions)
|
|
656
|
+
moduleNodes += countNodes(fn, index);
|
|
657
|
+
let budget = Math.max(MIN_CLONED_NODES, moduleNodes * CLONED_NODE_FRACTION);
|
|
658
|
+
const names = new Set(mod.functions.map((fn) => symbolName(fn.name)));
|
|
659
|
+
const partialTargets = partialAssertionTargets(mod);
|
|
660
|
+
const cloneCounts = new Map();
|
|
661
|
+
const clones = new Map();
|
|
662
|
+
const pending = [];
|
|
663
|
+
/** The static record value an argument passes, or null. */
|
|
664
|
+
function staticArgument(arg) {
|
|
665
|
+
const value = arg.kind === "dynFrom" ? arg.value : arg;
|
|
666
|
+
if (value.type.kind !== "record")
|
|
667
|
+
return null;
|
|
668
|
+
const shape = context.records.get(value.type.shapeId);
|
|
669
|
+
if (!shape || shape.tuple)
|
|
670
|
+
return null;
|
|
671
|
+
// A shape a partial record assertion names may hold a value its own
|
|
672
|
+
// fields are absent from; the clone would read one natively.
|
|
673
|
+
if (partialTargets.has(value.type.shapeId))
|
|
674
|
+
return null;
|
|
675
|
+
return value;
|
|
676
|
+
}
|
|
677
|
+
function cloneFor(target, paramIndex, type) {
|
|
678
|
+
const key = `${target.name}\0${paramIndex}\0${typeKey(type)}`;
|
|
679
|
+
const known = clones.get(key);
|
|
680
|
+
if (known !== undefined)
|
|
681
|
+
return known;
|
|
682
|
+
let clone = null;
|
|
683
|
+
const count = cloneCounts.get(target.name) ?? 0;
|
|
684
|
+
if (count < MAX_CLONES_PER_FUNCTION &&
|
|
685
|
+
target !== functions.get(mod.entry) &&
|
|
686
|
+
!target.async &&
|
|
687
|
+
target.generator === undefined &&
|
|
688
|
+
target.captures === undefined &&
|
|
689
|
+
!target.classCaptures?.length &&
|
|
690
|
+
!target.fastRead &&
|
|
691
|
+
!target.speculativeDispatch) {
|
|
692
|
+
const candidate = buildClone(context, target, paramIndex, type);
|
|
693
|
+
if (candidate) {
|
|
694
|
+
const size = countNodes(candidate);
|
|
695
|
+
if (size <= budget) {
|
|
696
|
+
budget -= size;
|
|
697
|
+
let name = `${target.name}.typedArg`;
|
|
698
|
+
while (names.has(symbolName(name)))
|
|
699
|
+
name += "_";
|
|
700
|
+
names.add(symbolName(name));
|
|
701
|
+
clone = { ...candidate, name };
|
|
702
|
+
cloneCounts.set(target.name, count + 1);
|
|
703
|
+
pending.push(clone);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
clones.set(key, clone);
|
|
708
|
+
return clone;
|
|
709
|
+
}
|
|
710
|
+
/** Rewrites one call: its first qualifying argument passes a qualified
|
|
711
|
+
* clone, and the argument becomes the record itself. */
|
|
712
|
+
function specializeCall(call) {
|
|
713
|
+
const target = functions.get(call.callee);
|
|
714
|
+
if (!target)
|
|
715
|
+
return call;
|
|
716
|
+
for (let paramIndex = 0; paramIndex < target.params.length; paramIndex++) {
|
|
717
|
+
const param = target.params[paramIndex];
|
|
718
|
+
if (param.type.kind !== "dyn" || param.owned)
|
|
719
|
+
continue;
|
|
720
|
+
const arg = call.args[paramIndex];
|
|
721
|
+
if (!arg)
|
|
722
|
+
continue;
|
|
723
|
+
const value = staticArgument(arg);
|
|
724
|
+
if (!value)
|
|
725
|
+
continue;
|
|
726
|
+
const clone = cloneFor(target, paramIndex, value.type);
|
|
727
|
+
if (!clone)
|
|
728
|
+
continue;
|
|
729
|
+
return {
|
|
730
|
+
...call,
|
|
731
|
+
callee: clone.name,
|
|
732
|
+
args: call.args.map((candidate, index) => (index === paramIndex ? value : candidate)),
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
return call;
|
|
736
|
+
}
|
|
737
|
+
function qualifies(call) {
|
|
738
|
+
const target = functions.get(call.callee);
|
|
739
|
+
if (!target)
|
|
740
|
+
return false;
|
|
741
|
+
return target.params.some((param, paramIndex) => {
|
|
742
|
+
if (param.type.kind !== "dyn" || param.owned)
|
|
743
|
+
return false;
|
|
744
|
+
const arg = call.args[paramIndex];
|
|
745
|
+
return arg !== undefined && staticArgument(arg) !== null;
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
function rewriteFunction(fn) {
|
|
749
|
+
let found = false;
|
|
750
|
+
const candidates = [];
|
|
751
|
+
everyStmtList(fn.body, {
|
|
752
|
+
stmt: () => true,
|
|
753
|
+
expr: (expr) => {
|
|
754
|
+
if (expr.kind === "call" && qualifies(expr)) {
|
|
755
|
+
found = true;
|
|
756
|
+
candidates.push(expr);
|
|
757
|
+
}
|
|
758
|
+
return true;
|
|
759
|
+
},
|
|
760
|
+
});
|
|
761
|
+
if (!found)
|
|
762
|
+
return fn;
|
|
763
|
+
const byNode = new Map();
|
|
764
|
+
for (const call of candidates) {
|
|
765
|
+
const rewritten = specializeCall(call);
|
|
766
|
+
if (rewritten !== call)
|
|
767
|
+
byNode.set(call, rewritten);
|
|
768
|
+
}
|
|
769
|
+
let mutated = false;
|
|
770
|
+
const body = transformStmtList(fn.body, {
|
|
771
|
+
expr: (expr) => {
|
|
772
|
+
const replacement = byNode.get(expr);
|
|
773
|
+
if (replacement)
|
|
774
|
+
mutated = true;
|
|
775
|
+
return replacement ?? expr;
|
|
776
|
+
},
|
|
777
|
+
stmt: (statement) => statement,
|
|
778
|
+
});
|
|
779
|
+
return mutated ? { ...fn, body } : fn;
|
|
780
|
+
}
|
|
781
|
+
const rewritten = mod.functions.map(rewriteFunction);
|
|
782
|
+
const additions = [];
|
|
783
|
+
for (let position = 0; position < pending.length; position++)
|
|
784
|
+
additions.push(rewriteFunction(pending[position]));
|
|
785
|
+
if (!additions.length)
|
|
786
|
+
return mod;
|
|
787
|
+
return { ...mod, functions: [...rewritten, ...additions] };
|
|
788
|
+
}
|
|
789
|
+
//# sourceMappingURL=typed-argument-clones.js.map
|