Skip to content

Commit

Permalink
Move KDebug to its own file, and share the trigger variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Jan 23, 2020
1 parent 4bde699 commit ae07a97
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 23 deletions.
3 changes: 2 additions & 1 deletion packages/SwingSet/src/kernel/deviceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { insistKernelType } from './parseKernelSlots';
import { insistVatType, parseVatSlot } from '../parseVatSlots';
import { insistCapData } from '../capdata';
import { insistMessage } from '../message';
import kdebug from './kdebug';

export default function makeDeviceManager(
deviceName,
Expand All @@ -13,7 +14,7 @@ export default function makeDeviceManager(
endowments,
deviceKeeper,
) {
const { kdebug, send, log } = syscallManager;
const { send, log } = syscallManager;

function mapDeviceSlotToKernelSlot(devSlot) {
insist(`${devSlot}` === devSlot, 'non-string devSlot');
Expand Down
7 changes: 7 additions & 0 deletions packages/SwingSet/src/kernel/kdebug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const enableKDebug = false;

export default function kdebug(...args) {
if (enableKDebug) {
console.log(...args);
}
}
8 changes: 1 addition & 7 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import makePromise from '../makePromise';
import makeDeviceManager from './deviceManager';
import { wrapStorage } from './state/storageWrapper';
import makeKernelKeeper from './state/kernelKeeper';
import kdebug from './kdebug';
import { insistKernelType, parseKernelSlot } from './parseKernelSlots';
import { makeVatSlot, parseVatSlot } from '../parseVatSlots';
import { insist } from '../insist';
Expand Down Expand Up @@ -48,13 +49,6 @@ export default function buildKernel(kernelEndowments) {
log: [],
};

const enableKDebug = false;
function kdebug(...args) {
if (enableKDebug) {
console.log(...args);
}
}

let running = false;

// runQueue entries are {type, vatID, more..}. 'more' depends on type:
Expand Down
8 changes: 1 addition & 7 deletions packages/SwingSet/src/kernel/state/kernelKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '../parseKernelSlots';
import { insistCapData } from '../../capdata';
import { insistDeviceID, insistVatID, makeDeviceID, makeVatID } from '../id';
import kdebug from '../kdebug';

// This holds all the kernel state, including that of each Vat and Device, in
// a single JSON-serializable object. At any moment (well, really only
Expand Down Expand Up @@ -91,13 +92,6 @@ const FIRST_PROMISE_ID = 40;
export default function makeKernelKeeper(storage) {
insistEnhancedStorageAPI(storage);

const enableKDebug = false;
function kdebug(...args) {
if (enableKDebug) {
console.log(...args);
}
}

function getRequired(key) {
if (!storage.has(key)) {
throw new Error(`storage lacks required key ${key}`);
Expand Down
8 changes: 1 addition & 7 deletions packages/SwingSet/src/kernel/state/vatKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { insist } from '../../insist';
import { parseKernelSlot } from '../parseKernelSlots';
import { makeVatSlot, parseVatSlot } from '../../parseVatSlots';
import { insistVatID } from '../id';
import kdebug from '../kdebug';

// makeVatKeeper is a pure function: all state is kept in the argument object

Expand All @@ -22,13 +23,6 @@ export function makeVatKeeper(
) {
insistVatID(vatID);

const enableKDebug = false;
function kdebug(...args) {
if (enableKDebug) {
console.log(...args);
}
}

function mapVatSlotToKernelSlot(vatSlot) {
insist(`${vatSlot}` === vatSlot, 'non-string vatSlot');
const vatKey = `${vatID}.c.${vatSlot}`;
Expand Down
3 changes: 2 additions & 1 deletion packages/SwingSet/src/kernel/vatManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { insistKernelType, parseKernelSlot } from './parseKernelSlots';
import { insistVatType, parseVatSlot } from '../parseVatSlots';
import { insistCapData } from '../capdata';
import { insistMessage } from '../message';
import kdebug from './kdebug';

export default function makeVatManager(
vatID,
Expand All @@ -14,7 +15,7 @@ export default function makeVatManager(
kernelKeeper,
vatKeeper,
) {
const { kdebug, process } = syscallManager;
const { process } = syscallManager;

// We use vat-centric terminology here, so "inbound" means "into a vat",
// generally from the kernel. We also have "comms vats" which use special
Expand Down

0 comments on commit ae07a97

Please sign in to comment.