@geastack/compiler 1.0.33 → 1.0.34
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 +1 -1
- package/dist/cli-coverage.js +2 -4
- package/dist/cli-emit.js +1 -1
- package/dist/cli-module-graph.js +1 -1
- package/dist/cli.js +2 -1
- package/dist/compiler.js +14 -6
- package/dist/conversion/array-view.js +9 -0
- package/dist/conversion/build.js +15 -8
- package/dist/conversion/dictionary-view.js +2 -2
- package/dist/conversion/nodes.d.ts +7 -0
- package/dist/conversion/nodes.js +58 -11
- package/dist/identity/ids.d.ts +4 -0
- package/dist/identity/ids.js +4 -0
- package/dist/ir/build.d.ts +4 -3
- package/dist/ir/build.js +14 -5
- package/dist/ir/call-dispatch.js +67 -7
- package/dist/ir/call-entry.js +1 -1
- package/dist/ir/callable-class-flow.d.ts +4 -0
- package/dist/ir/callable-class-flow.js +123 -1
- package/dist/ir/certify/parallel-region.js +698 -20
- package/dist/ir/certify.d.ts +3 -0
- package/dist/ir/certify.js +44 -9
- package/dist/ir/class-allocation-domain.js +2 -2
- package/dist/ir/class-construction-status.d.ts +10 -0
- package/dist/ir/class-construction-status.js +36 -0
- package/dist/ir/convert-carriers.d.ts +10 -1
- package/dist/ir/convert-carriers.js +18 -1
- package/dist/ir/dynamic-constructor-conversions.js +4 -2
- package/dist/ir/finite-iterator-close.d.ts +14 -0
- package/dist/ir/finite-iterator-close.js +50 -0
- package/dist/ir/host-template-conversions.js +9 -0
- package/dist/ir/lower-allocation.js +1 -1
- package/dist/ir/lower-flow.js +24 -3
- package/dist/ir/lower-operands.js +88 -7
- package/dist/ir/lower-protocol.js +1 -1
- package/dist/ir/lower.js +9 -4
- package/dist/ir/model.d.ts +39 -1
- package/dist/ir/native-accessor-definition.d.ts +3 -2
- package/dist/ir/native-accessor-definition.js +29 -10
- package/dist/ir/native-array-transport.js +2 -2
- package/dist/ir/native-field-view-domains.d.ts +23 -0
- package/dist/ir/native-field-view-domains.js +115 -9
- package/dist/ir/native-field-view-facts.d.ts +46 -2
- package/dist/ir/native-field-view-facts.js +159 -4
- package/dist/ir/native-iterable.d.ts +17 -0
- package/dist/ir/native-iterable.js +72 -0
- package/dist/ir/native-key-query.js +1 -1
- package/dist/ir/operation-conversions.js +15 -3
- package/dist/ir/program-conversions.js +2 -2
- package/dist/ir/publish-native-field-view-facts.js +9 -4
- package/dist/ir/pure-conversion-reuse.d.ts +58 -0
- package/dist/ir/pure-conversion-reuse.js +263 -0
- package/dist/ir/queries.js +1 -0
- package/dist/ir/reflection-demand.js +70 -18
- package/dist/ir/shake.js +2 -2
- package/dist/ir/unobserved-callable-inputs.d.ts +37 -0
- package/dist/ir/unobserved-callable-inputs.js +111 -0
- package/dist/native-signatures.d.ts +1 -1
- package/dist/native-signatures.js +27 -2
- package/dist/plugins/gea/component-classes.d.ts +2 -1
- package/dist/plugins/gea/component-classes.js +3 -3
- package/dist/plugins/gea/contract.d.ts +26 -3
- package/dist/plugins/gea/contract.js +42 -43
- package/dist/plugins/gea/host.d.ts +9 -0
- package/dist/plugins/gea/host.js +25 -4
- package/dist/plugins/gea/plugin.js +12 -6
- package/dist/plugins/gea/producer.d.ts +2 -2
- package/dist/plugins/gea/producer.js +2 -2
- package/dist/plugins/load.js +18 -1
- package/dist/plugins/model.d.ts +5 -0
- package/dist/plugins/native-iterable-providers.d.ts +18 -0
- package/dist/plugins/native-iterable-providers.js +51 -0
- package/dist/project-preparation.d.ts +8 -0
- package/dist/project-preparation.js +49 -7
- package/dist/projection/bindings.d.ts +13 -0
- package/dist/projection/bindings.js +20 -1
- package/dist/projection/classes.d.ts +4 -2
- package/dist/projection/classes.js +12 -5
- package/dist/representation/collections.js +2 -0
- package/dist/representation/derive.js +1 -0
- package/dist/representation/model.d.ts +2 -0
- package/dist/representation/model.js +1 -0
- package/dist/representation/policies.d.ts +2 -0
- package/dist/representation/primitive-domain.d.ts +1 -1
- package/dist/representation/primitive-domain.js +1 -1
- package/dist/representation/unassigned-binding-cells.js +6 -1
- package/dist/representation/union.js +6 -6
- package/dist/semantics/frontend.d.ts +2 -0
- package/dist/semantics/frontend.js +34 -5
- package/dist/semantics/host-methods.js +4 -1
- package/dist/semantics/jsx-runtime-provider.d.ts +5 -0
- package/dist/semantics/jsx-runtime-provider.js +16 -0
- package/dist/semantics/model/native-iterable.d.ts +14 -0
- package/dist/semantics/model/native-iterable.js +7 -0
- package/dist/semantics/model/operands.d.ts +30 -0
- package/dist/semantics/model/operations.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.js +27 -4
- package/dist/semantics/module-resolution.js +13 -2
- package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +32 -4
- package/dist/semantics/normalize/callback-parameter-contracts.js +66 -6
- package/dist/semantics/normalize/census.d.ts +3 -0
- package/dist/semantics/normalize/census.js +17 -12
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +4 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +29 -9
- package/dist/semantics/normalize/flow/callable-reach.js +94 -3
- package/dist/semantics/normalize/flow/component-solver.js +144 -55
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +9 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +30 -4
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +2 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +27 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.js +87 -14
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +2 -0
- package/dist/semantics/normalize/flow/source-commonjs-exports.js +2 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +17 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +125 -0
- package/dist/semantics/normalize/flow/source-native-origin.d.ts +6 -0
- package/dist/semantics/normalize/flow/source-native-origin.js +38 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.js +201 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +73 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +50 -1
- package/dist/semantics/normalize/flow/source-value-session.js +596 -57
- package/dist/semantics/normalize/flow/value-flow.d.ts +17 -0
- package/dist/semantics/normalize/flow/value-flow.js +84 -0
- package/dist/semantics/normalize/fresh-dictionary-storage.js +2 -2
- package/dist/semantics/normalize/fresh-table-last-use.d.ts +52 -0
- package/dist/semantics/normalize/fresh-table-last-use.js +129 -0
- package/dist/semantics/normalize/gating.js +5 -1
- package/dist/semantics/normalize/global-host-mutations.js +190 -13
- package/dist/semantics/normalize/identities.js +20 -1
- package/dist/semantics/normalize/local-bindings.js +2 -2
- package/dist/semantics/normalize/parameter-bindings.js +10 -1
- package/dist/semantics/normalize/producer-context.d.ts +5 -0
- package/dist/semantics/normalize/producers/binding-kind.js +2 -0
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +2 -2
- package/dist/semantics/normalize/producers/cited-value-type.js +2 -2
- package/dist/semantics/normalize/producers/class-lifecycle.js +39 -9
- package/dist/semantics/normalize/producers/computations.js +36 -5
- package/dist/semantics/normalize/producers/conditional-guard.d.ts +6 -0
- package/dist/semantics/normalize/producers/conditional-guard.js +5 -0
- package/dist/semantics/normalize/producers/control.js +7 -1
- package/dist/semantics/normalize/producers/destructuring.js +8 -9
- package/dist/semantics/normalize/producers/invocations.js +55 -2
- package/dist/semantics/normalize/producers/properties.d.ts +13 -0
- package/dist/semantics/normalize/producers/properties.js +21 -3
- package/dist/semantics/normalize/producers/references.js +8 -4
- package/dist/semantics/normalize/reachability.d.ts +15 -3
- package/dist/semantics/normalize/reachability.js +128 -20
- package/dist/semantics/normalize/return-bindings.js +3 -3
- package/dist/semantics/normalize/source-native-iterable.d.ts +19 -0
- package/dist/semantics/normalize/source-native-iterable.js +74 -0
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
- package/dist/semantics/normalize/structural-declarations.js +1 -1
- package/dist/semantics/normalize/structural-indexed-access.js +9 -0
- package/dist/semantics/normalize/structural.js +11 -0
- package/dist/semantics/normalize/unshared-array-result.d.ts +42 -0
- package/dist/semantics/normalize/unshared-array-result.js +269 -0
- package/dist/semantics/package-sources.js +3 -2
- package/dist/semantics/program.d.ts +8 -0
- package/dist/semantics/program.js +55 -0
- package/dist/semantics/source-transform-exports.d.ts +8 -0
- package/dist/semantics/source-transform-exports.js +145 -0
- package/dist/semantics/source-transform-protocol.d.ts +22 -0
- package/dist/semantics/this-constructor-source-transform.js +19 -1
- package/dist/targets/cpp/class-layout.d.ts +2 -0
- package/dist/targets/cpp/class-layout.js +35 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +11 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +33 -4
- package/dist/targets/cpp/conversions.js +6 -3
- package/dist/targets/cpp/emit-callable.js +73 -7
- package/dist/targets/cpp/emit-context.d.ts +23 -9
- package/dist/targets/cpp/emit-context.js +19 -8
- package/dist/targets/cpp/emit-equality.js +41 -1
- package/dist/targets/cpp/emit-exceptions.js +29 -11
- package/dist/targets/cpp/emit-iterator-object-view.js +2 -2
- package/dist/targets/cpp/emit-iterator.js +33 -9
- package/dist/targets/cpp/emit-live-field-view.js +6 -1
- package/dist/targets/cpp/emit-narrowing.d.ts +11 -3
- package/dist/targets/cpp/emit-narrowing.js +58 -18
- package/dist/targets/cpp/emit-native-field-view.d.ts +3 -1
- package/dist/targets/cpp/emit-native-field-view.js +84 -8
- package/dist/targets/cpp/emit-properties.d.ts +1 -0
- package/dist/targets/cpp/emit-properties.js +26 -7
- package/dist/targets/cpp/emit-protocol-iterator.js +5 -2
- package/dist/targets/cpp/emit-record-view.js +14 -2
- package/dist/targets/cpp/emit-tostring.js +23 -1
- package/dist/targets/cpp/emit-union-properties.js +1 -1
- package/dist/targets/cpp/emit.d.ts +1 -1
- package/dist/targets/cpp/emit.js +99 -13
- package/dist/targets/cpp/host/emit-host-invoke.js +2 -2
- package/dist/targets/cpp/host/emit-host-object.js +28 -2
- package/dist/targets/cpp/host/emit-host-properties.js +9 -1
- package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
- package/dist/targets/cpp/host/emit-host-value.js +8 -6
- package/dist/targets/cpp/host/host-members.js +2 -1
- package/dist/targets/cpp/prototype/emit-prototype-array.js +69 -5
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +9 -9
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +2 -2
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +7 -7
- package/dist/targets/cpp/records.d.ts +1 -0
- package/dist/targets/cpp/records.js +16 -7
- package/dist/targets/cpp/translation-unit.js +30 -16
- package/package.json +8 -7
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +42 -3
- package/src/targets/cpp/runtime/gea_eval.h +3 -0
- package/src/targets/cpp/runtime/gea_runtime.h +2399 -676
- package/dist/representation/any-null-record-members.d.ts +0 -41
- package/dist/representation/any-null-record-members.js +0 -115
- package/dist/semantics/any-null-member-declarations.d.ts +0 -32
- package/dist/semantics/any-null-member-declarations.js +0 -90
- package/dist/semantics/normalize/fresh-array-result.d.ts +0 -32
- package/dist/semantics/normalize/fresh-array-result.js +0 -125
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ boards, desktop, mobile and consoles. The other repositories plug into it:
|
|
|
34
34
|
- Xbox — the Xbox target is not open source; it is available commercially.
|
|
35
35
|
Contact [contact@geastack.com](mailto:contact@geastack.com).
|
|
36
36
|
- [`node-compat`](https://github.com/geastack/node-compat) — the Node.js
|
|
37
|
-
runtime and geatsc plugin for compiling Node servers (`node:http`,
|
|
37
|
+
runtime and geatsc plugin for compiling Node servers (`node:http`, HTTP frameworks) to
|
|
38
38
|
native executables. It is a dependency of this package: running `geatsc`
|
|
39
39
|
with no input file inside a Node project builds each of the project's entry
|
|
40
40
|
points through node-compat into `dist/`.
|
package/dist/cli-coverage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { relative, resolve } from 'node:path';
|
|
1
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
3
|
import { compile } from './compiler.js';
|
|
4
4
|
import { nodeOfOperation, operationOfResult } from './identity/ids.js';
|
|
@@ -308,9 +308,7 @@ export const runCoverage = async (argv) => {
|
|
|
308
308
|
process.stderr.write(`coverage: ${parsed.plugin} does not export a compiler plugin factory\n`);
|
|
309
309
|
return 1;
|
|
310
310
|
}
|
|
311
|
-
const projectFileName = parsed.projectFileName === 'discover'
|
|
312
|
-
? findProjectFile(entry.slice(0, Math.max(0, entry.lastIndexOf('/'))) || '.')
|
|
313
|
-
: parsed.projectFileName;
|
|
311
|
+
const projectFileName = parsed.projectFileName === 'discover' ? findProjectFile(dirname(entry)) : parsed.projectFileName;
|
|
314
312
|
const result = compile({
|
|
315
313
|
rootFileNames: [entry],
|
|
316
314
|
projectFileName,
|
package/dist/cli-emit.js
CHANGED
|
@@ -195,7 +195,7 @@ export const runEmit = async (argv, moduleGraph = false) => {
|
|
|
195
195
|
// A named project wins over discovery, and over the bundle rule above: a
|
|
196
196
|
// caller that states which project an input belongs to has answered the
|
|
197
197
|
// question this command would otherwise guess at.
|
|
198
|
-
const projectFileName = parsed.projectFileName ?? (bundled ? null : findProjectFile(
|
|
198
|
+
const projectFileName = parsed.projectFileName ?? (bundled ? null : findProjectFile(dirname(input)));
|
|
199
199
|
const result = compile({
|
|
200
200
|
rootFileNames: [input],
|
|
201
201
|
projectFileName,
|
package/dist/cli-module-graph.js
CHANGED
|
@@ -93,7 +93,7 @@ export const readModuleGraph = (manifestPath, stage, statedEntry) => {
|
|
|
93
93
|
for (const one of module.imports ?? []) {
|
|
94
94
|
if (!one.resolvedId)
|
|
95
95
|
continue;
|
|
96
|
-
const linked = byId.get(one.resolvedId) ?? (one.resolvedId
|
|
96
|
+
const linked = byId.get(one.resolvedId) ?? (isAbsolute(one.resolvedId) ? resolve(one.resolvedId) : null);
|
|
97
97
|
if (!linked)
|
|
98
98
|
continue;
|
|
99
99
|
// A dependency the bundler resolved to its BUILD, redirected to the
|
package/dist/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { findProjectFile } from './semantics/program.js';
|
|
|
9
9
|
import { preflightReportLines } from './preflight/report.js';
|
|
10
10
|
import { structuralShapeKey } from './semantics/model/structural-types.js';
|
|
11
11
|
import { closeSync, openSync, writeSync } from 'node:fs';
|
|
12
|
+
import { dirname } from 'node:path';
|
|
12
13
|
/**
|
|
13
14
|
* `--project <tsconfig.json>` names the project explicitly; `--no-project`
|
|
14
15
|
* compiles the roots under this compiler's own defaults. With neither, the
|
|
@@ -22,7 +23,7 @@ const parseArguments = (argv) => {
|
|
|
22
23
|
const named = flagIndex >= 0 ? (argv[flagIndex + 1] ?? null) : null;
|
|
23
24
|
const rootFileNames = named ? positional.filter((argument) => argument !== named) : positional;
|
|
24
25
|
const first = rootFileNames[0];
|
|
25
|
-
const discovered = first ? findProjectFile(
|
|
26
|
+
const discovered = first ? findProjectFile(dirname(first)) : null;
|
|
26
27
|
return {
|
|
27
28
|
rootFileNames,
|
|
28
29
|
preflight: argv.includes('--preflight'),
|
package/dist/compiler.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mergeNativeIterableProviders } from './plugins/native-iterable-providers.js';
|
|
1
2
|
import { nodeOfOperation, operationOfResult } from './identity/ids.js';
|
|
2
3
|
import { readFileSync } from 'fs';
|
|
3
4
|
import { projectAbis } from './projection/abi.js';
|
|
@@ -15,7 +16,7 @@ import { publishNativeOwnAssignments } from './ir/native-own-assignment.js';
|
|
|
15
16
|
import { publishNativeAccessorDefinitions } from './ir/native-accessor-definition.js';
|
|
16
17
|
import { publishNativeFieldViewFacts } from './ir/publish-native-field-view-facts.js';
|
|
17
18
|
import { publishNativeArrayDescriptorSnapshots } from './ir/native-array-descriptor-snapshot.js';
|
|
18
|
-
import { projectBindingPlacements } from './projection/bindings.js';
|
|
19
|
+
import { hostDeclarationFileTable, projectBindingPlacements } from './projection/bindings.js';
|
|
19
20
|
import { physicalClassInstanceResolverOf, physicalClassLayoutsOf, projectClasses } from './projection/classes.js';
|
|
20
21
|
import { isMaterializable } from './conversion/algebra.js';
|
|
21
22
|
import { recipeClosureOf } from './conversion/recipe-closure.js';
|
|
@@ -61,6 +62,7 @@ import { splitGeneratorBodies } from './ir/generator-split.js';
|
|
|
61
62
|
import { shakeProgram } from './ir/shake.js';
|
|
62
63
|
import { pruneProvenBranches } from './ir/proven-branches.js';
|
|
63
64
|
import { threadShortCircuitJoins } from './ir/short-circuit-threading.js';
|
|
65
|
+
import { dropUnreadPureConversions } from './ir/pure-conversion-reuse.js';
|
|
64
66
|
import { publishEmissionRepresentationsOf } from './ir/emission-representations.js';
|
|
65
67
|
import { finalizeTypedComputedReads, reflectionExposureOf } from './ir/reflection-demand.js';
|
|
66
68
|
import { confirmUnboxedMethodBinds } from './ir/boxed-bind-assumptions.js';
|
|
@@ -268,6 +270,7 @@ export const compile = (request) => {
|
|
|
268
270
|
producers: installedProducers((context) => plugins.flatMap((plugin) => plugin.producers(context))),
|
|
269
271
|
hostTypedArrayDeclarations: plugins.flatMap((plugin) => plugin.capabilities.typedArrayDeclarations ?? []),
|
|
270
272
|
nativeTypes,
|
|
273
|
+
nativeIterableProviders: mergeNativeIterableProviders(plugins.map((plugin) => plugin.capabilities.nativeIterableProviders)),
|
|
271
274
|
nativeTypesByDeclaration,
|
|
272
275
|
hostSingletonDeclarations: new Map(plugins.flatMap((plugin) => [...(plugin.capabilities.hostSingletonDeclarations ?? new Map())])),
|
|
273
276
|
standardClasses: new Set(coreNativeTypes.keys()),
|
|
@@ -338,6 +341,7 @@ export const compile = (request) => {
|
|
|
338
341
|
// done once, here, so the carrier states the transitive answer and nobody
|
|
339
342
|
// downstream has to walk anything (see `Representation`'s `native-handle`).
|
|
340
343
|
const hostBases = new Map(plugins.flatMap((plugin) => [...plugin.capabilities.nativeBases]));
|
|
344
|
+
const hostReferenceIdentities = new Set(plugins.flatMap((plugin) => [...(plugin.capabilities.nativeReferenceIdentities ?? [])]));
|
|
341
345
|
const hostViews = new Map(plugins.flatMap((plugin) => [...(plugin.capabilities.nativeViews ?? [])]));
|
|
342
346
|
const hostBaseChain = (native) => {
|
|
343
347
|
const chain = [];
|
|
@@ -369,6 +373,7 @@ export const compile = (request) => {
|
|
|
369
373
|
}, {
|
|
370
374
|
forDeclaration: (declaration) => frontend.hostProtocols.get(declaration) ?? null,
|
|
371
375
|
basesOf: (native) => hostBaseChain(native),
|
|
376
|
+
referenceIdentityOf: (native) => native !== null && hostReferenceIdentities.has(native),
|
|
372
377
|
viewsInto: (native) => (native === null ? new Map() : (hostViews.get(native) ?? new Map()))
|
|
373
378
|
}, {
|
|
374
379
|
forDeclaration: (declaration) => frontend.typedArrayElements.get(declaration) ?? null
|
|
@@ -684,9 +689,9 @@ export const compile = (request) => {
|
|
|
684
689
|
// is: each plugin's own table is keyed by ITS declaration files, so a
|
|
685
690
|
// union of the per-plugin maps cannot let one plugin's file collide with
|
|
686
691
|
// another's.
|
|
687
|
-
hostConstantsByDeclaration:
|
|
692
|
+
hostConstantsByDeclaration: hostDeclarationFileTable(plugins.flatMap((plugin) => [...plugin.capabilities.hostConstantsByDeclaration])),
|
|
688
693
|
hostFunctions: new Map([...plugins.flatMap((plugin) => [...plugin.capabilities.hostFunctions]), ...coreHostFunctions]),
|
|
689
|
-
hostFunctionsByDeclaration:
|
|
694
|
+
hostFunctionsByDeclaration: hostDeclarationFileTable(plugins.flatMap((plugin) => [...plugin.capabilities.hostFunctionsByDeclaration])),
|
|
690
695
|
// The backend's own table, unioned in the same way `coreHostMembers` is
|
|
691
696
|
// above and for the same reason: `btoa`/`encodeURIComponent` are language
|
|
692
697
|
// builtins, so a plugin row for one would make an ECMAScript global
|
|
@@ -698,11 +703,11 @@ export const compile = (request) => {
|
|
|
698
703
|
coreGlobalSingletons,
|
|
699
704
|
standardLibraryExternals: frontend.standardLibraryBindings,
|
|
700
705
|
hostNamespaces: hosts.namespaces,
|
|
701
|
-
hostNamespaceRootsByDeclaration:
|
|
706
|
+
hostNamespaceRootsByDeclaration: hostDeclarationFileTable(plugins.flatMap((plugin) => [...plugin.capabilities.hostNamespaceRootsByDeclaration])),
|
|
702
707
|
hostNamespaceBindings: frontend.hostNamespaceBindings,
|
|
703
708
|
exactHostNamespaceNames: new Set(hostNamespaceRootDeclarations.map((row) => row.declarationName)),
|
|
704
709
|
hostSingletons: hosts.singletons,
|
|
705
|
-
hostSingletonsByDeclaration:
|
|
710
|
+
hostSingletonsByDeclaration: hostDeclarationFileTable(plugins.flatMap((plugin) => [...plugin.capabilities.hostSingletonsByDeclaration])),
|
|
706
711
|
hostSingletonBindings: frontend.hostSingletonBindings
|
|
707
712
|
});
|
|
708
713
|
stage('diagnostics+abi');
|
|
@@ -1102,7 +1107,7 @@ export const compile = (request) => {
|
|
|
1102
1107
|
// only the CLOSED exposure can say its class never gained a dynamic protocol.
|
|
1103
1108
|
const absentArmBodies = finalizedBodies && reflection ? finalizeAbsentClassArms(finalizedBodies, reflection, executableClasses) : finalizedBodies;
|
|
1104
1109
|
// Last, so the call targets it follows into a callee are the final ones.
|
|
1105
|
-
const
|
|
1110
|
+
const sharedEmptyBodies = absentArmBodies
|
|
1106
1111
|
? shareReadOnlyEmptyRecords(absentArmBodies, {
|
|
1107
1112
|
placements: splitPlacements,
|
|
1108
1113
|
declaresField: (shapeId, key) => {
|
|
@@ -1116,6 +1121,9 @@ export const compile = (request) => {
|
|
|
1116
1121
|
}
|
|
1117
1122
|
})
|
|
1118
1123
|
: absentArmBodies;
|
|
1124
|
+
// Before the recipes and certification that read the final operation list:
|
|
1125
|
+
// a selection an `instanceof` no longer reads (`call-dispatch.ts`) goes.
|
|
1126
|
+
const emittedBodies = sharedEmptyBodies ? dropUnreadPureConversions(sharedEmptyBodies, conversionCensus) : sharedEmptyBodies;
|
|
1119
1127
|
stage('reflection');
|
|
1120
1128
|
// Certification is a walk of the IR lowering actually built
|
|
1121
1129
|
// (one question, one census): every capability the printer
|
|
@@ -41,6 +41,15 @@ const arrayStorageViewPlanOf = (source, target, accepted, readAccepted, resolve,
|
|
|
41
41
|
const read = exact(source.element, target.element, readAccepted, resolve);
|
|
42
42
|
if (!read || !liveRead(read, resolve))
|
|
43
43
|
return null;
|
|
44
|
+
// A typed array holds exactly the values its element carrier admits, every
|
|
45
|
+
// one of which JavaScript reads back as is. A reader that checks them --
|
|
46
|
+
// `Array<Vector2 | Vector3>` seen as a stated `Array<Vector2>` -- throws on
|
|
47
|
+
// an element the program stored and never tested, so it is no view of that
|
|
48
|
+
// array; the pair refuses instead. A dynamic element stays checked: there
|
|
49
|
+
// the program's own type is the only statement of what the value is.
|
|
50
|
+
if (source.element.kind !== 'dynamic' &&
|
|
51
|
+
[...recipeClosureOf([read], resolve).values()].some((child) => conversionRequiresSourceGuard(child.capability, resolve)))
|
|
52
|
+
return null;
|
|
44
53
|
if (source.element.kind === 'dynamic') {
|
|
45
54
|
const write = nativeEntryWriterOf(target.element, source.element, accepted, resolve);
|
|
46
55
|
if (!write)
|
package/dist/conversion/build.js
CHANGED
|
@@ -908,20 +908,27 @@ export const buildConversionGraph = (plan, registry = emptyConversionRegistry, c
|
|
|
908
908
|
continue;
|
|
909
909
|
const installed = registry.narrowing(representation, target);
|
|
910
910
|
// The same order `conversion/nodes.ts`'s `capabilityOf` asks in: an
|
|
911
|
-
// installed
|
|
912
|
-
// `never` minted here is what
|
|
913
|
-
//
|
|
914
|
-
//
|
|
915
|
-
|
|
911
|
+
// installed narrowing, else an installed widening or recast, else the
|
|
912
|
+
// registry's static recipe, else never. A `never` minted here is what
|
|
913
|
+
// `nodeFor` hands back for the pair, so a pair the static recipe
|
|
914
|
+
// answers must be answered here too or the eager graph would refuse
|
|
915
|
+
// what a late question would allow -- and an installed recast must win
|
|
916
|
+
// here as it does there: `never[]` into a class array is the identity
|
|
917
|
+
// `gea::emptyArraySentinel`, not the element-wise copy the static chain
|
|
918
|
+
// would mint for it, which the array rule then refuses.
|
|
919
|
+
const recast = installed ? null : (registry.widening(representation, target) ?? registry.recasting(representation, target));
|
|
920
|
+
const recipe = installed || recast ? null : registry.staticRecipe(representation, target);
|
|
916
921
|
nodes.set(id, {
|
|
917
922
|
id,
|
|
918
923
|
source: representation,
|
|
919
924
|
target,
|
|
920
925
|
capability: installed
|
|
921
926
|
? narrowingCapabilityFor(representation, target, installed)
|
|
922
|
-
:
|
|
923
|
-
? { kind: '
|
|
924
|
-
:
|
|
927
|
+
: recast
|
|
928
|
+
? { kind: 'atom', classifier: recast.classifier, materializer: recast.materializer }
|
|
929
|
+
: recipe
|
|
930
|
+
? { kind: 'static', materializer: recipe }
|
|
931
|
+
: { kind: 'never', reason: `no runtime narrowing is installed from ${sourceKey} to ${targetKey}` }
|
|
925
932
|
});
|
|
926
933
|
}
|
|
927
934
|
}
|
|
@@ -96,8 +96,8 @@ const checkedDynamicWrapperRead = (node, resolve) => {
|
|
|
96
96
|
* An entry read into the table's declared any/unknown carrier: `gea::Value::box`
|
|
97
97
|
* of a primitive keeps the ECMAScript value, and of a shared class reference
|
|
98
98
|
* holds that same object. The box allocates only its envelope, so the read is
|
|
99
|
-
* live -- `Record<string, Node>` reaching `Record<string, unknown>` (
|
|
100
|
-
* `hasChildren`) or `Record<string, number>` likewise.
|
|
99
|
+
* live -- `Record<string, Node>` reaching `Record<string, unknown>` (a trie
|
|
100
|
+
* router's `hasChildren`) or `Record<string, number>` likewise.
|
|
101
101
|
*/
|
|
102
102
|
const boxedEntryIsLive = (node) => {
|
|
103
103
|
if (node.target.kind !== 'dynamic' || node.target.reason === 'untyped-callable' || node.capability.kind !== 'atom')
|
|
@@ -208,6 +208,13 @@ export declare const ARM_VIEW_MATERIALIZER = "gea::host::armView";
|
|
|
208
208
|
export declare const ASSERTED_UNION_MATERIALIZER = "gea::host::assertedUnion";
|
|
209
209
|
/** The asserted-union node that may rebuild an `Array<any>` arm as a copy. */
|
|
210
210
|
export declare const ASSERTED_UNION_COPY_MATERIALIZER = "gea::host::assertedUnionCopy";
|
|
211
|
+
/**
|
|
212
|
+
* The live-arm dispatch of a union ARGUMENT a callable adapter frame hands to a
|
|
213
|
+
* body declaring one of its classes (`nodes.ts`'s `checkedFrameNarrowingFor`):
|
|
214
|
+
* `assertedUnionFor`'s dispatch, but a boxed arm is admitted by a class check
|
|
215
|
+
* and a value that is no instance is a catchable `TypeError`, not an abort.
|
|
216
|
+
*/
|
|
217
|
+
export declare const FRAME_ARGUMENT_UNION_MATERIALIZER = "gea::host::frameArgumentUnion";
|
|
211
218
|
/** The materializer id every asserted-view node carries; the printer dispatches its recipe on it. */
|
|
212
219
|
export declare const ASSERTED_VIEW_MATERIALIZER = "gea::host::assertedView";
|
|
213
220
|
/** A structural record carrier: a value that can be a view of a class allocation only through its origin. */
|
package/dist/conversion/nodes.js
CHANGED
|
@@ -184,7 +184,7 @@ export const createConversionNodes = (input) => {
|
|
|
184
184
|
const recipe = input.registry.staticRecipe(source, target);
|
|
185
185
|
if (recipe && !recipe.staticRecipeFallback)
|
|
186
186
|
return { kind: 'static', materializer: recipe };
|
|
187
|
-
const structural = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
187
|
+
const structural = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
188
188
|
if (structural)
|
|
189
189
|
return { kind: 'static', materializer: structural };
|
|
190
190
|
if (recipe)
|
|
@@ -259,7 +259,7 @@ export const createConversionNodes = (input) => {
|
|
|
259
259
|
// census happened to mint first.
|
|
260
260
|
const payload = target.kind === 'optional' ? nodeFor(source, target.payload).capability : null;
|
|
261
261
|
const sealed = payload === null || ('materializer' in payload && payload.materializer.documentRecordView)
|
|
262
|
-
? input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
262
|
+
? input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor)
|
|
263
263
|
: undefined;
|
|
264
264
|
capability = sealed?.documentRecordView
|
|
265
265
|
? { kind: 'static', materializer: sealed }
|
|
@@ -335,7 +335,7 @@ export const createConversionNodes = (input) => {
|
|
|
335
335
|
if (source.kind === 'tagged-union' &&
|
|
336
336
|
(target.kind === 'record' || (target.kind === 'native-record-ref' && target.native === null)) &&
|
|
337
337
|
(capability.materializer.armSelection !== undefined || capability.materializer.nativeSelection !== undefined)) {
|
|
338
|
-
const complete = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
338
|
+
const complete = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
339
339
|
if (complete?.recordView?.view.kind === 'dispatch')
|
|
340
340
|
capability = { kind: 'static', materializer: complete };
|
|
341
341
|
}
|
|
@@ -353,13 +353,13 @@ export const createConversionNodes = (input) => {
|
|
|
353
353
|
target.value.kind !== 'dynamic' &&
|
|
354
354
|
(capability.materializer.wrapperKind === 'unbox-tag' || capability.materializer.wrapperKind === 'unbox-payload') &&
|
|
355
355
|
dictionaryEntriesAreSharedRecords(target.value)) {
|
|
356
|
-
const viewed = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
356
|
+
const viewed = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
357
357
|
if (viewed?.dictionaryView !== undefined)
|
|
358
358
|
capability = { kind: 'static', materializer: viewed };
|
|
359
359
|
}
|
|
360
360
|
const materializer = capability.materializer;
|
|
361
361
|
if (structuralRecipeRequiredFor({ id, source, target, capability })) {
|
|
362
|
-
const sealed = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
362
|
+
const sealed = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
363
363
|
capability =
|
|
364
364
|
sealed?.recordView ||
|
|
365
365
|
sealed?.documentRecordView ||
|
|
@@ -598,7 +598,7 @@ export const createConversionNodes = (input) => {
|
|
|
598
598
|
});
|
|
599
599
|
const sealed = input.registry.structuralRecipe?.(source, frame, (from, into) => representationKey(from) === representationKey(result.source) && representationKey(into) === representationKey(result.target)
|
|
600
600
|
? result
|
|
601
|
-
: nodeFor(from, into), undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
601
|
+
: nodeFor(from, into), undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
602
602
|
if (sealed?.callableView === undefined)
|
|
603
603
|
return null;
|
|
604
604
|
frameAdaptation = contextualNode(source, frame, 'native-method-result-frame', sealed);
|
|
@@ -735,12 +735,15 @@ export const createConversionNodes = (input) => {
|
|
|
735
735
|
return node;
|
|
736
736
|
};
|
|
737
737
|
const assertedUnions = new Map();
|
|
738
|
-
const assertedUnionFor = (source, target, copyAllowed) =>
|
|
738
|
+
const assertedUnionFor = (source, target, copyAllowed) => liveArmDispatchFor(source, target, copyAllowed ? 'copy' : 'asserted');
|
|
739
|
+
const liveArmDispatchFor = (source, target, mode) => {
|
|
740
|
+
const copyAllowed = mode === 'copy';
|
|
739
741
|
if (source.kind !== 'tagged-union' && !(source.kind === 'optional' && source.payload.kind === 'tagged-union'))
|
|
740
742
|
return null;
|
|
741
743
|
if (target.kind === 'tagged-union' || target.kind === 'dynamic')
|
|
742
744
|
return null;
|
|
743
|
-
const
|
|
745
|
+
const suffix = mode === 'copy' ? 'asserted-union:copy' : mode === 'frame-argument' ? 'frame-argument-union' : 'asserted-union';
|
|
746
|
+
const id = `${representationKey(source)}->${representationKey(target)}#${suffix}`;
|
|
744
747
|
const remembered = assertedUnions.get(id);
|
|
745
748
|
if (remembered !== undefined)
|
|
746
749
|
return remembered;
|
|
@@ -770,8 +773,16 @@ export const createConversionNodes = (input) => {
|
|
|
770
773
|
capability: {
|
|
771
774
|
kind: 'static',
|
|
772
775
|
materializer: {
|
|
773
|
-
id:
|
|
774
|
-
|
|
776
|
+
id: mode === 'copy'
|
|
777
|
+
? ASSERTED_UNION_COPY_MATERIALIZER
|
|
778
|
+
: mode === 'frame-argument'
|
|
779
|
+
? FRAME_ARGUMENT_UNION_MATERIALIZER
|
|
780
|
+
: ASSERTED_UNION_MATERIALIZER,
|
|
781
|
+
domain: mode === 'copy'
|
|
782
|
+
? 'static:asserted-union-copy'
|
|
783
|
+
: mode === 'frame-argument'
|
|
784
|
+
? 'static:frame-argument-union'
|
|
785
|
+
: 'static:asserted-union',
|
|
775
786
|
allocates: copyAllowed,
|
|
776
787
|
...(native ? { nativeFieldProtocol: 'unused' } : {})
|
|
777
788
|
}
|
|
@@ -839,7 +850,7 @@ export const createConversionNodes = (input) => {
|
|
|
839
850
|
const remembered = familyMemberViews.get(id);
|
|
840
851
|
if (remembered !== undefined)
|
|
841
852
|
return remembered;
|
|
842
|
-
const materializer = input.registry.structuralRecipe?.(source, target, nodeFor, members, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
853
|
+
const materializer = input.registry.structuralRecipe?.(source, target, nodeFor, members, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor) ?? null;
|
|
843
854
|
if (materializer === null)
|
|
844
855
|
return null;
|
|
845
856
|
const node = { id, source, target, capability: { kind: 'static', materializer }, familyMembers: members };
|
|
@@ -895,6 +906,35 @@ export const createConversionNodes = (input) => {
|
|
|
895
906
|
assertedClassDowncasts.set(id, node);
|
|
896
907
|
return node;
|
|
897
908
|
};
|
|
909
|
+
// The checked narrowing a callable ADAPTER FRAME may apply to an argument
|
|
910
|
+
// (`structural-plan.ts`'s `callableViewPlan`, `downcast`). Besides the
|
|
911
|
+
// class downcast above, a union-typed public parameter entering a body
|
|
912
|
+
// that declares one of its arms: a function value stored into a method
|
|
913
|
+
// slot that some other writer widened (`m.hook = (s, r: Renderer) => ...`
|
|
914
|
+
// beside `n.hook = (s, r: any) => ...` makes the slot's frame take
|
|
915
|
+
// `Renderer | any`), which TypeScript admits through method-parameter
|
|
916
|
+
// bivariance. The frame has no `instanceof` guard for the ordinary arm
|
|
917
|
+
// selection to trust, so the live arm is dispatched instead
|
|
918
|
+
// (`FRAME_ARGUMENT_UNION_MATERIALIZER`): the arm the body declares passes as
|
|
919
|
+
// it is, with no conversion; every other arm through its own conversion,
|
|
920
|
+
// except that a boxed (`any`) arm is admitted by a class check first -- an
|
|
921
|
+
// `any` holding the instance unboxes to it, anything else is a catchable
|
|
922
|
+
// TypeError, never the unbox's abort -- and an arm that cannot be the
|
|
923
|
+
// parameter at all is the same TypeError. Only a union one of whose arms
|
|
924
|
+
// reaches the target without a prior guard qualifies; a frame narrowing
|
|
925
|
+
// that converts no arm stays refused. The ordinary unguarded conversion,
|
|
926
|
+
// where one exists, is still preferred (`callableViewPlan`'s `guarded`).
|
|
927
|
+
const checkedFrameNarrowingFor = (source, target) => {
|
|
928
|
+
const downcast = assertedClassDowncastFor(source, target);
|
|
929
|
+
if (downcast !== null)
|
|
930
|
+
return downcast;
|
|
931
|
+
if (source.kind !== 'tagged-union' || target.kind !== 'class-ref')
|
|
932
|
+
return null;
|
|
933
|
+
const targetKey = representationKey(target);
|
|
934
|
+
const homed = source.arms.some((arm) => representationKey(arm.value) === targetKey ||
|
|
935
|
+
(arm.value.kind !== 'dynamic' && recipeIsMaterializableWithoutPriorSourceGuard(nodeFor(arm.value, target), nodeById)));
|
|
936
|
+
return homed ? liveArmDispatchFor(source, target, 'frame-argument') : null;
|
|
937
|
+
};
|
|
898
938
|
const nullishOptionals = new Map();
|
|
899
939
|
const nullishOptionalFor = (source, target) => {
|
|
900
940
|
if (source.kind !== 'dynamic' || source.reason === 'untyped-callable' || target.kind !== 'optional' || target.absence !== 'undefined')
|
|
@@ -1027,6 +1067,13 @@ const isArmViewPair = (source, target) => {
|
|
|
1027
1067
|
export const ASSERTED_UNION_MATERIALIZER = 'gea::host::assertedUnion';
|
|
1028
1068
|
/** The asserted-union node that may rebuild an `Array<any>` arm as a copy. */
|
|
1029
1069
|
export const ASSERTED_UNION_COPY_MATERIALIZER = 'gea::host::assertedUnionCopy';
|
|
1070
|
+
/**
|
|
1071
|
+
* The live-arm dispatch of a union ARGUMENT a callable adapter frame hands to a
|
|
1072
|
+
* body declaring one of its classes (`nodes.ts`'s `checkedFrameNarrowingFor`):
|
|
1073
|
+
* `assertedUnionFor`'s dispatch, but a boxed arm is admitted by a class check
|
|
1074
|
+
* and a value that is no instance is a catchable `TypeError`, not an abort.
|
|
1075
|
+
*/
|
|
1076
|
+
export const FRAME_ARGUMENT_UNION_MATERIALIZER = 'gea::host::frameArgumentUnion';
|
|
1030
1077
|
/** The materializer id every asserted-view node carries; the printer dispatches its recipe on it. */
|
|
1031
1078
|
export const ASSERTED_VIEW_MATERIALIZER = 'gea::host::assertedView';
|
|
1032
1079
|
/** A structural record carrier: a value that can be a view of a class allocation only through its origin. */
|
package/dist/identity/ids.d.ts
CHANGED
|
@@ -176,4 +176,8 @@ export declare const isRegionId: (owner: FunctionId | RegionId) => owner is Regi
|
|
|
176
176
|
export declare const fileIdentityOf: (owner: FunctionId | RegionId | DeclarationId) => string;
|
|
177
177
|
/** The role an already-minted result fills. */
|
|
178
178
|
export declare const roleOfResult: (result: SemanticResultId) => ResultRole;
|
|
179
|
+
/** A lexical cell associated with a declaration, distinct from its source
|
|
180
|
+
* declaration identity. Role slots are assigned by the owning language rule.
|
|
181
|
+
*/
|
|
182
|
+
export declare const lexicalCellDeclarationId: (owner: DeclarationId, slot: number) => DeclarationId;
|
|
179
183
|
export {};
|
package/dist/identity/ids.js
CHANGED
|
@@ -210,3 +210,7 @@ export const roleOfResult = (result) => {
|
|
|
210
210
|
throw new Error(`semantic result ${result} does not carry a known result role`);
|
|
211
211
|
return known;
|
|
212
212
|
};
|
|
213
|
+
/** A lexical cell associated with a declaration, distinct from its source
|
|
214
|
+
* declaration identity. Role slots are assigned by the owning language rule.
|
|
215
|
+
*/
|
|
216
|
+
export const lexicalCellDeclarationId = (owner, slot) => `lexical-cell|${encode(owner)}|${slot}`;
|
package/dist/ir/build.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NativeIterableReceipt } from '../semantics/model/native-iterable.js';
|
|
1
2
|
import type { DeclarationId, FunctionId, IrValueId, PhysicalBodyId, RegionId, SemanticResultId } from '../identity/ids.js';
|
|
2
3
|
import type { CallableAbi, Representation } from '../representation/model.js';
|
|
3
4
|
import type { ConstantLiteral } from '../semantics/model/operands.js';
|
|
@@ -113,7 +114,7 @@ export interface IrBodyBuilder {
|
|
|
113
114
|
readonly allocateArrayObject: (block: IrBlockId, lineage: SemanticResultId, elements: readonly IrArrayElement[], representation: Representation) => IrValueId;
|
|
114
115
|
readonly allocateCallable: (block: IrBlockId, lineage: SemanticResultId, functionId: FunctionId, captures: readonly IrOperand[], representation: Representation, callableOwnPrototype?: boolean) => IrValueId;
|
|
115
116
|
readonly bindCallable: (block: IrBlockId, lineage: SemanticResultId, source: IrOperand, sourceFunctionId: FunctionId | null, sourceAbi: CallableAbi, thisArgument: IrOperand | null, receiver: IrOperand | null, bound: readonly IrOperand[], representation: Representation, unboxedMethod?: UnboxedMethodAssumption, shadowGuarded?: true) => IrValueId;
|
|
116
|
-
readonly allocateConstructor: (block: IrBlockId, lineage: SemanticResultId, declaration: DeclarationId, captures: readonly IrOperand[], representation: Representation, heritage?: IrOperand) => IrValueId;
|
|
117
|
+
readonly allocateConstructor: (block: IrBlockId, lineage: SemanticResultId, declaration: DeclarationId, captures: readonly IrOperand[], representation: Representation, heritage?: IrOperand, constructionDeferred?: true) => IrValueId;
|
|
117
118
|
readonly allocateProxy: (block: IrBlockId, lineage: SemanticResultId, target: IrOperand, handler: IrOperand, representation: Representation) => IrValueId;
|
|
118
119
|
readonly proxyPart: (block: IrBlockId, lineage: SemanticResultId, proxy: IrOperand, part: 'target' | 'handler', representation: Representation) => IrValueId;
|
|
119
120
|
readonly proxyTrapCheck: (block: IrBlockId, lineage: SemanticResultId, trap: 'set' | 'deleteProperty', answer: IrOperand) => void;
|
|
@@ -130,11 +131,11 @@ export interface IrBodyBuilder {
|
|
|
130
131
|
readonly elementChild: (block: IrBlockId, lineage: SemanticResultId, node: IrOperand, child: IrOperand, textLeaf: boolean) => void;
|
|
131
132
|
/** `ToBoolean` of a value, for the conditional that has to branch on it. The result is a boolean scalar by construction. */
|
|
132
133
|
readonly test: (block: IrBlockId, lineage: SemanticResultId, value: IrOperand, predicate?: 'to-boolean' | 'is-present' | 'is-defined') => IrValueId;
|
|
133
|
-
readonly convert: (block: IrBlockId, lineage: SemanticResultId, conversionUse: ConversionUseId, source: IrOperand, representation: Representation, rebuild?: 'unshared-array', nativeCallableSource?: import('./native-callable-argument.js').NativeCallableSourceProof, nativeObjectSample?: import('./native-object-sample.js').NativeObjectSampleReceipt) => IrValueId;
|
|
134
|
+
readonly convert: (block: IrBlockId, lineage: SemanticResultId, conversionUse: ConversionUseId, source: IrOperand, representation: Representation, rebuild?: 'unshared-array' | 'unshared-dictionary', nativeCallableSource?: import('./native-callable-argument.js').NativeCallableSourceProof, nativeObjectSample?: import('./native-object-sample.js').NativeObjectSampleReceipt, releasesSource?: true) => IrValueId;
|
|
134
135
|
/** See `MergeLiveArmRebuildOperation` -- the control-flow-proven live-arm sibling of representation-global `convert`. */
|
|
135
136
|
readonly mergeLiveArmRebuild: (block: IrBlockId, lineage: SemanticResultId, source: IrOperand, representation: Representation, liveArms: readonly number[], sourceAbsenceLive: boolean, conversions: ConversionCensus) => IrValueId;
|
|
136
137
|
readonly deadLogicalMergeValue: (block: IrBlockId, lineage: SemanticResultId, source: IrOperand, representation: Representation) => IrValueId;
|
|
137
|
-
readonly getIterator: (block: IrBlockId, lineage: SemanticResultId, protocol: GetIteratorOperation['protocol'], receiver: IrOperand, method: IrOperand | null, representation: Representation) => IrValueId;
|
|
138
|
+
readonly getIterator: (block: IrBlockId, lineage: SemanticResultId, protocol: GetIteratorOperation['protocol'], receiver: IrOperand, method: IrOperand | null, representation: Representation, nativeIterable?: NativeIterableReceipt) => IrValueId;
|
|
138
139
|
readonly iteratorNext: (block: IrBlockId, lineage: SemanticResultId, iterator: IrOperand, value: IrOperand | null, representation: Representation, settlesValue?: boolean) => IrValueId;
|
|
139
140
|
/** `IteratorResult`'s `done` half -- see `IteratorDoneOperation`'s own comment (ir/model.ts) for why this is a separate op rather than a second result on `iteratorNext`. */
|
|
140
141
|
readonly iteratorDone: (block: IrBlockId, lineage: SemanticResultId, iterator: IrOperand, representation: Representation) => IrValueId;
|
package/dist/ir/build.js
CHANGED
|
@@ -386,9 +386,17 @@ export const createIrBodyBuilder = (owner, sourceOwner, abi, constructAbi = null
|
|
|
386
386
|
});
|
|
387
387
|
return result.id;
|
|
388
388
|
};
|
|
389
|
-
const allocateConstructor = (block, lineage, declaration, captures, representation, heritage) => {
|
|
389
|
+
const allocateConstructor = (block, lineage, declaration, captures, representation, heritage, constructionDeferred) => {
|
|
390
390
|
const result = mintResult(representation);
|
|
391
|
-
append(block, {
|
|
391
|
+
append(block, {
|
|
392
|
+
kind: 'allocate-constructor',
|
|
393
|
+
lineage,
|
|
394
|
+
declaration,
|
|
395
|
+
captures,
|
|
396
|
+
...(heritage ? { heritage } : {}),
|
|
397
|
+
...(constructionDeferred ? { constructionDeferred } : {}),
|
|
398
|
+
result
|
|
399
|
+
});
|
|
392
400
|
return result.id;
|
|
393
401
|
};
|
|
394
402
|
const allocateProxy = (block, lineage, target, handler, representation) => {
|
|
@@ -446,7 +454,7 @@ export const createIrBodyBuilder = (owner, sourceOwner, abi, constructAbi = null
|
|
|
446
454
|
append(block, { kind: 'test', lineage, predicate, value, result });
|
|
447
455
|
return result.id;
|
|
448
456
|
};
|
|
449
|
-
const convert = (block, lineage, conversionUse, source, representation, rebuild, nativeCallableSource, nativeObjectSample) => {
|
|
457
|
+
const convert = (block, lineage, conversionUse, source, representation, rebuild, nativeCallableSource, nativeObjectSample, releasesSource) => {
|
|
450
458
|
const result = mintResult(representation);
|
|
451
459
|
append(block, {
|
|
452
460
|
kind: 'convert',
|
|
@@ -455,6 +463,7 @@ export const createIrBodyBuilder = (owner, sourceOwner, abi, constructAbi = null
|
|
|
455
463
|
source,
|
|
456
464
|
result,
|
|
457
465
|
...(rebuild ? { rebuild } : {}),
|
|
466
|
+
...(rebuild === 'unshared-array' && releasesSource ? { releasesSource } : {}),
|
|
458
467
|
...(nativeCallableSource ? { nativeCallableSource } : {}),
|
|
459
468
|
...(nativeObjectSample ? { nativeObjectSample } : {})
|
|
460
469
|
});
|
|
@@ -479,9 +488,9 @@ export const createIrBodyBuilder = (owner, sourceOwner, abi, constructAbi = null
|
|
|
479
488
|
append(block, { kind: 'dead-logical-merge-value', lineage, source, result });
|
|
480
489
|
return result.id;
|
|
481
490
|
};
|
|
482
|
-
const getIterator = (block, lineage, protocol, receiver, method, representation) => {
|
|
491
|
+
const getIterator = (block, lineage, protocol, receiver, method, representation, nativeIterable) => {
|
|
483
492
|
const result = mintResult(representation);
|
|
484
|
-
append(block, { kind: 'get-iterator', lineage, protocol, receiver, method, result });
|
|
493
|
+
append(block, { kind: 'get-iterator', lineage, protocol, receiver, method, result, ...(nativeIterable ? { nativeIterable } : {}) });
|
|
485
494
|
return result.id;
|
|
486
495
|
};
|
|
487
496
|
const iteratorNext = (block, lineage, iterator, value, representation, settlesValue) => {
|
package/dist/ir/call-dispatch.js
CHANGED
|
@@ -11,6 +11,7 @@ import { classInstanceTestOf, classViewCarrierKinds } from '../projection/instan
|
|
|
11
11
|
import { classPrototypeReadOf } from '../projection/class-prototype.js';
|
|
12
12
|
import { operandsOfIrOperation, resultOfIrOperation } from './queries.js';
|
|
13
13
|
import { nativeUnionMethodTargetsOf } from './native-union-method-targets.js';
|
|
14
|
+
import { pureNativeConversion } from './pure-conversion-reuse.js';
|
|
14
15
|
/**
|
|
15
16
|
* Fills the post-shake call facts. `CallOperation.target` says which
|
|
16
17
|
* FunctionId (if any) a call's callee can use for physical devirtualization,
|
|
@@ -898,9 +899,23 @@ const resolveClassMethod = (producer, body, producers, classes, abiOf, capturesN
|
|
|
898
899
|
const isSuperAccess = producers.get(producer.receiver.value)?.kind === 'receiver' &&
|
|
899
900
|
body.abi?.receiver?.kind === 'class-ref' &&
|
|
900
901
|
body.abi.receiver.declaration !== receiver.declaration;
|
|
901
|
-
if ((
|
|
902
|
-
classPrototypeMethodMutableOf(classes, receiver.declaration, key))
|
|
902
|
+
if (classPrototypeMethodMutableOf(classes, receiver.declaration, key))
|
|
903
903
|
return unresolvedCall;
|
|
904
|
+
if (!isSuperAccess && classMethodOverrideOf(classes, receiver.declaration, key)) {
|
|
905
|
+
// Only an own property can replace the body here: no subclass redeclares
|
|
906
|
+
// the key and the prototype is never written. An instance whose own slot
|
|
907
|
+
// is empty therefore runs exactly this body, so the call may name it
|
|
908
|
+
// behind a test of that slot (`CallOperation.ownShadowGuard`).
|
|
909
|
+
const functionId = site.method.callable;
|
|
910
|
+
const heldAbi = abiOfCallee(producer.result.representation);
|
|
911
|
+
const bodyAbi = abiOf(functionId);
|
|
912
|
+
const guardable = classFamilyOverridesOf(classes, receiver.declaration, key).length === 0 &&
|
|
913
|
+
capturesNothing(functionId) &&
|
|
914
|
+
heldAbi !== null &&
|
|
915
|
+
bodyAbi !== null &&
|
|
916
|
+
abiKey(heldAbi) === abiKey(bodyAbi);
|
|
917
|
+
return guardable ? { target: unresolvedTarget, ownShadowGuard: { functionId, key } } : unresolvedCall;
|
|
918
|
+
}
|
|
904
919
|
if (classFamilyOverridesOf(classes, receiver.declaration, key).length === 0 || isSuperAccess) {
|
|
905
920
|
const functionId = site.method.callable;
|
|
906
921
|
return {
|
|
@@ -972,6 +987,13 @@ const resolveCall = (operation, body, producers, classes, abiOf, capturesNothing
|
|
|
972
987
|
const actual = operation.thisArgument ?? operation.receiver;
|
|
973
988
|
if (heldAbi === null || heldAbi.receiver === null || actual?.value !== producer.receiver.value)
|
|
974
989
|
return { target: unresolvedTarget, ...(classCall.closedCallee ? { closedCallee: classCall.closedCallee } : {}) };
|
|
990
|
+
// The guarded body receives the call's own arguments in the held frame, so
|
|
991
|
+
// the frame the call fills must be the one the guard was proved against.
|
|
992
|
+
if (classCall.ownShadowGuard !== undefined) {
|
|
993
|
+
const bodyAbi = abiOf(classCall.ownShadowGuard.functionId);
|
|
994
|
+
if (bodyAbi === null || abiKey(heldAbi) !== abiKey(bodyAbi) || operation.argumentsAreSpread)
|
|
995
|
+
return unresolvedCall;
|
|
996
|
+
}
|
|
975
997
|
return classCall;
|
|
976
998
|
}
|
|
977
999
|
const arms = nativeUnionMethodTargetsOf(producer.receiver.representation, classes, key);
|
|
@@ -994,14 +1016,42 @@ const resolveCall = (operation, body, producers, classes, abiOf, capturesNothing
|
|
|
994
1016
|
};
|
|
995
1017
|
const rewriteBody = (body, classes, abiOf, capturesNothing, verdict, callableBindings, callableMembers, observed, prototypes, viewed, plainObjects, conversions, viewHolders) => {
|
|
996
1018
|
const producers = producerMapOf(body);
|
|
1019
|
+
let uses = null;
|
|
1020
|
+
const usesOf = (value) => {
|
|
1021
|
+
if (uses === null) {
|
|
1022
|
+
const counted = new Map();
|
|
1023
|
+
for (const block of body.blocks.values())
|
|
1024
|
+
for (const operation of [...block.operations, block.terminator])
|
|
1025
|
+
for (const operand of operandsOfIrOperation(operation))
|
|
1026
|
+
counted.set(operand.value, (counted.get(operand.value) ?? 0) + 1);
|
|
1027
|
+
uses = counted;
|
|
1028
|
+
}
|
|
1029
|
+
return uses.get(value) ?? 0;
|
|
1030
|
+
};
|
|
1031
|
+
// `x instanceof C` asks about the object, which a native selection or
|
|
1032
|
+
// widening of `x` keeps: a narrowing that exists only to be tested (the
|
|
1033
|
+
// `else if (value instanceof SpotLight)` arm of a chain, after the earlier
|
|
1034
|
+
// arms narrowed `value`'s carrier) is a union copy and a destruction around a
|
|
1035
|
+
// tag test. Tested on the selection's own source, the test reads the tags in
|
|
1036
|
+
// place and the selection, now unread, is dropped (`pure-conversion-reuse.ts`).
|
|
1037
|
+
const instanceSourceOf = (left) => {
|
|
1038
|
+
if (conversions === undefined)
|
|
1039
|
+
return null;
|
|
1040
|
+
const producer = producers.get(left.value);
|
|
1041
|
+
if (producer?.kind !== 'convert' || usesOf(left.value) !== 1 || !pureNativeConversion(producer, conversions))
|
|
1042
|
+
return null;
|
|
1043
|
+
const source = producer.source.representation;
|
|
1044
|
+
return source.kind === 'tagged-union' || source.kind === 'optional' || source.kind === 'class-ref' ? producer.source : null;
|
|
1045
|
+
};
|
|
997
1046
|
let bodyChanged = false;
|
|
998
1047
|
const blocks = new Map();
|
|
999
1048
|
for (const [blockId, block] of body.blocks) {
|
|
1000
1049
|
let blockChanged = false;
|
|
1001
1050
|
const operations = block.operations.map((operation) => {
|
|
1002
1051
|
if (operation.kind === 'compute' && operation.form === 'instanceof') {
|
|
1003
|
-
const [
|
|
1004
|
-
const
|
|
1052
|
+
const [selected, right] = operation.operands;
|
|
1053
|
+
const tested = selected && right ? instanceSourceOf(selected) : null;
|
|
1054
|
+
const testOf = (left) => right
|
|
1005
1055
|
? classInstanceTestOf(left.representation, right.representation, classes, {
|
|
1006
1056
|
prototypeOf: classPrototypeOf(left.value, producers, classes),
|
|
1007
1057
|
materialized: prototypes,
|
|
@@ -1010,6 +1060,12 @@ const rewriteBody = (body, classes, abiOf, capturesNothing, verdict, callableBin
|
|
|
1010
1060
|
...(viewHolders === undefined ? {} : { viewHolders })
|
|
1011
1061
|
})
|
|
1012
1062
|
: undefined;
|
|
1063
|
+
const sourceTest = tested === null ? undefined : testOf(tested);
|
|
1064
|
+
if (tested !== null && sourceTest !== undefined) {
|
|
1065
|
+
blockChanged = true;
|
|
1066
|
+
return { ...operation, operands: [tested, ...operation.operands.slice(1)], classInstanceTest: sourceTest };
|
|
1067
|
+
}
|
|
1068
|
+
const classInstanceTest = selected ? testOf(selected) : undefined;
|
|
1013
1069
|
if (classInstanceTest === undefined)
|
|
1014
1070
|
return operation;
|
|
1015
1071
|
blockChanged = true;
|
|
@@ -1042,9 +1098,13 @@ const rewriteBody = (body, classes, abiOf, capturesNothing, verdict, callableBin
|
|
|
1042
1098
|
}
|
|
1043
1099
|
if (operation.kind !== 'call')
|
|
1044
1100
|
return operation;
|
|
1045
|
-
const { target, closedCallee } = resolveCall(operation, body, producers, classes, abiOf, capturesNothing, verdict, callableBindings, callableMembers);
|
|
1046
|
-
if (target.kind === 'unresolved' && closedCallee === undefined)
|
|
1047
|
-
|
|
1101
|
+
const { target, closedCallee, ownShadowGuard } = resolveCall(operation, body, producers, classes, abiOf, capturesNothing, verdict, callableBindings, callableMembers);
|
|
1102
|
+
if (target.kind === 'unresolved' && closedCallee === undefined) {
|
|
1103
|
+
if (ownShadowGuard === undefined)
|
|
1104
|
+
return operation;
|
|
1105
|
+
blockChanged = true;
|
|
1106
|
+
return { ...operation, ownShadowGuard };
|
|
1107
|
+
}
|
|
1048
1108
|
// A closed static body whose ABI has no receiver cannot observe the
|
|
1049
1109
|
// constructor used for method syntax. Keep its evaluation in preceding
|
|
1050
1110
|
// IR, but normalize the invocation to the body's actual convention.
|
package/dist/ir/call-entry.js
CHANGED
|
@@ -385,7 +385,7 @@ export const hostTemplateFrameOf = (operation, conversions, deriver, classes) =>
|
|
|
385
385
|
// fresh object with no own property, which publishes nothing it could
|
|
386
386
|
// hand to dynamic code. Without this frame `Object.create(null)` was an
|
|
387
387
|
// unknown call whose result published every carrier its value type
|
|
388
|
-
// reaches --
|
|
388
|
+
// reaches -- an HTTP framework's `Record<string, HandlerSet<T>>` made the router's
|
|
389
389
|
// handler tuples fully reflected.
|
|
390
390
|
if (template === 'object-create')
|
|
391
391
|
return operation.arguments.length === 1 && operation.arguments[0]?.representation.kind === 'null';
|