Fix attempt to pop from the stack

-Keeps it in newThreads
-Update thread status to STATUS_RUNNING to keep it going
This commit is contained in:
Tim Mickel 2016-05-03 13:53:52 -04:00
parent 852b11519a
commit 548d95b765
3 changed files with 27 additions and 25 deletions

View file

@ -57,20 +57,21 @@ Sequencer.prototype.stepThreads = function (threads) {
activeThread.status = Thread.STATUS_RUNNING;
// @todo Deal with the return value
}
// First attempt to pop from the stack
if (activeThread.stack.length > 0 &&
activeThread.nextBlock === null &&
activeThread.status === Thread.STATUS_DONE) {
activeThread.nextBlock = activeThread.stack.pop();
// Don't pop stack frame - we need the data.
// A new one won't be created when we execute.
if (activeThread.nextBlock !== null) {
activeThread.status === Thread.STATUS_RUNNING;
}
}
if (activeThread.nextBlock === null &&
activeThread.status === Thread.STATUS_DONE) {
// First attempt to pop from the stack
if (activeThread.stack.length > 0
&& activeThread.nextBlock === null) {
activeThread.nextBlock = activeThread.stack.pop();
// Don't pop stack frame - we need the data.
// A new one won't be created when we execute.
}
if (activeThread.nextBlock === null) {
// No more on the stack
// Finished with this thread - tell runtime to clean it up.
inactiveThreads.push(activeThread);
}
// Finished with this thread - tell runtime to clean it up.
inactiveThreads.push(activeThread);
} else {
// Keep this thead in the loop.
newThreads.push(activeThread);

25
vm.js
View file

@ -1621,20 +1621,21 @@
activeThread.status = Thread.STATUS_RUNNING;
// @todo Deal with the return value
}
// First attempt to pop from the stack
if (activeThread.stack.length > 0 &&
activeThread.nextBlock === null &&
activeThread.status === Thread.STATUS_DONE) {
activeThread.nextBlock = activeThread.stack.pop();
// Don't pop stack frame - we need the data.
// A new one won't be created when we execute.
if (activeThread.nextBlock !== null) {
activeThread.status === Thread.STATUS_RUNNING;
}
}
if (activeThread.nextBlock === null &&
activeThread.status === Thread.STATUS_DONE) {
// First attempt to pop from the stack
if (activeThread.stack.length > 0
&& activeThread.nextBlock === null) {
activeThread.nextBlock = activeThread.stack.pop();
// Don't pop stack frame - we need the data.
// A new one won't be created when we execute.
}
if (activeThread.nextBlock === null) {
// No more on the stack
// Finished with this thread - tell runtime to clean it up.
inactiveThreads.push(activeThread);
}
// Finished with this thread - tell runtime to clean it up.
inactiveThreads.push(activeThread);
} else {
// Keep this thead in the loop.
newThreads.push(activeThread);

2
vm.min.js vendored

File diff suppressed because one or more lines are too long