diff --git a/packages/SwingSet/src/kernel/deviceTranslator.js b/packages/SwingSet/src/kernel/deviceTranslator.js index 229d27512aaf..6152e4b4943b 100644 --- a/packages/SwingSet/src/kernel/deviceTranslator.js +++ b/packages/SwingSet/src/kernel/deviceTranslator.js @@ -69,7 +69,7 @@ function makeDRTranslator(deviceID, kernelKeeper) { * * @param {string} deviceID * @param {string} deviceName - * @param {*} kernelKeeper + * @param {KernelKeeper} kernelKeeper * @returns {(dsc: DeviceSyscallObject) => KernelSyscallObject} */ export function makeDSTranslator(deviceID, deviceName, kernelKeeper) { diff --git a/packages/SwingSet/src/kernel/gc-actions.js b/packages/SwingSet/src/kernel/gc-actions.js index 01adbeeff45b..eebe81652ac4 100644 --- a/packages/SwingSet/src/kernel/gc-actions.js +++ b/packages/SwingSet/src/kernel/gc-actions.js @@ -34,7 +34,7 @@ function parseAction(s) { } /** - * @param {*} kernelKeeper + * @param {KernelKeeper} kernelKeeper * @returns {import('../types-internal.js').RunQueueEvent | undefined} */ export function processGCActionSet(kernelKeeper) { @@ -66,11 +66,18 @@ export function processGCActionSet(kernelKeeper) { // whether the current state of the c-lsits and reference counts warrants // permits the action to run, or if it should be negated/bypassed. + /** + * + * @param {VatKeeper} vatKeeper + * @param {unknown} action + * @param {string} type + * @param {string} kref + */ + // FIXME does nothing with the 'action' argument function filterAction(vatKeeper, action, type, kref) { const hasCList = vatKeeper.hasCListEntry(kref); const isReachable = hasCList ? vatKeeper.getReachableFlag(kref) : undefined; const exists = kernelKeeper.kernelObjectExists(kref); - // @ts-expect-error xxx const { reachable, recognizable } = exists ? kernelKeeper.getObjectRefCount(kref) : {}; diff --git a/packages/SwingSet/src/kernel/kernel.js b/packages/SwingSet/src/kernel/kernel.js index 200a69a434b3..2595ef410370 100644 --- a/packages/SwingSet/src/kernel/kernel.js +++ b/packages/SwingSet/src/kernel/kernel.js @@ -51,7 +51,7 @@ function abbreviateReplacer(_, arg) { /** * Provide the kref of a vat's root object, as if it had been exported. * - * @param {*} kernelKeeper Kernel keeper managing persistent kernel state. + * @param {KernelKeeper} kernelKeeper Kernel keeper managing persistent kernel state. * @param {string} vatID Vat ID of the vat whose root kref is sought. * * @returns {string} the kref of the root object of the given vat. diff --git a/packages/SwingSet/src/kernel/state/kernelKeeper.js b/packages/SwingSet/src/kernel/state/kernelKeeper.js index 192be013c41a..06972d4dd500 100644 --- a/packages/SwingSet/src/kernel/state/kernelKeeper.js +++ b/packages/SwingSet/src/kernel/state/kernelKeeper.js @@ -132,6 +132,7 @@ const enableKernelGC = true; // Prefix reserved for host written data: // host. +/** @type {(s: string) => string[]} s */ export function commaSplit(s) { if (s === '') { return []; @@ -500,7 +501,9 @@ export default function makeKernelKeeper(kernelStorage, kernelSlog) { function getObjectRefCount(kernelSlot) { const data = kvStore.get(`${kernelSlot}.refCount`); - data || Fail`getObjectRefCount(${kernelSlot}) was missing`; + if (!data) { + throw Fail`getObjectRefCount(${kernelSlot}) was missing`; + } const [reachable, recognizable] = commaSplit(data).map(Number); reachable <= recognizable || Fail`refmismatch(get) ${kernelSlot} ${reachable},${recognizable}`; @@ -1635,3 +1638,4 @@ export default function makeKernelKeeper(kernelStorage, kernelSlog) { dump, }); } +/** @typedef {ReturnType} KernelKeeper */ diff --git a/packages/SwingSet/src/types-external.js b/packages/SwingSet/src/types-external.js index a62c411bd6bd..bdb8039b0e7a 100644 --- a/packages/SwingSet/src/types-external.js +++ b/packages/SwingSet/src/types-external.js @@ -124,7 +124,7 @@ export {}; * * @typedef { { transcriptCount: number } } VatStats * @typedef { ReturnType } VatKeeper - * @typedef { ReturnType } KernelKeeper + * @typedef { import('./kernel/state/kernelKeeper.js').KernelKeeper } KernelKeeper * @typedef { Awaited> } XSnap * @typedef { (dr: VatDeliveryResult) => void } SlogFinishDelivery * @typedef { (ksr: KernelSyscallResult, vsr: VatSyscallResult) => void } SlogFinishSyscall