@scriptc/compiler 0.3.0 → 0.3.2
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 +346 -17
- 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 +39 -15
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +15 -1
- 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/bigint-wrap.d.ts +4 -0
- package/dist/backend/llvm/bigint-wrap.js +590 -0
- package/dist/backend/llvm/bigint-wrap.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +2 -0
- package/dist/backend/llvm/blocks.js +4 -0
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.d.ts +4 -1
- package/dist/backend/llvm/call-lifetimes.js +66 -7
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +14 -3
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +1 -1
- package/dist/backend/llvm/checked-narrows.test.js.map +1 -1
- package/dist/backend/llvm/classes.js +67 -14
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +6 -6
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +7 -5
- package/dist/backend/llvm/common.js +7 -5
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.js +10 -28
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.js +146 -53
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +68 -3
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +4 -0
- package/dist/backend/llvm/dyn.js +15 -2
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +163 -8
- package/dist/backend/llvm/emitter.js +973 -100
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +14 -7
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +242 -49
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.js +1 -1
- package/dist/backend/llvm/expr-async.test.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +51 -36
- 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 +153 -4
- 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 +279 -78
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-calls.test.d.ts +1 -0
- package/dist/backend/llvm/expr-calls.test.js +132 -0
- package/dist/backend/llvm/expr-calls.test.js.map +1 -0
- package/dist/backend/llvm/expr-containers.d.ts +7 -0
- package/dist/backend/llvm/expr-containers.js +49 -5
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +4 -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-dispatch.js +3 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +28 -6
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +14 -0
- package/dist/backend/llvm/expr-primitives.js +110 -48
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +95 -5
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +9 -0
- package/dist/backend/llvm/expr-records.js +144 -16
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +9 -1
- package/dist/backend/llvm/expr-stream-bridges.js +152 -4
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +98 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/int32-abi.d.ts +47 -0
- package/dist/backend/llvm/int32-abi.js +83 -0
- package/dist/backend/llvm/int32-abi.js.map +1 -0
- package/dist/backend/llvm/int32-abi.test.d.ts +1 -0
- package/dist/backend/llvm/int32-abi.test.js +181 -0
- package/dist/backend/llvm/int32-abi.test.js.map +1 -0
- package/dist/backend/llvm/int32-locals.d.ts +30 -0
- package/dist/backend/llvm/int32-locals.js +95 -0
- package/dist/backend/llvm/int32-locals.js.map +1 -0
- package/dist/backend/llvm/integer-values.d.ts +4 -0
- package/dist/backend/llvm/integer-values.js +30 -1
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/integer-views.d.ts +8 -1
- package/dist/backend/llvm/integer-views.js +47 -2
- package/dist/backend/llvm/integer-views.js.map +1 -1
- package/dist/backend/llvm/lazy-captures.d.ts +16 -0
- package/dist/backend/llvm/lazy-captures.js +88 -2
- package/dist/backend/llvm/lazy-captures.js.map +1 -1
- package/dist/backend/llvm/lazy-captures.test.js +48 -0
- package/dist/backend/llvm/lazy-captures.test.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +21 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +61 -0
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +83 -9
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +26 -5
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +3 -2
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.d.ts +24 -2
- package/dist/backend/llvm/local-union-storage.js +127 -12
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +108 -3
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +2 -2
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/record-results.d.ts +26 -0
- package/dist/backend/llvm/record-results.js +252 -0
- package/dist/backend/llvm/record-results.js.map +1 -0
- package/dist/backend/llvm/reference-effects.js +4 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +3 -0
- package/dist/backend/llvm/reference-writes.js +25 -11
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/regex-matchers.d.ts +39 -0
- package/dist/backend/llvm/regex-matchers.js +1649 -0
- package/dist/backend/llvm/regex-matchers.js.map +1 -0
- package/dist/backend/llvm/regex-matchers.test.d.ts +1 -0
- package/dist/backend/llvm/regex-matchers.test.js +96 -0
- package/dist/backend/llvm/regex-matchers.test.js.map +1 -0
- package/dist/backend/llvm/regions.d.ts +67 -0
- package/dist/backend/llvm/regions.js +309 -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/shapes.d.ts +70 -8
- package/dist/backend/llvm/shapes.js +157 -29
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +7 -6
- 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 +130 -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 +252 -0
- package/dist/backend/llvm/stack-objects.test.js.map +1 -0
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-construction.test.js +2 -2
- package/dist/backend/llvm/string-construction.test.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +5 -5
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-literal-equality.d.ts +22 -0
- package/dist/backend/llvm/string-literal-equality.js +78 -0
- package/dist/backend/llvm/string-literal-equality.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 +60 -13
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +71 -6
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/union-retype.test.d.ts +1 -0
- package/dist/backend/llvm/union-retype.test.js +229 -0
- package/dist/backend/llvm/union-retype.test.js.map +1 -0
- package/dist/backend/llvm/walkers.d.ts +2 -0
- package/dist/backend/llvm/walkers.js +4 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/llvm/wrapping-sums.d.ts +17 -0
- package/dist/backend/llvm/wrapping-sums.js +113 -0
- package/dist/backend/llvm/wrapping-sums.js.map +1 -0
- package/dist/backend/loop-polls.js +1 -0
- package/dist/backend/loop-polls.js.map +1 -1
- package/dist/backend/mangle.d.ts +9 -0
- package/dist/backend/mangle.js +15 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/may-throw.js +7 -3
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +5 -0
- package/dist/backend/native/executable.js +16 -1
- 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 +2 -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/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 +14 -0
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +13 -0
- package/dist/backend/target-diagnostics.test.js.map +1 -1
- package/dist/contracts/check.js +4 -0
- package/dist/contracts/check.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/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/array-values.d.ts +14 -0
- package/dist/frontend/lowering/array-values.js +29 -0
- package/dist/frontend/lowering/array-values.js.map +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/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/errors.js +20 -0
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- 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/module-calls.js +16 -1
- 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/process.js +15 -3
- 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/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/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 +6 -3
- package/dist/frontend/lowering/class-dynamic-dispatch.js +54 -31
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +74 -4
- 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-pipelines.d.ts +54 -0
- package/dist/frontend/lowering/containers/array-pipelines.js +1827 -0
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -0
- package/dist/frontend/lowering/containers/exec-result-uses.d.ts +10 -0
- package/dist/frontend/lowering/containers/exec-result-uses.js +88 -0
- package/dist/frontend/lowering/containers/exec-result-uses.js.map +1 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js +106 -7
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.d.ts +2 -1
- package/dist/frontend/lowering/containers/string-replacement.js +32 -136
- package/dist/frontend/lowering/containers/string-replacement.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/devirtualize.d.ts +33 -0
- package/dist/frontend/lowering/devirtualize.js +199 -0
- package/dist/frontend/lowering/devirtualize.js.map +1 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js +55 -7
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +5 -56
- 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/identifier-uses.d.ts +7 -0
- package/dist/frontend/lowering/identifier-uses.js +23 -0
- package/dist/frontend/lowering/identifier-uses.js.map +1 -0
- package/dist/frontend/lowering/iterator-adapters.js +51 -3
- package/dist/frontend/lowering/iterator-adapters.js.map +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 +28 -2
- package/dist/frontend/lowering/lower-array-sort.js +112 -2
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +99 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +135 -131
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +4 -3
- package/dist/frontend/lowering/lower-classes.js +117 -13
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-console.d.ts +27 -0
- package/dist/frontend/lowering/lower-console.js +651 -0
- package/dist/frontend/lowering/lower-console.js.map +1 -0
- 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-exprs.js +272 -25
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +7 -3
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +25 -7
- package/dist/frontend/lowering/lower-generators.js +264 -113
- 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 +119 -18
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +24 -14
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +4 -0
- package/dist/frontend/lowering/lower-stdlib.js +35 -1
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +66 -11
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +13 -10
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +47 -5
- package/dist/frontend/lowering/lowerer.js +235 -54
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/nan-coded-reads.d.ts +16 -0
- package/dist/frontend/lowering/nan-coded-reads.js +108 -1
- package/dist/frontend/lowering/nan-coded-reads.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-bounds.d.ts +4 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js +2 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-bounds.test.js +27 -0
- package/dist/frontend/lowering/runtime-optional-bounds.test.js.map +1 -1
- package/dist/frontend/lowering/split-consumers.js +2 -18
- package/dist/frontend/lowering/split-consumers.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +115 -18
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +6 -1
- package/dist/frontend/lowering/union-retag.js +64 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +46 -0
- package/dist/frontend/lowering/union-retag.test.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/pipeline.js +5 -3
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +3 -2
- package/dist/frontend/program.js +23 -5
- 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/type-mapper.d.ts +13 -1
- package/dist/frontend/type-mapper.js +160 -14
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +31 -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 +157 -16
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/function-references.d.ts +12 -0
- package/dist/ir/function-references.js +29 -0
- package/dist/ir/function-references.js.map +1 -0
- package/dist/ir/function-references.test.d.ts +1 -0
- package/dist/ir/function-references.test.js +277 -0
- package/dist/ir/function-references.test.js.map +1 -0
- package/dist/ir/int32-slots.d.ts +7 -4
- package/dist/ir/int32-slots.js +215 -49
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +38 -1
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +4 -4
- package/dist/ir/integer-ranges.js +89 -64
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +71 -9
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/intrinsic-signatures.js +3 -0
- package/dist/ir/intrinsic-signatures.js.map +1 -1
- package/dist/ir/ir.d.ts +111 -20
- package/dist/ir/ir.js +6 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +1 -0
- package/dist/ir/runtime-features.js +38 -3
- 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/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +201 -25
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +90 -7
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.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 +159 -17
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
/* Focused LLVM expression emission extracted from emitter.ts. */
|
|
2
2
|
import { InternalCompilerError } from "../../errors.js";
|
|
3
3
|
import { newValueMayThrow } from "../../ir/analysis.js";
|
|
4
|
-
import { isFfiCallbackParam, isFfiContextParam, isFfiReleaseParam, isRefCounted, } from "../../ir/ir.js";
|
|
4
|
+
import { isDynTypedRefType, isFfiCallbackParam, isFfiContextParam, isFfiReleaseParam, isRefCounted, typeKey, } from "../../ir/ir.js";
|
|
5
|
+
import { liveRefView } from "./expr-stream-bridges.js";
|
|
6
|
+
import { typedRefConstructor, vAdapters } from "./shapes.js";
|
|
7
|
+
import { INT32_ABI_SUFFIX, SCALAR_UNION_RESULT } from "./int32-abi.js";
|
|
8
|
+
import { canStackObject, emitStackObject } from "./stack-objects.js";
|
|
5
9
|
import { collectFfiRetainedOps, parseFfiCallbackKey } from "../ffi-callbacks.js";
|
|
6
|
-
import { mangleBorrowedFunction, mangleClassNew, mangleClassRetain, mangleClassStruct, mangleFnClosure, mangleFunction, mangleWrapper, mangleVtStruct, } from "../mangle.js";
|
|
10
|
+
import { mangleAsyncAdoptCall, mangleAsyncAwaitCall, mangleBorrowedFunction, mangleBorrowingWrapper, mangleClassNew, mangleClassRetain, mangleClassStruct, mangleFnClosure, mangleFunction, mangleWrapper, mangleVtStruct, } from "../mangle.js";
|
|
7
11
|
import { classMembershipIntervals, classEnvironmentIndex, classStructSym } from "./classes.js";
|
|
8
12
|
import { LlvmUnsupportedError } from "./unsupported.js";
|
|
9
13
|
import { f64Lit, ffiNativeTypeLl, ffiNativeParamLl, ffiNativeReturnLl } from "./common.js";
|
|
10
14
|
import { canStackUnion, emitStackUnion } from "./stack-unions.js";
|
|
11
15
|
import { emitCallArrayRead } from "./local-array-reads.js";
|
|
16
|
+
import { emitScalarOptional, isScalarOptionalSource } from "./local-union-storage.js";
|
|
12
17
|
import { emitStackMapRead } from "./map-read-lifetimes.js";
|
|
13
18
|
import { borrowableInputs, emitBorrowedInput, emitBorrowedInputs, inputSuffixWrites, } from "./borrowed-inputs.js";
|
|
14
|
-
export function emitCallExpr(host, e
|
|
19
|
+
export function emitCallExpr(host, e, awaitEntry = false,
|
|
20
|
+
/** A projection consumes a scalar union result (Int32Abi.union): answer
|
|
21
|
+
* a private stack box instead of a heap box. */
|
|
22
|
+
stackResult = false,
|
|
23
|
+
/** The frame storage a result-slot entry (record-results.ts) writes:
|
|
24
|
+
* passed after the call's own arguments. */
|
|
25
|
+
resultSlot) {
|
|
15
26
|
const B = host.B;
|
|
16
27
|
switch (e.kind) {
|
|
17
28
|
case "call": {
|
|
@@ -57,6 +68,16 @@ export function emitCallExpr(host, e) {
|
|
|
57
68
|
}
|
|
58
69
|
if (canStackUnion(a, host.boxedUnionsById))
|
|
59
70
|
return emitStackUnion(host, a).value;
|
|
71
|
+
if ((a.kind === "optChain" ||
|
|
72
|
+
a.kind === "nullish" ||
|
|
73
|
+
a.kind === "ternary" ||
|
|
74
|
+
a.kind === "arrIntrinsic") &&
|
|
75
|
+
isScalarOptionalSource(a, host.unionSources))
|
|
76
|
+
return emitScalarOptional(host, a);
|
|
77
|
+
if (a.kind === "call" && host.scalarResultCall(a))
|
|
78
|
+
return emitCallExpr(host, a, false, true);
|
|
79
|
+
if (host.stackObjects && canStackObject(host, a))
|
|
80
|
+
return emitStackObject(host, a);
|
|
60
81
|
if (host.nullableFieldGet(a))
|
|
61
82
|
return { name: host.emitOwnedNullableStack(a).box, type: a.type };
|
|
62
83
|
}
|
|
@@ -65,6 +86,8 @@ export function emitCallExpr(host, e) {
|
|
|
65
86
|
}
|
|
66
87
|
return host.emitExpr(a);
|
|
67
88
|
});
|
|
89
|
+
if (resultSlot)
|
|
90
|
+
args.push(resultSlot);
|
|
68
91
|
// A borrowed parameter's owned argument stays in the caller frame.
|
|
69
92
|
// This also preserves snapshots when a later argument mutates its
|
|
70
93
|
// source, and releases earlier arguments if evaluation throws.
|
|
@@ -72,14 +95,37 @@ export function emitCallExpr(host, e) {
|
|
|
72
95
|
if (!borrowed?.has(index))
|
|
73
96
|
host.moveTemp(a);
|
|
74
97
|
});
|
|
98
|
+
const abi = awaitEntry ? undefined : host.int32Abis.get(e.callee);
|
|
75
99
|
const argList = args
|
|
76
|
-
.map((a, i) =>
|
|
100
|
+
.map((a, i) => abi?.params[i]
|
|
101
|
+
? `i32 ${host.int32Argument(a, e.args[i])}`
|
|
102
|
+
: `${host.llType(callee.params[i].type)} ${a.name}`)
|
|
77
103
|
.join(", ");
|
|
104
|
+
if (awaitEntry) {
|
|
105
|
+
// The enclosing await routes this call through the callee's
|
|
106
|
+
// await-call entry: the result is the awaited value, and the
|
|
107
|
+
// await's rejection re-throw is the pending check. An adopting
|
|
108
|
+
// entry (`return f(...)`) also takes the adoption's then-job turn.
|
|
109
|
+
const adopt = awaitEntry === "adopt";
|
|
110
|
+
(adopt ? host.adoptCallees : host.awaitCallees).add(e.callee);
|
|
111
|
+
const awaited = callee.returnType;
|
|
112
|
+
const entry = `@${adopt ? mangleAsyncAdoptCall(e.callee) : mangleAsyncAwaitCall(e.callee)}`;
|
|
113
|
+
if (awaited.kind === "void") {
|
|
114
|
+
B.line(`call void ${entry}(${argList})`);
|
|
115
|
+
host.emitPendingCheck();
|
|
116
|
+
return { name: "", type: awaited };
|
|
117
|
+
}
|
|
118
|
+
const t = B.tmp();
|
|
119
|
+
B.line(`${t} = call ${host.llType(awaited)} ${entry}(${argList})`);
|
|
120
|
+
const out = host.own({ name: t, type: awaited });
|
|
121
|
+
host.emitPendingCheck();
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
78
124
|
// Async callee: the spawn wrapper runs the body eagerly to its
|
|
79
125
|
// first suspension and returns the promise (+1). The call itself
|
|
80
126
|
// never unwinds — rejections surface at await (computeMayThrow's
|
|
81
127
|
// async exclusion).
|
|
82
|
-
const target = `@${borrowed ? mangleBorrowedFunction(e.callee) : host.callTarget(e.callee)}`;
|
|
128
|
+
const target = `@${borrowed ? mangleBorrowedFunction(e.callee) : host.callTarget(e.callee)}${abi ? INT32_ABI_SUFFIX : ""}`;
|
|
83
129
|
if (e.type.kind === "void") {
|
|
84
130
|
B.line(`call void ${target}(${argList})`);
|
|
85
131
|
if (host.mayThrow.has(e.callee))
|
|
@@ -89,6 +135,25 @@ export function emitCallExpr(host, e) {
|
|
|
89
135
|
return { name: "", type: e.type };
|
|
90
136
|
}
|
|
91
137
|
const t = B.tmp();
|
|
138
|
+
if (abi?.union) {
|
|
139
|
+
B.line(`${t} = call ${SCALAR_UNION_RESULT} ${target}(${argList})`);
|
|
140
|
+
if (host.mayThrow.has(e.callee))
|
|
141
|
+
host.emitPendingCheck();
|
|
142
|
+
if (borrowed)
|
|
143
|
+
host.releaseFrame(host.frames.pop());
|
|
144
|
+
if (stackResult)
|
|
145
|
+
return host.stackScalarUnion(t, e.type);
|
|
146
|
+
return host.own({ name: host.boxScalarUnion(t, e.type), type: e.type });
|
|
147
|
+
}
|
|
148
|
+
if (abi?.result) {
|
|
149
|
+
B.line(`${t} = call i32 ${target}(${argList})`);
|
|
150
|
+
const out = host.int32Result(t, e.type);
|
|
151
|
+
if (host.mayThrow.has(e.callee))
|
|
152
|
+
host.emitPendingCheck(out);
|
|
153
|
+
if (borrowed)
|
|
154
|
+
host.releaseFrame(host.frames.pop());
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
92
157
|
B.line(`${t} = call ${host.llType(e.type)} ${target}(${argList})`);
|
|
93
158
|
let out;
|
|
94
159
|
if (borrowed && host.borrowedReturns.has(e.callee)) {
|
|
@@ -548,6 +613,13 @@ export function emitCallExpr(host, e) {
|
|
|
548
613
|
B.line(`${kindPtr} = getelementptr inbounds %ScrClosure, ptr ${c}, i64 0, i32 4`);
|
|
549
614
|
B.line(`store i32 ${functionKind}, ptr ${kindPtr}`);
|
|
550
615
|
}
|
|
616
|
+
if (host.lendsEveryArgument(e.fnName)) {
|
|
617
|
+
// The body that borrows its reference arguments, for callers that
|
|
618
|
+
// keep them alive across the call (the runtime's comparator sort).
|
|
619
|
+
const entry = B.tmp();
|
|
620
|
+
B.line(`${entry} = getelementptr inbounds %ScrClosure, ptr ${c}, i64 0, i32 7`);
|
|
621
|
+
B.line(`store ptr @${mangleBorrowedFunction(e.fnName)}, ptr ${entry}`);
|
|
622
|
+
}
|
|
551
623
|
e.captures.forEach((localId, i) => {
|
|
552
624
|
const box = host.captureBox(localId);
|
|
553
625
|
const retained = host.retainBox(box);
|
|
@@ -584,10 +656,41 @@ export function emitCallExpr(host, e) {
|
|
|
584
656
|
if (e.args.length !== ft.params.length)
|
|
585
657
|
throw new LlvmUnsupportedError("callValue:arity", e.loc);
|
|
586
658
|
const callee = host.stackCallbacks.emit(host, e.callee) ?? emitBorrowedInput(host, e.callee);
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
659
|
+
// A class instance bound as the callee's `this` (`h.fn(x)`) is boxed
|
|
660
|
+
// only if the callee reads it: the receiver window records the
|
|
661
|
+
// instance (owned by this frame for the whole call) with its typed-ref
|
|
662
|
+
// recipe, and dyn.this builds the box on first read.
|
|
663
|
+
const lazyReceiver = e.receiver?.kind === "dynFrom" &&
|
|
664
|
+
e.receiver.value.type.kind === "object" &&
|
|
665
|
+
isDynTypedRefType(e.receiver.value.type) &&
|
|
666
|
+
!host.shapeHost.isErrorClass(e.receiver.value.type.className)
|
|
667
|
+
? host.emitExpr(e.receiver.value)
|
|
668
|
+
: null;
|
|
669
|
+
const receiver = e.receiver === undefined || lazyReceiver ? null : host.emitExpr(e.receiver);
|
|
670
|
+
const pushReceiver = () => {
|
|
671
|
+
if (lazyReceiver) {
|
|
672
|
+
const t = lazyReceiver.type;
|
|
673
|
+
const key = typeKey(t);
|
|
674
|
+
let recipe = host.typedRefRecipes.get(key);
|
|
675
|
+
if (recipe === undefined) {
|
|
676
|
+
const adapter = host.liveDynRefAdapter(t);
|
|
677
|
+
const rc = vAdapters(host.shapeHost, t);
|
|
678
|
+
const ctor = typedRefConstructor(host.shapeHost, t);
|
|
679
|
+
const kind = ctor.endsWith("_traced") ? 2 : ctor.endsWith("_observed") ? 1 : 0;
|
|
680
|
+
// The box binds the same live view eager boxing attaches, so
|
|
681
|
+
// `in`, for-in and Object.keys see the class members.
|
|
682
|
+
const view = liveRefView(adapter);
|
|
683
|
+
recipe = `@sc_trr_${host.typedRefRecipes.size}`;
|
|
684
|
+
host.typedRefRecipes.set(key, recipe);
|
|
685
|
+
host.resolveThunkDefs.push(`${recipe} = internal constant { ptr, ptr, ptr, ${host.sizeType}, ptr, ptr, i32, i32, ptr } { ptr ${rc.retain}, ptr ${rc.release}, ptr ${host.cstr(key)}, ${host.sizeType} ${Buffer.byteLength(key, "utf8")}, ptr @${adapter.snapshot}, ptr ${adapter.commit}, i32 ${kind}, i32 ${view?.code ?? 0}, ptr ${view?.ops ?? "null"} }`);
|
|
686
|
+
}
|
|
687
|
+
host.declare("declare void @scr_dyn_this_push_typed(ptr, ptr)");
|
|
688
|
+
B.line(`call void @scr_dyn_this_push_typed(ptr ${lazyReceiver.name}, ptr ${recipe})`);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
host.declare("declare void @scr_dyn_this_push_dyn(ptr)");
|
|
692
|
+
B.line(`call void @scr_dyn_this_push_dyn(ptr ${receiver?.name ?? "null"})`);
|
|
693
|
+
};
|
|
591
694
|
const knownName = e.callee.kind === "closure"
|
|
592
695
|
? e.callee.fnName
|
|
593
696
|
: e.callee.kind === "varRef"
|
|
@@ -604,32 +707,105 @@ export function emitCallExpr(host, e) {
|
|
|
604
707
|
else
|
|
605
708
|
direct = `@${host.callTarget(known.name)}`;
|
|
606
709
|
}
|
|
607
|
-
|
|
710
|
+
// A known closure body that borrows reference parameters is entered
|
|
711
|
+
// directly with lent arguments, as a direct call to a borrowing body
|
|
712
|
+
// is: an argument is read without a reference when neither a later
|
|
713
|
+
// argument nor the body can write what it was read from, and any
|
|
714
|
+
// other value stays owned by this frame until the call returns. The
|
|
715
|
+
// fallback through the closure's own entry passes owned values.
|
|
716
|
+
//
|
|
717
|
+
// An unknown closure is entered through its borrowing entry
|
|
718
|
+
// (ScrClosure.fn_borrowed, which lends every reference argument) when
|
|
719
|
+
// it has one and every reference argument can be lent across any of
|
|
720
|
+
// the call's possible targets.
|
|
721
|
+
// A declared function as a value lends through its interned closure's
|
|
722
|
+
// borrowing wrapper, when it has one.
|
|
723
|
+
let lent = known === undefined
|
|
724
|
+
? undefined
|
|
725
|
+
: known.captures !== undefined
|
|
726
|
+
? host.callLifetimes.borrowed.get(known.name)
|
|
727
|
+
: host.lendsEveryArgument(known.name)
|
|
728
|
+
? host.callLifetimes.borrowed.get(known.name)
|
|
729
|
+
: undefined;
|
|
730
|
+
let lend = lent
|
|
731
|
+
? borrowableInputs(host, e.args, false, host.referenceWrites?.summary(known.name))
|
|
732
|
+
: [];
|
|
733
|
+
let dynamic = false;
|
|
734
|
+
if (!direct && e.receiver === undefined) {
|
|
735
|
+
const references = new Set();
|
|
736
|
+
ft.params.forEach((param, index) => {
|
|
737
|
+
if (isRefCounted(param))
|
|
738
|
+
references.add(index);
|
|
739
|
+
});
|
|
740
|
+
if (references.size > 0) {
|
|
741
|
+
const inputs = borrowableInputs(host, e.args, false, host.referenceWrites?.ownWrites(e));
|
|
742
|
+
if ([...references].every((index) => inputs[index] === true)) {
|
|
743
|
+
lent = references;
|
|
744
|
+
lend = inputs;
|
|
745
|
+
dynamic = true;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (lent)
|
|
750
|
+
host.frames.push([]);
|
|
751
|
+
const args = e.args.map((a, i) => lent?.has(i) && lend[i] ? host.emitReadReceiver(a) : host.emitExpr(a));
|
|
752
|
+
args.forEach((a, i) => {
|
|
753
|
+
if (!lent?.has(i))
|
|
754
|
+
host.moveTemp(a);
|
|
755
|
+
});
|
|
756
|
+
const argListOf = (values) => [
|
|
608
757
|
`ptr ${callee.name}`,
|
|
609
|
-
...
|
|
758
|
+
...values.map((a, i) => `${host.llType(ft.params[i])} ${a.name}`),
|
|
610
759
|
].join(", ");
|
|
611
|
-
|
|
760
|
+
// The owned entry consumes a reference of each lent argument.
|
|
761
|
+
const ownedArgs = () => lent
|
|
762
|
+
? args.map((a, i) => lent.has(i) ? { name: host.retainValue(a.name, a.type), type: a.type } : a)
|
|
763
|
+
: args;
|
|
764
|
+
const invoke = (target, needsReceiver, values = args) => {
|
|
612
765
|
if (needsReceiver) {
|
|
613
|
-
host.declare("declare void @scr_dyn_this_push_dyn(ptr)");
|
|
614
766
|
host.declare("declare void @scr_dyn_this_pop()");
|
|
615
|
-
|
|
767
|
+
pushReceiver();
|
|
616
768
|
}
|
|
617
769
|
const result = e.type.kind === "void" ? "" : B.tmp();
|
|
618
|
-
B.line(`${result ? `${result} = ` : ""}call ${host.llType(e.type)} ${target}(${
|
|
770
|
+
B.line(`${result ? `${result} = ` : ""}call ${host.llType(e.type)} ${target}(${argListOf(values)})`);
|
|
619
771
|
if (needsReceiver)
|
|
620
772
|
B.line("call void @scr_dyn_this_pop()");
|
|
621
773
|
return result;
|
|
622
774
|
};
|
|
775
|
+
const lending = lent && !dynamic
|
|
776
|
+
? known.captures !== undefined
|
|
777
|
+
? `@${mangleBorrowedFunction(known.name)}`
|
|
778
|
+
: `@${mangleBorrowingWrapper(known.name)}`
|
|
779
|
+
: undefined;
|
|
623
780
|
let t;
|
|
624
781
|
if (direct && e.callee.kind === "closure") {
|
|
625
|
-
t = invoke(direct, !host.receiverReaders.ignores(known));
|
|
782
|
+
t = invoke(lending ?? direct, !host.receiverReaders.ignores(known));
|
|
626
783
|
}
|
|
627
784
|
else {
|
|
628
785
|
const fnp = B.tmp(), fn = B.tmp();
|
|
629
786
|
B.line(`${fnp} = getelementptr inbounds %ScrClosure, ptr ${callee.name}, i64 0, i32 1`);
|
|
630
787
|
B.line(`${fn} = load ptr, ptr ${fnp}`);
|
|
631
|
-
if (
|
|
632
|
-
|
|
788
|
+
if (dynamic) {
|
|
789
|
+
const entryp = B.tmp(), entry = B.tmp(), has = B.tmp(), borrowing = B.newLabel("callback.lend"), owning = B.newLabel("callback.own"), done = B.newLabel("callback.done");
|
|
790
|
+
B.line(`${entryp} = getelementptr inbounds %ScrClosure, ptr ${callee.name}, i64 0, i32 7`);
|
|
791
|
+
B.line(`${entry} = load ptr, ptr ${entryp}`);
|
|
792
|
+
B.line(`${has} = icmp ne ptr ${entry}, null`);
|
|
793
|
+
B.condBr(has, borrowing, owning);
|
|
794
|
+
B.startBlock(borrowing);
|
|
795
|
+
const lentResult = invoke(entry, true);
|
|
796
|
+
const borrowingEnd = B.currentLabel();
|
|
797
|
+
B.br(done);
|
|
798
|
+
B.startBlock(owning);
|
|
799
|
+
const ownedResult = invoke(fn, true, ownedArgs());
|
|
800
|
+
const owningEnd = B.currentLabel();
|
|
801
|
+
B.br(done);
|
|
802
|
+
B.startBlock(done);
|
|
803
|
+
t = e.type.kind === "void" ? "" : B.tmp();
|
|
804
|
+
if (t)
|
|
805
|
+
B.line(`${t} = phi ${host.llType(e.type)} [ ${lentResult}, %${borrowingEnd} ], [ ${ownedResult}, %${owningEnd} ]`);
|
|
806
|
+
}
|
|
807
|
+
else if (!direct)
|
|
808
|
+
t = invoke(fn, true, ownedArgs());
|
|
633
809
|
else {
|
|
634
810
|
// A global initializer may not have run, or a callback may enter
|
|
635
811
|
// through a boundary the census cannot prove. Validate the actual
|
|
@@ -639,20 +815,25 @@ export function emitCallExpr(host, e) {
|
|
|
639
815
|
B.line(`${matches} = icmp eq ptr ${fn}, ${direct}`);
|
|
640
816
|
B.condBr(matches, fast, fallback);
|
|
641
817
|
B.startBlock(fast);
|
|
642
|
-
const specialized = invoke(direct, !host.receiverReaders.ignores(known));
|
|
818
|
+
const specialized = invoke(lending ?? direct, !host.receiverReaders.ignores(known));
|
|
819
|
+
// `fast` may have split for exception checks; join from the end.
|
|
820
|
+
const fastEnd = B.currentLabel();
|
|
643
821
|
B.br(done);
|
|
644
822
|
B.startBlock(fallback);
|
|
645
|
-
const indirect = invoke(fn, true);
|
|
823
|
+
const indirect = invoke(fn, true, ownedArgs());
|
|
824
|
+
const fallbackEnd = B.currentLabel();
|
|
646
825
|
B.br(done);
|
|
647
826
|
B.startBlock(done);
|
|
648
827
|
t = e.type.kind === "void" ? "" : B.tmp();
|
|
649
828
|
if (t)
|
|
650
|
-
B.line(`${t} = phi ${host.llType(e.type)} [ ${specialized}, %${
|
|
829
|
+
B.line(`${t} = phi ${host.llType(e.type)} [ ${specialized}, %${fastEnd} ], [ ${indirect}, %${fallbackEnd} ]`);
|
|
651
830
|
}
|
|
652
831
|
}
|
|
653
832
|
if (e.type.kind === "void") {
|
|
654
833
|
if (host.indirectMayThrow)
|
|
655
834
|
host.emitPendingCheck();
|
|
835
|
+
if (lent)
|
|
836
|
+
host.releaseFrame(host.frames.pop());
|
|
656
837
|
return { name: "", type: e.type };
|
|
657
838
|
}
|
|
658
839
|
// The check runs AFTER the result temp joins the frame: an unwind
|
|
@@ -660,6 +841,11 @@ export function emitCallExpr(host, e) {
|
|
|
660
841
|
const out = host.own({ name: t, type: e.type });
|
|
661
842
|
if (host.indirectMayThrow)
|
|
662
843
|
host.emitPendingCheck();
|
|
844
|
+
if (lent) {
|
|
845
|
+
host.moveTemp(out);
|
|
846
|
+
host.releaseFrame(host.frames.pop());
|
|
847
|
+
return host.own(out);
|
|
848
|
+
}
|
|
663
849
|
return out;
|
|
664
850
|
}
|
|
665
851
|
case "selfRef":
|
|
@@ -677,60 +863,7 @@ export function emitCallExpr(host, e) {
|
|
|
677
863
|
const o = B.tmp();
|
|
678
864
|
B.line(`${o} = call ptr @${mangleClassNew(e.className)}()`);
|
|
679
865
|
const out = host.own({ name: o, type: e.type });
|
|
680
|
-
|
|
681
|
-
const borrowed = host.callLifetimes.borrowed.get(ctorName);
|
|
682
|
-
if (borrowed) {
|
|
683
|
-
// The borrowed constructor body, like a direct call: this frame
|
|
684
|
-
// owns the new object across the call, borrowed arguments stay
|
|
685
|
-
// owned by a call frame, and projection-only parameters (stores
|
|
686
|
-
// into nullable-pointer fields, tests) receive private stack boxes.
|
|
687
|
-
const projected = host.callLifetimes.parameters.get(ctorName);
|
|
688
|
-
const inputs = borrowableInputs(host, e.args, host.referenceEffects.functions.has(ctorName), host.referenceWrites?.constructWrites(e.className));
|
|
689
|
-
host.frames.push([]);
|
|
690
|
-
const args = e.args.map((a, i) => {
|
|
691
|
-
if (borrowed.has(i + 1)) {
|
|
692
|
-
if (projected?.has(i + 1) && canStackUnion(a, host.boxedUnionsById))
|
|
693
|
-
return emitStackUnion(host, a).value;
|
|
694
|
-
if (projected?.has(i + 1) && host.nullableFieldGet(a))
|
|
695
|
-
return { name: host.emitOwnedNullableStack(a).box, type: a.type };
|
|
696
|
-
if (inputs[i])
|
|
697
|
-
return host.emitReadReceiver(a);
|
|
698
|
-
}
|
|
699
|
-
return host.emitExpr(a);
|
|
700
|
-
});
|
|
701
|
-
args.forEach((a, i) => {
|
|
702
|
-
if (!borrowed.has(i + 1))
|
|
703
|
-
host.moveTemp(a);
|
|
704
|
-
});
|
|
705
|
-
const self = borrowed.has(0)
|
|
706
|
-
? o
|
|
707
|
-
: (() => {
|
|
708
|
-
const r = B.tmp();
|
|
709
|
-
B.line(`${r} = call ptr @${mangleClassRetain(e.className)}(ptr ${o})`);
|
|
710
|
-
return r;
|
|
711
|
-
})();
|
|
712
|
-
const argList = [
|
|
713
|
-
`ptr ${self}`,
|
|
714
|
-
...args.map((a, i) => `${host.llType(ctor.params[i + 1].type)} ${a.name}`),
|
|
715
|
-
].join(", ");
|
|
716
|
-
B.line(`call void @${mangleBorrowedFunction(ctorName)}(${argList})`);
|
|
717
|
-
if (host.mayThrow.has(ctorName))
|
|
718
|
-
host.emitPendingCheck();
|
|
719
|
-
host.releaseFrame(host.frames.pop());
|
|
720
|
-
return out;
|
|
721
|
-
}
|
|
722
|
-
const args = e.args.map((a) => host.emitExpr(a));
|
|
723
|
-
for (const a of args)
|
|
724
|
-
host.moveTemp(a);
|
|
725
|
-
const r = B.tmp();
|
|
726
|
-
B.line(`${r} = call ptr @${mangleClassRetain(e.className)}(ptr ${o})`);
|
|
727
|
-
const argList = [
|
|
728
|
-
`ptr ${r}`,
|
|
729
|
-
...args.map((a, i) => `${host.llType(ctor.params[i + 1].type)} ${a.name}`),
|
|
730
|
-
].join(", ");
|
|
731
|
-
B.line(`call void @${mangleFunction(`%${e.className}.constructor`)}(${argList})`);
|
|
732
|
-
if (host.mayThrow.has(`%${e.className}.constructor`))
|
|
733
|
-
host.emitPendingCheck();
|
|
866
|
+
emitConstruction(host, e, o, ctor);
|
|
734
867
|
return out;
|
|
735
868
|
}
|
|
736
869
|
case "classRef": {
|
|
@@ -902,7 +1035,8 @@ export function emitCallExpr(host, e) {
|
|
|
902
1035
|
const fnp = B.tmp();
|
|
903
1036
|
const fn = B.tmp();
|
|
904
1037
|
B.line(`${vtp} = getelementptr inbounds %${classStructSym(e.className)}, ptr ${recv}, i64 0, i32 1`);
|
|
905
|
-
|
|
1038
|
+
// Set once at allocation (classes.ts launders each new object).
|
|
1039
|
+
B.line(`${vt} = load ptr, ptr ${vtp}, !invariant.group !{}`);
|
|
906
1040
|
B.line(`${fnp} = getelementptr inbounds %${mangleVtStruct(meta.root.def.name)}, ptr ${vt}, i64 0, i32 ${slotIdx + 1}`);
|
|
907
1041
|
B.line(`${fn} = load ptr, ptr ${fnp} ; ${e.method}`);
|
|
908
1042
|
const argList = args
|
|
@@ -935,6 +1069,14 @@ export function emitCallExpr(host, e) {
|
|
|
935
1069
|
}
|
|
936
1070
|
}
|
|
937
1071
|
}
|
|
1072
|
+
/** A constructor call's arguments after the receiver, i32 where the
|
|
1073
|
+
* constructor's i32 entry takes them. */
|
|
1074
|
+
function ctorArguments(host, ctorName, ctor, args, exprs) {
|
|
1075
|
+
const abi = host.int32Abis.get(ctorName);
|
|
1076
|
+
return args.map((a, i) => abi?.params[i + 1]
|
|
1077
|
+
? `i32 ${host.int32Argument(a, exprs[i])}`
|
|
1078
|
+
: `${host.llType(ctor.params[i + 1].type)} ${a.name}`);
|
|
1079
|
+
}
|
|
938
1080
|
/** A direct call to a borrowed-return function whose result a receiver or
|
|
939
1081
|
* walk consumes without owning it (LlEmitter.canBorrowReceiver proved every
|
|
940
1082
|
* reference argument borrowable and every argument edge-preserving). The
|
|
@@ -944,11 +1086,70 @@ export function emitBorrowedResultCall(host, e) {
|
|
|
944
1086
|
if (!callee || !host.borrowedReturns.has(e.callee))
|
|
945
1087
|
throw new InternalCompilerError(`llvm emitter bug: borrowed result of ${e.callee}`);
|
|
946
1088
|
const args = e.args.map((arg) => isRefCounted(arg.type) ? host.emitReadReceiver(arg) : host.emitExpr(arg));
|
|
947
|
-
const
|
|
1089
|
+
const abi = host.int32Abis.get(e.callee);
|
|
1090
|
+
const argList = args
|
|
1091
|
+
.map((a, i) => abi?.params[i]
|
|
1092
|
+
? `i32 ${host.int32Argument(a, e.args[i])}`
|
|
1093
|
+
: `${host.llType(callee.params[i].type)} ${a.name}`)
|
|
1094
|
+
.join(", ");
|
|
948
1095
|
const t = host.B.tmp();
|
|
949
|
-
host.B.line(`${t} = call ${host.llType(e.type)} @${mangleBorrowedFunction(e.callee)}(${argList}) ; borrowed result`);
|
|
1096
|
+
host.B.line(`${t} = call ${host.llType(e.type)} @${mangleBorrowedFunction(e.callee)}${abi ? INT32_ABI_SUFFIX : ""}(${argList}) ; borrowed result`);
|
|
950
1097
|
if (host.mayThrow.has(e.callee))
|
|
951
1098
|
host.emitPendingCheck();
|
|
952
1099
|
return { name: t, type: e.type };
|
|
953
1100
|
}
|
|
1101
|
+
/** Run the constructor of `new` over the allocated object `o` (fields
|
|
1102
|
+
* zeroed, header stamped). The ctor owns and releases its `this` param like
|
|
1103
|
+
* any callee, so it receives a +1 distinct from the caller's reference. */
|
|
1104
|
+
export function emitConstruction(host, e, o, ctor) {
|
|
1105
|
+
const B = host.B;
|
|
1106
|
+
const ctorName = `%${e.className}.constructor`;
|
|
1107
|
+
const borrowed = host.callLifetimes.borrowed.get(ctorName);
|
|
1108
|
+
if (borrowed) {
|
|
1109
|
+
// The borrowed constructor body, like a direct call: this frame
|
|
1110
|
+
// owns the new object across the call, borrowed arguments stay
|
|
1111
|
+
// owned by a call frame, and projection-only parameters (stores
|
|
1112
|
+
// into nullable-pointer fields, tests) receive private stack boxes.
|
|
1113
|
+
const projected = host.callLifetimes.parameters.get(ctorName);
|
|
1114
|
+
const inputs = borrowableInputs(host, e.args, host.referenceEffects.functions.has(ctorName), host.referenceWrites?.constructWrites(e.className));
|
|
1115
|
+
host.frames.push([]);
|
|
1116
|
+
const args = e.args.map((a, i) => {
|
|
1117
|
+
if (borrowed.has(i + 1)) {
|
|
1118
|
+
if (projected?.has(i + 1) && canStackUnion(a, host.boxedUnionsById))
|
|
1119
|
+
return emitStackUnion(host, a).value;
|
|
1120
|
+
if (projected?.has(i + 1) && host.nullableFieldGet(a))
|
|
1121
|
+
return { name: host.emitOwnedNullableStack(a).box, type: a.type };
|
|
1122
|
+
if (inputs[i])
|
|
1123
|
+
return host.emitReadReceiver(a);
|
|
1124
|
+
}
|
|
1125
|
+
return host.emitExpr(a);
|
|
1126
|
+
});
|
|
1127
|
+
args.forEach((a, i) => {
|
|
1128
|
+
if (!borrowed.has(i + 1))
|
|
1129
|
+
host.moveTemp(a);
|
|
1130
|
+
});
|
|
1131
|
+
const self = borrowed.has(0)
|
|
1132
|
+
? o
|
|
1133
|
+
: (() => {
|
|
1134
|
+
const r = B.tmp();
|
|
1135
|
+
B.line(`${r} = call ptr @${mangleClassRetain(e.className)}(ptr ${o})`);
|
|
1136
|
+
return r;
|
|
1137
|
+
})();
|
|
1138
|
+
const argList = [`ptr ${self}`, ...ctorArguments(host, ctorName, ctor, args, e.args)].join(", ");
|
|
1139
|
+
B.line(`call void @${mangleBorrowedFunction(ctorName)}${host.int32Abis.has(ctorName) ? INT32_ABI_SUFFIX : ""}(${argList})`);
|
|
1140
|
+
if (host.mayThrow.has(ctorName))
|
|
1141
|
+
host.emitPendingCheck();
|
|
1142
|
+
host.releaseFrame(host.frames.pop());
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
const args = e.args.map((a) => host.emitExpr(a));
|
|
1146
|
+
for (const a of args)
|
|
1147
|
+
host.moveTemp(a);
|
|
1148
|
+
const r = B.tmp();
|
|
1149
|
+
B.line(`${r} = call ptr @${mangleClassRetain(e.className)}(ptr ${o})`);
|
|
1150
|
+
const argList = [`ptr ${r}`, ...ctorArguments(host, ctorName, ctor, args, e.args)].join(", ");
|
|
1151
|
+
B.line(`call void @${mangleFunction(ctorName)}${host.int32Abis.has(ctorName) ? INT32_ABI_SUFFIX : ""}(${argList})`);
|
|
1152
|
+
if (host.mayThrow.has(`%${e.className}.constructor`))
|
|
1153
|
+
host.emitPendingCheck();
|
|
1154
|
+
}
|
|
954
1155
|
//# sourceMappingURL=expr-calls.js.map
|