@geastack/compiler 1.0.32 → 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 +35 -28
- 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 +22 -6
- package/dist/ir/model.d.ts +41 -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.d.ts +4 -3
- package/dist/representation/unassigned-binding-cells.js +19 -2
- 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 +132 -21
- 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 +2407 -684
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';
|
|
@@ -36,6 +36,10 @@ export interface NativeCallableFlow {
|
|
|
36
36
|
readonly nativeFieldOperationStorageValues?: ReadonlyMap<IrOperation, ReadonlyMap<string, readonly NativeFieldStorageDomain[]>>;
|
|
37
37
|
/** Installed physical descriptors; independent of mutable Function implementation provenance. */
|
|
38
38
|
readonly nativeFieldViewStorageValues: ReadonlyMap<IrValueId, ReadonlyMap<string, readonly NativeFieldStorageDomain[]>>;
|
|
39
|
+
/** Receivers of a runtime-keyed store whose every allocation has a certified home for an undeclared key (`nativeFieldViewOpenWriteHomesOf`). */
|
|
40
|
+
readonly nativeFieldViewOpenWriteValues?: ReadonlySet<IrValueId>;
|
|
41
|
+
/** Stores of a named key a view forwards to a source that does not declare it (`nativeFieldViewForwardedWriteKey`). */
|
|
42
|
+
readonly nativeFieldViewForwardedWrites?: ReadonlySet<string>;
|
|
39
43
|
/** A static key no installed descriptor of the value's live carrier names (`NativeFieldViewDomains.absentRoutesOf`). */
|
|
40
44
|
readonly nativeFieldViewAbsentRoutesOf?: (receiver: IrValueId, key: string | null) => readonly NativeFieldStorageDomain[] | null;
|
|
41
45
|
/** Complete physical data-slot carriers of the same native allocation/alias census. */
|
|
@@ -18,7 +18,7 @@ import { nativeDictionaryTransportOf } from './native-dictionary-transport.js';
|
|
|
18
18
|
import { nativeFieldViewIdentityTransportOf, nativeFieldViewLiveLeavesOf, nativeFieldViewPlansOf } from '../conversion/native-field-view.js';
|
|
19
19
|
import { nativeRecordProductsOf } from '../conversion/native-record-products.js';
|
|
20
20
|
import { nativeFieldViewCarrierNeedsReceipt, nativeFieldViewBodyCitationsOf } from './native-field-view-facts.js';
|
|
21
|
-
import { nativeFieldViewDomainsOf } from './native-field-view-domains.js';
|
|
21
|
+
import { nativeFieldViewDomainsOf, nativeFieldViewOpenWriteHomesOf, nativeFieldViewForwardedWriteKey, nativeFieldViewPlansByTargetOf } from './native-field-view-domains.js';
|
|
22
22
|
import { NATIVE_SUM_MATERIALIZER } from '../conversion/native-sum.js';
|
|
23
23
|
import { recipeClosureOf } from '../conversion/recipe-closure.js';
|
|
24
24
|
import { nativeSequenceTransportOf } from './native-sequence-transport.js';
|
|
@@ -174,6 +174,25 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
174
174
|
cell.escapeReason ??= reason;
|
|
175
175
|
};
|
|
176
176
|
const absorbEscape = (cell, target) => {
|
|
177
|
+
// The absorbed sources are read for one thing: `callablePublications`,
|
|
178
|
+
// the publications of the FUNCTIONS a cell holds. A cell holding none needs
|
|
179
|
+
// only the flag. Copying every escaped target's whole source list into
|
|
180
|
+
// every aliasing cell regardless kept a set of publication sites per cell
|
|
181
|
+
// per program -- gigabytes on a large program, and its out-of-memory. A
|
|
182
|
+
// cell that later gains a function is `changed` (`addFunction`), so it is
|
|
183
|
+
// processed again and absorbs from the start (`escapeAbsorbed` is only
|
|
184
|
+
// recorded below, once it has).
|
|
185
|
+
if (cell.functions.size === 0) {
|
|
186
|
+
if (!cell.escaped) {
|
|
187
|
+
cell.escaped = true;
|
|
188
|
+
changed(cell);
|
|
189
|
+
for (const incoming of cell.incoming)
|
|
190
|
+
schedule(incoming);
|
|
191
|
+
}
|
|
192
|
+
if (trace && target.escapeReason !== undefined)
|
|
193
|
+
cell.escapeReason ??= target.escapeReason;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
177
196
|
const list = target.escapeSourceList;
|
|
178
197
|
const from = cell.escapeAbsorbed?.get(target) ?? 0;
|
|
179
198
|
if (from === list.length && cell.escaped) {
|
|
@@ -1722,6 +1741,32 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
1722
1741
|
changed(cell);
|
|
1723
1742
|
}
|
|
1724
1743
|
}
|
|
1744
|
+
else if (node && (to.kind === 'optional' || to.kind === 'borrowed-ref')) {
|
|
1745
|
+
// A live view installed for the payload of an optional (or borrowed)
|
|
1746
|
+
// carrier: `options = {}` parameters receive their argument as
|
|
1747
|
+
// `optional(view target)`, so the view node is a child of the
|
|
1748
|
+
// wrapper conversion rather than the conversion itself. The value
|
|
1749
|
+
// can still be that view, and a reader must see its routes; without
|
|
1750
|
+
// this, the source allocations reached the parameter as if they were
|
|
1751
|
+
// plain allocations of the target, and a key only the view answers
|
|
1752
|
+
// (three's `_setTextureOptions( options )` reading `options.mapping`
|
|
1753
|
+
// through WebGLCubeRenderTarget's `{}`) had no certified route.
|
|
1754
|
+
const payload = to.kind === 'optional' ? to.payload : to.referent;
|
|
1755
|
+
const sources = new Set([representationKey(from)]);
|
|
1756
|
+
if (from.kind === 'optional')
|
|
1757
|
+
sources.add(representationKey(from.payload));
|
|
1758
|
+
if (from.kind === 'borrowed-ref')
|
|
1759
|
+
sources.add(representationKey(from.referent));
|
|
1760
|
+
const cell = value(operation.result.id);
|
|
1761
|
+
for (const child of recipeClosureOf([node], conversions?.nodeById).values())
|
|
1762
|
+
if (nativeFieldViewIdentityTransportOf(child) &&
|
|
1763
|
+
sources.has(representationKey(child.source)) &&
|
|
1764
|
+
representationKey(child.target) === representationKey(payload) &&
|
|
1765
|
+
!cell.fieldViews.has(child.id)) {
|
|
1766
|
+
cell.fieldViews.add(child.id);
|
|
1767
|
+
changed(cell);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1725
1770
|
const document = node === null || node === undefined ? null : nativeDocumentEntryViewOf(node, conversions?.nodeById);
|
|
1726
1771
|
if (document !== null &&
|
|
1727
1772
|
node !== null &&
|
|
@@ -2466,6 +2511,56 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2466
2511
|
storeExpando(owner, null, { kind: 'dynamic', reason: 'declared-any-never-narrowed' });
|
|
2467
2512
|
}
|
|
2468
2513
|
}
|
|
2514
|
+
// A runtime-keyed store over a live view target (`for (const key in
|
|
2515
|
+
// parameters) data[key] = parameters[key]`): a key no descriptor names
|
|
2516
|
+
// lands, in the value's own carrier, in the expando of the plain allocation
|
|
2517
|
+
// or of each original source behind a view (`nativeFieldViewOpenWriteOf`),
|
|
2518
|
+
// under each proven key or, with none proven, under any key. Decided from
|
|
2519
|
+
// the operation alone, so the publication and certification solves agree
|
|
2520
|
+
// on what a reader may meet.
|
|
2521
|
+
//
|
|
2522
|
+
// A NAMED key lands there too when a view forwards it to an original
|
|
2523
|
+
// source whose own layout does not declare it (`event.target = this` over
|
|
2524
|
+
// a `{ type: 'dispose' }` literal viewed as an event with `target`): the
|
|
2525
|
+
// descriptor's `sourceAbsent` route. Its readers already read that
|
|
2526
|
+
// source's expando, and now meet the carrier stored there.
|
|
2527
|
+
const openWritePlans = nativeFieldViewPlansByTargetOf(viewNodes);
|
|
2528
|
+
const nativeFieldViewOpenWriteValues = new Set();
|
|
2529
|
+
const nativeFieldViewForwardedWrites = new Set();
|
|
2530
|
+
let forwardDomains;
|
|
2531
|
+
const forwardedAbsentKeysOf = (receiver) => {
|
|
2532
|
+
forwardDomains ??= nativeFieldViewDomainsOf(viewNodes, deriver, (id) => bodyById.get(id)?.abi ?? null, classes);
|
|
2533
|
+
const keys = new Set();
|
|
2534
|
+
for (const [key, routes] of forwardDomains(receiver) ?? [])
|
|
2535
|
+
if (routes.some((route) => route.sourceAbsent === true))
|
|
2536
|
+
keys.add(key);
|
|
2537
|
+
return keys;
|
|
2538
|
+
};
|
|
2539
|
+
if (openWritePlans.size > 0)
|
|
2540
|
+
for (const operation of operations) {
|
|
2541
|
+
if (operation.kind !== 'set')
|
|
2542
|
+
continue;
|
|
2543
|
+
const open = nativeFieldViewOpenWriteHomesOf(operation.receiver.representation, openWritePlans, deriver);
|
|
2544
|
+
if (open === null)
|
|
2545
|
+
continue;
|
|
2546
|
+
const constant = keyOf(operation.key);
|
|
2547
|
+
const forwarded = forwardedAbsentKeysOf(operation.receiver.representation);
|
|
2548
|
+
const keys = constant !== null ? [constant] : (operation.provenKeyTexts ?? [null]);
|
|
2549
|
+
const forwardedKeys = keys.length === 1 && keys[0] === null ? [...forwarded] : keys.filter((key) => key !== null && forwarded.has(key));
|
|
2550
|
+
for (const key of forwardedKeys)
|
|
2551
|
+
nativeFieldViewForwardedWrites.add(nativeFieldViewForwardedWriteKey(operation.receiver.value, key));
|
|
2552
|
+
// A key the descriptors name, but no source behind them declares, is
|
|
2553
|
+
// all a constant key can add; a proven key set the descriptors name in
|
|
2554
|
+
// full stores nothing else.
|
|
2555
|
+
const extending = constant === null && (operation.provenKeyTexts === undefined || operation.provenKeyTexts.some((key) => !open.named.has(key)));
|
|
2556
|
+
if (extending)
|
|
2557
|
+
nativeFieldViewOpenWriteValues.add(operation.receiver.value);
|
|
2558
|
+
else if (forwardedKeys.length === 0)
|
|
2559
|
+
continue;
|
|
2560
|
+
for (const home of open.homes)
|
|
2561
|
+
for (const key of extending ? keys : forwardedKeys)
|
|
2562
|
+
storeExpando(home, key, operation.value.representation);
|
|
2563
|
+
}
|
|
2469
2564
|
const expandoStoredOf = (shapeId, key) => {
|
|
2470
2565
|
const byKey = expandoStored.get(shapeId);
|
|
2471
2566
|
if (byKey === undefined)
|
|
@@ -2525,6 +2620,31 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2525
2620
|
}
|
|
2526
2621
|
domains.set(key, entries);
|
|
2527
2622
|
}
|
|
2623
|
+
// A receiver that may hold a live view also holds, in this cell, the
|
|
2624
|
+
// allocations behind each view -- of another layout, which the plain
|
|
2625
|
+
// receiver's own C++ carrier can never be. When one of those leaves this
|
|
2626
|
+
// read unanswered (its source may carry the key in an expando), the
|
|
2627
|
+
// receiver's own allocations still answer with their slots, and the view
|
|
2628
|
+
// answers through its installed routes below. Without this, three's
|
|
2629
|
+
// `_setTextureOptions( options )` -- its own `{}` default, caller literals
|
|
2630
|
+
// and an `Object.assign` result seen through a view -- read
|
|
2631
|
+
// `options.mapping` with a receipt holding only the view's answers, and a
|
|
2632
|
+
// plain allocation's slot was refused at run time.
|
|
2633
|
+
if (operation.kind === 'get' && !domains.has(key) && receiver.fieldViews.size > 0) {
|
|
2634
|
+
const own = new Set(nativeReferences(operation.receiver.representation).heaps);
|
|
2635
|
+
const plain = heaps.filter((heap) => own.has(heap.template ?? heap));
|
|
2636
|
+
if (plain.length > 0 && plain.every((heap) => heap.fields.has(key) || originalDescriptorAbsent(operation, key, heap))) {
|
|
2637
|
+
const entries = new Map();
|
|
2638
|
+
for (const heap of plain) {
|
|
2639
|
+
const slot = heap.fields.get(key);
|
|
2640
|
+
const entry = slot === undefined
|
|
2641
|
+
? { read: { kind: 'undefined' }, write: null, originalAbsent: true }
|
|
2642
|
+
: { read: slot.representation, write: slot.representation };
|
|
2643
|
+
entries.set(`${representationKey(entry.read)}:${entry.originalAbsent === true}`, entry);
|
|
2644
|
+
}
|
|
2645
|
+
domains.set(key, [...entries.values()]);
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2528
2648
|
if (receiver.fieldViews.size > 0) {
|
|
2529
2649
|
const ids = [...receiver.fieldViews].sort();
|
|
2530
2650
|
const identity = JSON.stringify(ids);
|
|
@@ -2636,6 +2756,8 @@ const computeNativeCallableFlow = (bodies, placements, classes, conversions, tra
|
|
|
2636
2756
|
nativeDescriptorSnapshotOpenValues,
|
|
2637
2757
|
nativeFieldOperationStorageValues,
|
|
2638
2758
|
nativeFieldViewStorageValues,
|
|
2759
|
+
nativeFieldViewOpenWriteValues,
|
|
2760
|
+
nativeFieldViewForwardedWrites,
|
|
2639
2761
|
nativeFieldViewAbsentRoutesOf: (receiver, key) => {
|
|
2640
2762
|
const carrier = valueCarriers.get(receiver);
|
|
2641
2763
|
return carrier === undefined ? null : descriptorDomainsOf.absentRoutesOf(carrier, key);
|