@agoric/xsnap 0.14.3-u16.1 → 0.14.3-u17.1
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/api.js +1 -1
- package/package.json +15 -15
- package/src/avaXS.js +6 -3
- package/src/build.js +4 -3
- package/src/replay.js +11 -4
- package/src/xsnap.js +25 -22
- package/src/xsrepl.js +6 -6
- package/src/defer.js +0 -31
package/api.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/xsnap",
|
|
3
|
-
"version": "0.14.3-
|
|
3
|
+
"version": "0.14.3-u17.1",
|
|
4
4
|
"description": "Snapshotting VM worker based on Moddable's XS Javascript engine",
|
|
5
5
|
"author": "Agoric",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,22 +28,22 @@
|
|
|
28
28
|
"test:xs": "exit 0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@agoric/
|
|
32
|
-
"@agoric/
|
|
33
|
-
"@
|
|
34
|
-
"@endo/
|
|
35
|
-
"@endo/eventual-send": "^1.2.
|
|
36
|
-
"@endo/init": "^1.1.
|
|
37
|
-
"@endo/netstring": "^1.0.
|
|
38
|
-
"@endo/promise-kit": "^1.1.
|
|
39
|
-
"@endo/stream": "^1.2.
|
|
40
|
-
"@endo/stream-node": "^1.1.
|
|
31
|
+
"@agoric/internal": "^0.4.0-u17.1",
|
|
32
|
+
"@agoric/xsnap-lockdown": "^0.14.1-u17.1",
|
|
33
|
+
"@endo/bundle-source": "^3.4.0",
|
|
34
|
+
"@endo/errors": "^1.2.5",
|
|
35
|
+
"@endo/eventual-send": "^1.2.5",
|
|
36
|
+
"@endo/init": "^1.1.4",
|
|
37
|
+
"@endo/netstring": "^1.0.10",
|
|
38
|
+
"@endo/promise-kit": "^1.1.5",
|
|
39
|
+
"@endo/stream": "^1.2.5",
|
|
40
|
+
"@endo/stream-node": "^1.1.5",
|
|
41
41
|
"glob": "^7.1.6",
|
|
42
42
|
"tmp": "^0.2.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@endo/base64": "^1.0.
|
|
46
|
-
"@endo/nat": "^5.0.
|
|
45
|
+
"@endo/base64": "^1.0.7",
|
|
46
|
+
"@endo/nat": "^5.0.10",
|
|
47
47
|
"@types/glob": "^8.1.0",
|
|
48
48
|
"ava": "^5.3.0",
|
|
49
49
|
"c8": "^9.1.0"
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"workerThreads": false
|
|
77
77
|
},
|
|
78
78
|
"typeCoverage": {
|
|
79
|
-
"atLeast":
|
|
79
|
+
"atLeast": 94.04
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "5259430561693bfcf58516c3ea54123895859708"
|
|
82
82
|
}
|
package/src/avaXS.js
CHANGED
|
@@ -9,9 +9,10 @@ Usage:
|
|
|
9
9
|
import '@endo/init';
|
|
10
10
|
|
|
11
11
|
import fs from 'fs';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
12
13
|
import { tmpName } from 'tmp';
|
|
13
14
|
|
|
14
|
-
import { assert, q, Fail } from '@
|
|
15
|
+
import { assert, q, Fail } from '@endo/errors';
|
|
15
16
|
import { getDebugLockdownBundle } from '@agoric/xsnap-lockdown';
|
|
16
17
|
import { xsnap } from './xsnap.js';
|
|
17
18
|
|
|
@@ -21,7 +22,7 @@ const avaHandler = `./avaHandler.cjs`;
|
|
|
21
22
|
|
|
22
23
|
/** @type { (ref: string, readFile: typeof import('fs').promises.readFile ) => Promise<string> } */
|
|
23
24
|
const asset = (ref, readFile) =>
|
|
24
|
-
readFile(new URL(ref, import.meta.url)
|
|
25
|
+
readFile(fileURLToPath(new URL(ref, import.meta.url)), 'utf8');
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* When we bundle test scripts, we leave these externals
|
|
@@ -384,7 +385,9 @@ export async function main(
|
|
|
384
385
|
|
|
385
386
|
stats.total += results.total;
|
|
386
387
|
stats.pass += results.pass;
|
|
387
|
-
|
|
388
|
+
for (const info of results.fail) {
|
|
389
|
+
stats.fail.push(info);
|
|
390
|
+
}
|
|
388
391
|
}
|
|
389
392
|
|
|
390
393
|
console.log(stats.pass, 'tests passed');
|
package/src/build.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* global process */
|
|
3
3
|
import * as childProcessTop from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
4
5
|
import fsTop from 'fs';
|
|
5
6
|
import osTop from 'os';
|
|
6
7
|
|
|
7
8
|
const { freeze } = Object;
|
|
8
9
|
|
|
9
10
|
/** @param {string} path */
|
|
10
|
-
const asset = path => new URL(path, import.meta.url)
|
|
11
|
+
const asset = path => fileURLToPath(new URL(path, import.meta.url));
|
|
11
12
|
|
|
12
13
|
const ModdableSDK = {
|
|
13
14
|
MODDABLE: asset('../moddable'),
|
|
@@ -341,7 +342,7 @@ async function main(args, { env, stdout, spawn, fs, os }) {
|
|
|
341
342
|
|
|
342
343
|
if (isWorkingCopy || showEnv) {
|
|
343
344
|
if (showEnv && !isWorkingCopy) {
|
|
344
|
-
throw
|
|
345
|
+
throw Error('XSnap requires a working copy and git to --show-env');
|
|
345
346
|
}
|
|
346
347
|
await updateSubmodules(showEnv, { env, stdout, spawn, fs });
|
|
347
348
|
hasSource = true;
|
|
@@ -362,7 +363,7 @@ async function main(args, { env, stdout, spawn, fs, os }) {
|
|
|
362
363
|
}
|
|
363
364
|
await makeXsnap({ spawn, fs, os }, { forceBuild });
|
|
364
365
|
} else if (!hasBin) {
|
|
365
|
-
throw
|
|
366
|
+
throw Error(
|
|
366
367
|
'XSnap has neither sources nor a pre-built binary. Docker? .dockerignore? npm files?',
|
|
367
368
|
);
|
|
368
369
|
}
|
package/src/replay.js
CHANGED
|
@@ -13,6 +13,7 @@ import osPowers from 'os';
|
|
|
13
13
|
import fsPowers from 'fs';
|
|
14
14
|
import { Readable } from 'stream';
|
|
15
15
|
import { tmpName as tmpNamePower } from 'tmp';
|
|
16
|
+
import { fileURLToPath } from 'url';
|
|
16
17
|
import { makeQueue } from '@endo/stream';
|
|
17
18
|
import { xsnap, DEFAULT_CRANK_METERING_LIMIT } from './xsnap.js';
|
|
18
19
|
|
|
@@ -38,7 +39,9 @@ function makeSyncStorage(path, { writeFileSync }) {
|
|
|
38
39
|
file: fn => {
|
|
39
40
|
/** @param {Uint8Array} data */
|
|
40
41
|
const put = data =>
|
|
41
|
-
writeFileSync(new URL(fn, base)
|
|
42
|
+
writeFileSync(fileURLToPath(new URL(fn, base)), data, {
|
|
43
|
+
flag: 'wx',
|
|
44
|
+
});
|
|
42
45
|
|
|
43
46
|
return freeze({
|
|
44
47
|
put,
|
|
@@ -60,14 +63,18 @@ function makeSyncAccess(path, { readdirSync, readFileSync }) {
|
|
|
60
63
|
const base = new URL(path, 'file://');
|
|
61
64
|
/** @param {string} fn */
|
|
62
65
|
const file = fn => {
|
|
63
|
-
const fullname = new URL(fn, base)
|
|
66
|
+
const fullname = fileURLToPath(new URL(fn, base));
|
|
64
67
|
|
|
65
68
|
return freeze({
|
|
66
69
|
getData: () => readFileSync(fullname),
|
|
67
70
|
getText: () => readFileSync(fullname, 'utf-8'),
|
|
68
71
|
});
|
|
69
72
|
};
|
|
70
|
-
return freeze({
|
|
73
|
+
return freeze({
|
|
74
|
+
path,
|
|
75
|
+
file,
|
|
76
|
+
readdir: () => readdirSync(fileURLToPath(base)),
|
|
77
|
+
});
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
/**
|
|
@@ -320,7 +327,7 @@ export async function main(
|
|
|
320
327
|
}
|
|
321
328
|
|
|
322
329
|
/* global process */
|
|
323
|
-
if (process.argv[1] === new URL(import.meta.url)
|
|
330
|
+
if (process.argv[1] === fileURLToPath(new URL(import.meta.url))) {
|
|
324
331
|
main([...process.argv.slice(2)], {
|
|
325
332
|
spawn: childProcessPowers.spawn,
|
|
326
333
|
fs: { ...fsPowers, ...fsPowers.promises },
|
package/src/xsnap.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
/* global process */
|
|
2
2
|
/* eslint no-await-in-loop: ["off"] */
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {typeof import('child_process').spawn} Spawn
|
|
6
|
-
* @import {Writable} from 'stream'
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @template T
|
|
11
|
-
* @typedef {import('./defer.js').Deferred<T>} Deferred
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
4
|
import { finished } from 'stream/promises';
|
|
15
5
|
import { PassThrough, Readable } from 'stream';
|
|
16
6
|
import { promisify } from 'util';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { Fail, q } from '@endo/errors';
|
|
17
9
|
import { makeNetstringReader, makeNetstringWriter } from '@endo/netstring';
|
|
18
10
|
import { makeNodeReader, makeNodeWriter } from '@endo/stream-node';
|
|
19
11
|
import { makePromiseKit, racePromises } from '@endo/promise-kit';
|
|
20
12
|
import { forever } from '@agoric/internal';
|
|
21
13
|
import { ErrorCode, ErrorSignal, ErrorMessage, METER_TYPE } from '../api.js';
|
|
22
|
-
import { defer } from './defer.js';
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
/** @import {PromiseKit} from '@endo/promise-kit' */
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {typeof import('child_process').spawn} Spawn
|
|
19
|
+
* @import {Writable} from 'stream'
|
|
20
|
+
*/
|
|
25
21
|
|
|
26
22
|
// This will need adjustment, but seems to be fine for a start.
|
|
27
23
|
export const DEFAULT_CRANK_METERING_LIMIT = 1e8;
|
|
@@ -179,15 +175,17 @@ export async function xsnap(options) {
|
|
|
179
175
|
throw Error(`xsnap does not support platform ${os}`);
|
|
180
176
|
}
|
|
181
177
|
|
|
182
|
-
let bin =
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
178
|
+
let bin = fileURLToPath(
|
|
179
|
+
new URL(
|
|
180
|
+
`../xsnap-native/xsnap/build/bin/${platform}/${
|
|
181
|
+
debug ? 'debug' : 'release'
|
|
182
|
+
}/xsnap-worker`,
|
|
183
|
+
import.meta.url,
|
|
184
|
+
),
|
|
185
|
+
);
|
|
188
186
|
|
|
189
|
-
/** @type {
|
|
190
|
-
const vatExit =
|
|
187
|
+
/** @type {PromiseKit<void>} */
|
|
188
|
+
const vatExit = makePromiseKit();
|
|
191
189
|
|
|
192
190
|
assert(!/^-/.test(name), `name '${name}' cannot start with hyphen`);
|
|
193
191
|
|
|
@@ -292,7 +290,7 @@ export async function xsnap(options) {
|
|
|
292
290
|
* @template T
|
|
293
291
|
* @typedef {object} RunResult
|
|
294
292
|
* @property {T} reply
|
|
295
|
-
* @property {{ meterType: string, allocate: number|null, compute: number|null, timestamps: number[]|null }} meterUsage
|
|
293
|
+
* @property {{ meterType: string, allocate: number|null, compute: number|null, currentHeapCount: number|null, timestamps: number[]|null }} meterUsage
|
|
296
294
|
*/
|
|
297
295
|
|
|
298
296
|
/**
|
|
@@ -317,7 +315,12 @@ export async function xsnap(options) {
|
|
|
317
315
|
xsnapProcess.kill();
|
|
318
316
|
throw Error('xsnap protocol error: received empty message');
|
|
319
317
|
} else if (message[0] === OK) {
|
|
320
|
-
let meterInfo = {
|
|
318
|
+
let meterInfo = {
|
|
319
|
+
compute: null,
|
|
320
|
+
allocate: null,
|
|
321
|
+
currentHeapCount: null,
|
|
322
|
+
timestamps: [],
|
|
323
|
+
};
|
|
321
324
|
const meterSeparator = message.indexOf(OK_SEPARATOR, 1);
|
|
322
325
|
if (meterSeparator >= 0) {
|
|
323
326
|
// The message is `.meterdata\1reply`.
|
package/src/xsrepl.js
CHANGED
|
@@ -4,17 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import '@endo/init';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @template T
|
|
9
|
-
* @typedef {import('./defer.js').Deferred<T>} Deferred
|
|
10
|
-
*/
|
|
11
7
|
import * as childProcess from 'child_process';
|
|
12
8
|
import fs from 'fs';
|
|
13
9
|
import { tmpName } from 'tmp';
|
|
14
10
|
import * as os from 'os';
|
|
15
11
|
import * as readline from 'readline';
|
|
12
|
+
import { makePromiseKit } from '@endo/promise-kit';
|
|
16
13
|
import { xsnap } from './xsnap.js';
|
|
17
|
-
|
|
14
|
+
|
|
15
|
+
/** @import {PromiseKit} from '@endo/promise-kit' */
|
|
18
16
|
|
|
19
17
|
const decoder = new TextDecoder();
|
|
20
18
|
|
|
@@ -65,7 +63,9 @@ async function main() {
|
|
|
65
63
|
* @returns {Promise<string>}
|
|
66
64
|
*/
|
|
67
65
|
function ask(prompt) {
|
|
68
|
-
const { promise, resolve } = /** @type {
|
|
66
|
+
const { promise, resolve } = /** @type {PromiseKit<string>} */ (
|
|
67
|
+
makePromiseKit()
|
|
68
|
+
);
|
|
69
69
|
rl.question(prompt, resolve);
|
|
70
70
|
return promise;
|
|
71
71
|
}
|
package/src/defer.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {boolean} _flag
|
|
3
|
-
* @returns {asserts _flag}
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
function assert(_flag) {}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @template T
|
|
10
|
-
* @typedef {{
|
|
11
|
-
* resolve(value?: T | Promise<T>): void,
|
|
12
|
-
* reject(error: Error): void,
|
|
13
|
-
* promise: Promise<T>
|
|
14
|
-
* }} Deferred
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @template T
|
|
19
|
-
* @returns {Deferred<T>}
|
|
20
|
-
*/
|
|
21
|
-
export function defer() {
|
|
22
|
-
let resolve;
|
|
23
|
-
let reject;
|
|
24
|
-
const promise = new Promise((res, rej) => {
|
|
25
|
-
resolve = res;
|
|
26
|
-
reject = rej;
|
|
27
|
-
});
|
|
28
|
-
assert(resolve !== undefined);
|
|
29
|
-
assert(reject !== undefined);
|
|
30
|
-
return { promise, resolve, reject };
|
|
31
|
-
}
|