Skip to content

Commit

Permalink
Revert "Add detection for whether we are on an active Stopify stack"
Browse files Browse the repository at this point in the history
Reverting this from master (it's on activeStack) to clean up master -> master
PR
  • Loading branch information
jpolitz authored and arjunguha committed Jul 31, 2024
1 parent 7a743f6 commit 84f9740
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 51 deletions.
13 changes: 0 additions & 13 deletions stopify-continuations/src/runtime/abstractRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ export abstract class RuntimeImpl implements Runtime {
// represents 'restore' mode.
mode: Mode;

// Represents whether the stack is currently active – that is, if you
// call a function if it can expect to do its capture/restore logic
// with the right things available on the stack.
stackActive: boolean;

/**
* A saved stack trace. This field is only used when a user-mode exception
* is thrown.
Expand All @@ -73,7 +68,6 @@ export abstract class RuntimeImpl implements Runtime {
this.stackSize = stackSize;
this.remainingStack = stackSize;
this.mode = true;
this.stackActive = false;
this.kind = undefined as any; // the worst
}

Expand All @@ -83,7 +77,6 @@ export abstract class RuntimeImpl implements Runtime {
f: () => {
this.stack = [];
this.mode = true;
this.stackActive = true;
return f();
},
this: this,
Expand All @@ -93,7 +86,6 @@ export abstract class RuntimeImpl implements Runtime {
runtime<T>(body: () => any, onDone: (x: Result) => T): T {

while(true) {
this.stackActive = true;
const result = this.abstractRun(body);

if (result.type === 'normal' || result.type === 'exception') {
Expand All @@ -118,23 +110,19 @@ export abstract class RuntimeImpl implements Runtime {
}
else if(result.type === 'normal') {
assert(this.mode, 'execution completed in restore mode');
this.stackActive = false;
return onDone(result);
}
else if(result.type === 'exception') {
assert(this.mode, `execution completed in restore mode, error was: ${result.value}`);
const stack = this.stackTrace;
this.stackTrace = [];
this.stackActive = false;
return onDone({ type: 'exception', value: result.value, stack });
}
}
else if (result.type === 'capture') {
this.stackActive = false;
body = () => result.f.call(global, this.makeCont(result.stack));
}
else if (result.type === 'restore') {
this.stackActive = false;
body = () => {
if (result.stack.length === 0) {
throw new Error(`Can't restore from empty stack`);
Expand All @@ -147,7 +135,6 @@ export abstract class RuntimeImpl implements Runtime {
};
}
else if (result.type === 'end-turn') {
this.stackActive = false;
return result.callback(onDone);
}
}
Expand Down
1 change: 0 additions & 1 deletion stopify-continuations/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export interface Runtime {

mode: Mode;
stack: Stack;
stackActive: boolean;

endTurn(callback: (onDone: (x: Result) => any) => any): never;

Expand Down
4 changes: 0 additions & 4 deletions stopify/src/runtime/abstractRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ export abstract class AbstractRunner implements AsyncRun {
this.continuationsRTS.runtime(body, callback);
}

isRunning(): boolean {
return this.continuationsRTS.stackActive;
}

processEvent(body: () => void, receiver: (x: Result) => void): void {
this.eventQueue.push({ body, receiver } );
this.processQueuedEvents();
Expand Down
1 change: 0 additions & 1 deletion stopify/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export interface AsyncRun {
onBreakpoint?: (line: number) => void): void;
pause(onPaused: (line?: number) => void): void;
resume(): void;
isRunning(): boolean;
setBreakpoints(line: number[]): void;
step(onStep: (line: number) => void): void;
pauseK(callback: (k: (r: Result) => void) => void): void;
Expand Down
32 changes: 0 additions & 32 deletions stopify/test/semantics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,38 +282,6 @@ describe('integration tests', function () {
}
});

describe('Test cases that check running status',() => {
test('Running status should be paused (not running) in synchronous code after starting to run', onDone => {
const runner = harness(`
function sum(x) {
if (x % 20 === 0) { checkRunning(); }
if (x % 30 === 0) { pauseAndCheckRunning(); }
if (x <= 1) {
return 1;
} else {
return x + sum(x-1);
}
}
assert.equal(sum(100), 5050);
`, { captureMethod: 'lazy' });
runner.g.checkRunning = function() {
assert.equal(runner.isRunning(), true);
};
runner.g.pauseAndCheckRunning = function() {
runner.pauseK(k => {
assert.equal(runner.isRunning(), false);
k({ type: 'normal', value: 'restart' });
});
};
runner.run(result => {
expect(result).toEqual({ type: 'normal' });
onDone();
expect(runner.isRunning()).toBe(false);
});
}, 10000);

});

describe('Test cases that require deep stacks',() => {
const runtimeOpts: Partial<types.RuntimeOpts> = {
stackSize: 100,
Expand Down

0 comments on commit 84f9740

Please sign in to comment.