@scriptc/compiler 0.3.1 → 0.3.3
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/scriptc-node-fallback.d.ts +832 -55
- package/dist/backend/cycle-analysis.js +6 -1
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/executable-features.js +1 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/literals.d.ts +7 -0
- package/dist/backend/literals.js +32 -0
- package/dist/backend/literals.js.map +1 -1
- package/dist/backend/literals.test.js +17 -1
- package/dist/backend/literals.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -4
- package/dist/backend/llvm/alloc.js +63 -25
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +62 -2
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/appended-array-literals.d.ts +2 -0
- package/dist/backend/llvm/appended-array-literals.js +109 -0
- package/dist/backend/llvm/appended-array-literals.js.map +1 -0
- package/dist/backend/llvm/appended-array-literals.test.d.ts +1 -0
- package/dist/backend/llvm/appended-array-literals.test.js +90 -0
- package/dist/backend/llvm/appended-array-literals.test.js.map +1 -0
- package/dist/backend/llvm/array-search.d.ts +8 -0
- package/dist/backend/llvm/array-search.js +52 -0
- package/dist/backend/llvm/array-search.js.map +1 -0
- package/dist/backend/llvm/array-search.test.d.ts +1 -0
- package/dist/backend/llvm/array-search.test.js +72 -0
- package/dist/backend/llvm/array-search.test.js.map +1 -0
- package/dist/backend/llvm/call-lifetimes.d.ts +11 -1
- package/dist/backend/llvm/call-lifetimes.js +74 -4
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +54 -0
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/classes.js +97 -38
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +2 -2
- package/dist/backend/llvm/common.d.ts +1 -1
- package/dist/backend/llvm/common.js +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +5 -0
- package/dist/backend/llvm/dense-array-access.js +18 -13
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +15 -2
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +6 -0
- package/dist/backend/llvm/dyn.js +84 -11
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +108 -16
- package/dist/backend/llvm/emitter.js +598 -108
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +26 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +174 -7
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +11 -0
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +8 -0
- package/dist/backend/llvm/expr-callbacks.js +96 -2
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +12 -1
- package/dist/backend/llvm/expr-calls.js +133 -54
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +7 -0
- package/dist/backend/llvm/expr-containers.js +80 -22
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +2 -0
- package/dist/backend/llvm/expr-control.d.ts +8 -0
- package/dist/backend/llvm/expr-control.js +103 -69
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +21 -10
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +7 -0
- package/dist/backend/llvm/expr-primitives.js +53 -51
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +19 -5
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
- package/dist/backend/llvm/expr-stream-bridges.js +111 -39
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +49 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +13 -2
- package/dist/backend/llvm/expr-stream-callbacks.js +80 -5
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/inline-unions.d.ts +48 -0
- package/dist/backend/llvm/inline-unions.js +134 -0
- package/dist/backend/llvm/inline-unions.js.map +1 -0
- package/dist/backend/llvm/inline-unions.test.d.ts +1 -0
- package/dist/backend/llvm/inline-unions.test.js +124 -0
- package/dist/backend/llvm/inline-unions.test.js.map +1 -0
- package/dist/backend/llvm/int32-abi.d.ts +18 -2
- package/dist/backend/llvm/int32-abi.js +23 -2
- package/dist/backend/llvm/int32-abi.js.map +1 -1
- package/dist/backend/llvm/int32-abi.test.js +75 -1
- package/dist/backend/llvm/int32-abi.test.js.map +1 -1
- package/dist/backend/llvm/integer-remainder.d.ts +28 -5
- package/dist/backend/llvm/integer-remainder.js +80 -9
- package/dist/backend/llvm/integer-remainder.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +170 -28
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +181 -5
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +9 -6
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +2 -2
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +208 -9
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +97 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +12 -6
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +6 -3
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.d.ts +26 -2
- package/dist/backend/llvm/local-union-storage.js +132 -12
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +107 -1
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-array-borrows.d.ts +8 -2
- package/dist/backend/llvm/loop-array-borrows.js +93 -13
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +20 -0
- package/dist/backend/llvm/map-number-lookup.js +66 -0
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.d.ts +1 -0
- package/dist/backend/llvm/map-number-lookup.test.js +102 -0
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -0
- package/dist/backend/llvm/map-read-lifetimes.js +1 -0
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +4 -0
- package/dist/backend/llvm/publish.js +3 -1
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/record-results.d.ts +29 -0
- package/dist/backend/llvm/record-results.js +260 -0
- package/dist/backend/llvm/record-results.js.map +1 -0
- package/dist/backend/llvm/reference-effects.js +15 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +29 -9
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/regions.d.ts +68 -0
- package/dist/backend/llvm/regions.js +314 -0
- package/dist/backend/llvm/regions.js.map +1 -0
- package/dist/backend/llvm/regions.test.d.ts +1 -0
- package/dist/backend/llvm/regions.test.js +173 -0
- package/dist/backend/llvm/regions.test.js.map +1 -0
- package/dist/backend/llvm/serialized-ir-emission.test.js +2 -0
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +86 -13
- package/dist/backend/llvm/shapes.js +208 -54
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +68 -9
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/split-loops.js +1 -1
- package/dist/backend/llvm/split-loops.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +29 -0
- package/dist/backend/llvm/stack-objects.js +142 -0
- package/dist/backend/llvm/stack-objects.js.map +1 -0
- package/dist/backend/llvm/stack-objects.test.d.ts +1 -0
- package/dist/backend/llvm/stack-objects.test.js +255 -0
- package/dist/backend/llvm/stack-objects.test.js.map +1 -0
- package/dist/backend/llvm/string-reads.d.ts +4 -1
- package/dist/backend/llvm/string-reads.js +89 -9
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.js +5 -4
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +13 -0
- package/dist/backend/llvm/walkers.js +108 -10
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +10 -4
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +7 -2
- package/dist/backend/native/executable.js +28 -2
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +1 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +3 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +1 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +1 -1
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -0
- package/dist/backend/runtime-pack-core.js +1 -0
- 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.test.js +1 -1
- package/dist/backend/target-diagnostics.js +17 -0
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +16 -0
- package/dist/backend/target-diagnostics.test.js.map +1 -1
- package/dist/compat/fetch-profile.js +4 -4
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/contracts/check.js +2 -0
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/report.js +1 -1
- package/dist/coverage/report.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +6 -5
- package/dist/diagnostics/diagnostic.js +7 -6
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +1 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +1 -1
- package/dist/frontend/builtin-modules.js +1 -0
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/comptime-node.js +2 -2
- package/dist/frontend/comptime-node.js.map +1 -1
- package/dist/frontend/experimental-import.d.ts +12 -0
- package/dist/frontend/experimental-import.js +63 -0
- package/dist/frontend/experimental-import.js.map +1 -0
- package/dist/frontend/lowering/binding-analysis.d.ts +1 -1
- package/dist/frontend/lowering/binding-analysis.js +1 -1
- package/dist/frontend/lowering/builtin-calls.d.ts +6 -1
- package/dist/frontend/lowering/builtin-calls.js +36 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
- package/dist/frontend/lowering/builtins/arguments.js +8 -4
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/blob.d.ts +20 -0
- package/dist/frontend/lowering/builtins/blob.js +167 -0
- package/dist/frontend/lowering/builtins/blob.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process-async.d.ts +2 -2
- package/dist/frontend/lowering/builtins/child-process-async.js +2 -2
- package/dist/frontend/lowering/builtins/child-process-methods.js +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.js +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.js +3 -2
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/console.d.ts +16 -6
- package/dist/frontend/lowering/builtins/console.js +33 -9
- package/dist/frontend/lowering/builtins/console.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.js +415 -120
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.js +20 -0
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +10 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +89 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +16 -7
- package/dist/frontend/lowering/builtins/filesystem.js +97 -15
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-glob.d.ts +23 -0
- package/dist/frontend/lowering/builtins/fs-glob.js +224 -0
- package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -0
- package/dist/frontend/lowering/builtins/json.d.ts +2 -2
- package/dist/frontend/lowering/builtins/json.js +13 -4
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/key-object.d.ts +13 -0
- package/dist/frontend/lowering/builtins/key-object.js +56 -0
- package/dist/frontend/lowering/builtins/key-object.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-calls.js +60 -12
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +1 -0
- package/dist/frontend/lowering/builtins/numbers.js +17 -0
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +18 -0
- package/dist/frontend/lowering/builtins/operating-system.js +361 -1
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/performance.d.ts +25 -3
- package/dist/frontend/lowering/builtins/performance.js +340 -5
- package/dist/frontend/lowering/builtins/performance.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +2 -2
- package/dist/frontend/lowering/builtins/process.js +122 -17
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +109 -2
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.d.ts +0 -7
- package/dist/frontend/lowering/builtins/properties.js +39 -11
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +23 -8
- package/dist/frontend/lowering/builtins/readline.js +266 -90
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.d.ts +3 -4
- package/dist/frontend/lowering/builtins/text-codecs.js +3 -4
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.d.ts +8 -0
- package/dist/frontend/lowering/builtins/url.js +36 -0
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.js +1 -1
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.js +20 -2
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/checked-promise-all.d.ts +10 -3
- package/dist/frontend/lowering/checked-promise-all.js +52 -6
- package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +8 -3
- package/dist/frontend/lowering/class-dynamic-dispatch.js +159 -32
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-protocol-dispatch.d.ts +45 -0
- package/dist/frontend/lowering/class-protocol-dispatch.js +516 -0
- package/dist/frontend/lowering/class-protocol-dispatch.js.map +1 -0
- package/dist/frontend/lowering/coercions/structural-plans.js +2 -1
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +3 -3
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/collation-repertoire.js +6 -5
- package/dist/frontend/lowering/collation-repertoire.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +33 -6
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +8 -4
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.d.ts +0 -7
- package/dist/frontend/lowering/containers/array-methods.js +43 -2
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.js +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +38 -26
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/for-of.d.ts +1 -1
- package/dist/frontend/lowering/containers/for-of.js +5 -1
- package/dist/frontend/lowering/containers/for-of.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +91 -0
- 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 +77 -12
- package/dist/frontend/lowering/crypto-tables.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +18 -2
- package/dist/frontend/lowering/cycle-initialization.js +166 -12
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.js +7 -2
- package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.test.js +28 -0
- package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +10 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +21 -68
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
- package/dist/frontend/lowering/generator-delegation.js +231 -10
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +2 -2
- package/dist/frontend/lowering/generic-functions.js +2 -2
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/http2-constants.js +1 -1
- package/dist/frontend/lowering/lifetime-regions.d.ts +11 -0
- package/dist/frontend/lowering/lifetime-regions.js +216 -0
- package/dist/frontend/lowering/lifetime-regions.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +40 -3
- package/dist/frontend/lowering/lower-array-sort.js +661 -194
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +103 -4
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +2 -2
- package/dist/frontend/lowering/lower-async-iteration.d.ts +6 -3
- package/dist/frontend/lowering/lower-async-iteration.js +248 -2
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +173 -111
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +12 -5
- package/dist/frontend/lowering/lower-classes.js +156 -11
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
- package/dist/frontend/lowering/lower-comptime.js +4 -4
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-console.d.ts +13 -0
- package/dist/frontend/lowering/lower-console.js +460 -4
- package/dist/frontend/lowering/lower-console.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -0
- package/dist/frontend/lowering/lower-event-emitter.js +124 -38
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-event-target.d.ts +63 -0
- package/dist/frontend/lowering/lower-event-target.js +362 -0
- package/dist/frontend/lowering/lower-event-target.js.map +1 -0
- package/dist/frontend/lowering/lower-expando.js +2 -2
- package/dist/frontend/lowering/lower-exprs.js +247 -42
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +15 -7
- package/dist/frontend/lowering/lower-generators.js +183 -99
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +8 -1
- package/dist/frontend/lowering/lower-inspect.js +247 -28
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.js +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +1 -1
- package/dist/frontend/lowering/lower-modules.js +27 -17
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +2 -2
- package/dist/frontend/lowering/lower-namespaces.js +2 -2
- package/dist/frontend/lowering/lower-server.js +39 -14
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +11 -1
- package/dist/frontend/lowering/lower-stdlib.js +45 -4
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +2 -2
- package/dist/frontend/lowering/lower-stmts.js +112 -23
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +234 -22
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +45 -6
- package/dist/frontend/lowering/lowerer.js +360 -48
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/native-ffi.js +2 -2
- package/dist/frontend/lowering/native-ffi.js.map +1 -1
- package/dist/frontend/lowering/regex-span-reads.d.ts +12 -0
- package/dist/frontend/lowering/regex-span-reads.js +164 -0
- package/dist/frontend/lowering/regex-span-reads.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-records.d.ts +115 -0
- package/dist/frontend/lowering/runtime-optional-records.js +715 -0
- package/dist/frontend/lowering/runtime-optional-records.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-records.test.d.ts +1 -0
- package/dist/frontend/lowering/runtime-optional-records.test.js +175 -0
- package/dist/frontend/lowering/runtime-optional-records.test.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +7 -3
- package/dist/frontend/lowering/surfaces.js +385 -32
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/var-hoisting.d.ts +3 -0
- package/dist/frontend/lowering/var-hoisting.js +261 -0
- package/dist/frontend/lowering/var-hoisting.js.map +1 -0
- package/dist/frontend/module-syntax.d.ts +1 -1
- package/dist/frontend/module-syntax.js +1 -1
- package/dist/frontend/npm-static-prune.js +1 -1
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +4 -3
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/pipeline.js +6 -4
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +6 -5
- package/dist/frontend/program.js +42 -22
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +13 -0
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/resolve.js +1 -1
- package/dist/frontend/ts7/adapter.js +1 -1
- package/dist/frontend/ts7/ast-bytes.d.ts +1 -1
- package/dist/frontend/ts7/ast-bytes.js +1 -1
- package/dist/frontend/ts7/semantic-json.d.ts +1 -1
- package/dist/frontend/ts7/semantic-json.js +1 -1
- package/dist/frontend/ts7/semantic-json.js.map +1 -1
- package/dist/frontend/ts7/world-check.js +1 -1
- package/dist/frontend/tsc-codes.js +2 -2
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +28 -1
- package/dist/frontend/type-mapper.js +288 -30
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +12 -6
- package/dist/ir/analysis.js +26 -10
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +15 -3
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/builtin-effects.js +108 -2
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +436 -53
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/function-references.test.js +1 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/int32-slots.js +2 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/intrinsic-signatures.js +2 -0
- package/dist/ir/intrinsic-signatures.js.map +1 -1
- package/dist/ir/ir.d.ts +129 -36
- package/dist/ir/ir.js +42 -1
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +1 -0
- package/dist/ir/runtime-features.js +116 -5
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.js +1 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/serialize.js +1 -1
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +1 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +250 -34
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +125 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/fence-eval.d.ts +1 -1
- package/dist/library/fence-eval.js +5 -4
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/ir-policy.js +11 -4
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-profile.js +13 -13
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.js +1 -1
- package/dist/library/prepare.js.map +1 -1
- package/dist/library/sidecar.js +3 -3
- package/dist/library/sidecar.js.map +1 -1
- package/dist/native/prepare.js +3 -2
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +1 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +537 -142
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { isIdentityCollectionKey, isRefCounted, mapOf, POINTER_KINDS, runtimeRcStem, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, } from "../../ir/ir.js";
|
|
1
|
+
import { isIdentityCollectionKey, isRefCounted, mapOf, POINTER_KINDS, runtimeRcStem, RUNTIME_EMITTER_CLASS, RUNTIME_EVENT_CLASS, RUNTIME_EVENT_TARGET_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, } from "../../ir/ir.js";
|
|
2
2
|
import { mangleClassRelease, mangleClassRetain, mangleClassTrace, mangleRecordGcFree, mangleRecordClone, mangleRecordNew, mangleRecordRelease, mangleRecordRetain, mangleRecordStruct, mangleRecordTrace, } from "../mangle.js";
|
|
3
3
|
import { cycTypeDescriptor, emitObjectAlloc, emitObjectFree } from "./alloc.js";
|
|
4
4
|
import { SCR_ARR_FIELD, llvmCommentText } from "./common.js";
|
|
5
|
+
import { INLINE_UNION_FIELD, loadInlineUnion, stackUnionBox, } from "./inline-unions.js";
|
|
5
6
|
import { LlvmUnsupportedError } from "./unsupported.js";
|
|
6
7
|
/** Every emitted function/helper carries #0 = { sanitize_address } — see
|
|
7
8
|
* the emitter header. */
|
|
@@ -38,13 +39,29 @@ export function vAdapters(host, t) {
|
|
|
38
39
|
retain: `@${mangleRecordRetain(t.shapeId)}`,
|
|
39
40
|
release: `@${mangleRecordRelease(t.shapeId)}`,
|
|
40
41
|
};
|
|
41
|
-
case "object":
|
|
42
|
+
case "object": {
|
|
43
|
+
// Subclasses of the runtime EventTarget and Event bases share the
|
|
44
|
+
// runtime's adapters (the same rc word and vtable dispatch as the
|
|
45
|
+
// emitted helpers): the engine recognizes their checked-dynamic
|
|
46
|
+
// capsules by the release adapter.
|
|
47
|
+
const root = host.classRootOf?.(t.className);
|
|
48
|
+
const runtime = root === RUNTIME_EVENT_TARGET_CLASS
|
|
49
|
+
? { retain: "scr_event_target_obj_retain_v", release: "scr_event_target_obj_release_v" }
|
|
50
|
+
: root === RUNTIME_EVENT_CLASS
|
|
51
|
+
? { retain: "scr_event_obj_retain_v", release: "scr_event_obj_release_v" }
|
|
52
|
+
: null;
|
|
53
|
+
if (runtime !== null) {
|
|
54
|
+
host.declare(`declare ptr @${runtime.retain}(ptr)`);
|
|
55
|
+
host.declare(`declare void @${runtime.release}(ptr)`);
|
|
56
|
+
return { retain: `@${runtime.retain}`, release: `@${runtime.release}` };
|
|
57
|
+
}
|
|
42
58
|
// Emitted per-class helpers are already `_v`-shaped (ptr → ptr /
|
|
43
59
|
// ptr → void), so the same symbols serve as container entry points.
|
|
44
60
|
return {
|
|
45
61
|
retain: `@${mangleClassRetain(t.className)}`,
|
|
46
62
|
release: `@${mangleClassRelease(t.className)}`,
|
|
47
63
|
};
|
|
64
|
+
}
|
|
48
65
|
default:
|
|
49
66
|
throw new LlvmUnsupportedError(`rc:${t.kind}`);
|
|
50
67
|
}
|
|
@@ -57,9 +74,13 @@ export function retainSym(host, t) {
|
|
|
57
74
|
if (nullable)
|
|
58
75
|
return nullableRetainSym(host, nullable.arm);
|
|
59
76
|
const stem = runtimeRcStem(t);
|
|
60
|
-
if (host.rcHelpers !== null && stem !== null && inlineRcFamily(stem, "retain") !== null) {
|
|
77
|
+
if (host.rcHelpers !== null && stem !== null && inlineRcFamily(host, stem, "retain") !== null) {
|
|
61
78
|
return inlineRcSym(host, stem, "retain");
|
|
62
79
|
}
|
|
80
|
+
// Direct retains keep the emitted helper (vAdapters' runtime adapters
|
|
81
|
+
// are for capsule and container entry points).
|
|
82
|
+
if (t.kind === "object" && stem === null)
|
|
83
|
+
return `@${mangleClassRetain(t.className)}`;
|
|
63
84
|
return vAdapters(host, t).retain;
|
|
64
85
|
}
|
|
65
86
|
/** The retain entry point of a nullable union's value: the arm's own when
|
|
@@ -90,7 +111,7 @@ export function releaseSym(host, t) {
|
|
|
90
111
|
if (nullable)
|
|
91
112
|
return releaseSym(host, nullable.arm);
|
|
92
113
|
const stem = runtimeRcStem(t);
|
|
93
|
-
if (host.rcHelpers !== null && stem !== null && inlineRcFamily(stem, "release") !== null) {
|
|
114
|
+
if (host.rcHelpers !== null && stem !== null && inlineRcFamily(host, stem, "release") !== null) {
|
|
94
115
|
return inlineRcSym(host, stem, "release");
|
|
95
116
|
}
|
|
96
117
|
if (stem !== null) {
|
|
@@ -117,8 +138,11 @@ export function releaseSym(host, t) {
|
|
|
117
138
|
* collector's on_dead bookkeeping) stays in the runtime release, which
|
|
118
139
|
* repeats its own checks, so the fast path never duplicates it.
|
|
119
140
|
*
|
|
141
|
+
* The dyn release buffers a surviving value by kind (scr_dyn_release):
|
|
142
|
+
* the fast path decides the always and never cases and calls
|
|
143
|
+
* scr_dyn_release_survivor for kinds whose candidacy is per value.
|
|
144
|
+
*
|
|
120
145
|
* Releases stay plain calls for:
|
|
121
|
-
* - dyn: scr_dyn_release buffers a surviving object only for some kinds.
|
|
122
146
|
* - arr: array releases are the most numerous release sites and the
|
|
123
147
|
* least hot (at most 1% self time across the benchmark suite), and
|
|
124
148
|
* inlining them roughly doubled the code growth for no measured speedup.
|
|
@@ -135,16 +159,31 @@ export const INLINE_RC_FAMILIES = {
|
|
|
135
159
|
promise: { cycle: "always", retainNull: true, release: "scr_promise_release" },
|
|
136
160
|
classobj: { cycle: "always", retainNull: true, release: "scr_classobj_release" },
|
|
137
161
|
box: { cycle: "always", retainNull: false, release: "scr_box_release" },
|
|
138
|
-
dyn: { cycle: "always", retainNull: false, release:
|
|
162
|
+
dyn: { cycle: "always", retainNull: false, release: "scr_dyn_release" },
|
|
139
163
|
};
|
|
140
164
|
/** The mirrored family for an RC operation on a runtime stem (`scr_str`),
|
|
141
165
|
* or null when it stays a call. */
|
|
142
|
-
export function inlineRcFamily(stem, op) {
|
|
143
|
-
return mirroredFamily(stem.replace(/^scr_/, ""), op);
|
|
166
|
+
export function inlineRcFamily(host, stem, op) {
|
|
167
|
+
return mirroredFamily(host, stem.replace(/^scr_/, ""), op);
|
|
168
|
+
}
|
|
169
|
+
const RELEASE_RC_OPS = new Set(["str:retain", "dyn:retain", "dyn:release"]);
|
|
170
|
+
/** The emitter's inline RC option for a native optimization posture: none
|
|
171
|
+
* at `dev`, the `release` subset by default. Sanitized builds compile the
|
|
172
|
+
* whole program in one AddressSanitizer pass, whose time grows with every
|
|
173
|
+
* inlined fast path, so they call the same helpers out of line. */
|
|
174
|
+
export function inlineRcOption(optimization, sanitize = false) {
|
|
175
|
+
if (optimization === "dev")
|
|
176
|
+
return {};
|
|
177
|
+
return {
|
|
178
|
+
inlineRc: optimization === "speed" ? "speed" : "release",
|
|
179
|
+
...(sanitize ? { rcHelpersNoinline: true } : {}),
|
|
180
|
+
};
|
|
144
181
|
}
|
|
145
|
-
function mirroredFamily(family, op) {
|
|
182
|
+
function mirroredFamily(host, family, op) {
|
|
146
183
|
if (!Object.hasOwn(INLINE_RC_FAMILIES, family))
|
|
147
184
|
return null;
|
|
185
|
+
if (host.rcMode !== "speed" && !RELEASE_RC_OPS.has(`${family}:${op}`))
|
|
186
|
+
return null;
|
|
148
187
|
const row = INLINE_RC_FAMILIES[family];
|
|
149
188
|
return op === "retain" || row.release !== null ? row : null;
|
|
150
189
|
}
|
|
@@ -156,7 +195,7 @@ function inlineRcSym(host, stem, op) {
|
|
|
156
195
|
/** The release call target for a capture box: scr_box_release's fast path,
|
|
157
196
|
* or scr_box_release itself without inline RC. */
|
|
158
197
|
export function boxReleaseSym(host) {
|
|
159
|
-
if (host.rcHelpers === null) {
|
|
198
|
+
if (host.rcHelpers === null || mirroredFamily(host, "box", "release") === null) {
|
|
160
199
|
host.declare(`declare void @scr_box_release(ptr)`);
|
|
161
200
|
return "@scr_box_release";
|
|
162
201
|
}
|
|
@@ -165,7 +204,7 @@ export function boxReleaseSym(host) {
|
|
|
165
204
|
/** Record the helper and declare the runtime symbols it calls now, so they
|
|
166
205
|
* land in the extern block. */
|
|
167
206
|
function requestRcHelper(host, family, op) {
|
|
168
|
-
if (host.rcHelpers === null || mirroredFamily(family, op) === null) {
|
|
207
|
+
if (host.rcHelpers === null || mirroredFamily(host, family, op) === null) {
|
|
169
208
|
throw new LlvmUnsupportedError(`inline rc:${family}:${op}`);
|
|
170
209
|
}
|
|
171
210
|
host.rcHelpers.add(`${family}:${op}`);
|
|
@@ -173,9 +212,67 @@ function requestRcHelper(host, family, op) {
|
|
|
173
212
|
host.declare(decl);
|
|
174
213
|
return `@${inlineRcName(family, op)}`;
|
|
175
214
|
}
|
|
215
|
+
function rcHelperAttrs(host) {
|
|
216
|
+
return host.rcHelpersNoinline === true ? `noinline ${FN_ATTRS}` : FN_ATTRS;
|
|
217
|
+
}
|
|
176
218
|
function inlineRcName(family, op) {
|
|
177
219
|
return `sc_rc_${op}_${family}`;
|
|
178
220
|
}
|
|
221
|
+
/** Inlined dyn releases one function body keeps. LLVM's optimization time
|
|
222
|
+
* grows faster than the number of inlined releases in one function, and
|
|
223
|
+
* generated dispatch tables and module initializers of large packages have
|
|
224
|
+
* thousands of release sites; a body with more calls scr_dyn_release, which
|
|
225
|
+
* the inline helper mirrors, at every site. */
|
|
226
|
+
export const INLINE_DYN_RELEASES_PER_FUNCTION = 256;
|
|
227
|
+
/** Apply {@link INLINE_DYN_RELEASES_PER_FUNCTION} to each function of an
|
|
228
|
+
* emitted module, given as parts joined by newlines. A function can span
|
|
229
|
+
* parts (main's lines) and a part can hold several functions. */
|
|
230
|
+
export function limitInlineDynReleases(parts) {
|
|
231
|
+
const call = `call void @${inlineRcName("dyn", "release")}(`;
|
|
232
|
+
const runtime = `call void @${INLINE_RC_FAMILIES["dyn"].release}(`;
|
|
233
|
+
// The function each release site belongs to: the last `define` line
|
|
234
|
+
// before it, counted over the joined text.
|
|
235
|
+
const sites = (part, each, first) => {
|
|
236
|
+
let fn = first;
|
|
237
|
+
let define = part.startsWith("define ") ? 0 : part.indexOf("\ndefine ");
|
|
238
|
+
for (let at = part.indexOf(call); at >= 0; at = part.indexOf(call, at + call.length)) {
|
|
239
|
+
while (define >= 0 && define < at) {
|
|
240
|
+
fn++;
|
|
241
|
+
define = part.indexOf("\ndefine ", define + 1);
|
|
242
|
+
}
|
|
243
|
+
each(at, fn);
|
|
244
|
+
}
|
|
245
|
+
while (define >= 0) {
|
|
246
|
+
fn++;
|
|
247
|
+
define = part.indexOf("\ndefine ", define + 1);
|
|
248
|
+
}
|
|
249
|
+
return fn;
|
|
250
|
+
};
|
|
251
|
+
const counts = new Map();
|
|
252
|
+
let fn = 0;
|
|
253
|
+
for (const part of parts)
|
|
254
|
+
fn = sites(part, (_, f) => counts.set(f, (counts.get(f) ?? 0) + 1), fn);
|
|
255
|
+
const over = new Set([...counts].filter(([, n]) => n > INLINE_DYN_RELEASES_PER_FUNCTION).map(([f]) => f));
|
|
256
|
+
if (over.size === 0)
|
|
257
|
+
return [...parts];
|
|
258
|
+
fn = 0;
|
|
259
|
+
return parts.map((part) => {
|
|
260
|
+
const cuts = [];
|
|
261
|
+
fn = sites(part, (at, f) => {
|
|
262
|
+
if (over.has(f))
|
|
263
|
+
cuts.push(at);
|
|
264
|
+
}, fn);
|
|
265
|
+
if (cuts.length === 0)
|
|
266
|
+
return part;
|
|
267
|
+
let out = "";
|
|
268
|
+
let from = 0;
|
|
269
|
+
for (const at of cuts) {
|
|
270
|
+
out += part.slice(from, at) + runtime;
|
|
271
|
+
from = at + call.length;
|
|
272
|
+
}
|
|
273
|
+
return out + part.slice(from);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
179
276
|
function rcHelperDecls(family, op) {
|
|
180
277
|
const row = INLINE_RC_FAMILIES[family];
|
|
181
278
|
if (op === "retain" || row.release === null)
|
|
@@ -183,6 +280,7 @@ function rcHelperDecls(family, op) {
|
|
|
183
280
|
return [
|
|
184
281
|
`declare void @${row.release}(ptr)`,
|
|
185
282
|
...(row.cycle === "always" ? [`declare void @scr_cyc_on_release(ptr)`] : []),
|
|
283
|
+
...(family === "dyn" ? [`declare void @scr_dyn_release_survivor(ptr)`] : []),
|
|
186
284
|
];
|
|
187
285
|
}
|
|
188
286
|
/** The runtime declarations the requested helpers call (deduplicated). */
|
|
@@ -230,7 +328,7 @@ function rcHeaderTest(cycle, yes, no) {
|
|
|
230
328
|
function retainHelper(host, family, row) {
|
|
231
329
|
const S = host.sizeType;
|
|
232
330
|
return [
|
|
233
|
-
`define internal ptr @${inlineRcName(family, "retain")}(ptr %o) ${
|
|
331
|
+
`define internal ptr @${inlineRcName(family, "retain")}(ptr %o) ${rcHelperAttrs(host)} { ; scr_${family}_retain fast path`,
|
|
234
332
|
`entry:`,
|
|
235
333
|
...(row.retainNull
|
|
236
334
|
? [` %isnull = icmp eq ptr %o, null`, ` br i1 %isnull, label %done, label %check`, `check:`]
|
|
@@ -252,7 +350,7 @@ function releaseHelper(host, family, row) {
|
|
|
252
350
|
const S = host.sizeType;
|
|
253
351
|
const cycle = row.cycle;
|
|
254
352
|
return [
|
|
255
|
-
`define internal void @${inlineRcName(family, "release")}(ptr %o) ${
|
|
353
|
+
`define internal void @${inlineRcName(family, "release")}(ptr %o) ${rcHelperAttrs(host)} { ; ${row.release} fast path`,
|
|
256
354
|
`entry:`,
|
|
257
355
|
` %isnull = icmp eq ptr %o, null`,
|
|
258
356
|
` br i1 %isnull, label %done, label %check`,
|
|
@@ -285,23 +383,37 @@ function releaseHelper(host, family, row) {
|
|
|
285
383
|
` br i1 %untraced, label %done, label %root`,
|
|
286
384
|
`root:`,
|
|
287
385
|
]
|
|
288
|
-
: family === "
|
|
386
|
+
: family === "dyn"
|
|
289
387
|
? [
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
//
|
|
293
|
-
` %kp = getelementptr i8, ptr %o, ${S} ${S === "i64" ? 8 : 4} ;
|
|
388
|
+
// scr_dyn_release buffers a surviving value by kind: always for
|
|
389
|
+
// arrays, objects, functions and proxies, per value for capsules
|
|
390
|
+
// and handles (scr_dyn_release_survivor), never for scalars.
|
|
391
|
+
` %kp = getelementptr i8, ptr %o, ${S} ${S === "i64" ? 8 : 4} ; ScrDyn.kind`,
|
|
294
392
|
` %kind = load i32, ptr %kp`,
|
|
295
|
-
|
|
296
|
-
`
|
|
297
|
-
`
|
|
298
|
-
`
|
|
299
|
-
`
|
|
300
|
-
` %untraced = icmp eq ptr %ot, null`,
|
|
301
|
-
` br i1 %untraced, label %done, label %root`,
|
|
393
|
+
// SCR_DYN_ARR 4, OBJ 5, FUNC 8, PROXY 13; HANDLE 9, TYPED_REF 12.
|
|
394
|
+
` switch i32 %kind, label %done [ i32 4, label %root i32 5, label %root i32 8, label %root i32 13, label %root i32 9, label %survivor i32 12, label %survivor ]`,
|
|
395
|
+
`survivor:`,
|
|
396
|
+
` call void @scr_dyn_release_survivor(ptr %o)`,
|
|
397
|
+
` br label %done`,
|
|
302
398
|
`root:`,
|
|
303
399
|
]
|
|
304
|
-
:
|
|
400
|
+
: family === "box"
|
|
401
|
+
? [
|
|
402
|
+
// scr_box_release buffers a surviving box only when its trace
|
|
403
|
+
// visits the payload (scr_box_traced): a closure (kind 4), or a
|
|
404
|
+
// class instance whose obj_trace is set.
|
|
405
|
+
` %kp = getelementptr i8, ptr %o, ${S} ${S === "i64" ? 8 : 4} ; ScrBox.kind`,
|
|
406
|
+
` %kind = load i32, ptr %kp`,
|
|
407
|
+
` %func = icmp eq i32 %kind, 4`,
|
|
408
|
+
` br i1 %func, label %root, label %objbox`,
|
|
409
|
+
`objbox:`,
|
|
410
|
+
` %otp = getelementptr i8, ptr %o, ${S} ${S === "i64" ? 32 : 16} ; ScrBox.obj_trace`,
|
|
411
|
+
` %ot = load ptr, ptr %otp`,
|
|
412
|
+
` %untraced = icmp eq ptr %ot, null`,
|
|
413
|
+
` br i1 %untraced, label %done, label %root`,
|
|
414
|
+
`root:`,
|
|
415
|
+
]
|
|
416
|
+
: []),
|
|
305
417
|
...(cycle === "always" ? cycleRootLines(host, "done") : [` br label %done`]),
|
|
306
418
|
`done:`,
|
|
307
419
|
` ret void`,
|
|
@@ -382,6 +494,10 @@ export function traceAdapter(host, t) {
|
|
|
382
494
|
host.declare(`declare void @scr_stream_trace(ptr, ptr, ptr)`);
|
|
383
495
|
return "@scr_stream_trace";
|
|
384
496
|
}
|
|
497
|
+
// The EventTarget and Event bases have no instances of their own:
|
|
498
|
+
// values of subclasses trace through their own classes' entries.
|
|
499
|
+
if (t.className === RUNTIME_EVENT_TARGET_CLASS || t.className === RUNTIME_EVENT_CLASS)
|
|
500
|
+
return null;
|
|
385
501
|
return `@${mangleClassTrace(t.className)}`;
|
|
386
502
|
case "map":
|
|
387
503
|
if (traceAdapter(host, t.key) === null && traceAdapter(host, t.value) === null)
|
|
@@ -452,7 +568,10 @@ function elemKindNum(elem) {
|
|
|
452
568
|
* SCR_ELEM_ARR spelling would hide them from the outer array's trace)
|
|
453
569
|
* construct through scr_arr_new_ops with the element type's `_v` RC entry
|
|
454
570
|
* points; every other element kind keeps the plain scr_arr_new call. */
|
|
455
|
-
export function arrNewCall(host, elem, capText
|
|
571
|
+
export function arrNewCall(host, elem, capText,
|
|
572
|
+
/** An empty array expected to receive a few elements (its first slots
|
|
573
|
+
* live in its own block): capText must be "0". */
|
|
574
|
+
small = false) {
|
|
456
575
|
const useRef = elem.kind === "record" ||
|
|
457
576
|
elem.kind === "object" ||
|
|
458
577
|
elem.kind === "union" ||
|
|
@@ -469,9 +588,17 @@ export function arrNewCall(host, elem, capText) {
|
|
|
469
588
|
elem.kind === "regex" || // RegExp values: scr_regex_* adapters, no trace (no refs inside)
|
|
470
589
|
(elem.kind === "array" && traceAdapter(host, elem) !== null);
|
|
471
590
|
if (!useRef) {
|
|
591
|
+
if (small) {
|
|
592
|
+
host.declare(`declare ptr @scr_arr_new_small(i32)`);
|
|
593
|
+
return `call ptr @scr_arr_new_small(i32 ${elemKindNum(elem)})`;
|
|
594
|
+
}
|
|
472
595
|
host.declare(`declare ptr @scr_arr_new(i32, ${host.sizeType})`);
|
|
473
596
|
return `call ptr @scr_arr_new(i32 ${elemKindNum(elem)}, ${host.sizeType} ${capText})`;
|
|
474
597
|
}
|
|
598
|
+
if (small) {
|
|
599
|
+
host.declare(`declare ptr @scr_arr_new_ops_small(ptr)`);
|
|
600
|
+
return `call ptr @scr_arr_new_ops_small(ptr ${arrOps(host, elem)})`;
|
|
601
|
+
}
|
|
475
602
|
host.declare(`declare ptr @scr_arr_new_ops(ptr, ${host.sizeType})`);
|
|
476
603
|
return `call ptr @scr_arr_new_ops(ptr ${arrOps(host, elem)}, ${host.sizeType} ${capText})`;
|
|
477
604
|
}
|
|
@@ -525,8 +652,11 @@ export function boxAccess(t) {
|
|
|
525
652
|
}
|
|
526
653
|
/* ── record shapes ────────────────────────────────────────────────────── */
|
|
527
654
|
/** A record field's in-struct LLVM type. bool fields store as i8 (the C
|
|
528
|
-
* _Bool layout); loads/stores convert at the access site.
|
|
529
|
-
|
|
655
|
+
* _Bool layout); loads/stores convert at the access site. An `inline`
|
|
656
|
+
* scalar-union field stores its tag and bits (inline-unions.ts). */
|
|
657
|
+
export function llFieldType(t, inline) {
|
|
658
|
+
if (inline)
|
|
659
|
+
return INLINE_UNION_FIELD;
|
|
530
660
|
if (POINTER_KINDS.has(t.kind))
|
|
531
661
|
return "ptr";
|
|
532
662
|
switch (t.kind) {
|
|
@@ -540,6 +670,23 @@ export function llFieldType(t) {
|
|
|
540
670
|
throw new LlvmUnsupportedError(`type:${t.kind}`);
|
|
541
671
|
}
|
|
542
672
|
}
|
|
673
|
+
/** Loads a struct field slot for helper code: i8 bools truncate to i1, and
|
|
674
|
+
* an inline union field lends a private stack box with the slot's own
|
|
675
|
+
* bits (ABSENT included). */
|
|
676
|
+
export function loadStructField(B, sizeType, ptr, t, inline) {
|
|
677
|
+
if (inline) {
|
|
678
|
+
const { tag, bits } = loadInlineUnion(B, ptr);
|
|
679
|
+
return stackUnionBox(B, sizeType, tag, bits);
|
|
680
|
+
}
|
|
681
|
+
const fieldTy = llFieldType(t, false);
|
|
682
|
+
const raw = B.tmp();
|
|
683
|
+
B.line(`${raw} = load ${fieldTy}, ptr ${ptr}`);
|
|
684
|
+
if (fieldTy !== "i8")
|
|
685
|
+
return raw;
|
|
686
|
+
const b = B.tmp();
|
|
687
|
+
B.line(`${b} = trunc i8 ${raw} to i1`);
|
|
688
|
+
return b;
|
|
689
|
+
}
|
|
543
690
|
/** The key's calling convention is independent of equality: bigint and
|
|
544
691
|
* union payloads travel by reference but compare by JavaScript value. */
|
|
545
692
|
export function mapKeyAccess(key) {
|
|
@@ -582,12 +729,13 @@ export function mapKeyKindNum(key, unionArms) {
|
|
|
582
729
|
export function mapValKindNum(value) {
|
|
583
730
|
return value.kind === "f64" ? 0 : value.kind === "bool" ? 1 : 2;
|
|
584
731
|
}
|
|
585
|
-
/** The RC-relevant members of a shape: every field
|
|
586
|
-
* on index-signature shapes (one more
|
|
587
|
-
* member's field position in the
|
|
588
|
-
|
|
732
|
+
/** The RC-relevant members of a shape: every field except inline scalar
|
|
733
|
+
* unions, plus the overflow map on index-signature shapes (one more
|
|
734
|
+
* map-typed member). `index` is the member's field position in the
|
|
735
|
+
* emitted struct type (rc header at 0). */
|
|
736
|
+
export function rcMembers(shape, inline) {
|
|
589
737
|
return [
|
|
590
|
-
...shape.fields.
|
|
738
|
+
...shape.fields.flatMap((f, i) => inline.record(f.type) ? [] : [{ index: i + 1, type: f.type, name: f.name }]),
|
|
591
739
|
...(shape.indexValue
|
|
592
740
|
? [
|
|
593
741
|
{
|
|
@@ -605,7 +753,7 @@ function rcMembers(shape) {
|
|
|
605
753
|
export function retainBody(host, fnName, comment = "", immortal = false) {
|
|
606
754
|
const S = host.sizeType;
|
|
607
755
|
if (immortal)
|
|
608
|
-
return immortalRcBody(fnName, "ptr", comment);
|
|
756
|
+
return immortalRcBody(host, fnName, "ptr", comment);
|
|
609
757
|
return [
|
|
610
758
|
`define internal ptr @${fnName}(ptr %o) ${FN_ATTRS} {${comment ? ` ; ${comment}` : ""}`,
|
|
611
759
|
`entry:`,
|
|
@@ -627,8 +775,12 @@ export function retainBody(host, fnName, comment = "", immortal = false) {
|
|
|
627
775
|
/** The retain or release entry point of a class whose every instance lives
|
|
628
776
|
* until the process exits (no collector header; see classes.ts
|
|
629
777
|
* programLifetimeClass and programLifetimeRc): nothing to count, so every
|
|
630
|
-
* inlined call site folds away.
|
|
631
|
-
|
|
778
|
+
* inlined call site folds away. Programs with lifetime regions count the
|
|
779
|
+
* references in the instance's region chunk instead (llvm/regions.ts). */
|
|
780
|
+
function immortalRcBody(host, fnName, ret, comment) {
|
|
781
|
+
const regions = host.regions ?? null;
|
|
782
|
+
if (regions !== null)
|
|
783
|
+
return regions.rcBody(fnName, ret, comment);
|
|
632
784
|
return [
|
|
633
785
|
`define internal ${ret} @${fnName}(ptr %o) ${FN_ATTRS} {${comment ? ` ; ${comment} (immortal)` : ""}`,
|
|
634
786
|
`entry:`,
|
|
@@ -673,7 +825,7 @@ export function directChildReleaseLines(host, tag, value, target, comment) {
|
|
|
673
825
|
];
|
|
674
826
|
if (target.traced) {
|
|
675
827
|
host.declare(`declare void @scr_cyc_on_dead(ptr)`);
|
|
676
|
-
lines.push(` %${tag}.bufp = getelementptr i8, ptr ${value}, ${S} -${host.
|
|
828
|
+
lines.push(` %${tag}.bufp = getelementptr i8, ptr ${value}, ${S} -${host.cycleBufOffset}`, ` %${tag}.buf = load i32, ptr %${tag}.bufp`, ` %${tag}.queued = icmp slt i32 %${tag}.buf, 0`, ` br i1 %${tag}.queued, label %${tag}.unbuffer, label %${tag}.teardown`, `${tag}.unbuffer:`, ` call void @scr_cyc_on_dead(ptr ${value})`, ` br label %${tag}.teardown`, `${tag}.teardown:`);
|
|
677
829
|
}
|
|
678
830
|
lines.push(` %${tag}.short = icmp ult i32 %d, ${DIRECT_DESTROY_CHAIN}`, ` br i1 %${tag}.short, label %${tag}.direct, label %${tag}.bounded`, `${tag}.direct:`, ` %${tag}.d = add i32 %d, 1`, ` call void @${target.destroy}_d(ptr ${value}, i32 %${tag}.d)`, ` br label %${tag}.next`, `${tag}.bounded:`, ` call void @scr_rc_destroy(ptr ${value}, ptr @${target.destroy})`, ` br label %${tag}.next`, `${tag}.next:`);
|
|
679
831
|
return lines;
|
|
@@ -779,7 +931,7 @@ export function releaseBody(host, fnName, traced, freeBody, comment = "", bounde
|
|
|
779
931
|
export function releaseFastPath(host, fnName, slow, traced, comment = "", immortal = false) {
|
|
780
932
|
const S = host.sizeType;
|
|
781
933
|
if (immortal)
|
|
782
|
-
return immortalRcBody(fnName, "void", comment);
|
|
934
|
+
return immortalRcBody(host, fnName, "void", comment);
|
|
783
935
|
return [
|
|
784
936
|
`define internal void @${fnName}(ptr %o) ${FN_ATTRS} {${comment ? ` ; ${comment} (fast path)` : ""}`,
|
|
785
937
|
`entry:`,
|
|
@@ -809,9 +961,9 @@ export function releaseFastPath(host, fnName, slow, traced, comment = "", immort
|
|
|
809
961
|
];
|
|
810
962
|
}
|
|
811
963
|
/** The possible-cycle-root step of a release that left a headered object
|
|
812
|
-
* alive: scr_cyc_on_release with its early return inlined.
|
|
813
|
-
* (the
|
|
814
|
-
*
|
|
964
|
+
* alive: scr_cyc_on_release with its early return inlined. Test the sign
|
|
965
|
+
* of `buf` (the i32 at obj-4; negative for a queued candidate or a tenured
|
|
966
|
+
* object) and call the runtime only to enqueue a new candidate.
|
|
815
967
|
* Every emitted release of a headered object shares this sequence
|
|
816
968
|
* (scr_runtime.h asserts the offset); it ends by branching to `done`. */
|
|
817
969
|
/** One traced field of an emitted trace function: load the slot and visit
|
|
@@ -835,9 +987,9 @@ export function cycleRootLines(host, done) {
|
|
|
835
987
|
const S = host.sizeType;
|
|
836
988
|
host.declare(`declare void @scr_cyc_on_release(ptr)`);
|
|
837
989
|
return [
|
|
838
|
-
` %bufp = getelementptr i8, ptr %o, ${S} -${host.
|
|
839
|
-
` %buf = load
|
|
840
|
-
` %queued = icmp
|
|
990
|
+
` %bufp = getelementptr i8, ptr %o, ${S} -${host.cycleBufOffset}`,
|
|
991
|
+
` %buf = load i32, ptr %bufp`,
|
|
992
|
+
` %queued = icmp slt i32 %buf, 0`,
|
|
841
993
|
` br i1 %queued, label %${done}, label %enqueue`,
|
|
842
994
|
`enqueue:`,
|
|
843
995
|
` call void @scr_cyc_on_release(ptr %o) ; buffer the candidate; may collect`,
|
|
@@ -852,9 +1004,9 @@ export function cycleDeadLines(host, next) {
|
|
|
852
1004
|
const S = host.sizeType;
|
|
853
1005
|
host.declare(`declare void @scr_cyc_on_dead(ptr)`);
|
|
854
1006
|
return [
|
|
855
|
-
` %dbufp = getelementptr i8, ptr %o, ${S} -${host.
|
|
856
|
-
` %dbuf = load
|
|
857
|
-
` %dqueued = icmp
|
|
1007
|
+
` %dbufp = getelementptr i8, ptr %o, ${S} -${host.cycleBufOffset}`,
|
|
1008
|
+
` %dbuf = load i32, ptr %dbufp`,
|
|
1009
|
+
` %dqueued = icmp slt i32 %dbuf, 0`,
|
|
858
1010
|
` br i1 %dqueued, label %unbuffer, label %${next}`,
|
|
859
1011
|
`unbuffer:`,
|
|
860
1012
|
` call void @scr_cyc_on_dead(ptr %o)`,
|
|
@@ -881,7 +1033,7 @@ export function emitRecordShapes(host, mod) {
|
|
|
881
1033
|
}
|
|
882
1034
|
for (const shape of records) {
|
|
883
1035
|
const struct = mangleRecordStruct(shape.id);
|
|
884
|
-
const fieldTys = shape.fields.map((f) => llFieldType(f.type));
|
|
1036
|
+
const fieldTys = shape.fields.map((f) => llFieldType(f.type, host.inlineUnions.record(f.type)));
|
|
885
1037
|
if (shape.indexValue)
|
|
886
1038
|
fieldTys.push("ptr"); // the overflow ScrMap *
|
|
887
1039
|
typeDefs.push(`%${struct} = type { ${host.sizeType}${fieldTys.length ? ", " + fieldTys.join(", ") : ""} } ` +
|
|
@@ -893,7 +1045,7 @@ export function emitRecordShapes(host, mod) {
|
|
|
893
1045
|
const candidates = [];
|
|
894
1046
|
const memberTypes = [];
|
|
895
1047
|
for (const shape of records) {
|
|
896
|
-
const members = rcMembers(shape);
|
|
1048
|
+
const members = rcMembers(shape, host.inlineUnions);
|
|
897
1049
|
for (const m of members)
|
|
898
1050
|
memberTypes.push(m.type);
|
|
899
1051
|
if (!members.some((m) => isRefCounted(m.type) && needsBoundedRelease(m.type)))
|
|
@@ -912,7 +1064,7 @@ export function emitRecordShapes(host, mod) {
|
|
|
912
1064
|
for (const shape of records) {
|
|
913
1065
|
const struct = mangleRecordStruct(shape.id);
|
|
914
1066
|
const traced = host.tracedShapes.has(`record:${shape.id}`);
|
|
915
|
-
const members = rcMembers(shape);
|
|
1067
|
+
const members = rcMembers(shape, host.inlineUnions);
|
|
916
1068
|
const refMembers = members.filter((m) => isRefCounted(m.type));
|
|
917
1069
|
const sizeOf = `ptrtoint (ptr getelementptr (%${struct}, ptr null, i32 1) to ${host.sizeType})`;
|
|
918
1070
|
defs.push(...retainBody(host, mangleRecordRetain(shape.id)), ``);
|
|
@@ -973,10 +1125,12 @@ export function emitRecordShapes(host, mod) {
|
|
|
973
1125
|
let i = 0;
|
|
974
1126
|
for (const field of shape.fields) {
|
|
975
1127
|
const index = i + 1;
|
|
976
|
-
const
|
|
1128
|
+
const inline = host.inlineUnions.record(field.type);
|
|
1129
|
+
const fieldTy = llFieldType(field.type, inline);
|
|
977
1130
|
clone.push(` %sp${i} = getelementptr inbounds %${struct}, ptr %src, i64 0, i32 ${index}`, ` %sv${i} = load ${fieldTy}, ptr %sp${i}`);
|
|
978
|
-
const
|
|
979
|
-
|
|
1131
|
+
const owned = isRefCounted(field.type) && !inline;
|
|
1132
|
+
const stored = owned ? `%sr${i}` : `%sv${i}`;
|
|
1133
|
+
if (owned) {
|
|
980
1134
|
clone.push(` ${stored} = call ptr ${retainSym(host, field.type)}(ptr %sv${i})`);
|
|
981
1135
|
}
|
|
982
1136
|
clone.push(` %dp${i} = getelementptr inbounds %${struct}, ptr %o, i64 0, i32 ${index}`, ` store ${fieldTy} ${stored}, ptr %dp${i} ; ${llvmCommentText(field.name)}`);
|