@agoric/swingset-liveslots 0.10.3-dev-ecf2d8e.0 → 0.10.3-other-dev-70beeb7.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/CHANGELOG.md +61 -0
- package/package.json +17 -20
- package/src/collectionManager.js +66 -135
- package/src/index.js +1 -2
- package/src/liveslots.js +74 -47
- package/src/virtualObjectManager.js +14 -56
- package/src/virtualReferences.js +0 -51
- package/test/liveslots-helpers.js +4 -4
- package/test/mock-gc.js +0 -1
- package/test/storeGC/test-lifecycle.js +1 -1
- package/test/storeGC/test-refcount-management.js +1 -0
- package/test/storeGC/test-scalar-store-kind.js +1 -0
- package/test/storeGC/test-weak-key.js +1 -0
- package/test/test-baggage.js +1 -0
- package/test/test-cache.js +1 -0
- package/test/test-collection-schema-refcount.js +1 -0
- package/test/test-collection-upgrade.js +2 -0
- package/test/test-collections.js +14 -117
- package/test/test-dropped-collection-weakrefs.js +1 -0
- package/test/test-durabilityChecks.js +3 -2
- package/test/test-facetiousness.js +2 -1
- package/test/test-gc-sensitivity.js +1 -1
- package/test/test-handled-promises.js +6 -4
- package/test/test-initial-vrefs.js +2 -1
- package/test/test-liveslots-mock-gc.js +1 -1
- package/test/test-liveslots-real-gc.js +1 -1
- package/test/test-liveslots.js +13 -12
- package/test/test-vo-test-harness.js +1 -0
- package/test/test-vpid-liveslots.js +2 -1
- package/test/util.js +1 -1
- package/test/virtual-objects/test-cease-recognition.js +2 -2
- package/test/virtual-objects/test-cross-facet.js +2 -1
- package/test/virtual-objects/test-empty-data.js +2 -1
- package/test/virtual-objects/test-facets.js +2 -1
- package/test/virtual-objects/test-kind-changes.js +1 -1
- package/test/virtual-objects/test-reachable-vrefs.js +2 -2
- package/test/virtual-objects/test-rep-tostring.js +3 -2
- package/test/virtual-objects/test-retain-remotable.js +1 -1
- package/test/virtual-objects/test-state-shape.js +1 -1
- package/test/virtual-objects/test-virtualObjectGC.js +1 -1
- package/test/virtual-objects/test-virtualObjectManager.js +1 -5
- package/test/virtual-objects/test-vo-real-gc.js +1 -1
- package/test/virtual-objects/test-weakcollections-vref-handling.js +2 -1
- package/src/vatDataTypes.d.ts +0 -230
- package/src/vatDataTypes.js +0 -2
- package/tools/fakeCollectionManager.js +0 -44
- package/tools/fakeVirtualObjectManager.js +0 -60
- package/tools/fakeVirtualSupport.js +0 -375
- package/tools/prepare-test-env.js +0 -13
- package/tools/setup-vat-data.js +0 -54
- package/tools/vo-test-harness.js +0 -143
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
### [0.10.3-u11.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.2...@agoric/swingset-liveslots@0.10.3-u11.0) (2023-08-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### [0.10.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.1...@agoric/swingset-liveslots@0.10.2) (2023-06-02)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### [0.10.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.0...@agoric/swingset-liveslots@0.10.1) (2023-05-24)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 0.10.0 (2023-05-19)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* better diagnostic for failed reanimate ([c0c9c94](https://github.com/Agoric/agoric-sdk/commit/c0c9c9433648d520aa2bcdbadbbfe877831567c7)), closes [Error#1](https://github.com/Agoric/Error/issues/1)
|
|
36
|
+
* **swingset-liveslots:** label virtual instances ([4191eb6](https://github.com/Agoric/agoric-sdk/commit/4191eb62d0e64048c3c715e5f71a53a747267350))
|
|
37
|
+
* add APIs for tracking/debugging undesired object retention (aka "leaks") ([0a7221b](https://github.com/Agoric/agoric-sdk/commit/0a7221b3c04f3b2894c30346fa2ea6fb0130c046)), closes [#7318](https://github.com/Agoric/agoric-sdk/issues/7318)
|
|
38
|
+
* move liveslots and specific tests to a new package ([0921a89](https://github.com/Agoric/agoric-sdk/commit/0921a8903b72cfefdf05a5906bcfb826cac1cc2f)), closes [#6596](https://github.com/Agoric/agoric-sdk/issues/6596)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
|
|
43
|
+
* **liveslots:** allow new Kind upgrade to add new facets ([6bc6694](https://github.com/Agoric/agoric-sdk/commit/6bc6694968e6d2f529e7c91ec1efb11fdff2e2d3)), closes [#7437](https://github.com/Agoric/agoric-sdk/issues/7437)
|
|
44
|
+
* **liveslots:** retain WeakRefs to voAware collections ([3935723](https://github.com/Agoric/agoric-sdk/commit/393572396781afd17691e1366abeba696228a24e)), closes [#7371](https://github.com/Agoric/agoric-sdk/issues/7371)
|
|
45
|
+
* **swingset-liveslots:** prevent VOM infinite loop if `globalThis.WeakSet` etc are replaced ([d7b35e2](https://github.com/Agoric/agoric-sdk/commit/d7b35e28715a715ef510f2717e0040fa017caab4))
|
|
46
|
+
* adding dup entries to virtual sets is OK ([c81d367](https://github.com/Agoric/agoric-sdk/commit/c81d3677d8085eb4debe5baa416816ff94d582cf)), closes [#7234](https://github.com/Agoric/agoric-sdk/issues/7234)
|
|
47
|
+
* code updates for new marshal ([292f971](https://github.com/Agoric/agoric-sdk/commit/292f971769db69e61782f96638c2f687c3f95ac2))
|
|
48
|
+
* **SwingSet:** Don't send stopVat during upgrade ([5cc47d2](https://github.com/Agoric/agoric-sdk/commit/5cc47d2d8892690f8c1653630b41dd64cc42d73b)), closes [#6650](https://github.com/Agoric/agoric-sdk/issues/6650)
|
|
49
|
+
* **types:** return value of deleter ([457f576](https://github.com/Agoric/agoric-sdk/commit/457f5765b9fc0a693e6eb5e6644ddf4af3b791db))
|
|
50
|
+
* move many type definitions from swingset to liveslots ([727143d](https://github.com/Agoric/agoric-sdk/commit/727143d5562498e2e3013c34304f229b4dd11da5))
|
|
51
|
+
* move rejectAllPromises from stopVat to kernels-side upgradeVat ([d79623f](https://github.com/Agoric/agoric-sdk/commit/d79623f3fb3b87653dba1c71eb1153711c9d962c)), closes [#6694](https://github.com/Agoric/agoric-sdk/issues/6694)
|
|
52
|
+
* Move upgrade-time abandonExports responsibility into the kernel ([66ac657](https://github.com/Agoric/agoric-sdk/commit/66ac657d51d3d1be61ee4a6e9a621a664086ee57)), closes [#6696](https://github.com/Agoric/agoric-sdk/issues/6696)
|
|
53
|
+
* only the exo api change ([5cf3bf1](https://github.com/Agoric/agoric-sdk/commit/5cf3bf10a71dd02094365a66e87032e5d17d004f))
|
|
54
|
+
* **liveslots:** use Map for vrefStatus, not object ([1456e2a](https://github.com/Agoric/agoric-sdk/commit/1456e2ae006bb1c702383cedda5e5c407968840e))
|
|
55
|
+
* **swingset:** move a bunch of types from swingset to swingset-liveslots ([14f9bb0](https://github.com/Agoric/agoric-sdk/commit/14f9bb00c82c085dc647f23b6c90b26e6a0a6dfd))
|
|
56
|
+
* **swingset-liveslots:** Move promise rejection responsibility into the kernel ([dd29ff3](https://github.com/Agoric/agoric-sdk/commit/dd29ff35c5dc72efbbf7087849182aa7f04b2bb1)), closes [#6694](https://github.com/Agoric/agoric-sdk/issues/6694)
|
|
57
|
+
* add 'v'/'d' virtual/durable annotations to vrefs ([b859e92](https://github.com/Agoric/agoric-sdk/commit/b859e92fe041415d6e34250f672a10ad927aa33e)), closes [#6695](https://github.com/Agoric/agoric-sdk/issues/6695)
|
|
58
|
+
* update description of "FINALIZED" state ([809f366](https://github.com/Agoric/agoric-sdk/commit/809f3660c083467e76deb1487015cb24205a801d))
|
|
59
|
+
* without assertKeyPattern ([#7035](https://github.com/Agoric/agoric-sdk/issues/7035)) ([c9fcd7f](https://github.com/Agoric/agoric-sdk/commit/c9fcd7f82757732435cd96f3377e4fbfb6586ce7))
|
|
60
|
+
* **swingset-liveslots:** copy helper files to new liveslots package ([be7229f](https://github.com/Agoric/agoric-sdk/commit/be7229f7217c1ecc523069a57945a372f4a1e00e))
|
|
61
|
+
* **swingset-liveslots:** update imports of helper files ([0b4b38a](https://github.com/Agoric/agoric-sdk/commit/0b4b38a1f9efbb3e1e860172b0b802548d18ae2e))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/swingset-liveslots",
|
|
3
|
-
"version": "0.10.3-dev-
|
|
3
|
+
"version": "0.10.3-other-dev-70beeb7.0+70beeb7",
|
|
4
4
|
"description": "SwingSet ocap support layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -13,31 +13,31 @@
|
|
|
13
13
|
"test:xs": "exit 0",
|
|
14
14
|
"lint-fix": "yarn lint:eslint --fix",
|
|
15
15
|
"lint": "run-s --continue-on-error lint:*",
|
|
16
|
-
"lint:types": "tsc",
|
|
16
|
+
"lint:types": "tsc -p jsconfig.json",
|
|
17
17
|
"lint:eslint": "eslint ."
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@agoric/assert": "0.6.1-dev-
|
|
21
|
-
"@agoric/internal": "0.3.3-dev-
|
|
22
|
-
"@agoric/store": "0.9.3-dev-
|
|
23
|
-
"@
|
|
24
|
-
"@endo/
|
|
25
|
-
"@endo/
|
|
26
|
-
"@endo/
|
|
27
|
-
"@endo/
|
|
28
|
-
"@endo/
|
|
29
|
-
"@endo/
|
|
30
|
-
"@endo/
|
|
31
|
-
"@endo/
|
|
20
|
+
"@agoric/assert": "0.6.1-other-dev-70beeb7.0+70beeb7",
|
|
21
|
+
"@agoric/internal": "0.3.3-other-dev-70beeb7.0+70beeb7",
|
|
22
|
+
"@agoric/store": "0.9.3-other-dev-70beeb7.0+70beeb7",
|
|
23
|
+
"@agoric/vat-data": "0.5.3-other-dev-70beeb7.0+70beeb7",
|
|
24
|
+
"@endo/eventual-send": "0.17.2",
|
|
25
|
+
"@endo/exo": "0.2.2",
|
|
26
|
+
"@endo/far": "0.2.18",
|
|
27
|
+
"@endo/init": "0.5.56",
|
|
28
|
+
"@endo/marshal": "0.8.5",
|
|
29
|
+
"@endo/nat": "4.1.27",
|
|
30
|
+
"@endo/pass-style": "0.1.3",
|
|
31
|
+
"@endo/patterns": "0.2.2",
|
|
32
|
+
"@endo/promise-kit": "0.2.56"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"ava": "^5.
|
|
35
|
+
"ava": "^5.2.0"
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
37
38
|
"src/**/*.js",
|
|
38
39
|
"src/**/*.d.ts",
|
|
39
40
|
"test/**/*.js",
|
|
40
|
-
"tools",
|
|
41
41
|
"exported.js"
|
|
42
42
|
],
|
|
43
43
|
"repository": {
|
|
@@ -54,14 +54,11 @@
|
|
|
54
54
|
"files": [
|
|
55
55
|
"test/**/test-*.js"
|
|
56
56
|
],
|
|
57
|
-
"require": [
|
|
58
|
-
"@endo/init/debug.js"
|
|
59
|
-
],
|
|
60
57
|
"timeout": "20m",
|
|
61
58
|
"workerThreads": false
|
|
62
59
|
},
|
|
63
60
|
"publishConfig": {
|
|
64
61
|
"access": "public"
|
|
65
62
|
},
|
|
66
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "70beeb7e476f24cfad30fa8cd5918f04746e8839"
|
|
67
64
|
}
|
package/src/collectionManager.js
CHANGED
|
@@ -15,10 +15,7 @@ import {
|
|
|
15
15
|
makeCopySet,
|
|
16
16
|
makeCopyMap,
|
|
17
17
|
getRankCover,
|
|
18
|
-
getCopyMapEntries,
|
|
19
|
-
getCopySetKeys,
|
|
20
18
|
} from '@endo/patterns';
|
|
21
|
-
import { isCopyMap, isCopySet } from '@agoric/store';
|
|
22
19
|
import { makeBaseRef, parseVatSlot } from './parseVatSlots.js';
|
|
23
20
|
import {
|
|
24
21
|
enumerateKeysStartEnd,
|
|
@@ -50,14 +47,6 @@ function throwNotDurable(value, slotIndex, serializedValue) {
|
|
|
50
47
|
Fail`value is not durable: ${value} at slot ${q(slotIndex)} of ${serializedValue.body}`;
|
|
51
48
|
}
|
|
52
49
|
|
|
53
|
-
function failNotFound(key, label) {
|
|
54
|
-
Fail`key ${key} not found in collection ${q(label)}`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function failNotIterable(value) {
|
|
58
|
-
Fail`provided data source is not iterable: ${value}`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
50
|
function prefixc(collectionID, dbEntryKey) {
|
|
62
51
|
return `vc.${collectionID}.${dbEntryKey}`;
|
|
63
52
|
}
|
|
@@ -347,26 +336,24 @@ export function makeCollectionManager(
|
|
|
347
336
|
const { keyShape } = getSchema();
|
|
348
337
|
if (!matches(key, keyShape)) {
|
|
349
338
|
return false;
|
|
350
|
-
}
|
|
339
|
+
}
|
|
340
|
+
if (passStyleOf(key) === 'remotable') {
|
|
351
341
|
return getOrdinal(key) !== undefined;
|
|
352
342
|
} else {
|
|
353
343
|
return syscall.vatstoreGet(keyToDBKey(key)) !== undefined;
|
|
354
344
|
}
|
|
355
345
|
}
|
|
356
346
|
|
|
357
|
-
function mustGet(key, label) {
|
|
358
|
-
if (passStyleOf(key) === 'remotable' && getOrdinal(key) === undefined) {
|
|
359
|
-
failNotFound(key, label);
|
|
360
|
-
}
|
|
361
|
-
const dbKey = keyToDBKey(key);
|
|
362
|
-
const result = syscall.vatstoreGet(dbKey) || failNotFound(key, label);
|
|
363
|
-
return { dbKey, result };
|
|
364
|
-
}
|
|
365
|
-
|
|
366
347
|
function get(key) {
|
|
367
348
|
const { keyShape, label } = getSchema();
|
|
368
349
|
mustMatch(key, keyShape, makeInvalidKeyTypeMsg(label));
|
|
369
|
-
|
|
350
|
+
if (passStyleOf(key) === 'remotable' && getOrdinal(key) === undefined) {
|
|
351
|
+
throw Fail`key ${key} not found in collection ${q(label)}`;
|
|
352
|
+
}
|
|
353
|
+
const result = syscall.vatstoreGet(keyToDBKey(key));
|
|
354
|
+
if (!result) {
|
|
355
|
+
throw Fail`key ${key} not found in collection ${q(label)}`;
|
|
356
|
+
}
|
|
370
357
|
return unserializeValue(JSON.parse(result));
|
|
371
358
|
}
|
|
372
359
|
|
|
@@ -390,11 +377,11 @@ export function makeCollectionManager(
|
|
|
390
377
|
currentGenerationNumber += 1;
|
|
391
378
|
assertAcceptableSyscallCapdataSize([serializedValue]);
|
|
392
379
|
if (durable) {
|
|
393
|
-
|
|
380
|
+
serializedValue.slots.forEach((vref, slotIndex) => {
|
|
394
381
|
if (!vrm.isDurable(vref)) {
|
|
395
382
|
throwNotDurable(value, slotIndex, serializedValue);
|
|
396
383
|
}
|
|
397
|
-
}
|
|
384
|
+
});
|
|
398
385
|
}
|
|
399
386
|
if (passStyleOf(key) === 'remotable') {
|
|
400
387
|
/** @type {string} */
|
|
@@ -410,9 +397,7 @@ export function makeCollectionManager(
|
|
|
410
397
|
vrm.addReachableVref(vref);
|
|
411
398
|
}
|
|
412
399
|
}
|
|
413
|
-
|
|
414
|
-
vrm.addReachableVref(vref);
|
|
415
|
-
}
|
|
400
|
+
serializedValue.slots.forEach(vrm.addReachableVref);
|
|
416
401
|
syscall.vatstoreSet(keyToDBKey(key), JSON.stringify(serializedValue));
|
|
417
402
|
updateEntryCount(1);
|
|
418
403
|
};
|
|
@@ -431,13 +416,15 @@ export function makeCollectionManager(
|
|
|
431
416
|
const after = serializeValue(harden(value));
|
|
432
417
|
assertAcceptableSyscallCapdataSize([after]);
|
|
433
418
|
if (durable) {
|
|
434
|
-
|
|
419
|
+
after.slots.forEach((vref, i) => {
|
|
435
420
|
if (!vrm.isDurable(vref)) {
|
|
436
421
|
throwNotDurable(value, i, after);
|
|
437
422
|
}
|
|
438
|
-
}
|
|
423
|
+
});
|
|
439
424
|
}
|
|
440
|
-
const
|
|
425
|
+
const dbKey = keyToDBKey(key);
|
|
426
|
+
const rawBefore = syscall.vatstoreGet(dbKey);
|
|
427
|
+
rawBefore || Fail`key ${key} not found in collection ${q(label)}`;
|
|
441
428
|
const before = JSON.parse(rawBefore);
|
|
442
429
|
vrm.updateReferenceCounts(before.slots, after.slots);
|
|
443
430
|
syscall.vatstoreSet(dbKey, JSON.stringify(after));
|
|
@@ -446,7 +433,12 @@ export function makeCollectionManager(
|
|
|
446
433
|
function deleteInternal(key) {
|
|
447
434
|
const { keyShape, label } = getSchema();
|
|
448
435
|
mustMatch(key, keyShape, makeInvalidKeyTypeMsg(label));
|
|
449
|
-
|
|
436
|
+
if (passStyleOf(key) === 'remotable' && getOrdinal(key) === undefined) {
|
|
437
|
+
throw Fail`key ${key} not found in collection ${q(label)}`;
|
|
438
|
+
}
|
|
439
|
+
const dbKey = keyToDBKey(key);
|
|
440
|
+
const rawValue = syscall.vatstoreGet(dbKey);
|
|
441
|
+
rawValue || Fail`key ${key} not found in collection ${q(label)}`;
|
|
450
442
|
const value = JSON.parse(rawValue);
|
|
451
443
|
const doMoreGC1 = value.slots.map(vrm.removeReachableVref).some(b => b);
|
|
452
444
|
syscall.vatstoreDelete(dbKey);
|
|
@@ -482,15 +474,18 @@ export function makeCollectionManager(
|
|
|
482
474
|
const end = prefix(coverEnd); // exclusive
|
|
483
475
|
|
|
484
476
|
const generationAtStart = currentGenerationNumber;
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
477
|
+
function checkGen() {
|
|
478
|
+
if (generationAtStart !== currentGenerationNumber) {
|
|
479
|
+
Fail`keys in store cannot be added to during iteration`;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
488
482
|
|
|
489
483
|
const needToMatchKey = !matchAny(keyPatt);
|
|
490
484
|
const needToMatchValue = !matchAny(valuePatt);
|
|
491
485
|
|
|
492
|
-
// we might not need to unserialize
|
|
486
|
+
// we always get the dbKey, but we might not need to unserialize it
|
|
493
487
|
const needKeys = yieldKeys || needToMatchKey;
|
|
488
|
+
// we don't always need the dbValue
|
|
494
489
|
const needValues = yieldValues || needToMatchValue;
|
|
495
490
|
|
|
496
491
|
/**
|
|
@@ -629,34 +624,6 @@ export function makeCollectionManager(
|
|
|
629
624
|
const snapshotMap = (keyPatt, valuePatt) =>
|
|
630
625
|
makeCopyMap(entries(keyPatt, valuePatt));
|
|
631
626
|
|
|
632
|
-
const addAllToSet = elems => {
|
|
633
|
-
if (typeof elems[Symbol.iterator] !== 'function') {
|
|
634
|
-
elems =
|
|
635
|
-
Object.isFrozen(elems) && isCopySet(elems)
|
|
636
|
-
? getCopySetKeys(elems)
|
|
637
|
-
: failNotIterable(elems);
|
|
638
|
-
}
|
|
639
|
-
for (const elem of elems) {
|
|
640
|
-
addToSet(elem);
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
const addAllToMap = mapEntries => {
|
|
645
|
-
if (typeof mapEntries[Symbol.iterator] !== 'function') {
|
|
646
|
-
mapEntries =
|
|
647
|
-
Object.isFrozen(mapEntries) && isCopyMap(mapEntries)
|
|
648
|
-
? getCopyMapEntries(mapEntries)
|
|
649
|
-
: failNotIterable(mapEntries);
|
|
650
|
-
}
|
|
651
|
-
for (const [key, value] of mapEntries) {
|
|
652
|
-
if (has(key)) {
|
|
653
|
-
set(key, value);
|
|
654
|
-
} else {
|
|
655
|
-
doInit(key, value, true);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
|
|
660
627
|
return {
|
|
661
628
|
has,
|
|
662
629
|
get,
|
|
@@ -668,8 +635,6 @@ export function makeCollectionManager(
|
|
|
668
635
|
keys,
|
|
669
636
|
values,
|
|
670
637
|
entries,
|
|
671
|
-
addAllToSet,
|
|
672
|
-
addAllToMap,
|
|
673
638
|
snapshotSet,
|
|
674
639
|
snapshotMap,
|
|
675
640
|
sizeInternal,
|
|
@@ -682,23 +647,12 @@ export function makeCollectionManager(
|
|
|
682
647
|
const hasWeakKeys = storeKindInfo[kindName].hasWeakKeys;
|
|
683
648
|
const raw = summonCollectionInternal(initial, collectionID, kindName);
|
|
684
649
|
|
|
685
|
-
const {
|
|
686
|
-
has,
|
|
687
|
-
get,
|
|
688
|
-
init,
|
|
689
|
-
addToSet,
|
|
690
|
-
addAllToMap,
|
|
691
|
-
addAllToSet,
|
|
692
|
-
set,
|
|
693
|
-
delete: del,
|
|
694
|
-
} = raw;
|
|
650
|
+
const { has, get, init, addToSet, set, delete: del } = raw;
|
|
695
651
|
const weakMethods = {
|
|
696
652
|
has,
|
|
697
653
|
get,
|
|
698
654
|
init,
|
|
699
655
|
addToSet,
|
|
700
|
-
addAllToSet,
|
|
701
|
-
addAllToMap,
|
|
702
656
|
set,
|
|
703
657
|
delete: del,
|
|
704
658
|
};
|
|
@@ -793,15 +747,13 @@ export function makeCollectionManager(
|
|
|
793
747
|
}
|
|
794
748
|
const schemataCapData = serialize(harden(schemata));
|
|
795
749
|
if (isDurable) {
|
|
796
|
-
|
|
750
|
+
schemataCapData.slots.forEach((vref, slotIndex) => {
|
|
797
751
|
if (!vrm.isDurable(vref)) {
|
|
798
752
|
throwNotDurable(vref, slotIndex, schemataCapData);
|
|
799
753
|
}
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
for (const vref of schemataCapData.slots) {
|
|
803
|
-
vrm.addReachableVref(vref);
|
|
754
|
+
});
|
|
804
755
|
}
|
|
756
|
+
schemataCapData.slots.forEach(vrm.addReachableVref);
|
|
805
757
|
|
|
806
758
|
schemaCache.set(
|
|
807
759
|
collectionID,
|
|
@@ -812,48 +764,12 @@ export function makeCollectionManager(
|
|
|
812
764
|
}
|
|
813
765
|
|
|
814
766
|
function collectionToMapStore(collection) {
|
|
815
|
-
const {
|
|
816
|
-
|
|
817
|
-
get,
|
|
818
|
-
init,
|
|
819
|
-
set,
|
|
820
|
-
delete: del,
|
|
821
|
-
addAllToMap,
|
|
822
|
-
keys,
|
|
823
|
-
values,
|
|
824
|
-
entries,
|
|
825
|
-
snapshotMap,
|
|
826
|
-
getSize,
|
|
827
|
-
clear,
|
|
828
|
-
} = collection;
|
|
829
|
-
const mapStore = {
|
|
830
|
-
has,
|
|
831
|
-
get,
|
|
832
|
-
init,
|
|
833
|
-
set,
|
|
834
|
-
delete: del,
|
|
835
|
-
addAll: addAllToMap,
|
|
836
|
-
keys,
|
|
837
|
-
values,
|
|
838
|
-
entries,
|
|
839
|
-
snapshot: snapshotMap,
|
|
840
|
-
getSize,
|
|
841
|
-
clear,
|
|
842
|
-
};
|
|
843
|
-
return Far('mapStore', mapStore);
|
|
767
|
+
const { snapshotSet: _, snapshotMap, ...rest } = collection;
|
|
768
|
+
return Far('mapStore', { snapshot: snapshotMap, ...rest });
|
|
844
769
|
}
|
|
845
770
|
|
|
846
771
|
function collectionToWeakMapStore(collection) {
|
|
847
|
-
|
|
848
|
-
const weakMapStore = {
|
|
849
|
-
has,
|
|
850
|
-
get,
|
|
851
|
-
init,
|
|
852
|
-
set,
|
|
853
|
-
delete: del,
|
|
854
|
-
addAll: addAllToMap,
|
|
855
|
-
};
|
|
856
|
-
return Far('weakMapStore', weakMapStore);
|
|
772
|
+
return Far('weakMapStore', collection);
|
|
857
773
|
}
|
|
858
774
|
|
|
859
775
|
function collectionToSetStore(collection) {
|
|
@@ -861,35 +777,50 @@ export function makeCollectionManager(
|
|
|
861
777
|
has,
|
|
862
778
|
addToSet,
|
|
863
779
|
delete: del,
|
|
864
|
-
addAllToSet,
|
|
865
780
|
keys,
|
|
866
|
-
snapshotSet,
|
|
867
781
|
getSize,
|
|
782
|
+
snapshotSet,
|
|
868
783
|
clear,
|
|
869
784
|
} = collection;
|
|
785
|
+
function* entries(patt) {
|
|
786
|
+
for (const k of keys(patt)) {
|
|
787
|
+
yield [k, k];
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function addAll(elems) {
|
|
791
|
+
for (const elem of elems) {
|
|
792
|
+
addToSet(elem, null);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
870
795
|
|
|
871
796
|
const setStore = {
|
|
872
797
|
has,
|
|
873
798
|
add: addToSet,
|
|
799
|
+
addAll,
|
|
874
800
|
delete: del,
|
|
875
|
-
addAll: addAllToSet,
|
|
876
801
|
keys: patt => keys(patt),
|
|
877
802
|
values: patt => keys(patt),
|
|
878
|
-
|
|
803
|
+
entries,
|
|
879
804
|
getSize: patt => getSize(patt),
|
|
805
|
+
snapshot: snapshotSet,
|
|
880
806
|
clear,
|
|
881
807
|
};
|
|
882
808
|
return Far('setStore', setStore);
|
|
883
809
|
}
|
|
884
810
|
|
|
885
811
|
function collectionToWeakSetStore(collection) {
|
|
886
|
-
const { has, addToSet, delete: del
|
|
812
|
+
const { has, addToSet, delete: del } = collection;
|
|
813
|
+
function addAll(elems) {
|
|
814
|
+
for (const elem of elems) {
|
|
815
|
+
addToSet(elem);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
887
818
|
|
|
888
819
|
const weakSetStore = {
|
|
889
820
|
has,
|
|
890
821
|
add: addToSet,
|
|
822
|
+
addAll,
|
|
891
823
|
delete: del,
|
|
892
|
-
addAll: addAllToSet,
|
|
893
824
|
};
|
|
894
825
|
return Far('weakSetStore', weakSetStore);
|
|
895
826
|
}
|
|
@@ -898,7 +829,7 @@ export function makeCollectionManager(
|
|
|
898
829
|
* Produce a big map.
|
|
899
830
|
*
|
|
900
831
|
* @template K,V
|
|
901
|
-
* @param {string} [label] - diagnostic label for the store
|
|
832
|
+
* @param {string} [label='map'] - diagnostic label for the store
|
|
902
833
|
* @param {StoreOptions} [options]
|
|
903
834
|
* @returns {MapStore<K,V>}
|
|
904
835
|
*/
|
|
@@ -942,7 +873,7 @@ export function makeCollectionManager(
|
|
|
942
873
|
* Produce a weak big map.
|
|
943
874
|
*
|
|
944
875
|
* @template K,V
|
|
945
|
-
* @param {string} [label] - diagnostic label for the store
|
|
876
|
+
* @param {string} [label='weakMap'] - diagnostic label for the store
|
|
946
877
|
* @param {StoreOptions} [options]
|
|
947
878
|
* @returns {WeakMapStore<K,V>}
|
|
948
879
|
*/
|
|
@@ -971,7 +902,7 @@ export function makeCollectionManager(
|
|
|
971
902
|
* Produce a big set.
|
|
972
903
|
*
|
|
973
904
|
* @template K
|
|
974
|
-
* @param {string} [label] - diagnostic label for the store
|
|
905
|
+
* @param {string} [label='set'] - diagnostic label for the store
|
|
975
906
|
* @param {StoreOptions} [options]
|
|
976
907
|
* @returns {SetStore<K>}
|
|
977
908
|
*/
|
|
@@ -998,7 +929,7 @@ export function makeCollectionManager(
|
|
|
998
929
|
* Produce a weak big set.
|
|
999
930
|
*
|
|
1000
931
|
* @template K
|
|
1001
|
-
* @param {string} [label] - diagnostic label for the store
|
|
932
|
+
* @param {string} [label='weakSet'] - diagnostic label for the store
|
|
1002
933
|
* @param {StoreOptions} [options]
|
|
1003
934
|
* @returns {WeakSetStore<K>}
|
|
1004
935
|
*/
|
|
@@ -1075,7 +1006,7 @@ export function makeCollectionManager(
|
|
|
1075
1006
|
* remotables.
|
|
1076
1007
|
*
|
|
1077
1008
|
* @template K,V
|
|
1078
|
-
* @param {string} [label] - diagnostic label for the store
|
|
1009
|
+
* @param {string} [label='map'] - diagnostic label for the store
|
|
1079
1010
|
* @param {StoreOptions} [options]
|
|
1080
1011
|
* @returns {MapStore<K,V>}
|
|
1081
1012
|
*/
|
|
@@ -1087,7 +1018,7 @@ export function makeCollectionManager(
|
|
|
1087
1018
|
* primitives, or remotables.
|
|
1088
1019
|
*
|
|
1089
1020
|
* @template K,V
|
|
1090
|
-
* @param {string} [label] - diagnostic label for the store
|
|
1021
|
+
* @param {string} [label='weakMap'] - diagnostic label for the store
|
|
1091
1022
|
* @param {StoreOptions} [options]
|
|
1092
1023
|
* @returns {WeakMapStore<K,V>}
|
|
1093
1024
|
*/
|
|
@@ -1099,7 +1030,7 @@ export function makeCollectionManager(
|
|
|
1099
1030
|
* remotables.
|
|
1100
1031
|
*
|
|
1101
1032
|
* @template K
|
|
1102
|
-
* @param {string} [label] - diagnostic label for the store
|
|
1033
|
+
* @param {string} [label='set'] - diagnostic label for the store
|
|
1103
1034
|
* @param {StoreOptions} [options]
|
|
1104
1035
|
* @returns {SetStore<K>}
|
|
1105
1036
|
*/
|
|
@@ -1111,7 +1042,7 @@ export function makeCollectionManager(
|
|
|
1111
1042
|
* primitives, or remotables.
|
|
1112
1043
|
*
|
|
1113
1044
|
* @template K
|
|
1114
|
-
* @param {string} [label] - diagnostic label for the store
|
|
1045
|
+
* @param {string} [label='weakSet'] - diagnostic label for the store
|
|
1115
1046
|
* @param {StoreOptions} [options]
|
|
1116
1047
|
* @returns {WeakSetStore<K>}
|
|
1117
1048
|
*/
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/export -- types files have no named runtime exports */
|
|
2
1
|
export { makeLiveSlots, makeMarshaller } from './liveslots.js';
|
|
3
2
|
|
|
4
3
|
export {
|
|
@@ -9,5 +8,5 @@ export {
|
|
|
9
8
|
insistVatSyscallResult,
|
|
10
9
|
} from './message.js';
|
|
11
10
|
|
|
11
|
+
// eslint-disable-next-line import/export -- no named exports
|
|
12
12
|
export * from './types.js';
|
|
13
|
-
export * from './vatDataTypes.js';
|