@swf2es/codegen 0.1.41 → 0.1.42
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/codegen.wasm +0 -0
- package/dist/index.d.ts +25 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +332 -16
- package/dist/index.js.map +1 -1
- package/dist/zig.d.ts +2 -0
- package/dist/zig.d.ts.map +1 -1
- package/dist/zig.js +2 -0
- package/dist/zig.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +430 -25
- package/src/zig.ts +4 -0
package/dist/codegen.wasm
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -161,17 +161,23 @@ export type MoveAbort =
|
|
|
161
161
|
| "refused"
|
|
162
162
|
/** A call meanwhile could not be journaled, so the spare could not catch up. */
|
|
163
163
|
| "unjournaled"
|
|
164
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* The domain was reset, recovered from a panic, or rebuilt in place
|
|
166
|
+
* meanwhile; or a revival took the place of a move that only compacted
|
|
167
|
+
* (see reviveDomain).
|
|
168
|
+
*/
|
|
165
169
|
| "superseded";
|
|
166
170
|
/**
|
|
167
|
-
* compactStep's moves: started, completed, and given up by why;
|
|
168
|
-
*
|
|
169
|
-
*
|
|
171
|
+
* compactStep's moves: started, completed, and given up by why; the
|
|
172
|
+
* domains revived by those completed (see reviveDomain); and of the last
|
|
173
|
+
* one completed, the calls replayed into its spare after its rebuild, and
|
|
174
|
+
* the bytes of its snapshot, which recovery keeps as its checkpoint.
|
|
170
175
|
*/
|
|
171
176
|
export interface MoveCounts {
|
|
172
177
|
started: number;
|
|
173
178
|
completed: number;
|
|
174
179
|
aborted: Record<MoveAbort, number>;
|
|
180
|
+
revived: number;
|
|
175
181
|
lastCaughtUp: number;
|
|
176
182
|
lastSavedBytes: number;
|
|
177
183
|
}
|
|
@@ -278,9 +284,22 @@ export interface Codegen {
|
|
|
278
284
|
* ancestors, the first of them a child of a live domain: given all their
|
|
279
285
|
* ABCs again by their indices, as they were added, their ABCs link as
|
|
280
286
|
* they did, by one rebuild at most, and what they found holds. Throws if
|
|
281
|
-
* they cannot be.
|
|
287
|
+
* they cannot be. True once live.
|
|
288
|
+
*
|
|
289
|
+
* A rebuild of a large domain takes seconds, so `stepped`, a revival that
|
|
290
|
+
* needs one is made by a move into the spare instance instead, a part at
|
|
291
|
+
* a time as compactStep moves a domain to compact it, the domain staying
|
|
292
|
+
* evicted here until the spare takes this instance's place: then false,
|
|
293
|
+
* and compactStep carries the move on ("moving" until it is done), while
|
|
294
|
+
* the host goes on compiling elsewhere; isLive tells when it is live, and
|
|
295
|
+
* calling this again meanwhile returns false. The host asks again with
|
|
296
|
+
* the chain's ABCs as they are then: a chain an eviction lengthened needs
|
|
297
|
+
* the new ancestor's, and those of a domain revived meanwhile are not
|
|
298
|
+
* taken. A revival that needs no rebuild, or only a small one, is done at
|
|
299
|
+
* once, and so is one whose move was given up as failed, in place as
|
|
300
|
+
* without `stepped`; without it, a revival under way finishes its move.
|
|
282
301
|
*/
|
|
283
|
-
reviveDomain(appDomain: number, abcs: Map<number, Uint8Array
|
|
302
|
+
reviveDomain(appDomain: number, abcs: Map<number, Uint8Array>, stepped?: boolean): boolean;
|
|
284
303
|
/** Record a definition an application domain has found; it holds for the ABCs added after. */
|
|
285
304
|
found(definition: FoundDefinition): void;
|
|
286
305
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,eAAe,EAAE,WAAW,EAAoC,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAUvD,OAAO,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,GAAG,EAA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,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC;IACvE;;;;OAIG;IACH,mBAAmB,CACjB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EAAE,GACf,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,CAAC;IAC5F;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACxC,0HAA0H;IAC1H,WAAW,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA+oDhF"}
|
package/dist/index.js
CHANGED
|
@@ -220,11 +220,18 @@ export async function createCodegen(module) {
|
|
|
220
220
|
if (!loaded) {
|
|
221
221
|
return false;
|
|
222
222
|
}
|
|
223
|
-
for (const
|
|
224
|
-
if (into.
|
|
223
|
+
for (const domain of saved.revive?.domains ?? []) {
|
|
224
|
+
if (into.domainLoadRevive(domain) !== 0) {
|
|
225
225
|
return false;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
+
for (const abcs of [saved.abcs, saved.revive?.abcs ?? []]) {
|
|
229
|
+
for (const [index, abc] of abcs) {
|
|
230
|
+
if (into.domainLoadAbc(index, abc) !== 0) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
228
235
|
return into.domainLoadRebuild();
|
|
229
236
|
};
|
|
230
237
|
// The rebuild domainCompact, domainRevive or domainLoadRebuild started in
|
|
@@ -285,6 +292,7 @@ export async function createCodegen(module) {
|
|
|
285
292
|
started: 0,
|
|
286
293
|
completed: 0,
|
|
287
294
|
aborted: { spare: 0, refused: 0, unjournaled: 0, superseded: 0 },
|
|
295
|
+
revived: 0,
|
|
288
296
|
lastCaughtUp: 0,
|
|
289
297
|
lastSavedBytes: 0,
|
|
290
298
|
};
|
|
@@ -295,8 +303,16 @@ export async function createCodegen(module) {
|
|
|
295
303
|
// same domain would likely fail the same way.
|
|
296
304
|
let lettings = 0;
|
|
297
305
|
let retryAt = 0;
|
|
306
|
+
const revivals = [];
|
|
307
|
+
// Whether the last spare could not be instantiated, so that a revival waiting for one is done in place.
|
|
308
|
+
let spareFailed = false;
|
|
298
309
|
const abortMove = (why) => {
|
|
299
310
|
if (move !== null) {
|
|
311
|
+
if (why === "spare" || why === "refused") {
|
|
312
|
+
for (const r of move.revivals) {
|
|
313
|
+
r.failed = true;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
300
316
|
move = null;
|
|
301
317
|
moves.aborted[why]++;
|
|
302
318
|
if (why !== "superseded") {
|
|
@@ -313,8 +329,10 @@ export async function createCodegen(module) {
|
|
|
313
329
|
instantiate(module).then((made) => {
|
|
314
330
|
spare = made;
|
|
315
331
|
making = false;
|
|
332
|
+
spareFailed = false;
|
|
316
333
|
}, () => {
|
|
317
334
|
making = false;
|
|
335
|
+
spareFailed = true;
|
|
318
336
|
});
|
|
319
337
|
}
|
|
320
338
|
};
|
|
@@ -357,8 +375,10 @@ export async function createCodegen(module) {
|
|
|
357
375
|
let bytes = 0;
|
|
358
376
|
if (checkpoint) {
|
|
359
377
|
bytes += checkpoint.state.byteLength;
|
|
360
|
-
for (const
|
|
361
|
-
|
|
378
|
+
for (const abcs of [checkpoint.abcs, checkpoint.revive?.abcs ?? new Map()]) {
|
|
379
|
+
for (const abc of abcs.values()) {
|
|
380
|
+
bytes += abc.byteLength;
|
|
381
|
+
}
|
|
362
382
|
}
|
|
363
383
|
}
|
|
364
384
|
for (const entry of journal) {
|
|
@@ -517,6 +537,12 @@ export async function createCodegen(module) {
|
|
|
517
537
|
into.domainEvict(entry.appDomain);
|
|
518
538
|
break;
|
|
519
539
|
case "restore":
|
|
540
|
+
// One of a domain a move's load revived (Checkpoint.revive), which
|
|
541
|
+
// this instance, still evicting it, gave back for a revival of
|
|
542
|
+
// another under it: `into` holds it, live.
|
|
543
|
+
if (into.domainState(abcDomains[entry.index] ?? -1) === 0) {
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
520
546
|
if (into.domainRestore(entry.index, entry.bytes) !== 0) {
|
|
521
547
|
throw new Error("a journaled ABC did not restore");
|
|
522
548
|
}
|
|
@@ -592,10 +618,10 @@ export async function createCodegen(module) {
|
|
|
592
618
|
// snapshot of this instance, as a move by compact is, and never reading
|
|
593
619
|
// this instance again, while the host goes on with it, each call it
|
|
594
620
|
// makes journaled and replayed into the spare once the spare has rebuilt.
|
|
595
|
-
const startMove = (into) => {
|
|
621
|
+
const startMove = (into, carried = []) => {
|
|
596
622
|
let saved;
|
|
597
623
|
try {
|
|
598
|
-
saved = saveCheckpoint();
|
|
624
|
+
saved = withRevivals(saveCheckpoint(), carried);
|
|
599
625
|
}
|
|
600
626
|
catch (error) {
|
|
601
627
|
if (error instanceof CodegenOutOfMemory) {
|
|
@@ -613,24 +639,101 @@ export async function createCodegen(module) {
|
|
|
613
639
|
replayed: 0,
|
|
614
640
|
word: 0,
|
|
615
641
|
restored: new Map(),
|
|
616
|
-
abcs:
|
|
642
|
+
abcs: [],
|
|
643
|
+
given: 0,
|
|
644
|
+
revivals: carried,
|
|
645
|
+
evicted: new Set([...journalDomains.keys()].filter((d) => wasm.domainState(d) === 1)),
|
|
617
646
|
phase: "load",
|
|
618
647
|
catchUp: 0,
|
|
619
648
|
};
|
|
620
649
|
moves.started++;
|
|
621
650
|
return true;
|
|
622
651
|
};
|
|
652
|
+
// `saved` with `carried` revived by its load, their ABCs' bytes joined,
|
|
653
|
+
// each once. A revival's ABCs were gathered when it was asked for: those
|
|
654
|
+
// of domains revived since, live in the snapshot, which holds them, are
|
|
655
|
+
// left out, else the load would take one twice and refuse the move. The
|
|
656
|
+
// chain's states here are the snapshot's, for a snapshot taken now and for
|
|
657
|
+
// one a revival is folded into (see scheduleRevivals).
|
|
658
|
+
const withRevivals = (saved, carried) => {
|
|
659
|
+
if (!carried.length) {
|
|
660
|
+
return saved;
|
|
661
|
+
}
|
|
662
|
+
const domains = [...(saved.revive?.domains ?? [])];
|
|
663
|
+
const abcs = new Map(saved.revive?.abcs ?? []);
|
|
664
|
+
for (const r of carried) {
|
|
665
|
+
// One an earlier revival's chain takes in is revived by that one's load.
|
|
666
|
+
if (!domains.some((d) => inChain(r.appDomain, d))) {
|
|
667
|
+
domains.push(r.appDomain);
|
|
668
|
+
}
|
|
669
|
+
for (const [index, bytes] of r.abcs) {
|
|
670
|
+
if (!abcs.has(index) && !saved.abcs.has(index) && evictedAbc(index)) {
|
|
671
|
+
abcs.set(index, bytes);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return { state: saved.state, abcs: saved.abcs, revive: { domains, abcs } };
|
|
676
|
+
};
|
|
677
|
+
const evictedAbc = (index) => Number.isInteger(index) &&
|
|
678
|
+
index >= 0 &&
|
|
679
|
+
index < abcDomains.length &&
|
|
680
|
+
wasm.domainState(abcDomains[index]) === 1;
|
|
681
|
+
// Domain `appDomain` and its evicted ancestors, the last a child of a live one.
|
|
682
|
+
const evictedChain = (appDomain) => {
|
|
683
|
+
const chain = new Set();
|
|
684
|
+
for (let d = appDomain; d > 0 && wasm.domainState(d) === 1; d = wasm.domainParent(d)) {
|
|
685
|
+
chain.add(d);
|
|
686
|
+
}
|
|
687
|
+
return chain;
|
|
688
|
+
};
|
|
689
|
+
// The domains the load of `m` revived, live in its spare, caught up, that
|
|
690
|
+
// this instance evicts and no revival still wants: those between a
|
|
691
|
+
// revival's domain and its chain's top, the domain dropped since. Evicted
|
|
692
|
+
// in the spare too before it takes this instance's place, else the move
|
|
693
|
+
// would leave them live where a compiler that never moved has them
|
|
694
|
+
// evicted; in order, a parent before its children, which it evicts.
|
|
695
|
+
const unwantedRevived = (m) => {
|
|
696
|
+
if (!m.revivals.length) {
|
|
697
|
+
return [];
|
|
698
|
+
}
|
|
699
|
+
const wanted = new Set();
|
|
700
|
+
for (const r of m.revivals) {
|
|
701
|
+
for (const d of evictedChain(r.appDomain)) {
|
|
702
|
+
wanted.add(d);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
const unwanted = [];
|
|
706
|
+
for (const d of [...journalDomains.keys()].sort((x, y) => x - y)) {
|
|
707
|
+
if (d > 0 &&
|
|
708
|
+
!wanted.has(d) &&
|
|
709
|
+
wasm.domainState(d) === 1 &&
|
|
710
|
+
m.into.domainState(d) === 0 &&
|
|
711
|
+
!unwanted.some((u) => inChain(u, d))) {
|
|
712
|
+
unwanted.push(d);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return unwanted;
|
|
716
|
+
};
|
|
623
717
|
// The spare, rebuilt and caught up, takes this instance's place, as a
|
|
624
718
|
// recovery's does, and the snapshot it rebuilt is the checkpoint, the
|
|
625
719
|
// calls since it the journal.
|
|
626
720
|
const swapMove = (m) => {
|
|
627
721
|
move = null;
|
|
628
722
|
moves.completed++;
|
|
723
|
+
moves.revived += m.revivals.length;
|
|
724
|
+
for (const r of m.revivals) {
|
|
725
|
+
const at = revivals.indexOf(r);
|
|
726
|
+
if (at >= 0) {
|
|
727
|
+
revivals.splice(at, 1);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
629
730
|
const kept = m.entries.filter((entry) => journal.has(entry));
|
|
630
731
|
moves.lastCaughtUp = kept.length;
|
|
631
732
|
moves.lastSavedBytes = m.saved.state.length;
|
|
632
|
-
for (const
|
|
633
|
-
|
|
733
|
+
for (const abcs of [m.saved.abcs, m.saved.revive?.abcs ?? new Map()]) {
|
|
734
|
+
for (const abc of abcs.values()) {
|
|
735
|
+
moves.lastSavedBytes += abc.length;
|
|
736
|
+
}
|
|
634
737
|
}
|
|
635
738
|
journal.clear();
|
|
636
739
|
restores.clear();
|
|
@@ -668,19 +771,28 @@ export async function createCodegen(module) {
|
|
|
668
771
|
abortMove("refused");
|
|
669
772
|
return "none";
|
|
670
773
|
}
|
|
671
|
-
|
|
774
|
+
// domainLoad's MOVE_Limit counts the snapshot alone: the chains
|
|
775
|
+
// revived after it add their ABCs at their weight, three times
|
|
776
|
+
// their bytes, small beside the limit's gigabyte.
|
|
777
|
+
for (const domain of m.saved.revive?.domains ?? []) {
|
|
778
|
+
if (into.domainLoadRevive(domain) !== 0) {
|
|
779
|
+
abortMove("refused");
|
|
780
|
+
return "none";
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
m.abcs = [...m.saved.abcs, ...(m.saved.revive?.abcs ?? [])];
|
|
672
784
|
m.phase = "abcs";
|
|
673
785
|
return "moving";
|
|
674
786
|
case "abcs": {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
if (into.domainLoadAbc(
|
|
787
|
+
if (m.given < m.abcs.length) {
|
|
788
|
+
const [index, bytes] = m.abcs[m.given++];
|
|
789
|
+
if (into.domainLoadAbc(index, bytes) !== 0) {
|
|
678
790
|
abortMove("refused");
|
|
679
791
|
return "none";
|
|
680
792
|
}
|
|
681
793
|
return "moving";
|
|
682
794
|
}
|
|
683
|
-
m.abcs =
|
|
795
|
+
m.abcs = [];
|
|
684
796
|
if (!into.domainLoadRebuild()) {
|
|
685
797
|
abortMove("refused");
|
|
686
798
|
return "none";
|
|
@@ -708,7 +820,16 @@ export async function createCodegen(module) {
|
|
|
708
820
|
m.replayed++;
|
|
709
821
|
}
|
|
710
822
|
if (m.replayed === m.entries.length) {
|
|
823
|
+
const unwanted = unwantedRevived(m);
|
|
824
|
+
for (const domain of unwanted) {
|
|
825
|
+
into.domainEvict(domain);
|
|
826
|
+
}
|
|
711
827
|
swapMove(m);
|
|
828
|
+
// Owned by the root, as evictDomain's: a revival journaled later
|
|
829
|
+
// needs it though the domain is dropped after.
|
|
830
|
+
for (const domain of unwanted) {
|
|
831
|
+
journaled({ kind: "evict", appDomain: domain });
|
|
832
|
+
}
|
|
712
833
|
return "done";
|
|
713
834
|
}
|
|
714
835
|
// A compile's log a log entry a part, a run of them taking long.
|
|
@@ -785,6 +906,158 @@ export async function createCodegen(module) {
|
|
|
785
906
|
spare = null;
|
|
786
907
|
return startMove(into) ? "moving" : "none";
|
|
787
908
|
};
|
|
909
|
+
// The revivals left to a move whose domains are still evicted here, those
|
|
910
|
+
// revived otherwise or dropped since let go of, as are those whose chain
|
|
911
|
+
// has grown by an ancestor evicted since, which the host, asking again,
|
|
912
|
+
// gives the bytes of; and the revivals waiting for a move, failed ones apart.
|
|
913
|
+
const waitingRevivals = () => {
|
|
914
|
+
for (let i = revivals.length - 1; i >= 0; i--) {
|
|
915
|
+
const r = revivals[i];
|
|
916
|
+
if (wasm.domainState(r.appDomain) !== 1 || !givenAll(r)) {
|
|
917
|
+
revivals.splice(i, 1);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return revivals.filter((r) => !r.failed && !move?.revivals.includes(r));
|
|
921
|
+
};
|
|
922
|
+
const givenAll = (r) => {
|
|
923
|
+
const chain = evictedChain(r.appDomain);
|
|
924
|
+
for (let index = 0; index < abcDomains.length; index++) {
|
|
925
|
+
if (chain.has(abcDomains[index]) && !r.abcs.has(index)) {
|
|
926
|
+
return false;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return true;
|
|
930
|
+
};
|
|
931
|
+
// Whether the chain of `r` is not what it was at the snapshot of `m`, an
|
|
932
|
+
// ancestor evicted or revived since, by a revival of its own or of
|
|
933
|
+
// another under it: its load would then revive a chain other than the one
|
|
934
|
+
// here, with ABCs of it not given, or the spare replay a revival or an
|
|
935
|
+
// eviction its load had made moot.
|
|
936
|
+
const chainChanged = (m, r) => {
|
|
937
|
+
if (m.entries.some((e) => (e.kind === "evict" || e.kind === "revive") && inChain(e.appDomain, r.appDomain))) {
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
940
|
+
const now = evictedChain(r.appDomain);
|
|
941
|
+
let d = r.appDomain;
|
|
942
|
+
for (; d > 0 && m.evicted.has(d); d = wasm.domainParent(d)) {
|
|
943
|
+
if (!now.delete(d)) {
|
|
944
|
+
return true;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
return now.size > 0;
|
|
948
|
+
};
|
|
949
|
+
// Revivals waiting, given to the move under way while its spare has not
|
|
950
|
+
// begun to rebuild, as its load revives them, unless their chain changed
|
|
951
|
+
// since its snapshot; else, if it only compacts, the move is given up for
|
|
952
|
+
// one that revives as it compacts, as going on would cost its rest and
|
|
953
|
+
// then a rebuild; those a move that revives cannot take wait for the next.
|
|
954
|
+
const scheduleRevivals = (waiting) => {
|
|
955
|
+
const m = move;
|
|
956
|
+
if (m === null || !waiting.length) {
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
const fresh = m.phase === "load" || m.phase === "abcs" ? waiting.filter((r) => !chainChanged(m, r)) : [];
|
|
960
|
+
if (fresh.length < waiting.length && !m.revivals.length) {
|
|
961
|
+
abortMove("superseded");
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
if (!fresh.length) {
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
const loaded = m.phase === "abcs";
|
|
968
|
+
const before = m.saved.revive;
|
|
969
|
+
const saved = withRevivals(m.saved, fresh);
|
|
970
|
+
try {
|
|
971
|
+
for (const domain of saved.revive?.domains ?? []) {
|
|
972
|
+
if (loaded && !before?.domains.includes(domain) && m.into.domainLoadRevive(domain) !== 0) {
|
|
973
|
+
for (const r of fresh) {
|
|
974
|
+
r.failed = true;
|
|
975
|
+
}
|
|
976
|
+
abortMove("refused");
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
catch (error) {
|
|
982
|
+
for (const r of fresh) {
|
|
983
|
+
r.failed = true;
|
|
984
|
+
}
|
|
985
|
+
abortMove(error instanceof CodegenPanic || error instanceof CodegenOutOfMemory ? "spare" : "refused");
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
m.revivals.push(...fresh);
|
|
989
|
+
m.saved = saved;
|
|
990
|
+
if (loaded) {
|
|
991
|
+
for (const entry of saved.revive?.abcs ?? []) {
|
|
992
|
+
if (!before?.abcs.has(entry[0])) {
|
|
993
|
+
m.abcs.push(entry);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
// A move that revives the domains waiting, and compacts as it does, once
|
|
999
|
+
// there is a spare to make it in; where none can be made, or the journal
|
|
1000
|
+
// cannot catch one up, they are done in place when asked for again.
|
|
1001
|
+
const beginRevival = (waiting) => {
|
|
1002
|
+
const fail = () => {
|
|
1003
|
+
for (const r of waiting) {
|
|
1004
|
+
r.failed = true;
|
|
1005
|
+
}
|
|
1006
|
+
return "none";
|
|
1007
|
+
};
|
|
1008
|
+
if (!replayable) {
|
|
1009
|
+
return fail();
|
|
1010
|
+
}
|
|
1011
|
+
const into = spare;
|
|
1012
|
+
if (into === null) {
|
|
1013
|
+
if (spareFailed && !making) {
|
|
1014
|
+
spareFailed = false;
|
|
1015
|
+
return fail();
|
|
1016
|
+
}
|
|
1017
|
+
prepare();
|
|
1018
|
+
return "moving";
|
|
1019
|
+
}
|
|
1020
|
+
spare = null;
|
|
1021
|
+
return startMove(into, waiting) ? "moving" : fail();
|
|
1022
|
+
};
|
|
1023
|
+
// The ABCs of evicted domain `appDomain` and its evicted ancestors, the
|
|
1024
|
+
// first a child of a live one, among `abcs`, copied: each must be there,
|
|
1025
|
+
// else the revival throws, as reviveDomain does when it cannot revive.
|
|
1026
|
+
const revivalAbcs = (appDomain, abcs) => {
|
|
1027
|
+
const chain = evictedChain(appDomain);
|
|
1028
|
+
const top = [...chain].pop() ?? appDomain;
|
|
1029
|
+
let missing = false;
|
|
1030
|
+
const owned = new Map();
|
|
1031
|
+
for (let index = 0; index < abcDomains.length; index++) {
|
|
1032
|
+
if (chain.has(abcDomains[index])) {
|
|
1033
|
+
const bytes = abcs.get(index);
|
|
1034
|
+
if (bytes === undefined) {
|
|
1035
|
+
missing = true;
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
owned.set(index, new Uint8Array(bytes));
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
if (missing || wasm.domainState(wasm.domainParent(top)) !== 0) {
|
|
1043
|
+
throw new Error(`application domain ${appDomain}: not evicted, its parent not live, or an ABC of it not given`);
|
|
1044
|
+
}
|
|
1045
|
+
return owned;
|
|
1046
|
+
};
|
|
1047
|
+
// Whether the domain, with the chain a revival links again, its ABCs
|
|
1048
|
+
// `abcs`, is large enough that the revival's rebuild goes to a move
|
|
1049
|
+
// rather than block: a small domain reviving a large chain rebuilds as
|
|
1050
|
+
// long as one that was large all along.
|
|
1051
|
+
const revivalSteps = (abcs) => {
|
|
1052
|
+
if (!replayable || moveRefused) {
|
|
1053
|
+
return false;
|
|
1054
|
+
}
|
|
1055
|
+
let weight = Number(wasm.domainUsage().split(" ")[0]);
|
|
1056
|
+
for (const bytes of abcs.values()) {
|
|
1057
|
+
weight += REVIVED_Weight * bytes.length;
|
|
1058
|
+
}
|
|
1059
|
+
return weight >= IN_PLACE_Live;
|
|
1060
|
+
};
|
|
788
1061
|
// Whether the domain was lost to a panic recovery could not undo (see fresh).
|
|
789
1062
|
let lost = false;
|
|
790
1063
|
const api = {
|
|
@@ -799,6 +1072,7 @@ export async function createCodegen(module) {
|
|
|
799
1072
|
reset(version = API_VERSION) {
|
|
800
1073
|
checkApiVersion(version);
|
|
801
1074
|
abortMove("superseded");
|
|
1075
|
+
revivals.length = 0;
|
|
802
1076
|
moveRefused = false;
|
|
803
1077
|
retryAt = 0;
|
|
804
1078
|
wasm.domainReset(version);
|
|
@@ -917,9 +1191,11 @@ export async function createCodegen(module) {
|
|
|
917
1191
|
return wasm.domainCompact(true) && rebuild(wasm, null, true);
|
|
918
1192
|
},
|
|
919
1193
|
compactStep(deadline) {
|
|
1194
|
+
const waiting = waitingRevivals();
|
|
1195
|
+
scheduleRevivals(waiting);
|
|
920
1196
|
let m = move;
|
|
921
1197
|
if (m === null) {
|
|
922
|
-
const begun = beginCompaction();
|
|
1198
|
+
const begun = waiting.length ? beginRevival(waiting) : beginCompaction();
|
|
923
1199
|
if (begun !== "moving" || move === null) {
|
|
924
1200
|
return begun;
|
|
925
1201
|
}
|
|
@@ -957,7 +1233,35 @@ export async function createCodegen(module) {
|
|
|
957
1233
|
isLive(appDomain) {
|
|
958
1234
|
return wasm.domainState(appDomain) === 0;
|
|
959
1235
|
},
|
|
960
|
-
reviveDomain(appDomain, abcs) {
|
|
1236
|
+
reviveDomain(appDomain, abcs, stepped = false) {
|
|
1237
|
+
// A revival left to a move already, of this domain or a descendant,
|
|
1238
|
+
// which revives it too.
|
|
1239
|
+
const queued = revivals.find((r) => inChain(appDomain, r.appDomain));
|
|
1240
|
+
if (stepped && queued !== undefined && !queued.failed && replayable) {
|
|
1241
|
+
return false;
|
|
1242
|
+
}
|
|
1243
|
+
// One the move under way makes, finished here, as compact finishes it;
|
|
1244
|
+
// a revival given up is done in place below.
|
|
1245
|
+
const m = move;
|
|
1246
|
+
if (queued !== undefined && m?.revivals.includes(queued)) {
|
|
1247
|
+
let progress = moveUnit(m);
|
|
1248
|
+
while (progress === "moving") {
|
|
1249
|
+
progress = moveUnit(m);
|
|
1250
|
+
}
|
|
1251
|
+
if (wasm.domainState(appDomain) === 0) {
|
|
1252
|
+
return true;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
if (queued !== undefined && revivals.includes(queued)) {
|
|
1256
|
+
revivals.splice(revivals.indexOf(queued), 1);
|
|
1257
|
+
}
|
|
1258
|
+
if (stepped && queued === undefined && wasm.domainReviveNeeds(appDomain) === 1) {
|
|
1259
|
+
const owned = revivalAbcs(appDomain, abcs);
|
|
1260
|
+
if (revivalSteps(owned)) {
|
|
1261
|
+
revivals.push({ appDomain, abcs: owned, failed: false });
|
|
1262
|
+
return false;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
961
1265
|
// A move's spare lets go of the ABCs of the domains evicted before its
|
|
962
1266
|
// snapshot, and before any rebuild a replayed revival makes in it,
|
|
963
1267
|
// which this instance may still hold: restores journaled before the
|
|
@@ -972,6 +1276,14 @@ export async function createCodegen(module) {
|
|
|
972
1276
|
let revived = wasm.domainRevive(appDomain, true);
|
|
973
1277
|
if (revived < 0) {
|
|
974
1278
|
for (const [index, bytes] of abcs) {
|
|
1279
|
+
// One of a domain live here, which a move revived after the host
|
|
1280
|
+
// gathered the chain's bytes, is held already.
|
|
1281
|
+
if (Number.isInteger(index) &&
|
|
1282
|
+
index >= 0 &&
|
|
1283
|
+
index < abcDomains.length &&
|
|
1284
|
+
wasm.domainState(abcDomains[index]) === 0) {
|
|
1285
|
+
continue;
|
|
1286
|
+
}
|
|
975
1287
|
const owned = new Uint8Array(bytes);
|
|
976
1288
|
const error = wasm.domainRestore(index, owned);
|
|
977
1289
|
if (error !== 0) {
|
|
@@ -1011,6 +1323,7 @@ export async function createCodegen(module) {
|
|
|
1011
1323
|
if (!done) {
|
|
1012
1324
|
throw new Error(`application domain ${appDomain}: not evicted, its parent not live, or an ABC of it not given`);
|
|
1013
1325
|
}
|
|
1326
|
+
return true;
|
|
1014
1327
|
},
|
|
1015
1328
|
found({ domain, nsKind, uri, name, abc, asType }) {
|
|
1016
1329
|
wasm.domainFound(domain, nsKind, uri, name, abc, asType);
|
|
@@ -1236,6 +1549,9 @@ const WANT_Spare = 3;
|
|
|
1236
1549
|
* rebuilds in place, in one call, rather than move a part at a time.
|
|
1237
1550
|
*/
|
|
1238
1551
|
const IN_PLACE_Live = 4 << 20;
|
|
1552
|
+
// The weight of an ABC's byte a revival links again, before its compiles:
|
|
1553
|
+
// the compiler's own ABC_Weight (zig/src/avm2/link/domain.zig).
|
|
1554
|
+
const REVIVED_Weight = 3;
|
|
1239
1555
|
/** A compile's log entry that verified an ABC: LogKind.verify (avm2/link/domain.zig). */
|
|
1240
1556
|
const LOG_Verify = 4;
|
|
1241
1557
|
/**
|