@agoric/xsnap 0.14.3-upgrade-16-dev-0549112.0 → 0.14.3-upgrade-16-dev-b7c2f02.0
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/build.env +1 -1
- package/package.json +7 -5
- package/scripts/get_xsnap_version.sh +14 -0
- package/scripts/test-package.sh +21 -0
- package/src/build.js +37 -4
- package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +3 -0
- package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +3 -0
- package/xsnap-native/xsnap/sources/xsnap-worker.c +16 -4
- package/xsnap-native/xsnap/sources/xsnap.c +3 -2
- package/xsnap-native/xsnap/sources/xsnapPlatform.c +6 -1
package/build.env
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
MODDABLE_URL=https://github.com/agoric-labs/moddable.git
|
|
2
2
|
MODDABLE_COMMIT_HASH=f6c5951fc055e4ca592b9166b9ae3cbb9cca6bf0
|
|
3
3
|
XSNAP_NATIVE_URL=https://github.com/agoric-labs/xsnap-pub
|
|
4
|
-
XSNAP_NATIVE_COMMIT_HASH=
|
|
4
|
+
XSNAP_NATIVE_COMMIT_HASH=eef9b67da5517ed18ff9e0073b842db20924eae3
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/xsnap",
|
|
3
|
-
"version": "0.14.3-upgrade-16-dev-
|
|
3
|
+
"version": "0.14.3-upgrade-16-dev-b7c2f02.0+b7c2f02",
|
|
4
4
|
"description": "Snapshotting VM worker based on Moddable's XS Javascript engine",
|
|
5
5
|
"author": "Agoric",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"build:env": "node src/build.js --show-env > build.env",
|
|
17
17
|
"build:from-env": "{ cat build.env; echo node src/build.js; } | xargs env",
|
|
18
18
|
"build": "yarn build:bin && yarn build:env",
|
|
19
|
+
"check-version": "xsnap_version=$(./scripts/get_xsnap_version.sh); if test \"${npm_package_version}\" != \"${xsnap_version}\"; then echo \"xsnap version mismatch; expected '${npm_package_version}', got '${xsnap_version}'\"; exit 1; fi",
|
|
19
20
|
"postinstall": "npm run build:from-env",
|
|
20
21
|
"clean": "rm -rf xsnap-native/xsnap/build",
|
|
21
22
|
"lint": "run-s --continue-on-error lint:*",
|
|
@@ -27,9 +28,9 @@
|
|
|
27
28
|
"test:xs": "exit 0"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@agoric/assert": "0.6.1-upgrade-16-dev-
|
|
31
|
-
"@agoric/internal": "0.3.3-upgrade-16-dev-
|
|
32
|
-
"@agoric/xsnap-lockdown": "0.14.1-upgrade-16-dev-
|
|
31
|
+
"@agoric/assert": "0.6.1-upgrade-16-dev-b7c2f02.0+b7c2f02",
|
|
32
|
+
"@agoric/internal": "0.3.3-upgrade-16-dev-b7c2f02.0+b7c2f02",
|
|
33
|
+
"@agoric/xsnap-lockdown": "0.14.1-upgrade-16-dev-b7c2f02.0+b7c2f02",
|
|
33
34
|
"@endo/bundle-source": "^3.2.3",
|
|
34
35
|
"@endo/eventual-send": "^1.2.2",
|
|
35
36
|
"@endo/init": "^1.1.2",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"moddable/xs/makefiles",
|
|
57
58
|
"moddable/xs/platforms/*.h",
|
|
58
59
|
"moddable/xs/sources",
|
|
60
|
+
"scripts",
|
|
59
61
|
"src",
|
|
60
62
|
"xsnap-native/xsnap/makefiles",
|
|
61
63
|
"xsnap-native/xsnap/sources"
|
|
@@ -76,5 +78,5 @@
|
|
|
76
78
|
"typeCoverage": {
|
|
77
79
|
"atLeast": 93.95
|
|
78
80
|
},
|
|
79
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "b7c2f02873a830fc76909505a8637a69a72f1adb"
|
|
80
82
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -ueo pipefail
|
|
4
|
+
|
|
5
|
+
# the xsnap binary lives in a platform-specific directory
|
|
6
|
+
unameOut="$(uname -s)"
|
|
7
|
+
case "${unameOut}" in
|
|
8
|
+
Linux*) platform=lin ;;
|
|
9
|
+
Darwin*) platform=mac ;;
|
|
10
|
+
*) platform=win ;;
|
|
11
|
+
esac
|
|
12
|
+
|
|
13
|
+
# extract the xsnap package version from the long version printed by xsnap-worker
|
|
14
|
+
"./xsnap-native/xsnap/build/bin/${platform}/release/xsnap-worker" -v | sed -e 's/^xsnap \([^ ]*\) (XS [^)]*)$/\1/g'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Verifies that files in package.json covers everything xsnap needs to compile
|
|
3
|
+
# from sources out of an npm package.
|
|
4
|
+
set -xueo pipefail
|
|
5
|
+
|
|
6
|
+
TEMP=$(mktemp -d)
|
|
7
|
+
# function cleanup() {
|
|
8
|
+
# rm -rf "$TEMP"
|
|
9
|
+
# }
|
|
10
|
+
# trap cleanup EXIT
|
|
11
|
+
|
|
12
|
+
yarn pack -f "$TEMP/package.tar"
|
|
13
|
+
(
|
|
14
|
+
cd "$TEMP"
|
|
15
|
+
tar xvf package.tar
|
|
16
|
+
cd package
|
|
17
|
+
time yarn
|
|
18
|
+
time yarn
|
|
19
|
+
time yarn
|
|
20
|
+
time yarn
|
|
21
|
+
)
|
package/src/build.js
CHANGED
|
@@ -220,16 +220,34 @@ const updateSubmodules = async (showEnv, { env, stdout, spawn, fs }) => {
|
|
|
220
220
|
* existsSync: typeof import('fs').existsSync,
|
|
221
221
|
* rmdirSync: typeof import('fs').rmdirSync,
|
|
222
222
|
* readFile: typeof import('fs').promises.readFile,
|
|
223
|
+
* writeFile: typeof import('fs').promises.writeFile,
|
|
223
224
|
* },
|
|
224
225
|
* os: {
|
|
225
226
|
* type: typeof import('os').type,
|
|
226
227
|
* }
|
|
227
228
|
* }} io
|
|
229
|
+
* @param {object} [options]
|
|
230
|
+
* @param {boolean} [options.forceBuild]
|
|
228
231
|
*/
|
|
229
|
-
const makeXsnap = async ({ spawn, fs, os }) => {
|
|
232
|
+
const makeXsnap = async ({ spawn, fs, os }, { forceBuild = false } = {}) => {
|
|
230
233
|
const pjson = await fs.readFile(asset('../package.json'), 'utf-8');
|
|
231
234
|
const pkg = JSON.parse(pjson);
|
|
232
235
|
|
|
236
|
+
const configEnvs = [
|
|
237
|
+
`XSNAP_VERSION=${pkg.version}`,
|
|
238
|
+
`CC=cc "-D__has_builtin(x)=1"`,
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
const configEnvFile = asset('../build.config.env');
|
|
242
|
+
const existingConfigEnvs = fs.existsSync(configEnvFile)
|
|
243
|
+
? await fs.readFile(configEnvFile, 'utf-8')
|
|
244
|
+
: '';
|
|
245
|
+
|
|
246
|
+
const expectedConfigEnvs = configEnvs.concat('').join('\n');
|
|
247
|
+
if (forceBuild || existingConfigEnvs.trim() !== expectedConfigEnvs.trim()) {
|
|
248
|
+
await fs.writeFile(configEnvFile, expectedConfigEnvs);
|
|
249
|
+
}
|
|
250
|
+
|
|
233
251
|
const platform = ModdableSDK.platforms[os.type()];
|
|
234
252
|
if (!platform) {
|
|
235
253
|
throw Error(`Unsupported OS found: ${os.type()}`);
|
|
@@ -241,8 +259,10 @@ const makeXsnap = async ({ spawn, fs, os }) => {
|
|
|
241
259
|
[
|
|
242
260
|
`MODDABLE=${ModdableSDK.MODDABLE}`,
|
|
243
261
|
`GOAL=${goal}`,
|
|
244
|
-
|
|
245
|
-
`
|
|
262
|
+
// Any other configuration variables that affect the build output
|
|
263
|
+
// should be placed in `configEnvs` to force a rebuild if they change
|
|
264
|
+
...configEnvs,
|
|
265
|
+
`EXTRA_DEPS=${configEnvFile}`,
|
|
246
266
|
'-f',
|
|
247
267
|
'xsnap-worker.mk',
|
|
248
268
|
],
|
|
@@ -263,6 +283,7 @@ const makeXsnap = async ({ spawn, fs, os }) => {
|
|
|
263
283
|
* existsSync: typeof import('fs').existsSync,
|
|
264
284
|
* rmdirSync: typeof import('fs').rmdirSync,
|
|
265
285
|
* readFile: typeof import('fs').promises.readFile,
|
|
286
|
+
* writeFile: typeof import('fs').promises.writeFile,
|
|
266
287
|
* },
|
|
267
288
|
* os: {
|
|
268
289
|
* type: typeof import('os').type,
|
|
@@ -328,7 +349,18 @@ async function main(args, { env, stdout, spawn, fs, os }) {
|
|
|
328
349
|
|
|
329
350
|
if (!showEnv) {
|
|
330
351
|
if (hasSource) {
|
|
331
|
-
|
|
352
|
+
// Force a rebuild if for some reason the binary is out of date
|
|
353
|
+
// Since the make checks may not always detect that situation
|
|
354
|
+
let forceBuild = !hasBin;
|
|
355
|
+
if (hasBin) {
|
|
356
|
+
const npm = makeCLI('npm', { spawn });
|
|
357
|
+
await npm
|
|
358
|
+
.run(['run', '-s', 'check-version'], { cwd: asset('..') })
|
|
359
|
+
.catch(() => {
|
|
360
|
+
forceBuild = true;
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
await makeXsnap({ spawn, fs, os }, { forceBuild });
|
|
332
364
|
} else if (!hasBin) {
|
|
333
365
|
throw new Error(
|
|
334
366
|
'XSnap has neither sources nor a pre-built binary. Docker? .dockerignore? npm files?',
|
|
@@ -344,6 +376,7 @@ const run = () =>
|
|
|
344
376
|
spawn: childProcessTop.spawn,
|
|
345
377
|
fs: {
|
|
346
378
|
readFile: fsTop.promises.readFile,
|
|
379
|
+
writeFile: fsTop.promises.writeFile,
|
|
347
380
|
existsSync: fsTop.existsSync,
|
|
348
381
|
rmdirSync: fsTop.rmdirSync,
|
|
349
382
|
},
|
|
@@ -7,6 +7,8 @@ ifneq ($(VERBOSE),1)
|
|
|
7
7
|
MAKEFLAGS += --silent
|
|
8
8
|
endif
|
|
9
9
|
|
|
10
|
+
EXTRA_DEPS =
|
|
11
|
+
|
|
10
12
|
# MODDABLE = $(CURDIR)/../../moddable
|
|
11
13
|
BUILD_DIR = $(CURDIR)/../../build
|
|
12
14
|
TLS_DIR = $(CURDIR)/../../sources
|
|
@@ -142,6 +144,7 @@ $(OBJECTS): $(SRC_DIR)/xsAll.h
|
|
|
142
144
|
$(OBJECTS): $(SRC_DIR)/xsScript.h
|
|
143
145
|
$(OBJECTS): $(SRC_DIR)/xsSnapshot.h
|
|
144
146
|
$(OBJECTS): $(INC_DIR)/xs.h
|
|
147
|
+
$(OBJECTS): $(EXTRA_DEPS)
|
|
145
148
|
$(TMP_DIR)/%.o: %.c
|
|
146
149
|
@echo "#" $(NAME) $(GOAL) ": cc" $(<F)
|
|
147
150
|
$(CC) $< $(C_OPTIONS) -c -o $@
|
|
@@ -7,6 +7,8 @@ ifneq ($(VERBOSE),1)
|
|
|
7
7
|
MAKEFLAGS += --silent
|
|
8
8
|
endif
|
|
9
9
|
|
|
10
|
+
EXTRA_DEPS =
|
|
11
|
+
|
|
10
12
|
# MODDABLE = $(CURDIR)/../../moddable
|
|
11
13
|
BUILD_DIR = $(CURDIR)/../../build
|
|
12
14
|
TLS_DIR = $(CURDIR)/../../sources
|
|
@@ -151,6 +153,7 @@ $(OBJECTS): $(SRC_DIR)/xsAll.h
|
|
|
151
153
|
$(OBJECTS): $(SRC_DIR)/xsScript.h
|
|
152
154
|
$(OBJECTS): $(SRC_DIR)/xsSnapshot.h
|
|
153
155
|
$(OBJECTS): $(INC_DIR)/xs.h
|
|
156
|
+
$(OBJECTS): $(EXTRA_DEPS)
|
|
154
157
|
$(TMP_DIR)/%.o: %.c
|
|
155
158
|
@echo "#" $(NAME) $(GOAL) ": cc" $(<F)
|
|
156
159
|
$(CC) $< $(C_OPTIONS) -c -o $@
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
#define SNAPSHOT_SIGNATURE "xsnap 1"
|
|
18
18
|
#ifndef XSNAP_VERSION
|
|
19
19
|
# error "You must define XSNAP_VERSION in the right Makefile"
|
|
20
|
+
#else
|
|
21
|
+
// Allows grepping the binary's strings for the version: strings xsnap-worker | grep xsnap_version
|
|
22
|
+
char *VERSION = "xsnap_version: " XSNAP_VERSION;
|
|
20
23
|
#endif
|
|
21
24
|
|
|
22
25
|
#ifndef XSNAP_TEST_RECORD
|
|
@@ -182,7 +185,7 @@ typedef enum {
|
|
|
182
185
|
// 250 syscalls
|
|
183
186
|
#define MAX_TIMESTAMPS 502
|
|
184
187
|
static struct timeval timestamps[MAX_TIMESTAMPS];
|
|
185
|
-
static
|
|
188
|
+
static int num_timestamps;
|
|
186
189
|
static unsigned int timestamps_overrun;
|
|
187
190
|
static void resetTimestamps() {
|
|
188
191
|
timestamps_overrun = 0;
|
|
@@ -210,7 +213,7 @@ static char timestampBuffer[1 + MAX_TIMESTAMPS * (DIGITS_FOR_64 + 1 + 6 + 1) + 1
|
|
|
210
213
|
|
|
211
214
|
static char *renderTimestamps() {
|
|
212
215
|
// return pointer to static string buffer with '[NN.NN,NN.NN]', or NULL
|
|
213
|
-
|
|
216
|
+
int size, i, wrote;
|
|
214
217
|
char *p = timestampBuffer;
|
|
215
218
|
size = sizeof(timestampBuffer); // holds all numbers, commas, and \0
|
|
216
219
|
*(p++) = '['; size--;
|
|
@@ -219,8 +222,17 @@ static char *renderTimestamps() {
|
|
|
219
222
|
// been printed if the size were unlimited, not including the
|
|
220
223
|
// final \0". It writes at most size-1 characters, then writes
|
|
221
224
|
// the trailing \0.
|
|
225
|
+
// The type of tv_usec is 32 bits on Darwin and 64 bits on Linux at
|
|
226
|
+
// time of writing.
|
|
227
|
+
// We cast into the wider precision to ensure the format specifier gets
|
|
228
|
+
// the expected number of bits behind the variadic args reference.
|
|
229
|
+
// We do the same for tv_sec out of an outrageous abundance of caution.
|
|
222
230
|
wrote = snprintf(p, size, "%lu.%06lu",
|
|
223
|
-
timestamps[i].tv_sec,
|
|
231
|
+
(unsigned long)timestamps[i].tv_sec,
|
|
232
|
+
(unsigned long)timestamps[i].tv_usec);
|
|
233
|
+
if (wrote > size) {
|
|
234
|
+
return NULL;
|
|
235
|
+
}
|
|
224
236
|
p += wrote;
|
|
225
237
|
size -= wrote;
|
|
226
238
|
if (size < 2) { // 2 is enough for "]\0", but 1 is not
|
|
@@ -329,7 +341,7 @@ int main(int argc, char* argv[])
|
|
|
329
341
|
return E_SUCCESS;
|
|
330
342
|
}
|
|
331
343
|
else if (!strcmp(argv[argi], "-n")) {
|
|
332
|
-
printf("
|
|
344
|
+
printf("deprecated\n");
|
|
333
345
|
return E_SUCCESS;
|
|
334
346
|
} else {
|
|
335
347
|
xsPrintUsage();
|
|
@@ -12,7 +12,7 @@ static void xsReplay(xsMachine* machine);
|
|
|
12
12
|
static void xs_currentMeterLimit(xsMachine* the);
|
|
13
13
|
static void xs_gc(xsMachine* the);
|
|
14
14
|
static void xs_issueCommand(xsMachine* the);
|
|
15
|
-
static void xs_lockdown(xsMachine *the);
|
|
15
|
+
//static void xs_lockdown(xsMachine *the);
|
|
16
16
|
static void xs_performance_now(xsMachine* the);
|
|
17
17
|
static void xs_print(xsMachine* the);
|
|
18
18
|
static void xs_resetMeter(xsMachine* the);
|
|
@@ -515,7 +515,6 @@ void xs_currentMeterLimit(xsMachine* the)
|
|
|
515
515
|
|
|
516
516
|
void xs_gc(xsMachine* the)
|
|
517
517
|
{
|
|
518
|
-
fprintf(stderr, "gc()\n");
|
|
519
518
|
xsCollectGarbage();
|
|
520
519
|
}
|
|
521
520
|
|
|
@@ -565,6 +564,7 @@ void xs_issueCommand(xsMachine* the)
|
|
|
565
564
|
fclose(file);
|
|
566
565
|
}
|
|
567
566
|
|
|
567
|
+
#if 0
|
|
568
568
|
void xs_lockdown(xsMachine *the)
|
|
569
569
|
{
|
|
570
570
|
fx_lockdown(the);
|
|
@@ -609,6 +609,7 @@ void xs_lockdown(xsMachine *the)
|
|
|
609
609
|
// xsResult = xsGet(xsGlobal, xsID("setTimeout"));
|
|
610
610
|
// xsCall1(xsGlobal, xsID("harden"), xsResult);
|
|
611
611
|
}
|
|
612
|
+
#endif
|
|
612
613
|
|
|
613
614
|
void xs_performance_now(xsMachine *the)
|
|
614
615
|
{
|
|
@@ -454,6 +454,8 @@ txID fxFindModule(txMachine* the, txSlot* realm, txID moduleID, txSlot* slot)
|
|
|
454
454
|
else
|
|
455
455
|
slash = path;
|
|
456
456
|
*slash = 0;
|
|
457
|
+
if ((c_strlen(path) + c_strlen(name + dot)) >= sizeof(path))
|
|
458
|
+
mxRangeError("path too long");
|
|
457
459
|
c_strcat(path, name + dot);
|
|
458
460
|
return fxNewNameC(the, path);
|
|
459
461
|
}
|
|
@@ -802,8 +804,9 @@ void fxDumpSnapshot(txMachine* the, txSnapshot* snapshot)
|
|
|
802
804
|
{
|
|
803
805
|
Atom atom;
|
|
804
806
|
txByte byte;
|
|
805
|
-
txID profileID;
|
|
806
807
|
txCreation creation;
|
|
808
|
+
txID profileID;
|
|
809
|
+
txInteger tag;
|
|
807
810
|
Atom blockAtom;
|
|
808
811
|
txByte* block = C_NULL;
|
|
809
812
|
// txByte* blockLimit;
|
|
@@ -851,6 +854,7 @@ void fxDumpSnapshot(txMachine* the, txSnapshot* snapshot)
|
|
|
851
854
|
atom.atomSize = ntohl(atom.atomSize) - 8;
|
|
852
855
|
mxThrowIf((*snapshot->read)(snapshot->stream, &creation, sizeof(txCreation)));
|
|
853
856
|
mxThrowIf((*snapshot->read)(snapshot->stream, &profileID, sizeof(txID)));
|
|
857
|
+
mxThrowIf((*snapshot->read)(snapshot->stream, &tag, sizeof(txInteger)));
|
|
854
858
|
fprintf(stderr, "%4.4s %d\n", (txString)&(atom.atomType), atom.atomSize + 8);
|
|
855
859
|
fprintf(stderr, "\tinitialChunkSize: %d\n", creation.initialChunkSize);
|
|
856
860
|
fprintf(stderr, "\tincrementalChunkSize: %d\n", creation.incrementalChunkSize);
|
|
@@ -865,6 +869,7 @@ void fxDumpSnapshot(txMachine* the, txSnapshot* snapshot)
|
|
|
865
869
|
fprintf(stderr, "\tparserTableModulo: %d\n", creation.parserTableModulo);
|
|
866
870
|
fprintf(stderr, "\tstaticSize: %d\n", creation.staticSize);
|
|
867
871
|
fprintf(stderr, "\tprofileID: %d\n", profileID);
|
|
872
|
+
fprintf(stderr, "\ttag: %d\n", tag);
|
|
868
873
|
|
|
869
874
|
mxThrowIf((*snapshot->read)(snapshot->stream, &blockAtom, sizeof(Atom)));
|
|
870
875
|
blockAtom.atomSize = ntohl(blockAtom.atomSize) - 8;
|