Skip to content

Commit

Permalink
refactor(swingset): move retireKernelObjects into kernelKeeper
Browse files Browse the repository at this point in the history
the "TODO: decref #2069 auxdata" comment was removed, because that will
be the responsibility of deleteKernelObject()
  • Loading branch information
warner committed Aug 11, 2024
1 parent 0aa60ba commit 53b83b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 1 addition & 10 deletions packages/SwingSet/src/kernel/kernelSyscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,7 @@ export function makeKernelSyscallHandler(tools) {

function retireExports(koids) {
Array.isArray(koids) || Fail`retireExports given non-Array ${koids}`;
const newActions = [];
for (const koid of koids) {
const importers = kernelKeeper.getImporters(koid);
for (const vatID of importers) {
newActions.push(`${vatID} retireImport ${koid}`);
}
// TODO: decref and delete any #2069 auxdata
kernelKeeper.deleteKernelObject(koid);
}
kernelKeeper.addGCActions(newActions);
kernelKeeper.retireKernelObjects(koids);
return OKNULL;
}

Expand Down
14 changes: 14 additions & 0 deletions packages/SwingSet/src/kernel/state/kernelKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,19 @@ export default function makeKernelKeeper(
return owner;
}

function retireKernelObjects(koids) {
Array.isArray(koids) || Fail`retireExports given non-Array ${koids}`;
const newActions = [];
for (const koid of koids) {
const importers = getImporters(koid);
for (const vatID of importers) {
newActions.push(`${vatID} retireImport ${koid}`);
}
deleteKernelObject(koid);
}
addGCActions(newActions);
}

function orphanKernelObject(kref, oldVat) {
const ownerKey = `${kref}.owner`;
const ownerVat = kvStore.get(ownerKey);
Expand Down Expand Up @@ -1823,6 +1836,7 @@ export default function makeKernelKeeper(
kernelObjectExists,
getImporters,
orphanKernelObject,
retireKernelObjects,
deleteKernelObject,
pinObject,

Expand Down

0 comments on commit 53b83b8

Please sign in to comment.