@geastack/compiler 1.0.48 → 1.0.62
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/README.md +57 -19
- package/dist/cli.js +2 -1
- package/dist/compiler.d.ts +1 -1
- package/dist/compiler.js +13 -6
- package/dist/conversion/derive.js +5 -0
- package/dist/conversion/native-field-view.d.ts +7 -0
- package/dist/conversion/native-field-view.js +50 -0
- package/dist/conversion/native-record-products.js +1 -0
- package/dist/conversion/native-view-origins.d.ts +1 -1
- package/dist/conversion/native-view-origins.js +5 -4
- package/dist/conversion/nodes.d.ts +9 -0
- package/dist/conversion/nodes.js +18 -0
- package/dist/conversion/record-view.d.ts +25 -1
- package/dist/conversion/record-view.js +61 -2
- package/dist/conversion/structural-plan.js +7 -6
- package/dist/ir/borrowed-field-reads.d.ts +30 -0
- package/dist/ir/borrowed-field-reads.js +218 -0
- package/dist/ir/borrowed-window-cells.d.ts +35 -0
- package/dist/ir/borrowed-window-cells.js +117 -0
- package/dist/ir/call-dispatch.js +21 -4
- package/dist/ir/callable-class-flow.js +269 -43
- package/dist/ir/captures.js +18 -1
- package/dist/ir/certify.js +14 -1
- package/dist/ir/construction-only-fields.d.ts +15 -1
- package/dist/ir/construction-only-fields.js +71 -3
- package/dist/ir/dead-logical-merge.d.ts +4 -0
- package/dist/ir/dead-logical-merge.js +89 -18
- package/dist/ir/dense-loops.d.ts +38 -4
- package/dist/ir/dense-loops.js +112 -17
- package/dist/ir/dense-read-windows.d.ts +42 -0
- package/dist/ir/dense-read-windows.js +137 -0
- package/dist/ir/facts.d.ts +12 -0
- package/dist/ir/facts.js +18 -2
- package/dist/ir/field-read-reuse.d.ts +71 -0
- package/dist/ir/field-read-reuse.js +430 -0
- package/dist/ir/hoist.d.ts +19 -2
- package/dist/ir/hoist.js +143 -24
- package/dist/ir/lower-narrow.js +19 -1
- package/dist/ir/model.d.ts +19 -0
- package/dist/ir/native-field-view-domains.d.ts +12 -2
- package/dist/ir/native-field-view-domains.js +51 -15
- package/dist/ir/native-field-view-facts.js +5 -2
- package/dist/ir/native-method-frames.js +15 -2
- package/dist/ir/plain-field-read.d.ts +31 -0
- package/dist/ir/plain-field-read.js +51 -0
- package/dist/ir/program-facts.d.ts +14 -0
- package/dist/ir/program-facts.js +85 -2
- package/dist/ir/proven-branches.js +8 -1
- package/dist/ir/publish-conversion-recipes.js +5 -1
- package/dist/ir/short-circuit-threading.d.ts +12 -4
- package/dist/ir/short-circuit-threading.js +124 -12
- package/dist/ir/stable-cell-reads.d.ts +24 -1
- package/dist/ir/stable-cell-reads.js +65 -42
- package/dist/ir/write-effects.d.ts +42 -0
- package/dist/ir/write-effects.js +208 -0
- package/dist/plugins/gea/contract.d.ts +3 -2
- package/dist/plugins/gea/contract.js +3 -1
- package/dist/plugins/gea/host.d.ts +7 -2
- package/dist/plugins/gea/host.js +25 -5
- package/dist/project-preparation.d.ts +11 -0
- package/dist/project-preparation.js +44 -0
- package/dist/projection/classes.d.ts +8 -0
- package/dist/projection/classes.js +112 -12
- package/dist/projection/dispatch.d.ts +24 -4
- package/dist/projection/dispatch.js +71 -2
- package/dist/projection/fields.js +2 -2
- package/dist/representation/model.d.ts +3 -0
- package/dist/representation/model.js +3 -0
- package/dist/representation/value-records.js +22 -0
- package/dist/semantics/frontend-timing.d.ts +9 -0
- package/dist/semantics/frontend-timing.js +43 -2
- package/dist/semantics/frontend.js +103 -7
- package/dist/semantics/model/operations.d.ts +7 -0
- package/dist/semantics/normalize/binding-fixpoint.js +7 -2
- package/dist/semantics/normalize/callable-data-write.js +6 -2
- package/dist/semantics/normalize/field-bindings.js +151 -111
- package/dist/semantics/normalize/flow/callable-reach.js +27 -0
- package/dist/semantics/normalize/flow/component-solver.js +23 -5
- package/dist/semantics/normalize/flow/source-record-data.js +6 -2
- package/dist/semantics/normalize/flow/source-value-session.d.ts +13 -0
- package/dist/semantics/normalize/flow/source-value-session.js +207 -65
- package/dist/semantics/normalize/global-host-mutations.js +162 -1
- package/dist/semantics/normalize/parameter-bindings.js +16 -1
- package/dist/semantics/normalize/producers/class-lifecycle.js +2 -1
- package/dist/semantics/normalize/producers/erasure.js +13 -8
- package/dist/semantics/subclass-member-overlay-transform.d.ts +3 -2
- package/dist/semantics/subclass-member-overlay-transform.js +416 -316
- package/dist/semantics/typescript-tsgo.d.ts +20 -0
- package/dist/semantics/typescript-tsgo.js +832 -0
- package/dist/semantics/typescript.d.ts +0 -9
- package/dist/semantics/typescript.js +4 -1
- package/dist/targets/cpp/borrowed-call-entry.d.ts +9 -0
- package/dist/targets/cpp/borrowed-call-entry.js +12 -2
- package/dist/targets/cpp/captures.js +4 -0
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +1 -1
- package/dist/targets/cpp/class-properties/computed-method-value.js +17 -7
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +8 -0
- package/dist/targets/cpp/class-properties/emit-class-properties.js +62 -2
- package/dist/targets/cpp/class-properties/native-method-read.js +12 -1
- package/dist/targets/cpp/conversions.js +1 -0
- package/dist/targets/cpp/emit-arrays.d.ts +5 -0
- package/dist/targets/cpp/emit-arrays.js +60 -10
- package/dist/targets/cpp/emit-binding-reference.d.ts +19 -6
- package/dist/targets/cpp/emit-binding-reference.js +26 -8
- package/dist/targets/cpp/emit-bindings.js +22 -0
- package/dist/targets/cpp/emit-callable.js +133 -16
- package/dist/targets/cpp/emit-carrier-members.d.ts +6 -0
- package/dist/targets/cpp/emit-carrier-members.js +24 -2
- package/dist/targets/cpp/emit-context.d.ts +97 -1
- package/dist/targets/cpp/emit-context.js +52 -0
- package/dist/targets/cpp/emit-equality.js +3 -0
- package/dist/targets/cpp/emit-narrowing.js +9 -0
- package/dist/targets/cpp/emit-native-field-view.d.ts +24 -0
- package/dist/targets/cpp/emit-native-field-view.js +87 -8
- package/dist/targets/cpp/emit-properties.js +139 -16
- package/dist/targets/cpp/emit-record-view.js +49 -22
- package/dist/targets/cpp/emit-return.js +5 -1
- package/dist/targets/cpp/emit-tonumber.js +4 -1
- package/dist/targets/cpp/emit-union-properties.js +1 -1
- package/dist/targets/cpp/emit.d.ts +4 -1
- package/dist/targets/cpp/emit.js +148 -6
- package/dist/targets/cpp/reactive-dependencies.js +100 -28
- package/dist/targets/cpp/translation-unit.js +71 -17
- package/dist/targets/cpp/virtual-methods.d.ts +2 -2
- package/dist/targets/cpp/virtual-methods.js +11 -3
- package/package.json +1 -1
- package/src/targets/cpp/runtime/gea_runtime.h +400 -21
package/README.md
CHANGED
|
@@ -45,13 +45,31 @@ The Gea and Apple plugins are peer dependencies. Other plugins are loaded with
|
|
|
45
45
|
[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) describes the pipeline, the
|
|
46
46
|
layering and the constraints. `CLAUDE.md` has the code conventions.
|
|
47
47
|
|
|
48
|
+
## Installing
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install -D @geastack/compiler
|
|
52
|
+
npx geatsc --help
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The package installs the `geatsc` command. Generated programs are built with a
|
|
56
|
+
C++ toolchain you supply (clang++ by default for Node projects).
|
|
57
|
+
|
|
58
|
+
The examples below use `node dist/cli.js`, the same command run from a checkout
|
|
59
|
+
of this repository after `npm ci` and `npm run build`. With the published
|
|
60
|
+
package, write `npx geatsc` instead. `npm run build` also runs the post-build
|
|
61
|
+
checks against `dist/`, which take about six minutes on a 20-thread machine.
|
|
62
|
+
[docs/TESTING.md](docs/TESTING.md) covers the test suite.
|
|
63
|
+
|
|
48
64
|
## Layering
|
|
49
65
|
|
|
50
66
|
```
|
|
51
67
|
identity/ canonical IDs
|
|
52
68
|
semantics/ target-neutral frontend: regions, structural types,
|
|
53
69
|
operations, edges, coverage
|
|
70
|
+
plugins/ compiler plugin contract, loader and the built-in plugins
|
|
54
71
|
representation/ physical carriers, the sealed plan, fail-closed guards
|
|
72
|
+
projection/ physical calling conventions, binding cells, class layouts
|
|
55
73
|
conversion/ the closed dynamic-conversion capability algebra
|
|
56
74
|
preflight/ whole-pipeline capability census and certificate
|
|
57
75
|
ir/ typed IR: verified operations and SSA values
|
|
@@ -59,8 +77,8 @@ targets/cpp/ C++ emission; consumes typed IR only
|
|
|
59
77
|
diagnostics/ authority-component sweep, deterministic ordering
|
|
60
78
|
```
|
|
61
79
|
|
|
62
|
-
`semantics/` is the frontend/backend boundary.
|
|
63
|
-
`typescript` or touch a TypeScript AST.
|
|
80
|
+
`semantics/` is the frontend/backend boundary. Outside `semantics/` and
|
|
81
|
+
`plugins/`, nothing may import `typescript` or touch a TypeScript AST.
|
|
64
82
|
|
|
65
83
|
## Constraints
|
|
66
84
|
|
|
@@ -70,8 +88,8 @@ diagnostics/ authority-component sweep, deterministic ordering
|
|
|
70
88
|
C++ text. Identity is a checker symbol/declaration, a sealed semantic ID,
|
|
71
89
|
or a versioned protocol identity.
|
|
72
90
|
2. **No boxing.** A value with a static type never gets the dynamic carrier.
|
|
73
|
-
`Representation.dynamic` is allowed only for the
|
|
74
|
-
|
|
91
|
+
`Representation.dynamic` is allowed only for the `DynamicReason` values
|
|
92
|
+
declared in `dynamicReasons` in `src/representation/model.ts`.
|
|
75
93
|
3. **Fail closed.** When a guard fires, the defect is upstream. Do not relax a
|
|
76
94
|
guard, downgrade an `unresolved`, or substitute a default for a missing
|
|
77
95
|
fact. `unresolved` is lattice bottom, not an answer.
|
|
@@ -80,33 +98,48 @@ diagnostics/ authority-component sweep, deterministic ordering
|
|
|
80
98
|
|
|
81
99
|
`scripts/architecture.mjs` checks `src/**/*.ts` for:
|
|
82
100
|
|
|
83
|
-
-
|
|
101
|
+
- lines longer than 300 columns
|
|
84
102
|
- RegExp literals under `src/targets/cpp/`
|
|
85
103
|
- source-position literal comparisons
|
|
86
|
-
- `typescript` imports outside `src/semantics/`
|
|
104
|
+
- `typescript` imports outside `src/semantics/` and `src/plugins/`
|
|
87
105
|
- source-shaped discriminants
|
|
88
106
|
- unclassified `Authority`/`Admission`/`Proof` contracts
|
|
89
107
|
- class declarations under `src/targets/`
|
|
90
108
|
- `any`
|
|
109
|
+
- diagnostic severity classified outside `diagnostics/sweep.ts`
|
|
110
|
+
- conversion calls that bypass the recipe dispatcher, and other single-owner
|
|
111
|
+
rules it names in its summary line
|
|
112
|
+
- private copies of the compiler build beside `dist/`
|
|
91
113
|
|
|
92
|
-
It reports every violation in one run.
|
|
114
|
+
It reports every violation in one run. `npm run architecture` also runs
|
|
115
|
+
`scripts/refusal-keys.mjs`, which checks that every refusal kind the C++
|
|
116
|
+
target can throw is a capability key.
|
|
93
117
|
|
|
94
118
|
## Diagnostics
|
|
95
119
|
|
|
96
120
|
```bash
|
|
97
|
-
node dist/cli.js test/fixtures/spread.ts
|
|
121
|
+
node dist/cli.js test/fixtures/spread.ts --no-project
|
|
98
122
|
```
|
|
99
123
|
|
|
100
124
|
Runs the full pipeline and prints every diagnostic. Exits non-zero when no
|
|
101
125
|
capability certificate was minted. `--preflight` prints the obligation census
|
|
102
126
|
as canonical NDJSON.
|
|
103
127
|
|
|
128
|
+
Without `--no-project` or `--project`, a file is compiled under the nearest
|
|
129
|
+
`tsconfig.json`. For the fixtures in this repository that is the compiler's
|
|
130
|
+
own, which pulls the whole compiler source into the program and takes minutes
|
|
131
|
+
instead of seconds.
|
|
132
|
+
|
|
104
133
|
### Coverage
|
|
105
134
|
|
|
106
135
|
```bash
|
|
107
|
-
node dist/cli.js coverage app/index.ts --plugin
|
|
136
|
+
node dist/cli.js coverage app/index.ts --plugin node_modules/@geastack/node-compat/plugin/index.mjs
|
|
108
137
|
```
|
|
109
138
|
|
|
139
|
+
`coverage` loads `--plugin` as a file path relative to the working directory.
|
|
140
|
+
The example loads the Node.js plugin from `@geastack/node-compat`, which this
|
|
141
|
+
package installs as a dependency.
|
|
142
|
+
|
|
110
143
|
Prints one row per statement with a code, a status and a one-line reason,
|
|
111
144
|
followed by a summary and a count per code. Boxed carriers are reported as
|
|
112
145
|
rows too. Exits 0 only if a certificate was minted and nothing was refused
|
|
@@ -137,7 +170,7 @@ node scripts/probe-carriers.mjs test/fixtures/language.ts
|
|
|
137
170
|
```
|
|
138
171
|
|
|
139
172
|
Prints the carrier and C++ spelling chosen for every declaration, and counts
|
|
140
|
-
unresolved and boxed carriers.
|
|
173
|
+
unresolved and boxed carriers. Exits non-zero when either count is not zero.
|
|
141
174
|
|
|
142
175
|
## Emitting C++
|
|
143
176
|
|
|
@@ -157,7 +190,7 @@ through `--geatsc-bin`). It writes to `--out-dir`:
|
|
|
157
190
|
| Option | Meaning |
|
|
158
191
|
| ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
159
192
|
| `--project <tsconfig.json>` | Project to compile the input under. Default: the nearest one. A `.js` bundle has none. |
|
|
160
|
-
| `--entry-symbol <name>` | C++ function the program starts at. Default `__gea_top_level`, called by `core/gea_app_entry.cpp
|
|
193
|
+
| `--entry-symbol <name>` | C++ function the program starts at. Default `__gea_top_level`, called by `packages/core/gea_app_entry.cpp` in the `core` repository. |
|
|
161
194
|
| `--dynamic-fallback` | Allow boxed C++ runtime dispatch for supported dynamic features. No JavaScript engine is involved. See [docs/DYNAMIC-FALLBACK.md](docs/DYNAMIC-FALLBACK.md). |
|
|
162
195
|
| `--isolate-symbols` | Make every definition private to this program, for builds that link several programs into one binary. Programs that cannot be isolated are refused. |
|
|
163
196
|
| `--translation-units single \| per-file \| balanced` | `single` (default): one C++ file. `per-file`: one file per source file, plus a shared `<stem>.hpp` and a program unit. `balanced`: per-file with small units grouped. See [docs/TRANSLATION-UNITS.md](docs/TRANSLATION-UNITS.md). |
|
|
@@ -170,14 +203,19 @@ form. It takes the same options.
|
|
|
170
203
|
|
|
171
204
|
## npm scripts
|
|
172
205
|
|
|
173
|
-
| Script
|
|
174
|
-
|
|
|
175
|
-
| `architecture`
|
|
176
|
-
| `typecheck`
|
|
177
|
-
| `build`
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
| `
|
|
206
|
+
| Script | Purpose |
|
|
207
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
208
|
+
| `architecture` | Run the architecture gate and the refusal-key check |
|
|
209
|
+
| `typecheck` | `tsc -p tsconfig.json --noEmit` |
|
|
210
|
+
| `build` | Architecture gate, compile to `dist/`, mark the bins executable, then run the post-build checks against `dist/` |
|
|
211
|
+
| `gate` | Emitted-set gate: emit the corpus and runtime programs and diff them against the tracked baselines |
|
|
212
|
+
| `test` | Build, then run the test suite (`test/run.mjs`) |
|
|
213
|
+
| `test:release` | Release-mode suite (`scripts/release-suite.mjs`) |
|
|
214
|
+
| `release:check` | `check`, `build`, `gate` and `test:release`, in that order |
|
|
215
|
+
| `check:contracts` | Build, then run `test/contracts.mjs` |
|
|
216
|
+
| `format` | `prettier --write .` |
|
|
217
|
+
| `format:check` | `prettier --check .` |
|
|
218
|
+
| `check` | Architecture gate, typecheck and format check |
|
|
181
219
|
|
|
182
220
|
## License
|
|
183
221
|
|
package/dist/cli.js
CHANGED
|
@@ -64,8 +64,9 @@ const formatDiagnostic = (diagnostic) => {
|
|
|
64
64
|
};
|
|
65
65
|
const usage = 'usage: geatsc [--dynamic-fallback] [--debug] [--emit-only] [--verbose] [--translation-units single|per-file|balanced] (build the current Node project)\n' +
|
|
66
66
|
'usage: geatsc <file.ts...> [--project <tsconfig.json>] [--no-project] [--preflight] [--emit] [--dynamic-fallback]\n' +
|
|
67
|
-
' geatsc compile <input> --out-dir <dir> [--project <tsconfig.json>] [--target cpp] [--entry-symbol <symbol>] [--translation-units single|per-file|balanced] [--dynamic-fallback] [--closed-script-scope]\n' +
|
|
67
|
+
' geatsc compile <input> --out-dir <dir> [--project <tsconfig.json>] [--target cpp] [--entry-symbol <symbol>] [--translation-units single|per-file|balanced] [--dynamic-fallback] [--isolate-symbols] [--closed-script-scope]\n' +
|
|
68
68
|
' geatsc compile-module-graph <manifest> --entry <file> --out-dir <dir> [compile options, including --closed-script-scope]\n' +
|
|
69
|
+
' --isolate-symbols gives every definition internal linkage, for builds that link several programs into one binary; a unit that cannot be isolated is refused\n' +
|
|
69
70
|
' --closed-script-scope asserts this compile is the complete classic-script lexical realm; it does not close globalThis or object mutation\n' +
|
|
70
71
|
' compile options include [--plugin <module>]... [--plugin-option <key>=<value>]...\n' +
|
|
71
72
|
' geatsc analyze <entry> --plugin <module>\n' +
|
package/dist/compiler.d.ts
CHANGED
|
@@ -237,5 +237,5 @@ export interface CompilationResult {
|
|
|
237
237
|
*/
|
|
238
238
|
readonly generatedSupportIncludes: readonly string[];
|
|
239
239
|
}
|
|
240
|
-
export declare const sourceTransformsFor: (plugins: readonly PluginInstance[]) => readonly SourceTransform[];
|
|
240
|
+
export declare const sourceTransformsFor: (plugins: readonly PluginInstance[], rootFileNames: readonly string[]) => readonly SourceTransform[];
|
|
241
241
|
export declare const compile: (request: CompilationRequest) => CompilationResult;
|
package/dist/compiler.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mergeNativeIterableProviders } from './plugins/native-iterable-providers.js';
|
|
2
|
+
import { progress } from './semantics/frontend-timing.js';
|
|
2
3
|
import { nodeOfOperation, operationOfResult } from './identity/ids.js';
|
|
3
4
|
import { readFileSync } from 'fs';
|
|
4
5
|
import { join } from 'path';
|
|
@@ -8,6 +9,7 @@ import { publishConversionRecipes } from './ir/publish-conversion-recipes.js';
|
|
|
8
9
|
import { discardUnreadCallResults } from './ir/dead-values.js';
|
|
9
10
|
import { programConversionKey, publishProgramConversionRecipes } from './ir/program-conversions.js';
|
|
10
11
|
import { publishDenseLoopPlan } from './ir/dense-loops.js';
|
|
12
|
+
import { plainFieldReadOf } from './ir/plain-field-read.js';
|
|
11
13
|
import { publishLogicalReceivers } from './ir/logical-receivers.js';
|
|
12
14
|
import { publishNativeHostMethodReads } from './ir/native-host-method-reads.js';
|
|
13
15
|
import { publishNativeCallablePrivateSlots } from './ir/native-callable-own-property.js';
|
|
@@ -64,6 +66,7 @@ import { splitGeneratorBodies } from './ir/generator-split.js';
|
|
|
64
66
|
import { shakeProgram } from './ir/shake.js';
|
|
65
67
|
import { pruneProvenBranches } from './ir/proven-branches.js';
|
|
66
68
|
import { threadShortCircuitJoins } from './ir/short-circuit-threading.js';
|
|
69
|
+
import { codeFreeFieldReadOf, reuseFieldReads } from './ir/field-read-reuse.js';
|
|
67
70
|
import { dropUnreadPureConversions } from './ir/pure-conversion-reuse.js';
|
|
68
71
|
import { publishEmissionRepresentationsOf } from './ir/emission-representations.js';
|
|
69
72
|
import { finalizeTypedComputedReads, reflectionExposureOf } from './ir/reflection-demand.js';
|
|
@@ -130,7 +133,7 @@ const declarerReaderFor = (plugins) => {
|
|
|
130
133
|
return text;
|
|
131
134
|
};
|
|
132
135
|
};
|
|
133
|
-
export const sourceTransformsFor = (plugins) => [
|
|
136
|
+
export const sourceTransformsFor = (plugins, rootFileNames) => [
|
|
134
137
|
// A pre-class constructor function and its `F.prototype.m = function` methods
|
|
135
138
|
// become the class they are, before anything below reads either as a class.
|
|
136
139
|
constructorFunctionClassSourceTransform,
|
|
@@ -181,8 +184,9 @@ export const sourceTransformsFor = (plugins) => [
|
|
|
181
184
|
// left exactly as written -- so it speaks only where the program was silent.
|
|
182
185
|
declarationOverlayTransform,
|
|
183
186
|
// The subclass overlay runs on the overlay's output and before the ambient
|
|
184
|
-
// realization, so a member it declares is respelled too.
|
|
185
|
-
|
|
187
|
+
// realization, so a member it declares is respelled too. It is given the
|
|
188
|
+
// program's roots so what it reads is this program's own module graph.
|
|
189
|
+
createSubclassMemberOverlayTransform(declarerReaderFor(plugins), rootFileNames),
|
|
186
190
|
// The alias-this field declaration runs after the subclass overlay so its
|
|
187
191
|
// "already declared" check sees any member the overlay just added, and
|
|
188
192
|
// never fights it over the same name. It states no type -- only that a
|
|
@@ -219,6 +223,7 @@ export const compile = (request) => {
|
|
|
219
223
|
// profile is written on exit).
|
|
220
224
|
const stopAfterStage = process.env['GEA_STOP_AFTER_STAGE'];
|
|
221
225
|
const stage = (name) => {
|
|
226
|
+
progress(`stage ${name} finished`);
|
|
222
227
|
if (stageStartedAt) {
|
|
223
228
|
const now = performance.now();
|
|
224
229
|
// Heap beside time: a compile that runs out of memory names the stage
|
|
@@ -345,7 +350,7 @@ export const compile = (request) => {
|
|
|
345
350
|
// offered to two plugins is offered to the second the way the first left
|
|
346
351
|
// it. Only a plugin that installs one appears here, so a compilation whose
|
|
347
352
|
// plugins state only data parses each file once past this first pass.
|
|
348
|
-
sourceTransforms: sourceTransformsFor(plugins)
|
|
353
|
+
sourceTransforms: sourceTransformsFor(plugins, request.rootFileNames)
|
|
349
354
|
});
|
|
350
355
|
// The frontend's host-protocol census reaches the deriver as a policy rather
|
|
351
356
|
// than as a table the deriver reads: `derive.ts` may not know what a JSX
|
|
@@ -896,7 +901,7 @@ export const compile = (request) => {
|
|
|
896
901
|
// the copy elision needs the placements to prove its cell is frame-local.
|
|
897
902
|
let prunedBodies = inFrame(() => publishLogicalReceivers(publishNativeHostMethodReads(publishNativeCallableDataSlots({
|
|
898
903
|
bodies: publishNativeCallablePrivateSlots({
|
|
899
|
-
bodies: elideReadOnlySpreadCopies(rewriteLiteralSetMembership(threadShortCircuitJoins(provenPruned.bodies)), splitPlacements, representations.deriver),
|
|
904
|
+
bodies: elideReadOnlySpreadCopies(rewriteLiteralSetMembership(reuseFieldReads(threadShortCircuitJoins(provenPruned.bodies), classes, representations.deriver)), splitPlacements, representations.deriver),
|
|
900
905
|
placements: splitPlacements,
|
|
901
906
|
conversions: conversionCensus,
|
|
902
907
|
deriver: representations.deriver,
|
|
@@ -1324,7 +1329,9 @@ export const compile = (request) => {
|
|
|
1324
1329
|
const denseLoopPlannedOf = () => {
|
|
1325
1330
|
const taken = finalRecipeBodies;
|
|
1326
1331
|
finalRecipeBodies = null;
|
|
1327
|
-
|
|
1332
|
+
const plainFieldRead = plainFieldReadOf(executableClasses, representations.deriver);
|
|
1333
|
+
const codeFreeFieldRead = codeFreeFieldReadOf(taken.values(), executableClasses, representations.deriver);
|
|
1334
|
+
return new Map([...taken].map(([id, body]) => [id, publishDenseLoopPlan(body, splitPlacements, conversionCensus, plainFieldRead, codeFreeFieldRead)]));
|
|
1328
1335
|
};
|
|
1329
1336
|
const certifiedBodies = finalRecipeBodies ? denseLoopPlannedOf() : null;
|
|
1330
1337
|
finalRecipeBodies = null;
|
|
@@ -164,7 +164,12 @@ const deriveAt = (target, context, path) => {
|
|
|
164
164
|
// boxed round trip this compiler declines to build. The one exception
|
|
165
165
|
// is the all-dynamic Map, which needs no per-entry check at all -- see
|
|
166
166
|
// `dynamicMapViewMaterializer`.
|
|
167
|
+
// The round trip, exactly as `dictionary` takes it: a typed Map or Set
|
|
168
|
+
// THIS program boxed comes back as itself, recognized by the payload
|
|
169
|
+
// type `Value::box` recorded -- a tag check, an address check and a
|
|
170
|
+
// handle copy, never a rebuilt collection.
|
|
167
171
|
return (maybeAtom(context.registry.dynamicMapViewMaterializer(target)) ??
|
|
172
|
+
maybeAtom(context.registry.boxedIdentityMaterializer(target)) ??
|
|
168
173
|
never('no checked Map/Set materializer is installed; recovering a keyed collection from a dynamic value needs a runtime ' +
|
|
169
174
|
'brand check plus a per-entry checked conversion of both key and value'));
|
|
170
175
|
case 'function':
|
|
@@ -40,3 +40,10 @@ export declare const nativeFieldViewIdentityTransportOf: (node: ConversionNode |
|
|
|
40
40
|
export declare const nativeFieldViewLiveLeavesOf: (nodes: Iterable<ConversionNode>) => readonly ConversionNode[];
|
|
41
41
|
/** Ownership dependencies may contain ordinary views; only sealed live plans install field callbacks. */
|
|
42
42
|
export declare const nativeFieldViewPlansOf: (nodes: Iterable<ConversionNode>) => readonly NativeFieldViewPlan[];
|
|
43
|
+
/**
|
|
44
|
+
* The plans a node installs over the converted value itself -- through its
|
|
45
|
+
* optional, assert, arm and union wrappers, which select a part of that same
|
|
46
|
+
* value -- as opposed to the plans its field reads install later, over
|
|
47
|
+
* whatever the field holds when it is read.
|
|
48
|
+
*/
|
|
49
|
+
export declare const nativeFieldViewInstalledPlansOf: (node: ConversionNode) => readonly NativeFieldViewPlan[];
|
|
@@ -95,6 +95,7 @@ const planKeepsNativeIdentity = (certified, active) => {
|
|
|
95
95
|
(arm.via === 'convert' ? converted(view.source.arms[index].value, target.value) : arm.via === 'exact' || follows(arm.via)));
|
|
96
96
|
}));
|
|
97
97
|
case 'iterator-result':
|
|
98
|
+
case 'present-field':
|
|
98
99
|
return false;
|
|
99
100
|
}
|
|
100
101
|
};
|
|
@@ -143,3 +144,52 @@ export const nativeFieldViewPlansOf = (nodes) => {
|
|
|
143
144
|
}
|
|
144
145
|
return [...plans];
|
|
145
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* The plans a node installs over the converted value itself -- through its
|
|
149
|
+
* optional, assert, arm and union wrappers, which select a part of that same
|
|
150
|
+
* value -- as opposed to the plans its field reads install later, over
|
|
151
|
+
* whatever the field holds when it is read.
|
|
152
|
+
*/
|
|
153
|
+
export const nativeFieldViewInstalledPlansOf = (node) => {
|
|
154
|
+
if (!nativeFieldViewIdentityTransportOf(node) || !('materializer' in node.capability))
|
|
155
|
+
return [];
|
|
156
|
+
const materializer = node.capability.materializer;
|
|
157
|
+
const plans = new Set();
|
|
158
|
+
for (const fields of materializer.documentRecordView?.nativeFields ?? [])
|
|
159
|
+
plans.add(fields);
|
|
160
|
+
if (materializer.nativeDescriptorSnapshot)
|
|
161
|
+
plans.add(materializer.nativeDescriptorSnapshot.nativeFields);
|
|
162
|
+
const certified = materializer.recordView;
|
|
163
|
+
if (certified === undefined)
|
|
164
|
+
return [...plans];
|
|
165
|
+
const visit = (plan) => {
|
|
166
|
+
switch (plan.kind) {
|
|
167
|
+
case 'owned':
|
|
168
|
+
return;
|
|
169
|
+
case 'optional':
|
|
170
|
+
case 'assert':
|
|
171
|
+
visit(plan.payload);
|
|
172
|
+
return;
|
|
173
|
+
case 'arm':
|
|
174
|
+
if (plan.payload)
|
|
175
|
+
visit(plan.payload);
|
|
176
|
+
return;
|
|
177
|
+
case 'dispatch':
|
|
178
|
+
case 'recast-union':
|
|
179
|
+
for (const arm of plan.arms)
|
|
180
|
+
if (typeof arm.via === 'object')
|
|
181
|
+
visit(arm.via);
|
|
182
|
+
return;
|
|
183
|
+
case 'iterator-result':
|
|
184
|
+
case 'present-field':
|
|
185
|
+
return;
|
|
186
|
+
case 'fields': {
|
|
187
|
+
const fields = certified.fieldViews?.get(plan);
|
|
188
|
+
if (fields)
|
|
189
|
+
plans.add(fields);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
visit(certified.view);
|
|
194
|
+
return [...plans];
|
|
195
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConversionNode, ConversionNodeResolver } from './algebra.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type RecordViewSource } from './record-view.js';
|
|
3
3
|
import type { NativeFieldViewPlan } from './native-field-view.js';
|
|
4
4
|
import type { Representation } from '../representation/model.js';
|
|
5
5
|
export interface NativeViewOrigin {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dispatchedHomesOf } from './record-view.js';
|
|
1
2
|
/** Native ownership edges selected by the admitted view recipes, including their sealed dependencies. */
|
|
2
3
|
export const nativeViewOriginsOf = (nodes, resolve) => {
|
|
3
4
|
const origins = [];
|
|
@@ -26,10 +27,10 @@ export const nativeViewOriginsOf = (nodes, resolve) => {
|
|
|
26
27
|
visitPlan(arm.via);
|
|
27
28
|
return;
|
|
28
29
|
case 'iterator-result':
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
case 'present-field':
|
|
31
|
+
for (const home of dispatchedHomesOf(plan))
|
|
32
|
+
if (home.payload !== null)
|
|
33
|
+
visitPlan(home.payload);
|
|
33
34
|
return;
|
|
34
35
|
case 'fields':
|
|
35
36
|
if (plan.source.ownership === 'shared-refcount' &&
|
|
@@ -40,6 +40,15 @@ export interface ConversionCensus {
|
|
|
40
40
|
readonly fieldReadFor: (source: Representation, target: Representation) => ConversionNode;
|
|
41
41
|
/** The selected live view's checked primitive reader, replayed on its original native storage. */
|
|
42
42
|
readonly checkedFieldReadFor: (source: Representation, target: Representation, checked: ConversionNode) => ConversionNode | null;
|
|
43
|
+
/**
|
|
44
|
+
* A live view's slot declared at a base class, read into the descendant the
|
|
45
|
+
* view's own field declares (a merged options record's `TimeoutContext`
|
|
46
|
+
* slot behind a `FindOptions` view's `CursorTimeoutContext`): the checked
|
|
47
|
+
* class downcast (`assertedClassDowncastFor`), lifted over a shared absence.
|
|
48
|
+
* The ordinary downcast trusts an `instanceof` guard a second [[Get]]
|
|
49
|
+
* through the view never ran. `null` for any other pair.
|
|
50
|
+
*/
|
|
51
|
+
readonly checkedClassFieldReadFor: (source: Representation, target: Representation) => ConversionNode | null;
|
|
43
52
|
readonly absentIndexReadFor: (source: Representation, target: Representation) => ConversionNode;
|
|
44
53
|
readonly nativeMethodFor: (source: Representation, target: Representation) => ConversionNode | null;
|
|
45
54
|
readonly nativeBufferMethodFor: (source: Representation, target: Representation) => ConversionNode | null;
|
package/dist/conversion/nodes.js
CHANGED
|
@@ -560,6 +560,23 @@ export const createConversionNodes = (input) => {
|
|
|
560
560
|
checkedNativeFieldRead: { checked }
|
|
561
561
|
});
|
|
562
562
|
};
|
|
563
|
+
const checkedClassFieldReadFor = (source, target) => {
|
|
564
|
+
if (source.kind !== 'optional')
|
|
565
|
+
return assertedClassDowncastFor(source, target);
|
|
566
|
+
if (target.kind !== 'optional' || target.absence !== source.absence)
|
|
567
|
+
return null;
|
|
568
|
+
if (assertedClassDowncastFor(source.payload, target.payload) === null)
|
|
569
|
+
return null;
|
|
570
|
+
return contextualNode(source, target, 'checked-class-field-read', {
|
|
571
|
+
id: ASSERTED_CLASS_DOWNCAST_MATERIALIZER,
|
|
572
|
+
domain: `static:asserted-class-downcast:${representationKey(target)}`,
|
|
573
|
+
allocates: false,
|
|
574
|
+
nativeFieldProtocol: 'unused',
|
|
575
|
+
nativePayloadTransport: 'preserved',
|
|
576
|
+
nativeClassReferenceIdentity: 'preserved',
|
|
577
|
+
callableIdentityTransport: 'preserved'
|
|
578
|
+
});
|
|
579
|
+
};
|
|
563
580
|
const absentIndexReadFor = (source, target) => {
|
|
564
581
|
const ordinary = nodeFor(source, target);
|
|
565
582
|
if (ordinary.capability.kind !== 'never')
|
|
@@ -989,6 +1006,7 @@ export const createConversionNodes = (input) => {
|
|
|
989
1006
|
callArgumentFor,
|
|
990
1007
|
fieldReadFor,
|
|
991
1008
|
checkedFieldReadFor,
|
|
1009
|
+
checkedClassFieldReadFor,
|
|
992
1010
|
absentIndexReadFor,
|
|
993
1011
|
nativeMethodFor,
|
|
994
1012
|
nativeBufferMethodFor,
|
|
@@ -247,6 +247,26 @@ export type RecordViewPlan = {
|
|
|
247
247
|
readonly target: TaggedUnion;
|
|
248
248
|
readonly yieldHome: IteratorResultHome;
|
|
249
249
|
readonly returnHome: IteratorResultHome;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* A record two arms of a sum both take, told apart by whether ONE of its
|
|
253
|
+
* fields holds a value at run time: `{ serverSelectionTimeoutMS, waitQueueTimeoutMS,
|
|
254
|
+
* timeoutMS }` with `timeoutMS: number | undefined` entering `(Legacy |
|
|
255
|
+
* Timed) & { session? }`, where only `Timed` requires `timeoutMS`. The arm
|
|
256
|
+
* that requires the field is built when it holds a value and the other when
|
|
257
|
+
* it does not, because that is what the program's own `typeof v.timeoutMS ===
|
|
258
|
+
* 'number'` asks of the object and no carrier answers it statically. Either
|
|
259
|
+
* arm keeps every key the record holds, so nothing but the arm is decided.
|
|
260
|
+
*/
|
|
261
|
+
| {
|
|
262
|
+
readonly kind: 'present-field';
|
|
263
|
+
readonly source: Extract<Representation, {
|
|
264
|
+
kind: 'record';
|
|
265
|
+
}>;
|
|
266
|
+
readonly target: TaggedUnion;
|
|
267
|
+
readonly key: string;
|
|
268
|
+
readonly presentHome: IteratorResultHome;
|
|
269
|
+
readonly absentHome: IteratorResultHome;
|
|
250
270
|
} | {
|
|
251
271
|
readonly kind: 'fields';
|
|
252
272
|
readonly source: RecordViewSource;
|
|
@@ -276,7 +296,7 @@ export type RecordViewPlan = {
|
|
|
276
296
|
readonly index: RecordIndexSidecar;
|
|
277
297
|
}[];
|
|
278
298
|
};
|
|
279
|
-
/** One arm of an `iterator-result` plan; `payload` null when the registry converts the pair without a view. */
|
|
299
|
+
/** One arm of an `iterator-result` or `present-field` plan; `payload` null when the registry converts the pair without a view. */
|
|
280
300
|
export interface IteratorResultHome {
|
|
281
301
|
readonly index: number;
|
|
282
302
|
readonly payload: RecordViewPlan | null;
|
|
@@ -344,6 +364,10 @@ export declare const restForwards: (member: CallableAbi, own: CallableAbi | null
|
|
|
344
364
|
export declare const restPacks: (member: CallableAbi, own: CallableAbi, convertible?: PairConvertible) => boolean;
|
|
345
365
|
/** An optional member's callable payload, or the member itself: the frame that holds a present method. */
|
|
346
366
|
export declare const optionalMethodPayloadOf: (member: Representation) => Representation;
|
|
367
|
+
/** The homes a dispatching plan builds, in no particular order. */
|
|
368
|
+
export declare const dispatchedHomesOf: (plan: Extract<RecordViewPlan, {
|
|
369
|
+
kind: "iterator-result" | "present-field";
|
|
370
|
+
}>) => readonly IteratorResultHome[];
|
|
347
371
|
/** Whether a carrier has a state for an absent value -- what an `undefined` a record really holds can be stored as. */
|
|
348
372
|
export declare const holdsAbsence: (carrier: Representation) => boolean;
|
|
349
373
|
export declare const structuralRecordViewPlan: (layouts: RecordLayoutPolicy, source: Representation, target: Representation, convertible: PairConvertible, members?: FamilyMemberKeys) => RecordViewPlan | null;
|
|
@@ -53,6 +53,7 @@ export const isRecordViewTarget = (value) => value.kind === 'record' || (value.k
|
|
|
53
53
|
/** Whether this view dispatches on a sum's live arm somewhere along its spine (`dispatch`, possibly under an optional or an assert). */
|
|
54
54
|
export const recordViewDispatchesArms = (plan) => plan.kind === 'dispatch' ||
|
|
55
55
|
plan.kind === 'iterator-result' ||
|
|
56
|
+
plan.kind === 'present-field' ||
|
|
56
57
|
((plan.kind === 'optional' || plan.kind === 'assert') && recordViewDispatchesArms(plan.payload));
|
|
57
58
|
/**
|
|
58
59
|
* Effects of an already-admitted view, not another conversion predicate.
|
|
@@ -109,7 +110,8 @@ export const recordViewUsesOnlyDirectFields = (plan, heldPairUnused) => {
|
|
|
109
110
|
case 'recast-union':
|
|
110
111
|
return plan.arms.every((arm) => arm.via === 'exact' || (arm.via !== 'convert' && direct(arm.via)));
|
|
111
112
|
case 'iterator-result':
|
|
112
|
-
|
|
113
|
+
case 'present-field':
|
|
114
|
+
return dispatchedHomesOf(plan).every((home) => {
|
|
113
115
|
const arm = plan.target.arms[home.index];
|
|
114
116
|
return home.payload !== null
|
|
115
117
|
? direct(home.payload)
|
|
@@ -161,7 +163,8 @@ export const recordViewResidualReflection = (plan, heldPairUnused) => {
|
|
|
161
163
|
case 'dispatch':
|
|
162
164
|
return inner.arms.every((arm) => arm.via === 'exact' || arm.via === 'absent' || (arm.via !== 'convert' && walk(arm.via)));
|
|
163
165
|
case 'iterator-result':
|
|
164
|
-
|
|
166
|
+
case 'present-field':
|
|
167
|
+
return dispatchedHomesOf(inner).every((home) => {
|
|
165
168
|
if (home.payload !== null)
|
|
166
169
|
return walk(home.payload);
|
|
167
170
|
const arm = inner.target.arms[home.index];
|
|
@@ -296,6 +299,59 @@ const iteratorResultHomes = (layouts, source, target, homes) => {
|
|
|
296
299
|
return null;
|
|
297
300
|
return firstDone.required ? { returnHome: first, yieldHome: second } : { returnHome: second, yieldHome: first };
|
|
298
301
|
};
|
|
302
|
+
/** The homes a dispatching plan builds, in no particular order. */
|
|
303
|
+
export const dispatchedHomesOf = (plan) => plan.kind === 'iterator-result' ? [plan.yieldHome, plan.returnHome] : [plan.presentHome, plan.absentHome];
|
|
304
|
+
/**
|
|
305
|
+
* Two homes a record ties between, decided by one field the record holds as
|
|
306
|
+
* `T | undefined`: exactly one of them requires that field as a present value
|
|
307
|
+
* and NOTHING else the record may lack, and the other requires nothing the
|
|
308
|
+
* record may lack. Every other required field of either arm is held as a
|
|
309
|
+
* present value, so each home is total on its side of the test.
|
|
310
|
+
*/
|
|
311
|
+
const presentFieldHomes = (layouts, source, target, homes) => {
|
|
312
|
+
if (homes.length !== 2 || source.kind !== 'record')
|
|
313
|
+
return null;
|
|
314
|
+
const held = new Map(source.fields.map((field) => [field.key, field]));
|
|
315
|
+
const mayBeAbsent = (key) => {
|
|
316
|
+
const field = held.get(key);
|
|
317
|
+
return field === undefined || !field.required || holdsAbsence(field.value);
|
|
318
|
+
};
|
|
319
|
+
// The fields an arm needs present that the record may not hold, or null
|
|
320
|
+
// when the arm needs one the record never holds at all.
|
|
321
|
+
const needs = (home) => {
|
|
322
|
+
const arm = target.arms[home.index]?.value;
|
|
323
|
+
const fields = arm?.kind === 'record' ? arm.fields : arm?.kind === 'native-record-ref' && arm.native === null ? layouts.forShape(arm.shapeId) : null;
|
|
324
|
+
if (fields === null || fields === undefined)
|
|
325
|
+
return null;
|
|
326
|
+
const keys = [];
|
|
327
|
+
for (const field of fields) {
|
|
328
|
+
if (!field.required || holdsAbsence(field.value) || !mayBeAbsent(field.key))
|
|
329
|
+
continue;
|
|
330
|
+
if (!held.has(field.key))
|
|
331
|
+
return null;
|
|
332
|
+
keys.push(field.key);
|
|
333
|
+
}
|
|
334
|
+
return keys;
|
|
335
|
+
};
|
|
336
|
+
const [first, second] = homes;
|
|
337
|
+
const firstNeeds = needs(first);
|
|
338
|
+
const secondNeeds = needs(second);
|
|
339
|
+
if (firstNeeds === null || secondNeeds === null)
|
|
340
|
+
return null;
|
|
341
|
+
const [presentHome, absentHome, key] = firstNeeds.length === 1 && secondNeeds.length === 0
|
|
342
|
+
? [first, second, firstNeeds[0]]
|
|
343
|
+
: secondNeeds.length === 1 && firstNeeds.length === 0
|
|
344
|
+
? [second, first, secondNeeds[0]]
|
|
345
|
+
: [null, null, null];
|
|
346
|
+
if (presentHome === null || key === null)
|
|
347
|
+
return null;
|
|
348
|
+
// The test reads the held value's presence flag: an `undefined`-absent
|
|
349
|
+
// optional, the one carrier whose empty state is exactly "holds no value".
|
|
350
|
+
const field = held.get(key);
|
|
351
|
+
if (field.value.kind !== 'optional' || field.value.absence !== 'undefined')
|
|
352
|
+
return null;
|
|
353
|
+
return { key, presentHome, absentHome };
|
|
354
|
+
};
|
|
299
355
|
/** Whether a carrier has a state for an absent value -- what an `undefined` a record really holds can be stored as. */
|
|
300
356
|
export const holdsAbsence = (carrier) => carrier.kind === 'optional' ||
|
|
301
357
|
carrier.kind === 'dynamic' ||
|
|
@@ -384,6 +440,9 @@ export const structuralRecordViewPlan = (layouts, source, target, convertible, m
|
|
|
384
440
|
const byDone = iteratorResultHomes(layouts, source, target, homes);
|
|
385
441
|
if (byDone !== null)
|
|
386
442
|
return { kind: 'iterator-result', source, target, ...byDone };
|
|
443
|
+
const byPresence = presentFieldHomes(layouts, source, target, homes);
|
|
444
|
+
if (byPresence !== null)
|
|
445
|
+
return { kind: 'present-field', source: source, target, ...byPresence };
|
|
387
446
|
const exact = homes.length > 1 ? homes.filter((candidate) => !widensFieldIntoDynamic(layouts, source, target.arms[candidate.index].value)) : homes;
|
|
388
447
|
const home = exact.length === 1 ? exact[0] : (widestHome(layouts, target, exact) ?? heldRequiredKeysHome(layouts, source, target, exact));
|
|
389
448
|
if (home !== undefined)
|
|
@@ -2,7 +2,7 @@ import { conversionRequiresSourceGuard } from './algebra.js';
|
|
|
2
2
|
import { abiOfCallee } from '../projection/callee.js';
|
|
3
3
|
import { carriesUndefined, containsUnresolved, representationKey } from '../representation/model.js';
|
|
4
4
|
import { containsOpenDocument } from './document-record-view.js';
|
|
5
|
-
import { optionalMethodPayloadOf, structuralRecordViewPlan } from './record-view.js';
|
|
5
|
+
import { dispatchedHomesOf, optionalMethodPayloadOf, structuralRecordViewPlan } from './record-view.js';
|
|
6
6
|
import { recipeIsMaterializableWithoutPriorSourceGuard } from './recipe-closure.js';
|
|
7
7
|
import { nativeFieldViewPlanOf } from './native-field-view.js';
|
|
8
8
|
import { nativeLogicalReceiverRecipeOf } from './native-logical-receiver.js';
|
|
@@ -182,7 +182,8 @@ export const certifiedRecordViewPlan = (layouts, source, target, accepted, membe
|
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
case 'iterator-result':
|
|
185
|
-
|
|
185
|
+
case 'present-field':
|
|
186
|
+
return dispatchedHomesOf(plan).every((home) => {
|
|
186
187
|
const arm = plan.target.arms[home.index];
|
|
187
188
|
return arm !== undefined && (home.payload === null ? add(plan.source, arm.value) : walk(home.payload));
|
|
188
189
|
});
|
|
@@ -273,10 +274,10 @@ export const certifiedRecordViewPlan = (layouts, source, target, accepted, membe
|
|
|
273
274
|
collect(arm.via);
|
|
274
275
|
return;
|
|
275
276
|
case 'iterator-result':
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
case 'present-field':
|
|
278
|
+
for (const home of dispatchedHomesOf(plan))
|
|
279
|
+
if (home.payload)
|
|
280
|
+
collect(home.payload);
|
|
280
281
|
return;
|
|
281
282
|
case 'fields': {
|
|
282
283
|
const fields = nativeFieldViewPlanOf(plan, layouts, (source, target) => leaves.get(structuralConversionKey(source, target)) ?? null);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DeclarationId, IrValueId } from '../identity/ids.js';
|
|
2
|
+
import { type CodeFreeFieldRead } from './field-read-reuse.js';
|
|
3
|
+
import { type GetOperation, type IrBody } from './model.js';
|
|
4
|
+
/**
|
|
5
|
+
* Field reads, and the merges of them `reuseFieldReads` built, that may name
|
|
6
|
+
* the field they read instead of holding a counted copy of it.
|
|
7
|
+
*
|
|
8
|
+
* A slab test reads `box.min` and `box.max` once per axis; the reuse pass
|
|
9
|
+
* turned six reads into two and carries each across the axis branches through
|
|
10
|
+
* a phi. Each kept read still copied the handle -- a retain and a release per
|
|
11
|
+
* box, per field -- because the value lives across statements, and the phi
|
|
12
|
+
* copied again. The field holds that value for as long as nothing can store
|
|
13
|
+
* the key, rewrite the receiver's cell, or run program code: exactly the
|
|
14
|
+
* availability `field-read-reuse.ts` already tracks. So a read, or a phi of
|
|
15
|
+
* such reads, may be a pointer to the field when, at every use, the read is
|
|
16
|
+
* still available under that same value and the use itself forgets nothing
|
|
17
|
+
* of it.
|
|
18
|
+
*
|
|
19
|
+
* A use that is a phi this admits is checked on its edge, at the end of the
|
|
20
|
+
* predecessor. Any other use reads through the pointer where it stands; a
|
|
21
|
+
* merge this does not admit copies at its edge. A member every use cannot
|
|
22
|
+
* vouch for leaves, and so does every phi that merges it, until nothing moves.
|
|
23
|
+
*
|
|
24
|
+
* Only reads through a binding cell (`admitsCell`): the cell keeps the
|
|
25
|
+
* receiver alive until something writes it, and a write of the cell forgets
|
|
26
|
+
* the read. A receiver that is itself an SSA value may render as an alias of
|
|
27
|
+
* another field that a store of a different key can release. `borrowable`
|
|
28
|
+
* is the target's answer to which reads it renders as a load at all.
|
|
29
|
+
*/
|
|
30
|
+
export declare const borrowedFieldReadsOf: (body: IrBody, codeFree: CodeFreeFieldRead, admitsCell: (declaration: DeclarationId) => boolean, borrowable: (operation: GetOperation) => boolean, inlined: (value: IrValueId) => boolean) => ReadonlySet<IrValueId>;
|