Skip to content

Commit c3b360d

Browse files
committed
Drop stale JIT entries before a warm restore, skip saved code for missing methods, and keep pending encoder work on a failed constant.
1 parent a20037f commit c3b360d

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/jvm.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ export class JVM {
12771277
return false;
12781278
}
12791279
try {
1280-
this.keepJit = false;
1280+
this.dropJit();
12811281
restoreVM(this, image, t);
12821282
this.warmRestored = true;
12831283
this.warmSaved = true;

‎src/snapshot.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ class Encoder {
117117

118118
// enc, or null with nothing recorded when v cannot be saved
119119
tryEnc(v: any, path: string): any {
120-
const before = this.twins.size;
120+
const before = this.twins.size, pending = this.work.length;
121121
try {
122122
return this.enc(v, path);
123123
} catch {
124-
this.work.length = 0;
124+
this.work.length = pending;
125125
[...this.twins.keys()].slice(before).forEach((k) => this.twins.delete(k));
126126
return null;
127127
}
@@ -421,7 +421,10 @@ export function restoreVM(vm: JVM, image: SnapshotImage, main: JThread) {
421421
c.nestHost = d.dec(r.nestHost);
422422
for (const [k, l] of r.links) c.methodMap.get(k)!.link = d.dec(l);
423423
for (const [k, cache] of r.caches ?? []) c.methodMap.get(k)!.cache = d.dec(cache);
424-
for (const [k, src, consts] of r.jit ?? []) restoreJit(vm, c.methodMap.get(k)!, { src, consts: d.dec(consts) });
424+
for (const [k, src, consts] of r.jit ?? []) {
425+
const m = c.methodMap.get(k);
426+
if (m) restoreJit(vm, m, { src, consts: d.dec(consts) });
427+
}
425428
});
426429
d.flush();
427430
const v = image.vm;

0 commit comments

Comments
 (0)