@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
|
@@ -16,9 +16,9 @@ import { nativeMergePayloadTransportMatches } from './native-merge-transport.js'
|
|
|
16
16
|
import { nativeArrayTransportOf } from './native-array-transport.js';
|
|
17
17
|
import { nativeArrayInsertionOf } from './native-array-insertion.js';
|
|
18
18
|
import { nativeDictionaryTransportOf } from './native-dictionary-transport.js';
|
|
19
|
-
import { nativeFieldViewIdentityTransportOf, nativeFieldViewLiveLeavesOf, nativeFieldViewPlansOf } from '../conversion/native-field-view.js';
|
|
19
|
+
import { nativeFieldViewIdentityTransportOf, nativeFieldViewLiveLeavesOf, nativeFieldViewPlansOf, nativeFieldViewInstalledPlansOf } from '../conversion/native-field-view.js';
|
|
20
20
|
import { nativeRecordProductsOf } from '../conversion/native-record-products.js';
|
|
21
|
-
import { nativeFieldViewCarrierNeedsReceipt, nativeFieldViewBodyCitationsOf } from './native-field-view-facts.js';
|
|
21
|
+
import { nativeFieldViewCarrierNeedsReceipt, nativeFieldViewBodyCitationsOf, nativeFieldViewCitationsOf } from './native-field-view-facts.js';
|
|
22
22
|
import { nativeFieldViewDomainsOf, nativeFieldViewOpenWriteHomesOf, nativeFieldViewForwardedWriteKey, nativeFieldViewPlansByTargetOf } from './native-field-view-domains.js';
|
|
23
23
|
import { NATIVE_SUM_MATERIALIZER } from '../conversion/native-sum.js';
|
|
24
24
|
import { recipeClosureOf } from '../conversion/recipe-closure.js';
|
|
@@ -1645,8 +1645,143 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
1645
1645
|
if (instanceMethods.has(id))
|
|
1646
1646
|
addFunction(cell, id);
|
|
1647
1647
|
};
|
|
1648
|
+
// The live views a `convert` installs over the converted value itself: the
|
|
1649
|
+
// conversion when it is the view, or else each identity-transporting node
|
|
1650
|
+
// of its recipe from a part of the operand to a part of the result -- an
|
|
1651
|
+
// optional's payload, a borrowed referent, a union's arm. `options = {}`
|
|
1652
|
+
// parameters receive their argument as `optional(view target)`, and a
|
|
1653
|
+
// record passed where a union is declared becomes a view in one arm: the
|
|
1654
|
+
// value can still be that view, and a reader must see its routes.
|
|
1655
|
+
const convertViews = new Map();
|
|
1656
|
+
const valuePartsOf = (representation, into) => {
|
|
1657
|
+
const key = representationKey(representation);
|
|
1658
|
+
if (into.has(key))
|
|
1659
|
+
return into;
|
|
1660
|
+
into.add(key);
|
|
1661
|
+
if (representation.kind === 'optional')
|
|
1662
|
+
valuePartsOf(representation.payload, into);
|
|
1663
|
+
else if (representation.kind === 'borrowed-ref')
|
|
1664
|
+
valuePartsOf(representation.referent, into);
|
|
1665
|
+
else if (representation.kind === 'tagged-union')
|
|
1666
|
+
for (const arm of representation.arms)
|
|
1667
|
+
valuePartsOf(arm.value, into);
|
|
1668
|
+
return into;
|
|
1669
|
+
};
|
|
1670
|
+
// The views a convert installs over the whole converted value (or the
|
|
1671
|
+
// payload an optional or borrow wraps). Only these mark a cell as holding a
|
|
1672
|
+
// view whose origin may be an allocation of another layout; a view over one
|
|
1673
|
+
// arm of a union, or one a field access adapts, does not widen which heaps
|
|
1674
|
+
// the cell's transports carry.
|
|
1675
|
+
const wholeValueViews = new Set();
|
|
1676
|
+
const convertViewsOf = (operation) => {
|
|
1677
|
+
let held = convertViews.get(operation);
|
|
1678
|
+
if (held !== undefined)
|
|
1679
|
+
return held;
|
|
1680
|
+
const found = [];
|
|
1681
|
+
const node = conversions?.nodeById(operation.conversionUse);
|
|
1682
|
+
const from = operation.source.representation;
|
|
1683
|
+
const to = operation.result.representation;
|
|
1684
|
+
if (node && conversions) {
|
|
1685
|
+
if (nativeFieldViewIdentityTransportOf(node) &&
|
|
1686
|
+
representationKey(node.source) === representationKey(from) &&
|
|
1687
|
+
representationKey(node.target) === representationKey(to))
|
|
1688
|
+
wholeValueViews.add(node.id);
|
|
1689
|
+
// An exact transport into a union still installs each arm's view as its
|
|
1690
|
+
// own node (`WriteConcern.fromOptions(client.s.options)` lands the
|
|
1691
|
+
// options record as the union's record arm): that child is installed over
|
|
1692
|
+
// this operand too, not somewhere this solve does not track.
|
|
1693
|
+
const sources = valuePartsOf(from, new Set());
|
|
1694
|
+
const targets = valuePartsOf(to, new Set());
|
|
1695
|
+
const payload = to.kind === 'optional' ? to.payload : to.kind === 'borrowed-ref' ? to.referent : null;
|
|
1696
|
+
const unwrapped = from.kind === 'optional' ? from.payload : from.kind === 'borrowed-ref' ? from.referent : null;
|
|
1697
|
+
for (const child of recipeClosureOf([node], conversions.nodeById).values())
|
|
1698
|
+
if (nativeFieldViewIdentityTransportOf(child) &&
|
|
1699
|
+
sources.has(representationKey(child.source)) &&
|
|
1700
|
+
targets.has(representationKey(child.target))) {
|
|
1701
|
+
found.push(child);
|
|
1702
|
+
const source = representationKey(child.source);
|
|
1703
|
+
if (payload !== null &&
|
|
1704
|
+
representationKey(child.target) === representationKey(payload) &&
|
|
1705
|
+
(source === representationKey(from) || (unwrapped !== null && source === representationKey(unwrapped))))
|
|
1706
|
+
wholeValueViews.add(child.id);
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
convertViews.set(operation, (held = found));
|
|
1710
|
+
return held;
|
|
1711
|
+
};
|
|
1712
|
+
const accessViews = new Map();
|
|
1713
|
+
const accessRecipeViewsOf = (operation) => {
|
|
1714
|
+
let held = accessViews.get(operation);
|
|
1715
|
+
if (held !== undefined)
|
|
1716
|
+
return held;
|
|
1717
|
+
const found = [];
|
|
1718
|
+
if (conversions && (operation.kind === 'get' || operation.kind === 'set'))
|
|
1719
|
+
for (const recipe of operation.conversionRecipes ?? []) {
|
|
1720
|
+
const roles = operation.kind === 'get' ? ['field-read', 'index-read'] : ['field-write', 'dynamic-write'];
|
|
1721
|
+
if (!roles.includes(recipe.role))
|
|
1722
|
+
continue;
|
|
1723
|
+
const node = conversions.nodeById(recipe.conversion);
|
|
1724
|
+
if (!node)
|
|
1725
|
+
continue;
|
|
1726
|
+
const source = representationKey(recipe.source);
|
|
1727
|
+
const overs = [];
|
|
1728
|
+
if (source === representationKey(operation.receiver.representation))
|
|
1729
|
+
overs.push('receiver');
|
|
1730
|
+
if (operation.kind === 'set' && source === representationKey(operation.value.representation))
|
|
1731
|
+
overs.push('stored');
|
|
1732
|
+
if (operation.kind === 'get' && representationKey(recipe.target) === representationKey(operation.result.representation))
|
|
1733
|
+
overs.push('result');
|
|
1734
|
+
if (overs.length === 0)
|
|
1735
|
+
overs.push('unclassified');
|
|
1736
|
+
for (const child of recipeClosureOf([node], conversions.nodeById).values())
|
|
1737
|
+
if (nativeFieldViewInstalledPlansOf(child).length > 0)
|
|
1738
|
+
for (const over of overs)
|
|
1739
|
+
if (!found.some((entry) => entry.node === child && entry.over === over))
|
|
1740
|
+
found.push({ node: child, over });
|
|
1741
|
+
}
|
|
1742
|
+
// A store through a live view converts the value into each slot carrier
|
|
1743
|
+
// it may land in: those views are stored, exactly as a recipe's.
|
|
1744
|
+
if (conversions && operation.kind === 'set')
|
|
1745
|
+
for (const target of operation.nativeFieldViewWrite?.targets ?? []) {
|
|
1746
|
+
const node = target.conversion === null ? null : conversions.nodeById(target.conversion);
|
|
1747
|
+
if (!node)
|
|
1748
|
+
continue;
|
|
1749
|
+
for (const child of recipeClosureOf([node], conversions.nodeById).values())
|
|
1750
|
+
if (nativeFieldViewInstalledPlansOf(child).length > 0 && !found.some((entry) => entry.node === child && entry.over === 'stored'))
|
|
1751
|
+
found.push({ node: child, over: 'stored' });
|
|
1752
|
+
}
|
|
1753
|
+
accessViews.set(operation, (held = found));
|
|
1754
|
+
return held;
|
|
1755
|
+
};
|
|
1756
|
+
// The stores whose stored views the solve placed on every slot they
|
|
1757
|
+
// reached, or whose value escaped to storage no reader follows.
|
|
1758
|
+
const coveredStores = new Set();
|
|
1759
|
+
const storeViews = (operation, targets) => {
|
|
1760
|
+
coveredStores.add(operation);
|
|
1761
|
+
for (const { node, over } of accessRecipeViewsOf(operation))
|
|
1762
|
+
if (over === 'stored')
|
|
1763
|
+
for (const cell of targets)
|
|
1764
|
+
if (!cell.fieldViews.has(node.id)) {
|
|
1765
|
+
ownSet(cell.fieldViews, (own) => (cell.fieldViews = own)).add(node.id);
|
|
1766
|
+
changed(cell);
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1648
1769
|
const processOperation = (operation) => {
|
|
1649
1770
|
const result = resultOfIrOperation(operation);
|
|
1771
|
+
// A read whose result adaptation installs a live view (a class instance
|
|
1772
|
+
// read into a union's `{}` arm) produces that view, exactly as a
|
|
1773
|
+
// `convert` does: its node rides the result's cell, on every path, so a
|
|
1774
|
+
// later view over the value sees it among its possible sources.
|
|
1775
|
+
if (operation.kind === 'get')
|
|
1776
|
+
for (const { node, over } of accessRecipeViewsOf(operation)) {
|
|
1777
|
+
if (over !== 'result')
|
|
1778
|
+
continue;
|
|
1779
|
+
const cell = value(operation.result.id);
|
|
1780
|
+
if (!cell.fieldViews.has(node.id)) {
|
|
1781
|
+
ownSet(cell.fieldViews, (own) => (cell.fieldViews = own)).add(node.id);
|
|
1782
|
+
changed(cell);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1650
1785
|
// A method identity in a carrier describes the value, not an invocation.
|
|
1651
1786
|
// Publish it when that value is produced/used so ordinary escape edges also
|
|
1652
1787
|
// cover detached methods without rooting every method in every layout.
|
|
@@ -1829,6 +1964,7 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
1829
1964
|
}
|
|
1830
1965
|
else {
|
|
1831
1966
|
linkPayload(value(operation.value.value), slot.cell, [slot.representation]);
|
|
1967
|
+
storeViews(operation, [slot.cell]);
|
|
1832
1968
|
if (operation.result)
|
|
1833
1969
|
link(value(operation.receiver.value), value(operation.result.id));
|
|
1834
1970
|
}
|
|
@@ -2195,10 +2331,12 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
2195
2331
|
const targets = slotsOf(operation.receiver, '');
|
|
2196
2332
|
if (targets === null) {
|
|
2197
2333
|
untrusted(operation);
|
|
2334
|
+
storeViews(operation, []);
|
|
2198
2335
|
return true;
|
|
2199
2336
|
}
|
|
2200
2337
|
for (const target of targets)
|
|
2201
2338
|
link(value(operation.value.value), target);
|
|
2339
|
+
storeViews(operation, targets);
|
|
2202
2340
|
return targets.length > 0;
|
|
2203
2341
|
}, undefined, operation.receiver.value);
|
|
2204
2342
|
if (operation.result && representationKey(operation.result.representation) === representationKey(operation.value.representation))
|
|
@@ -2210,10 +2348,12 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
2210
2348
|
const targets = slotsOf(operation.receiver, key, operation);
|
|
2211
2349
|
if (targets === null) {
|
|
2212
2350
|
untrusted(operation);
|
|
2351
|
+
storeViews(operation, []);
|
|
2213
2352
|
return true;
|
|
2214
2353
|
}
|
|
2215
2354
|
for (const target of targets)
|
|
2216
2355
|
link(value(operation.value.value), target);
|
|
2356
|
+
storeViews(operation, targets);
|
|
2217
2357
|
return targets.length > 0;
|
|
2218
2358
|
}, undefined, operation.receiver.value);
|
|
2219
2359
|
if (operation.result &&
|
|
@@ -2221,8 +2361,10 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
2221
2361
|
representationKey(operation.kind === 'set' ? operation.value.representation : operation.receiver.representation))
|
|
2222
2362
|
link(value(operation.kind === 'set' ? operation.value.value : operation.receiver.value), value(operation.result.id));
|
|
2223
2363
|
}
|
|
2224
|
-
else
|
|
2364
|
+
else {
|
|
2225
2365
|
untrusted(operation);
|
|
2366
|
+
storeViews(operation, []);
|
|
2367
|
+
}
|
|
2226
2368
|
break;
|
|
2227
2369
|
}
|
|
2228
2370
|
case 'dead-logical-merge-value':
|
|
@@ -2258,42 +2400,13 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
2258
2400
|
to.arms.some((arm) => representationKey(arm.value) === representationKey(from));
|
|
2259
2401
|
if (dynamicArm)
|
|
2260
2402
|
documentNeutralCells.add(value(operation.result.id));
|
|
2261
|
-
|
|
2262
|
-
nativeFieldViewIdentityTransportOf(node) &&
|
|
2263
|
-
representationKey(node.source) === representationKey(from) &&
|
|
2264
|
-
representationKey(node.target) === representationKey(to)) {
|
|
2403
|
+
for (const view of convertViewsOf(operation)) {
|
|
2265
2404
|
const cell = value(operation.result.id);
|
|
2266
|
-
if (!cell.fieldViews.has(
|
|
2267
|
-
ownSet(cell.fieldViews, (own) => (cell.fieldViews = own)).add(
|
|
2405
|
+
if (!cell.fieldViews.has(view.id)) {
|
|
2406
|
+
ownSet(cell.fieldViews, (own) => (cell.fieldViews = own)).add(view.id);
|
|
2268
2407
|
changed(cell);
|
|
2269
2408
|
}
|
|
2270
2409
|
}
|
|
2271
|
-
else if (node && (to.kind === 'optional' || to.kind === 'borrowed-ref')) {
|
|
2272
|
-
// A live view installed for the payload of an optional (or borrowed)
|
|
2273
|
-
// carrier: `options = {}` parameters receive their argument as
|
|
2274
|
-
// `optional(view target)`, so the view node is a child of the
|
|
2275
|
-
// wrapper conversion rather than the conversion itself. The value
|
|
2276
|
-
// can still be that view, and a reader must see its routes; without
|
|
2277
|
-
// this, the source allocations reached the parameter as if they were
|
|
2278
|
-
// plain allocations of the target, and a key only the view answers
|
|
2279
|
-
// (three's `_setTextureOptions( options )` reading `options.mapping`
|
|
2280
|
-
// through WebGLCubeRenderTarget's `{}`) had no certified route.
|
|
2281
|
-
const payload = to.kind === 'optional' ? to.payload : to.referent;
|
|
2282
|
-
const sources = new Set([representationKey(from)]);
|
|
2283
|
-
if (from.kind === 'optional')
|
|
2284
|
-
sources.add(representationKey(from.payload));
|
|
2285
|
-
if (from.kind === 'borrowed-ref')
|
|
2286
|
-
sources.add(representationKey(from.referent));
|
|
2287
|
-
const cell = value(operation.result.id);
|
|
2288
|
-
for (const child of recipeClosureOf([node], conversions?.nodeById).values())
|
|
2289
|
-
if (nativeFieldViewIdentityTransportOf(child) &&
|
|
2290
|
-
sources.has(representationKey(child.source)) &&
|
|
2291
|
-
representationKey(child.target) === representationKey(payload) &&
|
|
2292
|
-
!cell.fieldViews.has(child.id)) {
|
|
2293
|
-
ownSet(cell.fieldViews, (own) => (cell.fieldViews = own)).add(child.id);
|
|
2294
|
-
changed(cell);
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
2410
|
const document = node === null || node === undefined ? null : nativeDocumentEntryViewOf(node, conversions?.nodeById);
|
|
2298
2411
|
if (document !== null &&
|
|
2299
2412
|
node !== null &&
|
|
@@ -2661,14 +2774,15 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
2661
2774
|
// A target with no allocation of its own that takes every one of
|
|
2662
2775
|
// this cell's holds the very same set until either writes it: most
|
|
2663
2776
|
// multi-allocation cells hold exactly the set of a cell before them.
|
|
2664
|
-
|
|
2777
|
+
const viewed = allowed !== null && [...cell.fieldViews].some((id) => wholeValueViews.has(id));
|
|
2778
|
+
if (target.heaps === emptyCellSet && target !== cell && cell.heaps.size > 0 && (allowed === null || viewed)) {
|
|
2665
2779
|
cell.heaps.shared = true;
|
|
2666
2780
|
target.heaps = cell.heaps;
|
|
2667
2781
|
changed(target);
|
|
2668
2782
|
}
|
|
2669
2783
|
else
|
|
2670
2784
|
for (const heap of cell.heaps)
|
|
2671
|
-
if (allowed === null ||
|
|
2785
|
+
if (allowed === null || viewed || heapAdmitted(heap, allowed))
|
|
2672
2786
|
addHeap(target, heap);
|
|
2673
2787
|
if (cell.unknown) {
|
|
2674
2788
|
const admitted = cell.unknownHeaps === null
|
|
@@ -3091,12 +3205,124 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
3091
3205
|
// a `{ type: 'dispose' }` literal viewed as an event with `target`): the
|
|
3092
3206
|
// descriptor's `sourceAbsent` route. Its readers already read that
|
|
3093
3207
|
// source's expando, and now meet the carrier stored there.
|
|
3208
|
+
// Which views can be the very value each live plan is installed over
|
|
3209
|
+
// (`nativeFieldViewDomainsOf`'s `sourcePlansOf`). A view a `convert`
|
|
3210
|
+
// installs records its node on the result's cell, exactly as the solve
|
|
3211
|
+
// above transports it, so a plan whose every installation is such a convert
|
|
3212
|
+
// is installed over its operands' cells: their recorded views, and every
|
|
3213
|
+
// plan installed anywhere this solve does not track on a cell. One operand
|
|
3214
|
+
// with unknown origins leaves the plan unbounded.
|
|
3215
|
+
const plansOfNode = new Map();
|
|
3216
|
+
const nodePlans = (node) => {
|
|
3217
|
+
let held = plansOfNode.get(node);
|
|
3218
|
+
if (held === undefined)
|
|
3219
|
+
plansOfNode.set(node, (held = nativeFieldViewPlansOf([node])));
|
|
3220
|
+
return held;
|
|
3221
|
+
};
|
|
3222
|
+
const installedPlans = new Map();
|
|
3223
|
+
const isOwnPlan = (plan, node) => {
|
|
3224
|
+
let held = installedPlans.get(node);
|
|
3225
|
+
if (held === undefined)
|
|
3226
|
+
installedPlans.set(node, (held = new Set(nativeFieldViewInstalledPlansOf(node))));
|
|
3227
|
+
return held.has(plan);
|
|
3228
|
+
};
|
|
3229
|
+
const installedOver = new Map();
|
|
3230
|
+
const untrackedPlans = new Set();
|
|
3231
|
+
const trackedNodes = new Set();
|
|
3232
|
+
for (const operation of operations) {
|
|
3233
|
+
const own = new Set();
|
|
3234
|
+
if (operation.kind === 'convert' && conversions) {
|
|
3235
|
+
for (const view of convertViewsOf(operation))
|
|
3236
|
+
own.add(view);
|
|
3237
|
+
const operand = value(operation.source.value);
|
|
3238
|
+
for (const node of own)
|
|
3239
|
+
for (const plan of nodePlans(node)) {
|
|
3240
|
+
if (!isOwnPlan(plan, node) || installedOver.get(plan) === null)
|
|
3241
|
+
continue;
|
|
3242
|
+
if (operand.unknown) {
|
|
3243
|
+
installedOver.set(plan, null);
|
|
3244
|
+
continue;
|
|
3245
|
+
}
|
|
3246
|
+
const reaching = installedOver.get(plan) ?? new Set();
|
|
3247
|
+
for (const id of operand.fieldViews) {
|
|
3248
|
+
const view = conversions.nodeById(id);
|
|
3249
|
+
if (view === null) {
|
|
3250
|
+
installedOver.set(plan, null);
|
|
3251
|
+
break;
|
|
3252
|
+
}
|
|
3253
|
+
for (const held of nodePlans(view))
|
|
3254
|
+
reaching.add(held);
|
|
3255
|
+
}
|
|
3256
|
+
if (installedOver.get(plan) !== null)
|
|
3257
|
+
installedOver.set(plan, reaching);
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
// What each access view is installed over, and whether the value it makes
|
|
3261
|
+
// rides a cell: a read's result views ride its result cell and a covered
|
|
3262
|
+
// store's stored views the slots it reached (the solve's `get`, `set`), so a
|
|
3263
|
+
// view over either value sees them; a receiver adaptation is consumed by
|
|
3264
|
+
// its access. A read's result view is installed over the slot's value,
|
|
3265
|
+
// which this does not follow; the others over an operand's cell.
|
|
3266
|
+
for (const { node, over } of operation.kind === 'get' || operation.kind === 'set' ? accessRecipeViewsOf(operation) : []) {
|
|
3267
|
+
if (operation.kind !== 'get' && operation.kind !== 'set')
|
|
3268
|
+
break;
|
|
3269
|
+
if (over === 'unclassified' || (over === 'stored' && !coveredStores.has(operation)))
|
|
3270
|
+
continue;
|
|
3271
|
+
own.add(node);
|
|
3272
|
+
const operand = over === 'receiver'
|
|
3273
|
+
? value(operation.receiver.value)
|
|
3274
|
+
: over === 'stored' && operation.kind === 'set'
|
|
3275
|
+
? value(operation.value.value)
|
|
3276
|
+
: null;
|
|
3277
|
+
for (const plan of nodePlans(node)) {
|
|
3278
|
+
if (!isOwnPlan(plan, node) || installedOver.get(plan) === null)
|
|
3279
|
+
continue;
|
|
3280
|
+
if (operand === null || operand.unknown) {
|
|
3281
|
+
installedOver.set(plan, null);
|
|
3282
|
+
continue;
|
|
3283
|
+
}
|
|
3284
|
+
const reaching = installedOver.get(plan) ?? new Set();
|
|
3285
|
+
for (const id of operand.fieldViews) {
|
|
3286
|
+
const view = conversions?.nodeById(id);
|
|
3287
|
+
if (!view) {
|
|
3288
|
+
installedOver.set(plan, null);
|
|
3289
|
+
break;
|
|
3290
|
+
}
|
|
3291
|
+
for (const held of nodePlans(view))
|
|
3292
|
+
reaching.add(held);
|
|
3293
|
+
}
|
|
3294
|
+
if (installedOver.get(plan) !== null)
|
|
3295
|
+
installedOver.set(plan, reaching);
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
for (const id of nativeFieldViewCitationsOf(operation)) {
|
|
3299
|
+
const cited = conversions?.nodeById(id);
|
|
3300
|
+
if (!cited)
|
|
3301
|
+
continue;
|
|
3302
|
+
for (const node of recipeClosureOf([cited], conversions?.nodeById).values()) {
|
|
3303
|
+
trackedNodes.add(node);
|
|
3304
|
+
for (const plan of nodePlans(node))
|
|
3305
|
+
if (!(own.has(node) && isOwnPlan(plan, node)))
|
|
3306
|
+
untrackedPlans.add(plan);
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
for (const node of viewNodes)
|
|
3311
|
+
if (!trackedNodes.has(node))
|
|
3312
|
+
for (const plan of nodePlans(node))
|
|
3313
|
+
untrackedPlans.add(plan);
|
|
3314
|
+
const sourcePlansOf = (plan) => {
|
|
3315
|
+
if (untrackedPlans.has(plan))
|
|
3316
|
+
return null;
|
|
3317
|
+
const reaching = installedOver.get(plan);
|
|
3318
|
+
return reaching === undefined || reaching === null ? null : new Set([...reaching, ...untrackedPlans]);
|
|
3319
|
+
};
|
|
3094
3320
|
const openWritePlans = nativeFieldViewPlansByTargetOf(viewNodes);
|
|
3095
3321
|
const nativeFieldViewOpenWriteValues = new Set();
|
|
3096
3322
|
const nativeFieldViewForwardedWrites = new Set();
|
|
3097
3323
|
let forwardDomains;
|
|
3098
3324
|
const forwardedAbsentKeysOf = (receiver) => {
|
|
3099
|
-
forwardDomains ??= nativeFieldViewDomainsOf(viewNodes, deriver, (id) => bodyById.get(id)?.abi ?? null, classes);
|
|
3325
|
+
forwardDomains ??= nativeFieldViewDomainsOf(viewNodes, deriver, (id) => bodyById.get(id)?.abi ?? null, classes, undefined, sourcePlansOf);
|
|
3100
3326
|
const keys = new Set();
|
|
3101
3327
|
for (const [key, routes] of forwardDomains(receiver) ?? [])
|
|
3102
3328
|
if (routes.some((route) => route.sourceAbsent === true))
|
|
@@ -3107,7 +3333,7 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
3107
3333
|
for (const operation of operations) {
|
|
3108
3334
|
if (operation.kind !== 'set')
|
|
3109
3335
|
continue;
|
|
3110
|
-
const open = nativeFieldViewOpenWriteHomesOf(operation.receiver.representation, openWritePlans, deriver);
|
|
3336
|
+
const open = nativeFieldViewOpenWriteHomesOf(operation.receiver.representation, openWritePlans, deriver, sourcePlansOf);
|
|
3111
3337
|
if (open === null)
|
|
3112
3338
|
continue;
|
|
3113
3339
|
const constant = keyOf(operation.key);
|
|
@@ -3130,7 +3356,7 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
3130
3356
|
}
|
|
3131
3357
|
const expandoStoredOf = expandoStoredReaderOf(expandoStored);
|
|
3132
3358
|
const nativeFieldViewStorageValues = new Map();
|
|
3133
|
-
const descriptorDomainsOf = descriptorDomainsOver(viewNodes, deriver, bodyById, classes, expandoStored);
|
|
3359
|
+
const descriptorDomainsOf = descriptorDomainsOver(viewNodes, deriver, bodyById, classes, expandoStored, sourcePlansOf);
|
|
3134
3360
|
for (const [id, carrier] of valueCarriers) {
|
|
3135
3361
|
const fields = descriptorDomainsOf(carrier);
|
|
3136
3362
|
if (fields !== null)
|
|
@@ -3224,7 +3450,7 @@ const solveNativeCallableFlow = (viewNodes, bodies, placements, classes, convers
|
|
|
3224
3450
|
const node = conversions?.nodeById(id);
|
|
3225
3451
|
return node && nativeFieldViewIdentityTransportOf(node) ? [node] : [];
|
|
3226
3452
|
}));
|
|
3227
|
-
installed = nativeFieldViewDomainsOf(nodes, deriver, (id) => bodyById.get(id)?.abi ?? null, classes, expandoStoredOf);
|
|
3453
|
+
installed = nativeFieldViewDomainsOf(nodes, deriver, (id) => bodyById.get(id)?.abi ?? null, classes, expandoStoredOf, sourcePlansOf);
|
|
3228
3454
|
originDomains.set(identity, installed);
|
|
3229
3455
|
}
|
|
3230
3456
|
// The retained allocation's C++ slot is behind this installed reader.
|
|
@@ -3570,14 +3796,14 @@ const expandoStoredReaderOf = (expandoStored) => (shapeId, key) => {
|
|
|
3570
3796
|
const any = byKey.get(null) ?? [];
|
|
3571
3797
|
return [...keyed, ...any.filter((value) => !keyed.some((one) => representationKey(one) === representationKey(value)))];
|
|
3572
3798
|
};
|
|
3573
|
-
const descriptorDomainsOver = (viewNodes, deriver, bodyById, classes, expandoStored) => {
|
|
3799
|
+
const descriptorDomainsOver = (viewNodes, deriver, bodyById, classes, expandoStored, sourcePlansOf) => {
|
|
3574
3800
|
// The domains outlive the solve inside every remembered and re-pointed
|
|
3575
3801
|
// reader, so they keep the ABIs rather than `bodyById`, which held the
|
|
3576
3802
|
// solved body generation for as long as any reader did.
|
|
3577
3803
|
const abis = new Map();
|
|
3578
3804
|
for (const [id, body] of bodyById)
|
|
3579
3805
|
abis.set(id, body?.abi ?? null);
|
|
3580
|
-
return nativeFieldViewDomainsOf(viewNodes, deriver, (id) => abis.get(id) ?? null, classes, expandoStoredReaderOf(expandoStored));
|
|
3806
|
+
return nativeFieldViewDomainsOf(viewNodes, deriver, (id) => abis.get(id) ?? null, classes, expandoStoredReaderOf(expandoStored), sourcePlansOf);
|
|
3581
3807
|
};
|
|
3582
3808
|
/** Whether `id` is `irValueId(owner, n)` for some ordinal, read without slicing it. */
|
|
3583
3809
|
/**
|
package/dist/ir/captures.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { representationKey } from '../representation/model.js';
|
|
2
|
-
import { dominatorTreeOf, isVisible } from './dominance.js';
|
|
2
|
+
import { cyclicBlocksOf, dominatorTreeOf, isVisible } from './dominance.js';
|
|
3
3
|
const captureFactsOf = (body, placements) => {
|
|
4
4
|
const direct = [];
|
|
5
5
|
const allocates = [];
|
|
@@ -250,13 +250,19 @@ const computeCaptureFacts = (bodies, placements, capturingAccessors) => {
|
|
|
250
250
|
// cell written more than once overwrites its entry, which never matters:
|
|
251
251
|
// `reassigned` refuses every such cell before the answer is consulted.
|
|
252
252
|
const writtenValues = new Map();
|
|
253
|
+
// A write a loop of its body repeats is one write in the program text and
|
|
254
|
+
// a new value on every turn.
|
|
255
|
+
const writtenInCycle = new Set();
|
|
253
256
|
const allocatedFunctionOfValue = new Map();
|
|
254
257
|
for (const body of bodies) {
|
|
258
|
+
const cyclic = cyclicBlocksOf(body);
|
|
255
259
|
for (const blockId of body.blockOrder) {
|
|
256
260
|
const block = body.blocks.get(blockId);
|
|
257
261
|
if (!block)
|
|
258
262
|
continue;
|
|
259
263
|
for (const operation of block.operations) {
|
|
264
|
+
if (operation.kind === 'binding-write' && cyclic.has(blockId))
|
|
265
|
+
writtenInCycle.add(operation.declaration);
|
|
260
266
|
if (operation.kind === 'allocate-callable') {
|
|
261
267
|
allocatedFunctionIds.add(operation.functionId);
|
|
262
268
|
// An SSA id embeds the physical body it belongs to
|
|
@@ -471,6 +477,7 @@ const computeCaptureFacts = (bodies, placements, capturingAccessors) => {
|
|
|
471
477
|
allocatedFunctionIds,
|
|
472
478
|
boxed,
|
|
473
479
|
earlyBox: capturedBeforeInitialization,
|
|
480
|
+
settled: new Set([...boxed].filter((declaration) => !reassigned.has(declaration) && !writtenInCycle.has(declaration))),
|
|
474
481
|
readsReceiver
|
|
475
482
|
};
|
|
476
483
|
};
|
|
@@ -530,6 +537,15 @@ capturingAccessors = new Set()) => {
|
|
|
530
537
|
owned.add(declaration);
|
|
531
538
|
earlyBoxByOwner.set(placement.storage.owner, owned);
|
|
532
539
|
}
|
|
540
|
+
const settledByOwner = new Map();
|
|
541
|
+
for (const declaration of facts.settled) {
|
|
542
|
+
const placement = placements.get(declaration);
|
|
543
|
+
if (placement?.storage.kind !== 'local')
|
|
544
|
+
continue;
|
|
545
|
+
const owned = settledByOwner.get(placement.storage.owner) ?? new Set();
|
|
546
|
+
owned.add(declaration);
|
|
547
|
+
settledByOwner.set(placement.storage.owner, owned);
|
|
548
|
+
}
|
|
533
549
|
const empty = new Set();
|
|
534
550
|
const published = new Map();
|
|
535
551
|
for (const body of bodyList) {
|
|
@@ -542,6 +558,7 @@ capturingAccessors = new Set()) => {
|
|
|
542
558
|
readsReceiver: facts.readsReceiver(owner),
|
|
543
559
|
boxed: boxedByOwner.get(owner) ?? empty,
|
|
544
560
|
requiresEarlyBox: earlyBoxByOwner.get(owner) ?? empty,
|
|
561
|
+
settledBoxes: settledByOwner.get(owner) ?? empty,
|
|
545
562
|
...(group ? { captureGroup: { id: group.id, owner: group.owner, members: group.members } } : {})
|
|
546
563
|
};
|
|
547
564
|
published.set(body.owner, { ...body, facts: bodyFacts });
|
package/dist/ir/certify.js
CHANGED
|
@@ -26,7 +26,7 @@ import { nativeArrayViewPlanMatches } from '../conversion/array-view.js';
|
|
|
26
26
|
import { nativeDescriptorSnapshotPlanMatches } from '../conversion/native-descriptor-snapshot.js';
|
|
27
27
|
import { nativeArrayDescriptorSnapshotMatches, nativeArrayDescriptorReinstallationOf } from './native-array-descriptor-snapshot.js';
|
|
28
28
|
import { operationOfResult } from '../identity/ids.js';
|
|
29
|
-
import { classFamilyMayAllocate, classMethodFamilyHasNativeBody } from '../projection/dispatch.js';
|
|
29
|
+
import { classFamilyMayAllocate, classMethodFamilyHasNativeBody, classMethodReadMayMissAbstractly } from '../projection/dispatch.js';
|
|
30
30
|
import { forEachEmbeddedRepresentation } from '../representation/embedded-carriers.js';
|
|
31
31
|
import { captureCapabilityOf, representationKey } from '../representation/model.js';
|
|
32
32
|
import { propertyAccessKeysOf } from './certify/property-access.js';
|
|
@@ -1371,6 +1371,19 @@ const internalConversionDemandsOf = (operation, ctx) => {
|
|
|
1371
1371
|
verdict: 'missing',
|
|
1372
1372
|
detail: 'an evaluated native method read has no executable source implementation or override family'
|
|
1373
1373
|
});
|
|
1374
|
+
// A read that misses on an abstract declaration is `undefined` there; the
|
|
1375
|
+
// empty callable of a dispatch carrier is that value, and calling it is
|
|
1376
|
+
// the TypeError. No other carrier has one to stand for it.
|
|
1377
|
+
else if (keyText !== null &&
|
|
1378
|
+
operation.receiver.representation.kind === 'class-ref' &&
|
|
1379
|
+
operation.result.representation.kind !== 'function-value-dispatch' &&
|
|
1380
|
+
classMethodReadMayMissAbstractly(ctx.classes, operation.receiver.representation.declaration, keyText) &&
|
|
1381
|
+
classFamilyMayAllocate(ctx.classes, operation.receiver.representation.declaration))
|
|
1382
|
+
demands.push({
|
|
1383
|
+
key: 'property-access:computed-class-method-virtual',
|
|
1384
|
+
verdict: 'missing',
|
|
1385
|
+
detail: 'a native method read that misses on an abstract declaration has no carrier for undefined'
|
|
1386
|
+
});
|
|
1374
1387
|
const abis = ctx.abis ??
|
|
1375
1388
|
new Map([...ctx.bodies.values()].flatMap((body) => (body.abi === null ? [] : [[body.sourceOwner, body.abi]])));
|
|
1376
1389
|
const methods = methodConversionInputsOf(operation, keyText, ctx.classes, abis, ctx.deriver, ctx.body);
|
|
@@ -2,6 +2,8 @@ import type { DeclarationId, FunctionId, IrValueId } from '../identity/ids.js';
|
|
|
2
2
|
import { type Representation } from '../representation/model.js';
|
|
3
3
|
import type { ClassConstruction } from './instantiation.js';
|
|
4
4
|
import { type IrBody } from './model.js';
|
|
5
|
+
import { type WindowSite } from './stable-cell-reads.js';
|
|
6
|
+
import { type WriteEffects } from './write-effects.js';
|
|
5
7
|
import type { ReflectionDemand } from './reflection-demand.js';
|
|
6
8
|
/**
|
|
7
9
|
* Class fields the program writes only while constructing the object that
|
|
@@ -111,6 +113,18 @@ export declare const stableFieldReadsOf: (body: IrBody, receivers: ReadonlySet<I
|
|
|
111
113
|
* suspending body keeps them too, for the reason `suspensionFreeReadsOf` gives.
|
|
112
114
|
*/
|
|
113
115
|
export declare const stableFieldCellsOf: (body: IrBody, stableReads: ReadonlySet<IrValueId>, admits: (declaration: DeclarationId) => boolean) => ReadonlySet<DeclarationId>;
|
|
116
|
+
/**
|
|
117
|
+
* Reads of a data field of a stable receiver (`stableReceiversOf`) that no
|
|
118
|
+
* operation between the read and any of its uses can store (`WriteEffects`),
|
|
119
|
+
* the field the program does rewrite elsewhere included: `const fog =
|
|
120
|
+
* scene.fog` across statements that never assign a `fog` names the field at
|
|
121
|
+
* every use, as a construction-only field's read does. `extraUses` adds the
|
|
122
|
+
* sites a read's value is also seen at -- the reads of the cell it
|
|
123
|
+
* initializes, and their uses -- so the window covers every one.
|
|
124
|
+
*/
|
|
125
|
+
export declare const windowStableFieldReadsOf: (body: IrBody, receivers: ReadonlySet<IrValueId>, integrity: {
|
|
126
|
+
readonly restricts: (representation: Representation) => boolean;
|
|
127
|
+
}, dying: Pick<ReadonlySet<IrValueId>, "has">, effects: WriteEffects, extraUses?: (value: IrValueId) => readonly WindowSite[]) => ReadonlySet<IrValueId>;
|
|
114
128
|
/**
|
|
115
129
|
* `stableFieldReadsOf` and `stableFieldCellsOf` together. A read whose one use
|
|
116
130
|
* is the write into its cell is dying -- the write moves it in -- and so is no
|
|
@@ -119,7 +133,7 @@ export declare const stableFieldCellsOf: (body: IrBody, stableReads: ReadonlySet
|
|
|
119
133
|
*/
|
|
120
134
|
export declare const stableFieldReadsAndCellsOf: (body: IrBody, receivers: ReadonlySet<IrValueId>, fields: ConstructionOnlyFields, integrity: {
|
|
121
135
|
readonly restricts: (representation: Representation) => boolean;
|
|
122
|
-
}, dying: ReadonlySet<IrValueId>, admits: (declaration: DeclarationId) => boolean) => {
|
|
136
|
+
}, dying: ReadonlySet<IrValueId>, admits: (declaration: DeclarationId) => boolean, effects?: WriteEffects) => {
|
|
123
137
|
readonly reads: ReadonlySet<IrValueId>;
|
|
124
138
|
readonly cells: ReadonlySet<DeclarationId>;
|
|
125
139
|
};
|