@geastack/compiler 1.0.62 → 1.0.64
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/dist/cli-emit.js +14 -5
- package/dist/conversion/dictionary-view.js +13 -2
- package/dist/conversion/document-record-view.d.ts +0 -1
- package/dist/conversion/document-record-view.js +30 -3
- package/dist/conversion/impossible-field-read.d.ts +9 -0
- package/dist/conversion/impossible-field-read.js +26 -0
- package/dist/conversion/nodes.d.ts +12 -0
- package/dist/conversion/nodes.js +106 -2
- package/dist/conversion/record-view.js +21 -0
- package/dist/ir/build.d.ts +5 -2
- package/dist/ir/build.js +9 -2
- package/dist/ir/callable-class-flow.js +233 -13
- package/dist/ir/certify/parallel-region.js +1 -0
- package/dist/ir/certify.js +32 -2
- package/dist/ir/dense-loops.js +8 -1
- package/dist/ir/hoist.js +15 -1
- package/dist/ir/host-template-conversions.js +12 -0
- package/dist/ir/lower-invocation.js +42 -2
- package/dist/ir/lower-property.js +2 -2
- package/dist/ir/model.d.ts +18 -6
- package/dist/ir/native-callable-data-reads.js +15 -2
- package/dist/ir/native-field-view-domains.d.ts +8 -0
- package/dist/ir/native-field-view-domains.js +44 -3
- package/dist/ir/native-field-view-facts.d.ts +2 -2
- package/dist/ir/native-field-view-facts.js +57 -13
- package/dist/ir/native-own-assignment.js +20 -2
- package/dist/ir/program-conversions.js +38 -7
- package/dist/ir/property-read-conversions.js +14 -5
- package/dist/ir/publish-native-field-view-facts.js +1 -1
- package/dist/ir/queries.js +2 -0
- package/dist/ir/read-only-dictionary.js +138 -15
- package/dist/ir/reflection-demand.js +7 -1
- package/dist/ir/shake.js +26 -6
- package/dist/ir/typed-property-access.d.ts +20 -0
- package/dist/ir/typed-property-access.js +56 -0
- package/dist/projection/bindings.js +14 -19
- package/dist/projection/fields.js +7 -1
- package/dist/projection/native-object-data.d.ts +8 -1
- package/dist/projection/native-object-data.js +16 -4
- package/dist/representation/derive.js +67 -1
- package/dist/representation/proxy-carriers.js +17 -2
- package/dist/representation/publish.js +34 -0
- package/dist/semantics/callable-own-data-slots.js +71 -6
- package/dist/semantics/model/operations.d.ts +15 -4
- package/dist/semantics/native-own-assignment.d.ts +3 -0
- package/dist/semantics/normalize/collection-bindings.js +2 -2
- package/dist/semantics/normalize/flow/array-element-continuation.d.ts +1 -1
- package/dist/semantics/normalize/flow/array-element-continuation.js +32 -9
- package/dist/semantics/normalize/flow/callable-reach.d.ts +3 -5
- package/dist/semantics/normalize/flow/callable-reach.js +3 -5
- package/dist/semantics/normalize/flow/component-solver.d.ts +2 -0
- package/dist/semantics/normalize/flow/component-solver.js +32 -6
- package/dist/semantics/normalize/flow/computed-key-set.js +53 -1
- package/dist/semantics/normalize/flow/source-value-session.js +16 -14
- package/dist/semantics/normalize/producers/invocations.js +40 -1
- package/dist/semantics/normalize/producers/native-own-assignment.js +12 -4
- package/dist/semantics/normalize/reachability.js +18 -8
- package/dist/semantics/normalize/structural-mutable-field.d.ts +1 -0
- package/dist/semantics/normalize/structural-mutable-field.js +170 -4
- package/dist/semantics/normalize/structural-parts.js +6 -1
- package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
- package/dist/semantics/normalize/structural-self-reference.js +9 -1
- package/dist/semantics/normalize/structural.js +10 -1
- package/dist/semantics/program.js +102 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +9 -0
- package/dist/targets/cpp/emit-allocation.js +22 -1
- package/dist/targets/cpp/emit-callable.js +3 -3
- package/dist/targets/cpp/emit-exceptions.js +6 -0
- package/dist/targets/cpp/emit-narrowing.js +24 -2
- package/dist/targets/cpp/emit-native-field-view.d.ts +1 -1
- package/dist/targets/cpp/emit-native-field-view.js +37 -5
- package/dist/targets/cpp/emit-native-own-assignment.js +5 -1
- package/dist/targets/cpp/emit-record-view.js +6 -1
- package/dist/targets/cpp/emit-tonumber.d.ts +22 -11
- package/dist/targets/cpp/emit-tonumber.js +86 -25
- package/dist/targets/cpp/emit.js +3 -0
- package/dist/targets/cpp/host/emit-host-invoke.js +6 -6
- package/dist/targets/cpp/prototype/emit-prototype-array.js +13 -1
- package/dist/targets/cpp/records.js +15 -7
- package/dist/targets/cpp/recursive-containers.js +5 -1
- package/dist/targets/cpp/translation-unit.js +17 -2
- package/package.json +4 -2
- package/src/targets/cpp/runtime/gea_runtime.h +212 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { operationOfResult } from '../identity/ids.js';
|
|
2
2
|
import { closedCallFrameOf, hostTemplateFrameOf } from './call-entry.js';
|
|
3
|
-
import { authenticatedArrayIsArrayCall } from './intrinsic-call-facts.js';
|
|
3
|
+
import { authenticatedArrayIsArrayCall, intrinsicCallFlagsMatch } from './intrinsic-call-facts.js';
|
|
4
4
|
import { nativeClassConstructionOf } from './native-class-construction.js';
|
|
5
5
|
import { allOperationsOf } from './model.js';
|
|
6
6
|
import { observesNativeCarrierOnly, operandsOfIrOperation, resultOfIrOperation } from './queries.js';
|
|
@@ -27,13 +27,18 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
27
27
|
const definitions = new Map();
|
|
28
28
|
const representations = new Map();
|
|
29
29
|
const cellReads = new Map();
|
|
30
|
-
const capturedCells = new
|
|
30
|
+
const capturedCells = new Map();
|
|
31
|
+
const readingBodies = new Map();
|
|
32
|
+
const cellWrites = new Map();
|
|
31
33
|
const bodiesOfFunction = new Map();
|
|
32
34
|
const parameters = new Map();
|
|
33
35
|
const observed = new Set();
|
|
34
36
|
for (const body of input.bodies.values()) {
|
|
35
|
-
for (const declaration of body.facts?.capturedDeclarations ?? [])
|
|
36
|
-
capturedCells.
|
|
37
|
+
for (const declaration of body.facts?.capturedDeclarations ?? []) {
|
|
38
|
+
const capturing = capturedCells.get(declaration) ?? new Set();
|
|
39
|
+
capturing.add(body);
|
|
40
|
+
capturedCells.set(declaration, capturing);
|
|
41
|
+
}
|
|
37
42
|
const source = body.sourceOwner;
|
|
38
43
|
const implementations = bodiesOfFunction.get(source) ?? [];
|
|
39
44
|
implementations.push(body);
|
|
@@ -64,10 +69,15 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
64
69
|
}
|
|
65
70
|
if (operation.kind === 'parameter')
|
|
66
71
|
formals.set(operation.ordinal, operation.result.id);
|
|
72
|
+
if (operation.kind === 'binding-write')
|
|
73
|
+
cellWrites.set(operation.declaration, (cellWrites.get(operation.declaration) ?? 0) + 1);
|
|
67
74
|
if (operation.kind === 'binding-read') {
|
|
68
75
|
const list = cellReads.get(operation.declaration) ?? [];
|
|
69
76
|
list.push({ value: operation.result.id, owner: body.sourceOwner });
|
|
70
77
|
cellReads.set(operation.declaration, list);
|
|
78
|
+
const reading = readingBodies.get(operation.declaration) ?? new Set();
|
|
79
|
+
reading.add(body);
|
|
80
|
+
readingBodies.set(operation.declaration, reading);
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
parameters.set(body, formals);
|
|
@@ -89,14 +99,52 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
89
99
|
const consumers = new Map();
|
|
90
100
|
const pending = [root];
|
|
91
101
|
const cursors = new Set();
|
|
102
|
+
// Fresh objects the handle was stored into as a field (`{ params: view }`):
|
|
103
|
+
// the handle is reachable through each, so each is followed like an alias,
|
|
104
|
+
// and every use of it must be one that cannot expose or mutate the handle.
|
|
105
|
+
const containers = new Set();
|
|
92
106
|
const retain = (value) => {
|
|
93
107
|
const carrier = representations.get(value);
|
|
94
108
|
if (carrier === undefined || carrier.kind === 'dynamic')
|
|
95
109
|
return false;
|
|
96
|
-
if (holdsDictionary(carrier) || cursors.has(value))
|
|
110
|
+
if (holdsDictionary(carrier) || cursors.has(value) || containers.has(value))
|
|
97
111
|
pending.push(value);
|
|
98
112
|
return true;
|
|
99
113
|
};
|
|
114
|
+
const contain = (value) => {
|
|
115
|
+
const carrier = representations.get(value);
|
|
116
|
+
if (carrier === undefined || carrier.kind === 'dynamic')
|
|
117
|
+
return false;
|
|
118
|
+
containers.add(value);
|
|
119
|
+
pending.push(value);
|
|
120
|
+
return true;
|
|
121
|
+
};
|
|
122
|
+
// Every alias step from a holder keeps following it as a holder.
|
|
123
|
+
let followingHolder = false;
|
|
124
|
+
const follow = (value) => (followingHolder ? holderStep(value) : retain(value));
|
|
125
|
+
// A value reached from a holder can itself be a holder (a nested object, a
|
|
126
|
+
// phi of two holders, a holder handed to a closed callee's parameter).
|
|
127
|
+
const objectLike = (carrier) => carrier.kind === 'optional'
|
|
128
|
+
? objectLike(carrier.payload)
|
|
129
|
+
: carrier.kind === 'borrowed-ref'
|
|
130
|
+
? objectLike(carrier.referent)
|
|
131
|
+
: carrier.kind === 'tagged-union'
|
|
132
|
+
? carrier.arms.some((arm) => objectLike(arm.value))
|
|
133
|
+
: carrier.kind === 'record' ||
|
|
134
|
+
carrier.kind === 'record-with-index' ||
|
|
135
|
+
carrier.kind === 'native-record-ref' ||
|
|
136
|
+
carrier.kind === 'class-ref' ||
|
|
137
|
+
carrier.kind === 'array-object';
|
|
138
|
+
const holderStep = (value) => {
|
|
139
|
+
const carrier = representations.get(value);
|
|
140
|
+
if (carrier === undefined || carrier.kind === 'dynamic')
|
|
141
|
+
return false;
|
|
142
|
+
return holdsDictionary(carrier) ? retain(value) : objectLike(carrier) ? contain(value) : true;
|
|
143
|
+
};
|
|
144
|
+
const freshObject = (value) => {
|
|
145
|
+
const definition = definitions.get(value);
|
|
146
|
+
return definition?.kind === 'allocate-record' || definition?.kind === 'allocate-ordinary-object';
|
|
147
|
+
};
|
|
100
148
|
while (pending.length) {
|
|
101
149
|
const value = pending.pop();
|
|
102
150
|
if (aliases.has(value))
|
|
@@ -117,20 +165,87 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
117
165
|
continue;
|
|
118
166
|
return null;
|
|
119
167
|
}
|
|
168
|
+
// The handle stored as a field of a fresh object: that object now
|
|
169
|
+
// reaches it, so it is followed in its turn.
|
|
170
|
+
if (operation.kind === 'define-own-property' && operation.value.value === value && !containers.has(value)) {
|
|
171
|
+
if (operation.receiver.value === value || operation.key.value === value || !freshObject(operation.receiver.value))
|
|
172
|
+
return null;
|
|
173
|
+
if (!contain(operation.receiver.value))
|
|
174
|
+
return null;
|
|
175
|
+
if (operation.result !== null && !contain(operation.result.id))
|
|
176
|
+
return null;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (operation.kind === 'allocate-record' && !containers.has(value)) {
|
|
180
|
+
if (!contain(operation.result.id))
|
|
181
|
+
return null;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
followingHolder = containers.has(value);
|
|
185
|
+
if (containers.has(value)) {
|
|
186
|
+
switch (operation.kind) {
|
|
187
|
+
// Writing another value into the holder neither reads nor exposes
|
|
188
|
+
// the handle; a read of a member hands out at most the handle
|
|
189
|
+
// itself, which is then followed as an alias.
|
|
190
|
+
case 'define-own-property':
|
|
191
|
+
case 'set':
|
|
192
|
+
if (operation.receiver.value !== value || operation.key.value === value || operation.value.value === value)
|
|
193
|
+
return null;
|
|
194
|
+
continue;
|
|
195
|
+
case 'get':
|
|
196
|
+
if (operation.receiver.value !== value || operation.key.value === value || !holderStep(operation.result.id))
|
|
197
|
+
return null;
|
|
198
|
+
continue;
|
|
199
|
+
case 'has-property':
|
|
200
|
+
if (operation.receiver.value !== value || operation.key.value === value)
|
|
201
|
+
return null;
|
|
202
|
+
continue;
|
|
203
|
+
case 'own-property-keys':
|
|
204
|
+
if (operation.receiver.value !== value)
|
|
205
|
+
return null;
|
|
206
|
+
continue;
|
|
207
|
+
// A holder converted to another record carrier still reaches the
|
|
208
|
+
// handle (a view, or a copy of the field), so the result is a
|
|
209
|
+
// holder too; into `dynamic` it escapes.
|
|
210
|
+
case 'convert': {
|
|
211
|
+
if (operation.source.value !== value || operation.rebuild !== undefined)
|
|
212
|
+
return null;
|
|
213
|
+
const node = input.conversions.nodeById(operation.conversionUse);
|
|
214
|
+
if (node === null || node.capability.kind === 'never' || !contain(operation.result.id))
|
|
215
|
+
return null;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
default:
|
|
219
|
+
// phi, cell writes, closed calls, constructions, converts and
|
|
220
|
+
// tests: the same rules as for the handle itself, below.
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
120
224
|
switch (operation.kind) {
|
|
121
225
|
case 'phi':
|
|
122
|
-
if (!
|
|
226
|
+
if (!follow(operation.result.id))
|
|
123
227
|
return null;
|
|
124
228
|
break;
|
|
125
229
|
case 'binding-write': {
|
|
126
230
|
const storage = input.placements.get(operation.declaration)?.storage;
|
|
127
231
|
if (operation.value.value !== value ||
|
|
128
232
|
(storage?.kind !== 'local' && storage?.kind !== 'region') ||
|
|
129
|
-
storage.owner !== use.owner.sourceOwner
|
|
130
|
-
|
|
233
|
+
storage.owner !== use.owner.sourceOwner)
|
|
234
|
+
return null;
|
|
235
|
+
// A cell a closure captures is read from other bodies too. When this
|
|
236
|
+
// is the cell's only write, every read anywhere yields this value, so
|
|
237
|
+
// following all of them covers every path to the handle -- provided
|
|
238
|
+
// each capturing body reads it itself. A capture fact with no read in
|
|
239
|
+
// its body is transitive (a nested closure, or reads this IR no
|
|
240
|
+
// longer shows), so those reads cannot be followed.
|
|
241
|
+
const capturing = capturedCells.get(operation.declaration);
|
|
242
|
+
const captured = capturing !== undefined;
|
|
243
|
+
if (captured &&
|
|
244
|
+
(cellWrites.get(operation.declaration) !== 1 ||
|
|
245
|
+
[...capturing].some((body) => readingBodies.get(operation.declaration)?.has(body) !== true)))
|
|
131
246
|
return null;
|
|
132
247
|
for (const read of cellReads.get(operation.declaration) ?? [])
|
|
133
|
-
if (read.owner !== use.owner.sourceOwner || !
|
|
248
|
+
if ((!captured && read.owner !== use.owner.sourceOwner) || !follow(read.value))
|
|
134
249
|
return null;
|
|
135
250
|
break;
|
|
136
251
|
}
|
|
@@ -149,16 +264,16 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
149
264
|
node.capability.materializer.nativePayloadTransport !== 'preserved'))
|
|
150
265
|
return null;
|
|
151
266
|
}
|
|
152
|
-
else if (!
|
|
267
|
+
else if (!follow(operation.result.id))
|
|
153
268
|
return null;
|
|
154
269
|
break;
|
|
155
270
|
}
|
|
156
271
|
case 'merge-live-arm-rebuild':
|
|
157
|
-
if (operation.source.value !== value || operation.nativeTransport === undefined || !
|
|
272
|
+
if (operation.source.value !== value || operation.nativeTransport === undefined || !follow(operation.result.id))
|
|
158
273
|
return null;
|
|
159
274
|
break;
|
|
160
275
|
case 'get':
|
|
161
|
-
if (operation.receiver.value !== value || operation.key.value === value || !
|
|
276
|
+
if (operation.receiver.value !== value || operation.key.value === value || !follow(operation.result.id))
|
|
162
277
|
return null;
|
|
163
278
|
break;
|
|
164
279
|
case 'has-property':
|
|
@@ -188,7 +303,7 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
188
303
|
if (operation.form === 'require-object-coercible' ||
|
|
189
304
|
operation.form === 'require-iterable-present' ||
|
|
190
305
|
operation.form === 'require-tagged-union-arm')
|
|
191
|
-
if (!
|
|
306
|
+
if (!follow(operation.result.id))
|
|
192
307
|
return null;
|
|
193
308
|
break;
|
|
194
309
|
case 'call': {
|
|
@@ -205,6 +320,14 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
205
320
|
authenticatedArrayIsArrayCall(operation, semantic, rendering, (id) => definitions.get(id) ?? null) &&
|
|
206
321
|
hostTemplateFrameOf(operation, input.conversions, null, input.classes) === true)
|
|
207
322
|
break;
|
|
323
|
+
// `Object.keys`/`getOwnPropertyNames`/`hasOwn` read the queried
|
|
324
|
+
// object's own keys exactly as `own-property-keys` does and return
|
|
325
|
+
// fresh strings or a boolean, never the object or a value from it.
|
|
326
|
+
if (operation.intrinsicOwnKeys === true &&
|
|
327
|
+
operation.arguments[0]?.value === value &&
|
|
328
|
+
operation.arguments.slice(1).every((argument) => argument.value !== value) &&
|
|
329
|
+
intrinsicCallFlagsMatch(operation, semantic, rendering, (id) => definitions.get(id) ?? null))
|
|
330
|
+
break;
|
|
208
331
|
const identity = operation.closedCallee;
|
|
209
332
|
if (identity?.kind !== 'exact' || identity.nativeEntryAbi !== undefined)
|
|
210
333
|
return null;
|
|
@@ -227,7 +350,7 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
227
350
|
if (argument.value !== value)
|
|
228
351
|
continue;
|
|
229
352
|
const target = formal(identity.functionId, ordinal);
|
|
230
|
-
if (target === null || !
|
|
353
|
+
if (target === null || !follow(target))
|
|
231
354
|
return null;
|
|
232
355
|
}
|
|
233
356
|
break;
|
|
@@ -244,7 +367,7 @@ export const createReadOnlyDictionaryAuthority = (input) => {
|
|
|
244
367
|
if (argument.value !== value)
|
|
245
368
|
continue;
|
|
246
369
|
const target = formal(entry.functionId, ordinal);
|
|
247
|
-
if (target === null || !
|
|
370
|
+
if (target === null || !follow(target))
|
|
248
371
|
return null;
|
|
249
372
|
}
|
|
250
373
|
break;
|
|
@@ -2539,7 +2539,13 @@ export const reflectionExposureOf = (bodies, classes, deriver, options) => {
|
|
|
2539
2539
|
else if (objectSurfacesOf(operand.representation).length > 0 ||
|
|
2540
2540
|
carriesCallable(operand.representation) ||
|
|
2541
2541
|
isDeferredCarrier(operand.representation))
|
|
2542
|
-
|
|
2542
|
+
// A live view published past the boundary answers its dynamic
|
|
2543
|
+
// protocol from its ORIGINAL (`gea::dictionary::aliasOf` reads through
|
|
2544
|
+
// `record::nativeViewRoute`'s owner), so every original behind it
|
|
2545
|
+
// crosses too: a merged options record viewed as `DbOptions` and
|
|
2546
|
+
// handed on as `Record<string, any>` otherwise enumerated its keys and
|
|
2547
|
+
// read every value as `undefined`.
|
|
2548
|
+
promoteLogicalReceiver(operand.representation, `unknown-operation-boundary:${operation.kind}${operation.kind === 'compute' ? `:${operation.form}:${operation.operator}` : ''}${operation.kind === 'convert' && promotionWatch !== undefined ? `:${convertCauseOf(operation)}` : ''}`);
|
|
2543
2549
|
// An unknown iterator/await can produce an object independently from its
|
|
2544
2550
|
// input's representation. Inventory is not a substitute for this edge.
|
|
2545
2551
|
if ((operation.kind === 'iterator-next' || operation.kind === 'await') && operation.result !== null)
|
package/dist/ir/shake.js
CHANGED
|
@@ -131,6 +131,10 @@ export const effectOf = (operation) => {
|
|
|
131
131
|
case 'commonjs-require':
|
|
132
132
|
case 'commonjs-binding-set':
|
|
133
133
|
return 'always';
|
|
134
|
+
// Only the realm's namespace slot changes, and an unread namespace makes
|
|
135
|
+
// that first-object identity unobservable.
|
|
136
|
+
case 'module-namespace':
|
|
137
|
+
return 'pure';
|
|
134
138
|
// Everything else is kept: a property read may run an accessor or reach a
|
|
135
139
|
// host, an iterator step runs the protocol, an element operation mutates a
|
|
136
140
|
// host tree, a call runs the program, and a catch binding is the shape of
|
|
@@ -447,7 +451,7 @@ const sliceBody = (body, placements, liveCells, structuralViewScopes) => {
|
|
|
447
451
|
}
|
|
448
452
|
}
|
|
449
453
|
}
|
|
450
|
-
// `String(x)`, `Number(x)` and `Boolean(x)` run the same OrdinaryToPrimitive
|
|
454
|
+
// `String(x)`, `Number(x)`, `BigInt(x)` and `Boolean(x)` run the same OrdinaryToPrimitive
|
|
451
455
|
// on their argument, and they are CALLS -- a `native-handle` callee named by
|
|
452
456
|
// the host -- not the `convert`/`compute` the clause above sees. Without
|
|
453
457
|
// this the method a class declares was shaken away while the printer's own
|
|
@@ -459,7 +463,10 @@ const sliceBody = (body, placements, liveCells, structuralViewScopes) => {
|
|
|
459
463
|
// the compilation -- the same narrowness the clause above is written for.
|
|
460
464
|
if (operation.kind === 'call' && operation.callee.representation.kind === 'native-handle') {
|
|
461
465
|
const protocol = operation.callee.representation.protocol;
|
|
462
|
-
if (protocol === 'StringConstructor' ||
|
|
466
|
+
if (protocol === 'StringConstructor' ||
|
|
467
|
+
protocol === 'NumberConstructor' ||
|
|
468
|
+
protocol === 'BigIntConstructor' ||
|
|
469
|
+
protocol === 'BooleanConstructor') {
|
|
463
470
|
for (const argument of operation.arguments) {
|
|
464
471
|
for (const scope of receiverClassScopes(argument.representation, structuralViewScopes)) {
|
|
465
472
|
spelledKeys.add(`${scope}#toString`);
|
|
@@ -683,11 +690,24 @@ const structuralViewScopesOf = (classes, deriver, bodies) => {
|
|
|
683
690
|
const targetShapes = new Set();
|
|
684
691
|
const documentViewers = new Set();
|
|
685
692
|
for (const body of bodies) {
|
|
686
|
-
|
|
687
|
-
|
|
693
|
+
// `receiverClassScopes` looks a record up through the optionals, unions
|
|
694
|
+
// and borrows that hold it, so a record reached only as an arm (a
|
|
695
|
+
// `parent?: { bsonOptions? } | Db` formal) is a target too: missing it
|
|
696
|
+
// left that arm's reads naming no class, and the getter a view of a
|
|
697
|
+
// class into it calls was pruned.
|
|
698
|
+
const addShapes = (carrier) => {
|
|
699
|
+
if (carrier.kind === 'record' || carrier.kind === 'record-with-index' || carrier.kind === 'native-record-ref')
|
|
688
700
|
targetShapes.add(carrier.shapeId);
|
|
689
|
-
|
|
690
|
-
|
|
701
|
+
else if (carrier.kind === 'optional')
|
|
702
|
+
addShapes(carrier.payload);
|
|
703
|
+
else if (carrier.kind === 'borrowed-ref')
|
|
704
|
+
addShapes(carrier.referent);
|
|
705
|
+
else if (carrier.kind === 'tagged-union')
|
|
706
|
+
for (const arm of carrier.arms)
|
|
707
|
+
addShapes(arm.value);
|
|
708
|
+
};
|
|
709
|
+
for (const carrier of body.values.values())
|
|
710
|
+
addShapes(carrier);
|
|
691
711
|
// A class instance converted into an open `any` document is that document
|
|
692
712
|
// (`gea::dictionary::aliasOf`), so a key read through the document names
|
|
693
713
|
// that class's member -- a prototype getter included.
|
|
@@ -116,3 +116,23 @@ export interface TypedComputedWriteRecipe {
|
|
|
116
116
|
* admitted, and it is the accessor case alone that is refused here.
|
|
117
117
|
*/
|
|
118
118
|
export declare const typedComputedWriteRecipeOf: (graph: SemanticGraph, operation: PropertyOperation, receiver: Representation, deriver: RepresentationDeriver, classes: ReadonlyMap<DeclarationId, ClassLayout>) => TypedComputedWriteRecipe | null;
|
|
119
|
+
/** One key of a correlated copy: the carrier of the field the stored value was read from. */
|
|
120
|
+
export interface CorrelatedSourceField {
|
|
121
|
+
readonly key: string;
|
|
122
|
+
readonly source: Representation;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* `target[ name ] = source[ name ]` over a closed key domain stores, for each
|
|
126
|
+
* key, exactly what the source holds under that same key -- `ca` copies the
|
|
127
|
+
* source's `ca`, never its `rejectUnauthorized`. The stored value's own
|
|
128
|
+
* carrier is the union across every key, so a store into one key's slot
|
|
129
|
+
* would otherwise have to check, at run time, an arm the copy already fixes.
|
|
130
|
+
*
|
|
131
|
+
* Both keys must be reads of one immutable binding, and the value must be the
|
|
132
|
+
* source read itself, not a value held across statements: the key is then the
|
|
133
|
+
* same string at the read and at the store. Each key's source carrier is the
|
|
134
|
+
* field the source's static type declares for it; a key with no plain data
|
|
135
|
+
* field on the source (an accessor, an index signature) names no carrier, and
|
|
136
|
+
* the whole copy is left uncorrelated.
|
|
137
|
+
*/
|
|
138
|
+
export declare const correlatedSourceFieldsOf: (graph: SemanticGraph, operation: PropertyOperation, deriver: RepresentationDeriver) => readonly CorrelatedSourceField[] | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withoutFunctionSpecialization } from '../identity/ids.js';
|
|
2
2
|
import { declaredRecordFieldOf } from '../projection/fields.js';
|
|
3
|
+
import { describedFieldRepresentationOf } from '../projection/native-object-data.js';
|
|
3
4
|
import { representationKey } from '../representation/model.js';
|
|
4
5
|
import { operandOf } from '../semantics/model/operands.js';
|
|
5
6
|
/**
|
|
@@ -269,3 +270,58 @@ const classAccessorKeysOf = (classes, declaration) => {
|
|
|
269
270
|
}
|
|
270
271
|
return keys;
|
|
271
272
|
};
|
|
273
|
+
/**
|
|
274
|
+
* `target[ name ] = source[ name ]` over a closed key domain stores, for each
|
|
275
|
+
* key, exactly what the source holds under that same key -- `ca` copies the
|
|
276
|
+
* source's `ca`, never its `rejectUnauthorized`. The stored value's own
|
|
277
|
+
* carrier is the union across every key, so a store into one key's slot
|
|
278
|
+
* would otherwise have to check, at run time, an arm the copy already fixes.
|
|
279
|
+
*
|
|
280
|
+
* Both keys must be reads of one immutable binding, and the value must be the
|
|
281
|
+
* source read itself, not a value held across statements: the key is then the
|
|
282
|
+
* same string at the read and at the store. Each key's source carrier is the
|
|
283
|
+
* field the source's static type declares for it; a key with no plain data
|
|
284
|
+
* field on the source (an accessor, an index signature) names no carrier, and
|
|
285
|
+
* the whole copy is left uncorrelated.
|
|
286
|
+
*/
|
|
287
|
+
export const correlatedSourceFieldsOf = (graph, operation, deriver) => {
|
|
288
|
+
if (operation.internalMethod !== 'set' || !operation.keyIsComputed)
|
|
289
|
+
return undefined;
|
|
290
|
+
const keys = computedPropertyKeyTextsOf(graph, operation);
|
|
291
|
+
if (keys === undefined || keys.length < 2)
|
|
292
|
+
return undefined;
|
|
293
|
+
const producerOf = (source) => {
|
|
294
|
+
if (source?.source.kind !== 'result')
|
|
295
|
+
return undefined;
|
|
296
|
+
const id = graph.results.get(source.source.result);
|
|
297
|
+
return id === undefined ? undefined : graph.operations.get(id);
|
|
298
|
+
};
|
|
299
|
+
// A plain `=` assignment evaluates to exactly its right-hand value, so the
|
|
300
|
+
// stored value is that value whichever of the two the set consumes.
|
|
301
|
+
let read = producerOf(operandOf(operation, 'value'));
|
|
302
|
+
if (read?.family === 'computation' && read.form === 'assignment' && read.operator === '=')
|
|
303
|
+
read = producerOf(operandOf(read, 'value'));
|
|
304
|
+
if (read?.family !== 'property' || read.internalMethod !== 'get' || !read.keyIsComputed)
|
|
305
|
+
return undefined;
|
|
306
|
+
const bindingOf = (key) => {
|
|
307
|
+
if (key?.source.kind !== 'result')
|
|
308
|
+
return undefined;
|
|
309
|
+
const id = graph.results.get(key.source.result);
|
|
310
|
+
const binding = id === undefined ? undefined : graph.operations.get(id);
|
|
311
|
+
return binding?.family === 'binding' && binding.action === 'read' && !binding.mutable ? binding.declaration : undefined;
|
|
312
|
+
};
|
|
313
|
+
const storedKey = bindingOf(operandOf(operation, 'key'));
|
|
314
|
+
if (storedKey === undefined || storedKey !== bindingOf(operandOf(read, 'key')))
|
|
315
|
+
return undefined;
|
|
316
|
+
const source = operandOf(read, 'receiver')?.type;
|
|
317
|
+
if (source === undefined)
|
|
318
|
+
return undefined;
|
|
319
|
+
const fields = [];
|
|
320
|
+
for (const key of keys) {
|
|
321
|
+
const field = describedFieldRepresentationOf(deriver, source, key);
|
|
322
|
+
if (field === null)
|
|
323
|
+
return undefined;
|
|
324
|
+
fields.push({ key, source: field });
|
|
325
|
+
}
|
|
326
|
+
return fields;
|
|
327
|
+
};
|
|
@@ -354,7 +354,8 @@ export const projectBindingPlacements = (input) => {
|
|
|
354
354
|
return placements;
|
|
355
355
|
};
|
|
356
356
|
/**
|
|
357
|
-
* The block-scoped bindings of a run-once region
|
|
357
|
+
* The block-scoped bindings of a run-once region: each lives in the region
|
|
358
|
+
* body's frame, never in a file-scope cell.
|
|
358
359
|
*
|
|
359
360
|
* A module-level `let`/`const` inside a loop is a new binding every time its
|
|
360
361
|
* block is entered (ECMA-262 14.7.4.2 CreatePerIterationEnvironment for a
|
|
@@ -362,32 +363,26 @@ export const projectBindingPlacements = (input) => {
|
|
|
362
363
|
* must hold its own. One file-scope cell cannot be that: every closure read
|
|
363
364
|
* the last value written. Such a binding is visible only to the region's own
|
|
364
365
|
* code and closures made inside its block, so it lives in the region body's
|
|
365
|
-
* frame and is captured like any function local.
|
|
366
|
-
*
|
|
366
|
+
* frame and is captured like any function local.
|
|
367
|
+
*
|
|
368
|
+
* One no closure names would be correct as a file-scope cell too, and was
|
|
369
|
+
* one, at a cost a module-level loop pays on every turn: a global counter is
|
|
370
|
+
* a `double` (only write-once cells narrow), a store through the `double*` the
|
|
371
|
+
* loop writes may alias it so it is reloaded every iteration, and the
|
|
372
|
+
* dense-window proof wants a local induction variable. Nothing outside the
|
|
373
|
+
* block can name the binding, so the frame is always available and is the
|
|
374
|
+
* only placement the loop optimizations see.
|
|
367
375
|
*/
|
|
368
376
|
const regionFrameCells = (graph) => {
|
|
369
|
-
const
|
|
377
|
+
const cells = new Set();
|
|
370
378
|
for (const operation of graph.operations.values()) {
|
|
371
379
|
if (operation.family !== 'binding' || !operation.blockScoped || operation.caller.kind === 'function')
|
|
372
380
|
continue;
|
|
373
381
|
if (operation.action !== 'initialize' && operation.action !== 'declare')
|
|
374
382
|
continue;
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
const captured = new Set();
|
|
378
|
-
if (candidates.size === 0)
|
|
379
|
-
return captured;
|
|
380
|
-
for (const operation of graph.operations.values()) {
|
|
381
|
-
const declaration = operation.family === 'binding' ? operation.declaration : operation.family === 'property' ? operation.resolvedBinding : undefined;
|
|
382
|
-
if (declaration === undefined)
|
|
383
|
-
continue;
|
|
384
|
-
const region = candidates.get(declaration);
|
|
385
|
-
if (region === undefined)
|
|
386
|
-
continue;
|
|
387
|
-
if (operation.caller.kind === 'function' || operation.caller.regionId !== region)
|
|
388
|
-
captured.add(declaration);
|
|
383
|
+
cells.add(operation.declaration);
|
|
389
384
|
}
|
|
390
|
-
return
|
|
385
|
+
return cells;
|
|
391
386
|
};
|
|
392
387
|
/**
|
|
393
388
|
* Every read of a cell, by the declaration it reads, in `graph.operations` order.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { walkRepresentation } from '../representation/model.js';
|
|
2
|
-
import { classPresentMethodArmsOf, methodCopyHeldBy } from './dispatch.js';
|
|
2
|
+
import { classDynamicMethodShadowOf, classPresentMethodArmsOf, methodCopyHeldBy } from './dispatch.js';
|
|
3
3
|
import { abiOfCallee } from './callee.js';
|
|
4
4
|
import { dynamicFieldAbsencePolicy } from '../representation/field-descriptor-policy.js';
|
|
5
5
|
/** The record layout a shape derives to, or `null` when it carries none. */
|
|
@@ -415,6 +415,12 @@ export const nativeClassMethodValueSourcesOf = (classes, declaration, key, proje
|
|
|
415
415
|
const own = classMethodOverrideOf(classes, arm.allocation, key);
|
|
416
416
|
if (own !== null)
|
|
417
417
|
sources.push(own.value);
|
|
418
|
+
// A shadow a runtime-keyed write installed is read out of the expando
|
|
419
|
+
// table as the slot would have held it: the method's own convention
|
|
420
|
+
// without a receiver -- the arm every method read selects beneath a
|
|
421
|
+
// missing own slot (`native-method-read.ts`, `native-method-frames.ts`).
|
|
422
|
+
else if (classDynamicMethodShadowOf(classes, arm.allocation, key))
|
|
423
|
+
sources.push({ kind: 'function-value-dispatch', abi: { ...abi, receiver: null } });
|
|
418
424
|
const prototype = classMethodOverrideOf(classes, owner.declaration, key);
|
|
419
425
|
if (prototype !== null)
|
|
420
426
|
sources.push(prototype.value);
|
|
@@ -24,7 +24,14 @@ export declare const describedFieldRepresentationOf: (deriver: Pick<Representati
|
|
|
24
24
|
* asserted field type cannot widen it, and differing actual writers require
|
|
25
25
|
* a separately published storage join rather than a dynamic carrier.
|
|
26
26
|
*/
|
|
27
|
-
export declare const nativeObjectDataStorageOf: (schema: NativeObjectDataSlotSchema, deriver: Pick<RepresentationDeriver, "deriveStored" | "nativeCallableConventions"> & Partial<Pick<RepresentationDeriver, "layoutOf"
|
|
27
|
+
export declare const nativeObjectDataStorageOf: (schema: NativeObjectDataSlotSchema, deriver: Pick<RepresentationDeriver, "deriveStored" | "nativeCallableConventions"> & Partial<Pick<RepresentationDeriver, "layoutOf">>,
|
|
28
|
+
/**
|
|
29
|
+
* The key's storage is the object's dynamic own-property table, which open
|
|
30
|
+
* writers already fill with Values: a writer whose own carrier is a Value
|
|
31
|
+
* (`copy.$scope = deserializeValue(value.$scope)` with an `any` result)
|
|
32
|
+
* stores exactly that, with nothing boxed.
|
|
33
|
+
*/
|
|
34
|
+
table?: boolean) => NativeObjectDataStorage | null;
|
|
28
35
|
/** A key such consumers can also write or read shares their one storage: the
|
|
29
36
|
* object's dynamic own-property table, the descriptor an open `Object.assign`
|
|
30
37
|
* writes. A typed store still installs its own native carrier there, but
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { representationKey } from '../representation/model.js';
|
|
2
2
|
import { nativeObjectDataSlotSchemasOf } from '../semantics/native-object-data-slots.js';
|
|
3
3
|
import { operandOf, resultOf } from '../semantics/model/operands.js';
|
|
4
|
-
import { nativeCallableDataCarrierHasStorageIdentity, nativeCallableDataValueRepresentationOf, storedSourceValueOf } from '../representation/native-callable-data-storage.js';
|
|
4
|
+
import { nativeCallableDataCarrierHasStorageIdentity as carrierHasStorageIdentity, nativeCallableDataValueRepresentationOf, storedSourceValueOf } from '../representation/native-callable-data-storage.js';
|
|
5
5
|
import { objectPrototypeMemberNames } from '../representation/record-fields.js';
|
|
6
6
|
/** The carrier a spread's copy stores for `key`: the source carrier's own
|
|
7
7
|
* field, exactly what `spread-conversions.ts` hands the copy's native store.
|
|
@@ -49,9 +49,17 @@ export const describedFieldRepresentationOf = (deriver, type, key) => {
|
|
|
49
49
|
* asserted field type cannot widen it, and differing actual writers require
|
|
50
50
|
* a separately published storage join rather than a dynamic carrier.
|
|
51
51
|
*/
|
|
52
|
-
export const nativeObjectDataStorageOf = (schema, deriver
|
|
52
|
+
export const nativeObjectDataStorageOf = (schema, deriver,
|
|
53
|
+
/**
|
|
54
|
+
* The key's storage is the object's dynamic own-property table, which open
|
|
55
|
+
* writers already fill with Values: a writer whose own carrier is a Value
|
|
56
|
+
* (`copy.$scope = deserializeValue(value.$scope)` with an `any` result)
|
|
57
|
+
* stores exactly that, with nothing boxed.
|
|
58
|
+
*/
|
|
59
|
+
table = false) => {
|
|
53
60
|
if (schema.blockers.length !== 0 || schema.writers.length === 0 || schema.key === '__proto__')
|
|
54
61
|
return null;
|
|
62
|
+
const nativeCallableDataCarrierHasStorageIdentity = (source) => (table && source.kind === 'dynamic') || carrierHasStorageIdentity(source);
|
|
55
63
|
const writers = [];
|
|
56
64
|
const bulkValueRepresentationOf = (value) => storedSourceValueOf(deriver, { callable: value.source.kind === 'function' ? value.source.callable : null, type: value.type });
|
|
57
65
|
for (const writer of schema.writers) {
|
|
@@ -101,9 +109,13 @@ export const nativeObjectDataStorageOf = (schema, deriver) => {
|
|
|
101
109
|
// The local semantic origin map intentionally does not invent parameter
|
|
102
110
|
// aliases. When the source session closes that domain, its complete slot
|
|
103
111
|
// inputs must agree with this storage too, including writes in the called
|
|
104
|
-
// body and values copied by other assignments to the same allocation.
|
|
112
|
+
// body and values copied by other assignments to the same allocation. A
|
|
113
|
+
// slot's possible absence is no stored value: a read answers it from the
|
|
114
|
+
// key's presence, as every extension read already does.
|
|
105
115
|
if (schema.storedValues !== undefined)
|
|
106
116
|
for (const value of schema.storedValues) {
|
|
117
|
+
if (value.absence === true)
|
|
118
|
+
continue;
|
|
107
119
|
const source = bulkValueRepresentationOf(value);
|
|
108
120
|
if (!source || !nativeCallableDataCarrierHasStorageIdentity(source) || representationKey(source) !== representationKey(storage))
|
|
109
121
|
return null;
|
|
@@ -127,7 +139,7 @@ const dynamicTableBlockers = new Set([
|
|
|
127
139
|
* the same key. `null` when the key has no such table storage. */
|
|
128
140
|
export const nativeObjectDataTableStorageOf = (schema, deriver) => schema.blockers.length === 0 || schema.blockers.some((blocker) => !dynamicTableBlockers.has(blocker.kind))
|
|
129
141
|
? null
|
|
130
|
-
: ((storage) => (storage === null ? null : { ...storage, schema }))(nativeObjectDataStorageOf({ ...schema, blockers: [] }, deriver));
|
|
142
|
+
: ((storage) => (storage === null ? null : { ...storage, schema }))(nativeObjectDataStorageOf({ ...schema, blockers: [] }, deriver, true));
|
|
131
143
|
/** Descriptor-object aliases and structural receiver aliases use the same
|
|
132
144
|
* canonical allocation census. No shape-wide row grants source identity.
|
|
133
145
|
*/
|