@threadedstack/wmd-web 0.1.60 → 0.1.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/RELEASE.json +12 -9
- package/guest/arm64/vm.wasm +0 -0
- package/package.json +3 -3
- package/src/boot.js +1 -0
- package/src/edge/pins.gen.js +1 -1
- package/src/host/ckpt-point.js +32 -3
- package/src/worker.js +3 -1
- package/wmdpack.wasm +0 -0
package/RELEASE.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wmd-web",
|
|
3
3
|
"version": "0.5.1",
|
|
4
|
-
"commit": "
|
|
4
|
+
"commit": "0f4c8957ac8af45e9d26401f91e1321102907353",
|
|
5
5
|
"previous": null,
|
|
6
6
|
"decisions": [
|
|
7
7
|
"D-388",
|
|
@@ -81,15 +81,18 @@
|
|
|
81
81
|
"D-666",
|
|
82
82
|
"D-686",
|
|
83
83
|
"D-687",
|
|
84
|
-
"D-688"
|
|
84
|
+
"D-688",
|
|
85
|
+
"D-689",
|
|
86
|
+
"D-690",
|
|
87
|
+
"D-691"
|
|
85
88
|
],
|
|
86
|
-
"vmSources": "
|
|
89
|
+
"vmSources": "eedab6f96cad4777f4e9f945f1c81920df054c6f",
|
|
87
90
|
"guest": {
|
|
88
91
|
"arch": "arm64",
|
|
89
92
|
"files": {
|
|
90
93
|
"vm.wasm": {
|
|
91
|
-
"sha256": "
|
|
92
|
-
"bytes":
|
|
94
|
+
"sha256": "9da8344493105efb6d95af491e457832c8c093a159148b578a75714f8d38c54a",
|
|
95
|
+
"bytes": 1580846
|
|
93
96
|
},
|
|
94
97
|
"Image": {
|
|
95
98
|
"sha256": "b7a8843d3469e2f5c32973ce2e6d663f90e07099ed2e9e9aee2ceac0e6a0685b",
|
|
@@ -179,11 +182,11 @@
|
|
|
179
182
|
"guest/arm64/Image-4k": "55ab90773d080416f1539ae2caac0a49bb98e2bb34ce9384849725fb8e601551",
|
|
180
183
|
"guest/arm64/features": "4dc6f2a114c7c87a67eb9f0fe53c52b6b8128bb30830a6be498432a3701587f4",
|
|
181
184
|
"guest/arm64/initramfs.cpio.gz": "ac7c0fc194b059579943c3d8ceaa0757c3e3e248231c2ad779260e97d5084cd3",
|
|
182
|
-
"guest/arm64/vm.wasm": "
|
|
185
|
+
"guest/arm64/vm.wasm": "9da8344493105efb6d95af491e457832c8c093a159148b578a75714f8d38c54a",
|
|
183
186
|
"package.json": "6de9aa9fabdb395651d39997c17e094f01a574f54a36f0af31bd3ffaae53cda1",
|
|
184
187
|
"src/base.js": "c79df2c3d4a6519fb9a6ef5cda39d66a5b9bc1a6dd009d21e7455e141943079f",
|
|
185
188
|
"src/blob.js": "bb2a2f0d87ce236280a7be2f246c926010dfe07f649c27da5e70d8eb5eaf7061",
|
|
186
|
-
"src/boot.js": "
|
|
189
|
+
"src/boot.js": "a6d17aa1a8b254101f0ea76739ac7d0be9e29f28e7fb414a826f17784b3c7ffd",
|
|
187
190
|
"src/build/builder.js": "57a8436acc00147d031a42cccffe508f8deb3735b0ab4f9efcc2aa1cf7c6859c",
|
|
188
191
|
"src/build/context.js": "d38097c61dbdadc4d41290c010425a4422f499aba473fa2b83f2a5c41e543571",
|
|
189
192
|
"src/build/dockerfile.js": "5957fe3d4ac8ff8b312f980ee04bd1d98ad4373a61f9a33e02f1ff1108b6ea53",
|
|
@@ -295,7 +298,7 @@
|
|
|
295
298
|
"src/host/ckpt-chain.js": "c208a882da772acafe1373ea1d7e04723e26e870396d4202ef330d4eaf758596",
|
|
296
299
|
"src/host/ckpt-file.js": "709344bfadf7c8151d51f70787b9e9d4b074ed1f5f80af113f11215851b9c28a",
|
|
297
300
|
"src/host/ckpt-io.js": "92e437fb3b118c4269ecc4aafec6e17cf99936d3fc0c410e38f48b9146e791fb",
|
|
298
|
-
"src/host/ckpt-point.js": "
|
|
301
|
+
"src/host/ckpt-point.js": "3d0896281eaf3f49e9b97928dd941a32c20da7ddfc7b239d11712f762e90ec9f",
|
|
299
302
|
"src/host/ckpt-save.js": "7bb07f536005fb5e7d9db6a09169a5ce1e3865d337ab65ce798a111334c6aa07",
|
|
300
303
|
"src/host/ckpt.js": "371acb574e31e94201ae1ff32a7cfad85801ae3eae2896cde7d53a96430c502d",
|
|
301
304
|
"src/host/clock.js": "aba6af3a8b1a985ae340892222e4b482d33afe20f5c8b3a4c7403ce87d1e247c",
|
|
@@ -350,7 +353,7 @@
|
|
|
350
353
|
"src/registry/pull.js": "24f2e01a76c9f7f27896af69b989f8c97f0ca31712b3e8110aaa5b5e3148b04b",
|
|
351
354
|
"src/registry/ref.js": "24038e0fbcb6ac143cb8e8f7b9fac4dd0803d0891961786dc88dba01a4402e7b",
|
|
352
355
|
"src/registry/wasi-mem.js": "8a8474a090a778db9eabfc2610f8c57f7f66b684ba7b7f8994aabd3ecb07a65a",
|
|
353
|
-
"src/worker.js": "
|
|
356
|
+
"src/worker.js": "80904f024ec99119f53b91a38e1b18277215246f45547bb93a097d69c973b832",
|
|
354
357
|
"src/workers.json": "2dd90729f76d5867a3a2974cdc958b610340383fc81a7a4d651272ba15c7e7dc"
|
|
355
358
|
},
|
|
356
359
|
"builder": {
|
package/guest/arm64/vm.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threadedstack/wmd-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.62",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/threadedstack/wmd-releases",
|
|
6
6
|
"repository": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"description": "Browser host for wmd's guest vm.wasm (Web Workers + shared memory + WASI preview1)",
|
|
11
11
|
"wmd": {
|
|
12
|
-
"tag": "v0.1.
|
|
13
|
-
"commit": "
|
|
12
|
+
"tag": "v0.1.62",
|
|
13
|
+
"commit": "0f4c8957ac8af45e9d26401f91e1321102907353",
|
|
14
14
|
"web": "0.5.1"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
package/src/boot.js
CHANGED
|
@@ -2626,6 +2626,7 @@ async function bootMachine(o) {
|
|
|
2626
2626
|
nonzeroPages: c.mem.nonzero,
|
|
2627
2627
|
memPages: c.mem.pages,
|
|
2628
2628
|
scannedPages: c.mem.scannedPages,
|
|
2629
|
+
zeroRangePages: c.mem.zeroRangePages ?? 0, // IOS-6 (c): pages vm.wasm listed as zero (vm_zero_ranges), not read
|
|
2629
2630
|
scanLimitBytes: c.mem.limitBytes,
|
|
2630
2631
|
heapTopPage: c.mem.heapTopRet ? Math.ceil(c.mem.heapTopRet / CKPT_PAGE) : null,
|
|
2631
2632
|
pagesAtOrAboveHeapTop: c.mem.heapTopRet ? Array.from(c.mem.index).filter(p => p >= Math.ceil(c.mem.heapTopRet / CKPT_PAGE)).length : null, // non-zero pages the checkpoint holds from the heap top up: 0 proves the heap-top bound
|
package/src/edge/pins.gen.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// The files of node in the sandboxed frame: the path under a source (the option edge: { sources } of bootWmd), the role the frame gives the file, its
|
|
3
3
|
// sha256 and its size. The page accepts a file only when it has exactly this sha256 and size. The notice files travel with the rest.
|
|
4
4
|
// EDGE_PACKAGE is the package that holds these files, for the {name} {version} {file} of a registry source's url (null: none named).
|
|
5
|
-
export const EDGE_PACKAGE = { name: '@threadedstack/wmd-node', version: '0.1.
|
|
5
|
+
export const EDGE_PACKAGE = { name: '@threadedstack/wmd-node', version: '0.1.62' }
|
|
6
6
|
export const EDGE_PINS = [
|
|
7
7
|
{ path: 'wmd_browser_bg.wasm', role: 'wasm', sha256: '1e3db7f2c5f4be0ee44e5f2c0205cf8ca11f906d9addd5512915fad4821661c2', size: 6334959 },
|
|
8
8
|
{ path: 'wmd_browser.js', role: 'glue', sha256: 'b389b072096881ba39b22cd705d3a230af02acc5409c61fb4f997d1081c4df6f', size: 75647 },
|
package/src/host/ckpt-point.js
CHANGED
|
@@ -146,12 +146,34 @@ export function touchedSkips(memory, desc) {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
/**
|
|
150
|
+
* IOS-6 (c) (D-691): the pages a checkpoint need not read, from vm.wasm's vm_zero_ranges (guest/vm/include/vm/zero_ranges.h): ranges
|
|
151
|
+
* of memory 0 it knows hold only zero bytes at the point. `desc` is the address of {count, then count (offset, length) u32 pairs}.
|
|
152
|
+
* Returns skip(p): whether page p of memory 0 lies wholly inside one of them (a page a range only partly covers is read).
|
|
153
|
+
*/
|
|
154
|
+
export function zeroRangeSkips(memory, desc) {
|
|
155
|
+
const total = memory.buffer.byteLength / PAGE
|
|
156
|
+
const n = Math.min(new Uint32Array(memory.buffer, desc, 1)[0], 64)
|
|
157
|
+
const d = new Uint32Array(memory.buffer, desc, 1 + 2 * n)
|
|
158
|
+
const spans = []
|
|
159
|
+
for (let i = 0; i < n; i++) {
|
|
160
|
+
const off = d[1 + 2 * i]
|
|
161
|
+
const lo = Math.ceil(off / PAGE)
|
|
162
|
+
const hi = Math.min(total, Math.floor((off + d[2 + 2 * i]) / PAGE)) // pages wholly inside, cut to the memory
|
|
163
|
+
if (hi > lo) spans.push([lo, hi])
|
|
164
|
+
}
|
|
165
|
+
return p => {
|
|
166
|
+
for (const [lo, hi] of spans) if (p >= lo && p < hi) return true
|
|
167
|
+
return false
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
149
171
|
/**
|
|
150
172
|
* The imports. memory: the machine's shared memory; ctl: the control block's Int32Array; post:
|
|
151
173
|
* message to the page; goTimeoutMs: how long vCPU 0 waits for the page (a page that is gone
|
|
152
174
|
* makes the point fail: the guest goes on, as it does for any failed point).
|
|
153
175
|
*/
|
|
154
|
-
export function createCkptImports({ memory, ram = null, touched = () => null, ctl, post, scanLimit = null, verifyBound = false, useHeapTop = false, heapTop = () => null, goTimeoutMs = 60_000, now = () => performance.timeOrigin + performance.now() }) {
|
|
176
|
+
export function createCkptImports({ memory, ram = null, touched = () => null, zeroRanges = () => null, ctl, post, scanLimit = null, verifyBound = false, useHeapTop = false, heapTop = () => null, goTimeoutMs = 60_000, now = () => performance.timeOrigin + performance.now() }) {
|
|
155
177
|
return {
|
|
156
178
|
ctl_attach(wordAddr) {
|
|
157
179
|
Atomics.store(ctl, CTL_CK_HOSTREQ, wordAddr >>> 0)
|
|
@@ -183,7 +205,14 @@ export function createCkptImports({ memory, ram = null, touched = () => null, ct
|
|
|
183
205
|
// RAM in memory 0 starts at a 64 KiB boundary (memory.grow), so a skipped page is all RAM
|
|
184
206
|
if (skips && (Number(new BigUint64Array(memory.buffer, desc, 6)[2]) % PAGE) !== 0) throw new Error('guest RAM is not page-aligned in memory 0')
|
|
185
207
|
const copy = Atomics.load(ctl, CTL_CK_STREAM) !== 1
|
|
186
|
-
|
|
208
|
+
// IOS-6 (c): and the ranges vm.wasm says are zero (its JIT tables' tails): not read, left out, zero again on a restore
|
|
209
|
+
const zr = zeroRanges()
|
|
210
|
+
const zskip = zr ? zeroRangeSkips(memory, zr) : null
|
|
211
|
+
let zeroRangePages = 0
|
|
212
|
+
const skip0 = skips ? skips.mem0 : null
|
|
213
|
+
const skip = zskip ? p => (zskip(p) ? (zeroRangePages++, true) : !!skip0 && skip0(p)) : skip0
|
|
214
|
+
cap = scanMemory(memory, { now, limitBytes: limit, verifyAbove: verifyBound, skip, copy })
|
|
215
|
+
cap.zeroRangePages = zeroRangePages
|
|
187
216
|
cap.streamed = !copy
|
|
188
217
|
cap.limitBytes = Number.isFinite(limit) ? limit : null
|
|
189
218
|
// the live g_rsv {brk, end} of vm.wasm 50c6495e / 3aef93fc (linear address 4251160), next to what vm_heap_top() says
|
|
@@ -201,7 +230,7 @@ export function createCkptImports({ memory, ram = null, touched = () => null, ct
|
|
|
201
230
|
Atomics.store(ctl, CTL_CK_GO, 0)
|
|
202
231
|
return -12
|
|
203
232
|
}
|
|
204
|
-
post({ t: 'ckpt-mem', streamed: cap.streamed, index: cap.index, chunks: cap.chunks, pages: cap.pages, scannedPages: cap.scannedPages, skippedPages: cap.skippedPages, ramScannedPages: cap.ram?.scannedPages, ramSkippedPages: cap.ram?.skippedPages, aboveNonzero: cap.aboveNonzero, brkLive: cap.brkLive, endLive: cap.endLive, heapTopRet: cap.heapTopRet, limitBytes: cap.limitBytes, nonzero: cap.nonzero, scanMs: cap.scanMs, copyMs: cap.copyMs, ram: cap.ram ? { index: cap.ram.index, chunks: cap.ram.chunks, pages: cap.ram.pages, nonzero: cap.ram.nonzero, scanMs: cap.ram.scanMs, copyMs: cap.ram.copyMs } : null, doneAt: now() }, [cap.index.buffer, ...cap.chunks, ...(cap.ram ? [cap.ram.index.buffer, ...cap.ram.chunks] : [])])
|
|
233
|
+
post({ t: 'ckpt-mem', streamed: cap.streamed, index: cap.index, chunks: cap.chunks, pages: cap.pages, scannedPages: cap.scannedPages, skippedPages: cap.skippedPages, zeroRangePages: cap.zeroRangePages, ramScannedPages: cap.ram?.scannedPages, ramSkippedPages: cap.ram?.skippedPages, aboveNonzero: cap.aboveNonzero, brkLive: cap.brkLive, endLive: cap.endLive, heapTopRet: cap.heapTopRet, limitBytes: cap.limitBytes, nonzero: cap.nonzero, scanMs: cap.scanMs, copyMs: cap.copyMs, ram: cap.ram ? { index: cap.ram.index, chunks: cap.ram.chunks, pages: cap.ram.pages, nonzero: cap.ram.nonzero, scanMs: cap.ram.scanMs, copyMs: cap.ram.copyMs } : null, doneAt: now() }, [cap.index.buffer, ...cap.chunks, ...(cap.ram ? [cap.ram.index.buffer, ...cap.ram.chunks] : [])])
|
|
205
234
|
Atomics.wait(ctl, CTL_CK_GO, 0, Atomics.load(ctl, CTL_CK_GO_MS) || goTimeoutMs)
|
|
206
235
|
// IOS-6 (a): no answer in time: give up in the cell itself, so a go that comes later is refused (giveGo) and the page knows its
|
|
207
236
|
// save read a memory that was no longer frozen; and say so at once (a save that never ends would otherwise leave the page waiting)
|
package/src/worker.js
CHANGED
|
@@ -168,8 +168,9 @@ async function run(m) {
|
|
|
168
168
|
const chan = m.chan ? createChanImports({ sab: m.chan, memory, exiting: () => Atomics.load(ctl, CTL_EXIT) !== 0 }) : {}
|
|
169
169
|
let heapTopFn = null // vm.wasm's vm_heap_top export, once the main thread has instantiated (null: a full scan)
|
|
170
170
|
let touchedFn = null // vm.wasm's vm_touched_map export: the RAM pages the guest wrote (null: every page is read)
|
|
171
|
+
let zeroFn = null // IOS-6 (c): vm.wasm's vm_zero_ranges export: ranges of memory 0 it knows are zero (null: none)
|
|
171
172
|
// P-B9: checkpoint support: wmd.ctl_attach and wmd.point (host/ckpt-point.js)
|
|
172
|
-
const ckpt = m.ckpt ? createCkptImports({ memory, ram: m.ram || null, ctl, scanLimit: m.ckptScanLimit ?? null, verifyBound: !!m.ckptVerifyBound, useHeapTop: !!m.ckptUseHeapTop, heapTop: () => heapTopFn?.() ?? null, touched: () => touchedFn?.() ?? null, post: (msg, transfer) => self.postMessage(msg, transfer || []) }) : null
|
|
173
|
+
const ckpt = m.ckpt ? createCkptImports({ memory, ram: m.ram || null, ctl, scanLimit: m.ckptScanLimit ?? null, verifyBound: !!m.ckptVerifyBound, useHeapTop: !!m.ckptUseHeapTop, heapTop: () => heapTopFn?.() ?? null, touched: () => touchedFn?.() ?? null, zeroRanges: () => zeroFn?.() ?? null, post: (msg, transfer) => self.postMessage(msg, transfer || []) }) : null
|
|
173
174
|
// the flat layout: guest RAM is the page's memory64 (host/ram-mem.js)
|
|
174
175
|
const ramImports = m.ram ? createRamImports({ memory, ram: m.ram }) : null
|
|
175
176
|
const wmd = createWmdImports({
|
|
@@ -254,6 +255,7 @@ async function run(m) {
|
|
|
254
255
|
const inst = instantiate()
|
|
255
256
|
if (typeof inst.exports.vm_heap_top === 'function') heapTopFn = () => Number(inst.exports.vm_heap_top())
|
|
256
257
|
if (typeof inst.exports.vm_touched_map === 'function') touchedFn = () => inst.exports.vm_touched_map() >>> 0
|
|
258
|
+
if (typeof inst.exports.vm_zero_ranges === 'function') zeroFn = () => inst.exports.vm_zero_ranges() >>> 0
|
|
257
259
|
self.postMessage({ t: 'ready', role, at: performance.timeOrigin + performance.now() })
|
|
258
260
|
try {
|
|
259
261
|
if (m.resume) {
|
package/wmdpack.wasm
CHANGED
|
Binary file
|