@geastack/compiler 1.0.49 → 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.js +8 -2
- 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.js +17 -4
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { representationKey } from '../../representation/model.js';
|
|
2
2
|
import { classMethodOverrideOf } from '../../projection/fields.js';
|
|
3
|
+
import { classDynamicMethodShadowOf } from '../../projection/dispatch.js';
|
|
3
4
|
import { createCppEmitBlockedError, defineValue, operandText } from './emit-context.js';
|
|
4
5
|
import { cppBodyName, cppTypeOf } from './types.js';
|
|
5
6
|
/**
|
|
@@ -111,7 +112,9 @@ const nullableClassReceiver = 'gea_to_number_receiver';
|
|
|
111
112
|
export const classToPrimitiveOf = (ctx, carrier) => {
|
|
112
113
|
const layouts = ctx.layouts;
|
|
113
114
|
const direct = layouts.classDirectMethodFor?.(carrier.declaration, 'valueOf') ?? null;
|
|
114
|
-
if (direct === null ||
|
|
115
|
+
if (direct === null ||
|
|
116
|
+
classMethodOverrideOf(ctx.classes, carrier.declaration, 'valueOf') !== null ||
|
|
117
|
+
classDynamicMethodShadowOf(ctx.classes, carrier.declaration, 'valueOf'))
|
|
115
118
|
return null;
|
|
116
119
|
const seen = new Set();
|
|
117
120
|
for (let current = carrier.declaration; current !== null && !seen.has(current);) {
|
|
@@ -294,7 +294,7 @@ const armRuntimeFieldText = (ctx, arm, armExprText, key, operation) => {
|
|
|
294
294
|
// A generic method's copies share its key; each allocation's arm
|
|
295
295
|
// materializes the copy this read publishes, as a lone class-ref
|
|
296
296
|
// read does (`computedOverriddenMethodValueText`).
|
|
297
|
-
return overriddenMethodValueText(ctx, arm, armExprText, key, (method) => classMethodValueText(ctx, operation, key, publishedMethodCopyOf(ctx, method, key, published), published, armExprText, arm)).text;
|
|
297
|
+
return overriddenMethodValueText(ctx, arm, armExprText, key, (method) => classMethodValueText(ctx, operation, key, publishedMethodCopyOf(ctx, method, key, published), published, armExprText, arm), null, published).text;
|
|
298
298
|
}
|
|
299
299
|
if (site.kind === 'accessor') {
|
|
300
300
|
if (site.accessor.getter === null)
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { NativeDebugSource } from './native-debug-source.js';
|
|
2
2
|
import type { ProgramConversionRecipe } from '../../ir/program-conversions.js';
|
|
3
|
+
import type { AllocationCell } from '../../ir/program-facts.js';
|
|
3
4
|
import { type IntegrityRestrictions } from '../../ir/integrity-restrictions.js';
|
|
4
5
|
import type { NativeSelectionHelper } from './native-selection-helpers.js';
|
|
5
6
|
import type { StableBorrowEntry } from './borrowed-call-entry.js';
|
|
6
7
|
import { type ConstructionOnlyFields } from '../../ir/construction-only-fields.js';
|
|
8
|
+
import { type WriteEffects } from '../../ir/write-effects.js';
|
|
9
|
+
import type { CodeFreeFieldRead } from '../../ir/field-read-reuse.js';
|
|
7
10
|
import type { FunctionId, DeclarationId, IrValueId } from '../../identity/ids.js';
|
|
8
11
|
import type { CallableFlowCandidate } from '../../ir/callable-flow-candidates.js';
|
|
9
12
|
import type { BindingPlacement } from '../../projection/bindings.js';
|
|
@@ -20,5 +23,5 @@ import type { IntegerStorageFacts } from '../../ir/integers.js';
|
|
|
20
23
|
import { type InstantiationFacts } from '../../ir/instantiation.js';
|
|
21
24
|
import { type CallableIdentityDemand } from '../../ir/callable-identity-demand.js';
|
|
22
25
|
import type { HostMethodAlias } from './host/host-method-aliases.js';
|
|
23
|
-
export declare const emitBody: (body: IrBody, placements: ReadonlyMap<DeclarationId, BindingPlacement>, classes: ReadonlyMap<DeclarationId, ClassLayout>, hosts: HostSpellings, deriver: RepresentationDeriver, wellKnownSymbols: ReadonlyMap<DeclarationId, string> | undefined, captures: CaptureIndex | undefined, symbolKeys: Map<string, string>, templateObjects: Map<string, TemplateObjectDefinition>, directCallableBindings?: ReadonlyMap<DeclarationId, FunctionId>, virtualDispatch?: ReadonlyMap<string, CallableAbi>, narrowedStorage?: IntegerStorageFacts, narrowedFormals?: ReadonlySet<number>, repeatedConstructors?: ReadonlyMap<DeclarationId, DeclarationId>, dyingArguments?: ReadonlySet<IrValueId>, instantiation?: InstantiationFacts, abiOfCallable?: (callable: FunctionId) => IrBody["abi"], functionFacts?: ReadonlyMap<FunctionId, CallableFactsSpelling>, constructEntries?: ReadonlySet<FunctionId>, hostMethodAliases?: ReadonlyMap<DeclarationId, HostMethodAlias>, callableMemberCandidates?: ReadonlyMap<string, FunctionId>, callableFlowCandidates?: ReadonlyMap<IrValueId, CallableFlowCandidate>, borrowableMemberBodies?: ReadonlySet<FunctionId>, stableBorrowEntries?: ReadonlyMap<string, StableBorrowEntry>, printerDrift?: PrinterDrift[], conversions?: ConversionCensus | null, nativeSelections?: ReadonlyMap<string, NativeSelectionHelper> | undefined, callableIdentityDemand?: CallableIdentityDemand, nativeIntegrityRestricted?: IntegrityRestrictions, fixedFieldStateConstant?: boolean, definitionCells?: ReadonlySet<DeclarationId>, constructionOnlyFields?: ConstructionOnlyFields, keyOrderUnobserved?: ReadonlySet<string>, debugSource?: NativeDebugSource, borrowedFormals?: ReadonlySet<number>, taskResults?: ReadonlySet<IrValueId>, conversionIsCertified?: (id: string) => boolean, programConversionRecipes?: readonly ProgramConversionRecipe[], physicalIndexProtocols?: ReadonlyMap<DeclarationId, boolean
|
|
26
|
+
export declare const emitBody: (body: IrBody, placements: ReadonlyMap<DeclarationId, BindingPlacement>, classes: ReadonlyMap<DeclarationId, ClassLayout>, hosts: HostSpellings, deriver: RepresentationDeriver, wellKnownSymbols: ReadonlyMap<DeclarationId, string> | undefined, captures: CaptureIndex | undefined, symbolKeys: Map<string, string>, templateObjects: Map<string, TemplateObjectDefinition>, directCallableBindings?: ReadonlyMap<DeclarationId, FunctionId>, virtualDispatch?: ReadonlyMap<string, CallableAbi>, narrowedStorage?: IntegerStorageFacts, narrowedFormals?: ReadonlySet<number>, repeatedConstructors?: ReadonlyMap<DeclarationId, DeclarationId>, dyingArguments?: ReadonlySet<IrValueId>, instantiation?: InstantiationFacts, abiOfCallable?: (callable: FunctionId) => IrBody["abi"], functionFacts?: ReadonlyMap<FunctionId, CallableFactsSpelling>, constructEntries?: ReadonlySet<FunctionId>, hostMethodAliases?: ReadonlyMap<DeclarationId, HostMethodAlias>, callableMemberCandidates?: ReadonlyMap<string, FunctionId>, callableFlowCandidates?: ReadonlyMap<IrValueId, CallableFlowCandidate>, borrowableMemberBodies?: ReadonlySet<FunctionId>, stableBorrowEntries?: ReadonlyMap<string, StableBorrowEntry>, printerDrift?: PrinterDrift[], conversions?: ConversionCensus | null, nativeSelections?: ReadonlyMap<string, NativeSelectionHelper> | undefined, callableIdentityDemand?: CallableIdentityDemand, nativeIntegrityRestricted?: IntegrityRestrictions, fixedFieldStateConstant?: boolean, definitionCells?: ReadonlySet<DeclarationId>, constructionOnlyFields?: ConstructionOnlyFields, keyOrderUnobserved?: ReadonlySet<string>, debugSource?: NativeDebugSource, borrowedFormals?: ReadonlySet<number>, taskResults?: ReadonlySet<IrValueId>, conversionIsCertified?: (id: string) => boolean, programConversionRecipes?: readonly ProgramConversionRecipe[], physicalIndexProtocols?: ReadonlyMap<DeclarationId, boolean>, writeEffects?: WriteEffects, returnsOwnReceiver?: boolean, allocationCells?: ReadonlyMap<DeclarationId, AllocationCell>, codeFreeFieldRead?: CodeFreeFieldRead) => readonly CppArtifact[];
|
|
24
27
|
export { cppConstructedThunkName, cppConstructThunkName, cppFormalName, cppReceiverName, cppThunkName, isCppEmitBlockedError } from './emit-context.js';
|
package/dist/targets/cpp/emit.js
CHANGED
|
@@ -13,15 +13,20 @@ import { owningConversionInputText } from './owning-conversion-input.js';
|
|
|
13
13
|
import { boxedValueText } from './emit-dynamic-properties.js';
|
|
14
14
|
import { stableCellReadsOf } from '../../ir/stable-cell-reads.js';
|
|
15
15
|
import { noConstructionOnlyFields, stableFieldReadsAndCellsOf, stableReceiversOf } from '../../ir/construction-only-fields.js';
|
|
16
|
+
import { everyStoreEffects } from '../../ir/write-effects.js';
|
|
17
|
+
import { codeFreeGetOf } from '../../ir/plain-field-read.js';
|
|
18
|
+
import { borrowedWindowCellsOf } from '../../ir/borrowed-window-cells.js';
|
|
19
|
+
import { borrowedFieldReadsOf } from '../../ir/borrowed-field-reads.js';
|
|
16
20
|
import { DyingArgumentSet, dyingTransferUsesOf, receiverRenamesOf, ownedDyingMergeInputsOf, ownedDyingValuesOf, ownedFormalInputsOf, transfersFormalConversion } from '../../ir/transfer.js';
|
|
17
21
|
import { classLayoutsConstructedBy, constructedBaseOf } from '../../projection/classes.js';
|
|
18
22
|
import { recordFieldsOfShape } from '../../projection/fields.js';
|
|
19
23
|
import { allOperationsOf } from '../../ir/model.js';
|
|
20
24
|
import { operandsOfIrOperation, resultOfIrOperation } from '../../ir/queries.js';
|
|
25
|
+
import { deferredMethodValuesOf } from '../../ir/native-method-frames.js';
|
|
21
26
|
import { namesMoreThanOnce } from './evaluated-once.js';
|
|
22
27
|
import { carriesNativeUndefined, isOpenDocument, representationKey } from '../../representation/model.js';
|
|
23
28
|
import { classFamilyMayAllocate } from '../../projection/dispatch.js';
|
|
24
|
-
import { copiedCaptureName, cppFormalName, cppReceiverName, createCppEmitBlockedError, createEmitContext, defineValue, defineValueAlias, nameOfValue, directCalleesOf, directCallableValuesOf, integerWideningsOf, emptyCaptureIndex, isFloatStorageValue, isIntegerStorageValue, isCppEmitBlockedError, operandText, storageTypeOf, cppThunkEntryText, sealFactFieldsForRender, suspendsInPlace, cppDensePointerName, declaredIntegerTypeOf } from './emit-context.js';
|
|
29
|
+
import { copiedCaptureName, cppFormalName, cppReceiverName, createCppEmitBlockedError, createEmitContext, defineFieldPointer, defineValue, defineValueAlias, nameOfValue, directCalleesOf, directCallableValuesOf, integerWideningsOf, emptyCaptureIndex, isFloatStorageValue, isIntegerStorageValue, isCppEmitBlockedError, operandText, storageTypeOf, cppThunkEntryText, sealFactFieldsForRender, suspendsInPlace, cppDensePointerName, declaredIntegerTypeOf } from './emit-context.js';
|
|
25
30
|
import { hostMemberReadsOf } from './host/emit-host-properties.js';
|
|
26
31
|
import { functionSourceReadsOf } from './function-source-reads.js';
|
|
27
32
|
import { prototypeMethodReadsOf } from './prototype/prototype-method-reads.js';
|
|
@@ -36,10 +41,11 @@ import { collectDirectBindingSinks, classObjectReadsOf, hostClassReadsOf, collec
|
|
|
36
41
|
import { alignedValueText, unsharedArrayRebuildText, unsharedDictionaryRebuildText, documentViewable, dynamicCarrierBoxText, emitMergeLiveArmRebuild, namedConversionText, movedValueText } from './emit-narrowing.js';
|
|
37
42
|
import { operationConversionText } from './emit-certified-conversion.js';
|
|
38
43
|
import { collectCharCodeBuffers } from './char-code-buffers.js';
|
|
39
|
-
import { admitDenseWindows, collectCapacityHints, emitAllocateArrayObject, emitDenseSetup, emitFillLoop, isConstantExpression } from './emit-arrays.js';
|
|
44
|
+
import { admitDenseWindows, collectCapacityHints, collectOutOfLineLiteralPushes, emitAllocateArrayObject, emitDenseSetup, emitFillLoop, isConstantExpression } from './emit-arrays.js';
|
|
40
45
|
import { noInstantiationFacts } from '../../ir/instantiation.js';
|
|
41
46
|
import { observesEveryCallableIdentity } from '../../ir/callable-identity-demand.js';
|
|
42
47
|
import { stringConstantsOf } from '../../ir/dead-values.js';
|
|
48
|
+
import { arrayStorageMutationOf } from '../../ir/hoist.js';
|
|
43
49
|
import { bodyValueOriginsOf, irBodyCensusOf } from '../../ir/facts.js';
|
|
44
50
|
import { emitGetIterator, emitIteratorClose, emitIteratorDone, emitIteratorNext, emitIteratorNextMethodCapture, renderIteratorCloseRegion } from './emit-iterator.js';
|
|
45
51
|
import { absenceComparisonText, booleanTestText, definedTestText, presenceTestText } from './emit-presence.js';
|
|
@@ -958,6 +964,20 @@ const emitCompute = (ctx, lines, operation) => {
|
|
|
958
964
|
lines.push(`${defineValue(ctx, operation.result)} = ${dynamicComparison};`);
|
|
959
965
|
return;
|
|
960
966
|
}
|
|
967
|
+
// A host data struct crosses by value (`derive.ts`: data-only bound bodies are
|
|
968
|
+
// `owned`), so every assignment copies it and no copy keeps the object's
|
|
969
|
+
// identity. `===` between two of them has no answer to spell; comparing the
|
|
970
|
+
// fields would call two distinct objects equal.
|
|
971
|
+
const ownedHostStruct = (carrier) => {
|
|
972
|
+
const value = carrier.kind === 'optional' ? carrier.payload : carrier;
|
|
973
|
+
return value.kind === 'native-record-ref' && value.ownership === 'owned' && value.native !== null;
|
|
974
|
+
};
|
|
975
|
+
if (identitySpelling &&
|
|
976
|
+
representationKey(firstCarrier) !== representationKey(secondCarrier) &&
|
|
977
|
+
(ownedHostStruct(firstCarrier) || ownedHostStruct(secondCarrier))) {
|
|
978
|
+
throw createCppEmitBlockedError(`conversion:${representationKey(first.representation)}->${representationKey(second.representation)}`, `binary "${operation.operator}" compares a host struct held by value, which carries no object identity; ` +
|
|
979
|
+
'track which object is held another way (a flag or an index)');
|
|
980
|
+
}
|
|
961
981
|
if (representationKey(first.representation) !== representationKey(second.representation)) {
|
|
962
982
|
throw createCppEmitBlockedError(`conversion:${representationKey(first.representation)}->${representationKey(second.representation)}`, `binary "${operation.operator}" mixes a "${first.representation.kind}" and a "${second.representation.kind}" carrier, ` +
|
|
963
983
|
'and the census names no coercion that brings them together');
|
|
@@ -2537,7 +2557,7 @@ export const emitBody = (body, placements, classes, hosts, deriver, wellKnownSym
|
|
|
2537
2557
|
symbolKeys, templateObjects, directCallableBindings = new Map(),
|
|
2538
2558
|
// `virtualDispatch` is every `class key` with a dispatch member (`virtual-methods.ts`);
|
|
2539
2559
|
// `narrowedStorage`/`narrowedFormals` are what the integer census settled here.
|
|
2540
|
-
virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new Set(), magnitudes: new Map() }, narrowedFormals = new Set(), repeatedConstructors = new Map(), dyingArguments = new Set(), instantiation = noInstantiationFacts, abiOfCallable = () => null, functionFacts = new Map(), constructEntries = new Set(), hostMethodAliases = new Map(), callableMemberCandidates = new Map(), callableFlowCandidates = new Map(), borrowableMemberBodies = new Set(), stableBorrowEntries = new Map(), printerDrift = [], conversions = null, nativeSelections = undefined, callableIdentityDemand = observesEveryCallableIdentity, nativeIntegrityRestricted = restrictsEveryCarrier, fixedFieldStateConstant = false, definitionCells = new Set(), constructionOnlyFields = noConstructionOnlyFields, keyOrderUnobserved = new Set(), debugSource, borrowedFormals = new Set(), taskResults = new Set(), conversionIsCertified, programConversionRecipes, physicalIndexProtocols) => {
|
|
2560
|
+
virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new Set(), magnitudes: new Map() }, narrowedFormals = new Set(), repeatedConstructors = new Map(), dyingArguments = new Set(), instantiation = noInstantiationFacts, abiOfCallable = () => null, functionFacts = new Map(), constructEntries = new Set(), hostMethodAliases = new Map(), callableMemberCandidates = new Map(), callableFlowCandidates = new Map(), borrowableMemberBodies = new Set(), stableBorrowEntries = new Map(), printerDrift = [], conversions = null, nativeSelections = undefined, callableIdentityDemand = observesEveryCallableIdentity, nativeIntegrityRestricted = restrictsEveryCarrier, fixedFieldStateConstant = false, definitionCells = new Set(), constructionOnlyFields = noConstructionOnlyFields, keyOrderUnobserved = new Set(), debugSource, borrowedFormals = new Set(), taskResults = new Set(), conversionIsCertified, programConversionRecipes, physicalIndexProtocols, writeEffects = everyStoreEffects, returnsOwnReceiver = false, allocationCells = new Map(), codeFreeFieldRead = () => false) => {
|
|
2541
2561
|
// Every fact this body settles before a single line renders, computed here
|
|
2542
2562
|
// -- from `body` and the plain, already-available inputs above -- and
|
|
2543
2563
|
// handed to `createEmitContext` as one argument instead of mutated onto the
|
|
@@ -2596,9 +2616,32 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
2596
2616
|
// the read had already rendered.
|
|
2597
2617
|
const receiverValues = new Set();
|
|
2598
2618
|
const bindingWriteCounts = new Map();
|
|
2619
|
+
// Reads of a cell holding its one plain allocation (`ir/program-facts.ts`'s
|
|
2620
|
+
// `allocationCells`): stable receivers, never a live view.
|
|
2621
|
+
const plainAllocationValues = new Set();
|
|
2622
|
+
const allocationFieldKeys = new Map();
|
|
2599
2623
|
let callsSuper = false;
|
|
2624
|
+
// A field read whose one use is the receiver of the next member read: its
|
|
2625
|
+
// handle is consumed in the same expression, so it can be borrowed rather
|
|
2626
|
+
// than retained and released (`nativeFieldViewBorrowedReadText`).
|
|
2627
|
+
const fieldReadUses = new Map();
|
|
2628
|
+
const memberReceivers = new Set();
|
|
2629
|
+
const fieldReads = new Set();
|
|
2600
2630
|
for (const block of body.blocks.values()) {
|
|
2601
2631
|
for (const operation of allOperationsOf(block)) {
|
|
2632
|
+
const cell = operation.kind === 'binding-read' ? allocationCells.get(operation.declaration) : undefined;
|
|
2633
|
+
if (cell !== undefined && operation.kind === 'binding-read') {
|
|
2634
|
+
plainAllocationValues.add(operation.result.id);
|
|
2635
|
+
if (representationKey(operation.result.representation) === cell.representation)
|
|
2636
|
+
allocationFieldKeys.set(operation.result.id, cell.keys);
|
|
2637
|
+
}
|
|
2638
|
+
for (const operand of operandsOfIrOperation(operation))
|
|
2639
|
+
fieldReadUses.set(operand.value, (fieldReadUses.get(operand.value) ?? 0) + 1);
|
|
2640
|
+
if (operation.kind === 'get') {
|
|
2641
|
+
fieldReads.add(operation.result.id);
|
|
2642
|
+
if (operation.key.value !== operation.receiver.value)
|
|
2643
|
+
memberReceivers.add(operation.receiver.value);
|
|
2644
|
+
}
|
|
2602
2645
|
// Censused in the same pass, for `EmitBodyFacts.receiverValues`: a
|
|
2603
2646
|
// member access has to know whether its receiver came from `super`, and
|
|
2604
2647
|
// the operation that defines it is the only place that says so.
|
|
@@ -2640,7 +2683,10 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
2640
2683
|
const directCalleeFacts = directCalleesOf(body, abiOfCallable);
|
|
2641
2684
|
// Only a counted handle: a cell of any other carrier is read by renderers
|
|
2642
2685
|
// (string appends, array and JSON fills) that name its storage directly.
|
|
2643
|
-
const { reads: stableFieldReads, cells: stableFieldCells } = stableFieldReadsAndCellsOf(body,
|
|
2686
|
+
const { reads: stableFieldReads, cells: stableFieldCells } = stableFieldReadsAndCellsOf(body, new Set([
|
|
2687
|
+
...stableReceiversOf(body, receiverValues, borrowedFormals, bindingWriteCounts, (declaration) => captures.isBoxed(declaration)),
|
|
2688
|
+
...plainAllocationValues
|
|
2689
|
+
]), constructionOnlyFields, nativeIntegrityRestricted, bodyDyingArguments, (declaration) => {
|
|
2644
2690
|
const placement = placements.get(declaration);
|
|
2645
2691
|
if (placement?.storage.kind !== 'local' || placement.storage.owner !== body.sourceOwner)
|
|
2646
2692
|
return false;
|
|
@@ -2648,11 +2694,16 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
2648
2694
|
return false;
|
|
2649
2695
|
const held = placement.representation;
|
|
2650
2696
|
return held?.kind === 'class-ref' || (held?.kind === 'optional' && held.payload.kind === 'class-ref');
|
|
2651
|
-
});
|
|
2697
|
+
}, writeEffects);
|
|
2652
2698
|
const bodyFacts = {
|
|
2653
2699
|
generatorBody: body.generator === true,
|
|
2654
2700
|
asyncCoroutineBody: isAsyncCoroutineBody(body),
|
|
2655
2701
|
returnsUnderFinallyGuard: body.tryRegions.some((region) => region.finallyEntry !== null),
|
|
2702
|
+
returnsOwnReceiver,
|
|
2703
|
+
plainAllocationValues,
|
|
2704
|
+
allocationFieldKeys,
|
|
2705
|
+
deferredMethodValues: deferredMethodValuesOf(body),
|
|
2706
|
+
borrowedFieldReads: new Set([...fieldReads].filter((value) => memberReceivers.has(value) && fieldReadUses.get(value) === 1)),
|
|
2656
2707
|
receiverValues,
|
|
2657
2708
|
bindingWriteCounts,
|
|
2658
2709
|
stableCellReads: stableCellReadsOf(body, (declaration) => placements.get(declaration)?.storage.kind === 'local'),
|
|
@@ -2768,6 +2819,24 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
2768
2819
|
capturedQueryCells.add(slot.declaration);
|
|
2769
2820
|
}
|
|
2770
2821
|
let entryPrologue = [];
|
|
2822
|
+
// A view write runs the view's routine and a reactive cell notifies its
|
|
2823
|
+
// subscribers; only a bare member store is code-free.
|
|
2824
|
+
const codeFreeStore = (operation) => {
|
|
2825
|
+
const key = keyTexts.get(operation.key.value);
|
|
2826
|
+
if (key === undefined || operation.nativeFieldViewWrite !== undefined || operation.nativeDocumentEntry !== undefined)
|
|
2827
|
+
return false;
|
|
2828
|
+
if (operation.typedComputedWrite !== undefined)
|
|
2829
|
+
return false;
|
|
2830
|
+
const receiver = operation.receiver.representation.kind === 'optional' ? operation.receiver.representation.payload : operation.receiver.representation;
|
|
2831
|
+
if (!writeEffects.plainField(receiver, key))
|
|
2832
|
+
return false;
|
|
2833
|
+
const declaring = receiver.kind === 'class-ref' ? (classMemberOf(classes, receiver.declaration, key)?.owner ?? null) : null;
|
|
2834
|
+
const struct = declaring !== null ? cppClassName(declaring) : structNameOfReceiver(receiver);
|
|
2835
|
+
if (struct === null)
|
|
2836
|
+
return false;
|
|
2837
|
+
return ctx.hosts.reactive.celled.get(struct)?.has(key) !== true && ctx.hosts.reactive.revisions.get(struct)?.has(key) !== true;
|
|
2838
|
+
};
|
|
2839
|
+
const codeFreeGet = codeFreeGetOf(body, writeEffects.plainField, codeFreeFieldRead);
|
|
2771
2840
|
// Every per-body census, in the one order they depend on each other in --
|
|
2772
2841
|
// `ir/facts.ts` owns that order now, and this backend supplies only the
|
|
2773
2842
|
// questions about its own carriers plus the two storage steps that have to
|
|
@@ -2775,6 +2844,9 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
2775
2844
|
const census = irBodyCensusOf(body, {
|
|
2776
2845
|
integerStorage: narrowedStorage,
|
|
2777
2846
|
copiedCapture: (declaration) => copiedCaptureName(ctx, declaration) !== null,
|
|
2847
|
+
settledCapture: (declaration) => copiedCaptureName(ctx, declaration, true) !== null,
|
|
2848
|
+
codeFreeStore,
|
|
2849
|
+
codeFreeGet,
|
|
2778
2850
|
// A read of a plain field defers like an Array's `length` does -- see
|
|
2779
2851
|
// `deferrableValuesOf`. Not a read of a reactive CELL: `gea_this->count`
|
|
2780
2852
|
// spells the `Signal<double>` itself, and only the temporary it used to be
|
|
@@ -3057,6 +3129,10 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
3057
3129
|
prepass.loopInvariantValues.add(value);
|
|
3058
3130
|
for (const [value, layout] of census.sharedStringLayouts)
|
|
3059
3131
|
prepass.sharedStringLayouts.set(value, layout);
|
|
3132
|
+
for (const [value, window] of census.denseReadWindows)
|
|
3133
|
+
prepass.denseReadWindows.set(value, window);
|
|
3134
|
+
for (const [operation, window] of census.denseWriteWindows)
|
|
3135
|
+
prepass.denseWriteWindows.set(operation, window);
|
|
3060
3136
|
for (const value of census.hoistedResults)
|
|
3061
3137
|
prepass.hoistedResults.add(value);
|
|
3062
3138
|
for (const [declaration, forwarded] of census.forwardedBindings)
|
|
@@ -3075,10 +3151,61 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
3075
3151
|
// After the hoists: a fill loop's bound is as often a relocated invariant
|
|
3076
3152
|
// (`n * n`, re-read from its cells in the loop's own test) as a plain cell.
|
|
3077
3153
|
collectCapacityHints(ctx, prepass, body, hoists);
|
|
3154
|
+
collectOutOfLineLiteralPushes(prepass, body);
|
|
3078
3155
|
collectDirectBindingSinks(prepass, body, hoists.relocated);
|
|
3079
3156
|
// After the hoists, because a window's own bound is often the loop-invariant
|
|
3080
3157
|
// read they relocate, and a relocated value is one this may name.
|
|
3081
3158
|
admitDenseWindows(ctx, prepass, body);
|
|
3159
|
+
// After the windows: a cell may point at the window cell it is written from
|
|
3160
|
+
// only when that read renders as the cell itself -- an array of counted or
|
|
3161
|
+
// struct elements read as its own carrier (`denseElementText`).
|
|
3162
|
+
const windowReads = new Set();
|
|
3163
|
+
for (const operation of ctx.denseAccesses.keys()) {
|
|
3164
|
+
if (operation.kind !== 'get' || operation.receiver.representation.kind !== 'array-object')
|
|
3165
|
+
continue;
|
|
3166
|
+
const element = operation.receiver.representation.element;
|
|
3167
|
+
if (element.kind !== 'scalar' && representationKey(element) === representationKey(operation.result.representation))
|
|
3168
|
+
windowReads.add(operation.result.id);
|
|
3169
|
+
}
|
|
3170
|
+
if (windowReads.size > 0) {
|
|
3171
|
+
for (const declaration of borrowedWindowCellsOf(body, windowReads, arrayStorageMutationOf(body, codeFreeStore, codeFreeGet), (declaration) => {
|
|
3172
|
+
const placement = placements.get(declaration);
|
|
3173
|
+
if (placement?.storage.kind !== 'local' || placement.storage.owner !== body.sourceOwner)
|
|
3174
|
+
return false;
|
|
3175
|
+
if (captures.isBoxed(declaration) || captures.isCaptured(declaration))
|
|
3176
|
+
return false;
|
|
3177
|
+
return !ctx.forwardedBindings.has(declaration) && !ctx.typeQueryBindings.has(declaration);
|
|
3178
|
+
}))
|
|
3179
|
+
prepass.borrowedWindowCells.add(declaration);
|
|
3180
|
+
}
|
|
3181
|
+
// After the windows and the forwarded cells: a field read through a cell
|
|
3182
|
+
// the body owns may name the field across the statements that reuse it, and
|
|
3183
|
+
// so may the merges of such reads (`ir/borrowed-field-reads.ts`). Only a
|
|
3184
|
+
// counted handle is worth it, and only a receiver the read renders straight
|
|
3185
|
+
// off: an absent receiver is a presence test, a snapshot read a copy's.
|
|
3186
|
+
for (const value of borrowedFieldReadsOf(body, codeFreeFieldRead, (declaration) => {
|
|
3187
|
+
const placement = placements.get(declaration);
|
|
3188
|
+
if (placement?.storage.kind !== 'local' || placement.storage.owner !== body.sourceOwner)
|
|
3189
|
+
return false;
|
|
3190
|
+
if (captures.isBoxed(declaration) || captures.isCaptured(declaration))
|
|
3191
|
+
return false;
|
|
3192
|
+
return !ctx.stableFieldCells.has(declaration) && !ctx.forwardedBindings.has(declaration) && !ctx.typeQueryBindings.has(declaration);
|
|
3193
|
+
}, (operation) => {
|
|
3194
|
+
const receiver = operation.receiver.representation.kind;
|
|
3195
|
+
const result = operation.result.representation;
|
|
3196
|
+
return ((receiver === 'class-ref' || receiver === 'record' || receiver === 'native-record-ref') &&
|
|
3197
|
+
(result.kind === 'class-ref' || result.kind === 'record' || result.kind === 'native-record-ref') &&
|
|
3198
|
+
result.ownership === 'shared-refcount' &&
|
|
3199
|
+
operation.spreadSnapshot !== true);
|
|
3200
|
+
},
|
|
3201
|
+
// A stable field read already names the member (`EmitContext.stableFieldReads`).
|
|
3202
|
+
(value) => ctx.deferrable.has(value) || ctx.stableFieldReads.has(value)))
|
|
3203
|
+
prepass.fieldPointerValues.add(value);
|
|
3204
|
+
for (const block of body.blocks.values())
|
|
3205
|
+
for (const operation of block.operations)
|
|
3206
|
+
if (operation.kind === 'phi' && prepass.fieldPointerValues.has(operation.result.id))
|
|
3207
|
+
for (const incoming of operation.incoming)
|
|
3208
|
+
prepass.fieldPointerMergeInputs.add(incoming.value.value);
|
|
3082
3209
|
const isSingleBlock = body.blockOrder.length === 1;
|
|
3083
3210
|
const orderLabels = isSingleBlock ? new Map() : blockLabelsOf(body.blockOrder);
|
|
3084
3211
|
const owner = sectionOwnerOf(body);
|
|
@@ -3086,7 +3213,15 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
3086
3213
|
// exist before any predecessor renders -- including a predecessor that comes
|
|
3087
3214
|
// earlier in the block order than the merge itself. Minting every merge's
|
|
3088
3215
|
// name up front is what makes that hold without depending on block order.
|
|
3089
|
-
|
|
3216
|
+
// A merge of field pointers is a pointer too; its edges assign addresses.
|
|
3217
|
+
const pointerMerges = new Set();
|
|
3218
|
+
const mergeWrites = mergeWritesOf(ctx, body, (result) => {
|
|
3219
|
+
if (!ctx.fieldPointerValues.has(result.id))
|
|
3220
|
+
return defineValue(ctx, result);
|
|
3221
|
+
const name = defineFieldPointer(ctx, result);
|
|
3222
|
+
pointerMerges.add(name);
|
|
3223
|
+
return name;
|
|
3224
|
+
});
|
|
3090
3225
|
// After the merges, because a block that writes one is not empty.
|
|
3091
3226
|
const flow = threadedFlowOf(ctx, body, orderLabels, hoists, mergeWrites);
|
|
3092
3227
|
const labels = flow.labels;
|
|
@@ -3221,6 +3356,13 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
|
|
|
3221
3356
|
// The writes belong after everything this block computed and before it
|
|
3222
3357
|
// transfers control: that is exactly where the incoming value is live.
|
|
3223
3358
|
for (const write of mergeWrites.get(blockId) ?? []) {
|
|
3359
|
+
if (pointerMerges.has(write.name)) {
|
|
3360
|
+
const pointer = ctx.fieldPointerTexts.get(write.value.value);
|
|
3361
|
+
if (pointer === undefined)
|
|
3362
|
+
throw new Error(`field pointer merge ${write.name} reads ${write.value.value}, which rendered no pointer`);
|
|
3363
|
+
lines.push(`${write.name} = ${pointer};`);
|
|
3364
|
+
continue;
|
|
3365
|
+
}
|
|
3224
3366
|
const raw = operandText(ctx, write.value);
|
|
3225
3367
|
const converted = alignedValueText(ctx, 'emit.ts:2111', write.value.representation, write.target, raw);
|
|
3226
3368
|
if (converted === null) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { classMemberOf } from '../../projection/fields.js';
|
|
2
2
|
import { operandsOfIrOperation } from '../../ir/queries.js';
|
|
3
|
+
import { representationKey } from '../../representation/model.js';
|
|
3
4
|
import { fieldDeclaringStructOf, structNameOfReceiver } from './class-layout.js';
|
|
4
5
|
const operationsByResult = (body) => {
|
|
5
6
|
const byResult = new Map();
|
|
@@ -406,7 +407,7 @@ export const reactiveRecordBindingsOfBodies = (bodies) => {
|
|
|
406
407
|
}
|
|
407
408
|
return false;
|
|
408
409
|
};
|
|
409
|
-
const noteRead = (operation, byResult) => {
|
|
410
|
+
const noteRead = (operation, byResult, forced) => {
|
|
410
411
|
if (operation.kind !== 'get')
|
|
411
412
|
return;
|
|
412
413
|
// Only RECORD receivers. A class field is celled by the plugin's own
|
|
@@ -430,22 +431,22 @@ export const reactiveRecordBindingsOfBodies = (bodies) => {
|
|
|
430
431
|
// Indexed receivers are re-read by a slot subscribed to the owning array
|
|
431
432
|
// revision, with or without an optional carrier. A row's record has its own
|
|
432
433
|
// member subscription. A field can require both channels.
|
|
433
|
-
const channel = indexedReceiver(operation.receiver.value, byResult) ? revision : element;
|
|
434
|
+
const channel = forced ?? (indexedReceiver(operation.receiver.value, byResult) ? revision : element);
|
|
434
435
|
const subscribed = channel.get(struct) ?? new Set();
|
|
435
436
|
subscribed.add(keyOperation.text);
|
|
436
437
|
channel.set(struct, subscribed);
|
|
437
438
|
};
|
|
438
|
-
const noteThunk = (operation, byResult) => {
|
|
439
|
+
const noteThunk = (operation, byResult, into = thunks) => {
|
|
439
440
|
if (operation.kind !== 'call')
|
|
440
441
|
return;
|
|
441
442
|
const callee = byResult.get(operation.callee.value);
|
|
442
443
|
if (callee && callee.kind === 'allocate-callable')
|
|
443
|
-
|
|
444
|
+
into.add(callee.functionId);
|
|
444
445
|
// Slots also read through typed helpers. Their subscription census already
|
|
445
446
|
// follows closed calls; the record-field census must follow the same edge
|
|
446
447
|
// or it mistakes a subscribed field for an unrendered one at write time.
|
|
447
448
|
if (operation.closedCallee?.kind === 'exact')
|
|
448
|
-
|
|
449
|
+
into.add(operation.closedCallee.functionId);
|
|
449
450
|
};
|
|
450
451
|
// Which values a `style={{...}}` record is built out of. The members of an
|
|
451
452
|
// object literal in a JSX attribute do not arrive as `allocate-record`
|
|
@@ -464,20 +465,10 @@ export const reactiveRecordBindingsOfBodies = (bodies) => {
|
|
|
464
465
|
}
|
|
465
466
|
return byReceiver;
|
|
466
467
|
};
|
|
467
|
-
//
|
|
468
|
-
//
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const stores = storedInto(body);
|
|
472
|
-
const queue = [];
|
|
473
|
-
for (const block of body.blocks.values()) {
|
|
474
|
-
for (const operation of block.operations) {
|
|
475
|
-
if (operation.kind === 'element-prop')
|
|
476
|
-
queue.push(operation.value.value);
|
|
477
|
-
else if (operation.kind === 'element-child')
|
|
478
|
-
queue.push(operation.child.value);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
468
|
+
// Walks back from slot operands to the record reads and thunk calls that
|
|
469
|
+
// produce them. `forced` names the channel for reads that only a whole
|
|
470
|
+
// invocation re-run can refresh (see pass three); `into` collects the thunks.
|
|
471
|
+
const trace = (byResult, stores, queue, into, forced) => {
|
|
481
472
|
const seen = new Set();
|
|
482
473
|
while (queue.length > 0) {
|
|
483
474
|
const value = queue.pop();
|
|
@@ -489,8 +480,8 @@ export const reactiveRecordBindingsOfBodies = (bodies) => {
|
|
|
489
480
|
const operation = byResult.get(value);
|
|
490
481
|
if (!operation)
|
|
491
482
|
continue;
|
|
492
|
-
noteRead(operation, byResult);
|
|
493
|
-
noteThunk(operation, byResult);
|
|
483
|
+
noteRead(operation, byResult, forced);
|
|
484
|
+
noteThunk(operation, byResult, into);
|
|
494
485
|
if (operation.kind === 'allocate-record')
|
|
495
486
|
for (const field of operation.fields)
|
|
496
487
|
queue.push(field.value.value);
|
|
@@ -514,28 +505,109 @@ export const reactiveRecordBindingsOfBodies = (bodies) => {
|
|
|
514
505
|
if (operation.kind === 'convert')
|
|
515
506
|
queue.push(operation.source.value);
|
|
516
507
|
}
|
|
508
|
+
};
|
|
509
|
+
// Pass one: what each body binds DIRECTLY into a JSX slot, and which thunks
|
|
510
|
+
// those slots call.
|
|
511
|
+
for (const body of bodies) {
|
|
512
|
+
const queue = [];
|
|
513
|
+
for (const block of body.blocks.values()) {
|
|
514
|
+
for (const operation of block.operations) {
|
|
515
|
+
if (operation.kind === 'element-prop')
|
|
516
|
+
queue.push(operation.value.value);
|
|
517
|
+
else if (operation.kind === 'element-child')
|
|
518
|
+
queue.push(operation.child.value);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
trace(operationsByResult(body), storedInto(body), queue, thunks);
|
|
517
522
|
}
|
|
518
523
|
// Pass two: a thunk's whole body is its dependency set -- every field it
|
|
519
524
|
// reads is one the slot re-reads when it re-runs -- so there is nothing to
|
|
520
525
|
// trace inside it. Repeated to a fixpoint because a thunk can call another
|
|
521
526
|
// (a style member's slot inside a row's slot), and a callee's body may sit
|
|
522
527
|
// anywhere in `bodies` relative to its caller's.
|
|
523
|
-
const
|
|
528
|
+
const sweep = (pending, swept, forced) => {
|
|
529
|
+
for (;;) {
|
|
530
|
+
let grew = false;
|
|
531
|
+
for (const body of bodies) {
|
|
532
|
+
if (!pending.has(body.sourceOwner) || swept.has(body.sourceOwner))
|
|
533
|
+
continue;
|
|
534
|
+
swept.add(body.sourceOwner);
|
|
535
|
+
grew = true;
|
|
536
|
+
const byResult = operationsByResult(body);
|
|
537
|
+
for (const block of body.blocks.values()) {
|
|
538
|
+
for (const operation of block.operations) {
|
|
539
|
+
noteRead(operation, byResult, forced);
|
|
540
|
+
noteThunk(operation, byResult, pending);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
if (!grew)
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
sweep(thunks, new Set());
|
|
549
|
+
// Pass three: a COMPONENT element is a props record and a call
|
|
550
|
+
// (`plugins/gea/lower.ts`), not a JSX slot of this body. `<Row
|
|
551
|
+
// checked={notice.checked}/>` as a list row reads `notice.checked` ONCE into
|
|
552
|
+
// the record, and the row's own body binds `props.checked` -- a field of the
|
|
553
|
+
// PROPS struct, never of `Notice`. So a write to `notice.checked` looked
|
|
554
|
+
// unrendered and ticked nothing: the row kept the value it was built with.
|
|
555
|
+
//
|
|
556
|
+
// A props field the callee binds makes the value stored into it bound too.
|
|
557
|
+
// Only a re-run of the whole invocation can deliver a new value through the
|
|
558
|
+
// record, which for a list row is the list's revision -- hence `revision`,
|
|
559
|
+
// never `element`: celling the source field would notify a cell no slot
|
|
560
|
+
// subscribes to. Repeated to a fixpoint because the callee may hand its own
|
|
561
|
+
// prop to a further component.
|
|
562
|
+
const carriers = new Set();
|
|
563
|
+
for (const body of bodies) {
|
|
564
|
+
for (const block of body.blocks.values()) {
|
|
565
|
+
for (const operation of block.operations) {
|
|
566
|
+
if (operation.kind === 'element')
|
|
567
|
+
carriers.add(representationKey(operation.result.representation));
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
const propThunks = new Set();
|
|
572
|
+
const propSwept = new Set();
|
|
573
|
+
const traced = new Set();
|
|
524
574
|
for (;;) {
|
|
525
575
|
let grew = false;
|
|
526
576
|
for (const body of bodies) {
|
|
527
|
-
if (!thunks.has(body.sourceOwner) || swept.has(body.sourceOwner))
|
|
528
|
-
continue;
|
|
529
|
-
swept.add(body.sourceOwner);
|
|
530
|
-
grew = true;
|
|
531
577
|
const byResult = operationsByResult(body);
|
|
578
|
+
const queue = [];
|
|
532
579
|
for (const block of body.blocks.values()) {
|
|
533
580
|
for (const operation of block.operations) {
|
|
534
|
-
|
|
535
|
-
|
|
581
|
+
if (operation.kind !== 'call' || operation.result === null)
|
|
582
|
+
continue;
|
|
583
|
+
if (!carriers.has(representationKey(operation.result.representation)))
|
|
584
|
+
continue;
|
|
585
|
+
for (const argument of operation.arguments) {
|
|
586
|
+
let record = byResult.get(argument.value);
|
|
587
|
+
while (record?.kind === 'convert')
|
|
588
|
+
record = byResult.get(record.source.value);
|
|
589
|
+
if (record?.kind !== 'allocate-record')
|
|
590
|
+
continue;
|
|
591
|
+
const struct = structNameOfReceiver(record.result.representation);
|
|
592
|
+
const rendered = struct === null ? undefined : bound.get(struct);
|
|
593
|
+
if (rendered === undefined)
|
|
594
|
+
continue;
|
|
595
|
+
for (const field of record.fields) {
|
|
596
|
+
const token = `${field.value.value}`;
|
|
597
|
+
if (!rendered.has(field.key) || traced.has(token))
|
|
598
|
+
continue;
|
|
599
|
+
traced.add(token);
|
|
600
|
+
queue.push(field.value.value);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
536
603
|
}
|
|
537
604
|
}
|
|
605
|
+
if (queue.length === 0)
|
|
606
|
+
continue;
|
|
607
|
+
grew = true;
|
|
608
|
+
trace(byResult, storedInto(body), queue, propThunks, revision);
|
|
538
609
|
}
|
|
610
|
+
sweep(propThunks, propSwept, revision);
|
|
539
611
|
if (!grew)
|
|
540
612
|
break;
|
|
541
613
|
}
|