summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2009-12-11 04:47:13 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2009-12-11 04:47:13 (GMT)
commit11915ee6b5791aab49447d524ef382336aeec38d (patch)
tree1f2bf344ff2311df7b4bd5a3874f1661c27cbc81 /generic/tclExecute.c
parente225192e11ee22d35470bef993063ace4970231b (diff)
downloadtcl-11915ee6b5791aab49447d524ef382336aeec38d.zip
tcl-11915ee6b5791aab49447d524ef382336aeec38d.tar.gz
tcl-11915ee6b5791aab49447d524ef382336aeec38d.tar.bz2
simplify the coroutine BP-chain monkey-patching; tclBasic does not need to
know about bottomPtr, tebc does not need to behave differently on exit for coros
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index f4a204e..fdc2dc4 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.462 2009/12/10 23:52:30 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.463 2009/12/11 04:47:13 msofer Exp $
*/
#include "tclInt.h"
@@ -1972,21 +1972,27 @@ TclExecuteByteCode(
* execution stack is large enough to execute this ByteCode.
*/
- resumeCoroutine:
if (!codePtr) {
- CoroutineData *corPtr = iPtr->execEnvPtr->corPtr;
+ CoroutineData *corPtr;
+
+ resumeCoroutine:
/*
* Reawakening a suspended coroutine: the [yield] command is
* returning.
*/
+ corPtr = iPtr->execEnvPtr->corPtr;
+
NRE_ASSERT(corPtr != NULL);
NRE_ASSERT(corPtr->eePtr == iPtr->execEnvPtr);
NRE_ASSERT(COR_IS_SUSPENDED(corPtr));
+ *corPtr->callerBPPtr = OBP;
OBP = iPtr->execEnvPtr->bottomPtr;
+
corPtr->stackLevel = &TAUX;
corPtr->base.cmdFramePtr->nextPtr = corPtr->caller.cmdFramePtr;
+
if (iPtr->execEnvPtr->rewind) {
TRESULT = TCL_ERROR;
}
@@ -2040,8 +2046,7 @@ TclExecuteByteCode(
corPtr->base.cmdFramePtr = bcFramePtr;
iPtr->varFramePtr = iPtr->rootFramePtr;
- corPtr->callerBP = BP->prevBottomPtr;
- BP->prevBottomPtr = NULL;
+ corPtr->callerBPPtr = &BP->prevBottomPtr;
}
if (!corPtr->stackLevel) {
@@ -2833,13 +2838,11 @@ TclExecuteByteCode(
* new one.
*/
- codePtr = param;
- if (codePtr) {
+ if (param) {
+ codePtr = param;
goto nonRecursiveCallStart;
} else {
- CoroutineData *corPtr = iPtr->execEnvPtr->corPtr;
-
- corPtr->callerBP = BP;
+ OBP = BP;
goto resumeCoroutine;
}
break;
@@ -2900,7 +2903,7 @@ TclExecuteByteCode(
corPtr->stackLevel = NULL;
iPtr->execEnvPtr = corPtr->callerEEPtr;
- OBP = corPtr->callerBP;
+ OBP = *corPtr->callerBPPtr;
goto returnToCaller;
}
default:
@@ -8027,24 +8030,6 @@ TclExecuteByteCode(
}
}
- /*
- * Deal with coros running in the caller's TEBC
- */
-
- if (iPtr->execEnvPtr->corPtr) {
- CoroutineData *corPtr = iPtr->execEnvPtr->corPtr;
- /*
- * The coro is returning internally iff
- * - this is its base TEBC
- * - this is it's callers TEBC, signalled by callerBP!=NULL
- */
-
- OBP = corPtr->callerBP;
- if (OBP && (corPtr->stackLevel == &TAUX)) {
- goto returnToCaller;
- }
- }
-
iPtr->execEnvPtr->bottomPtr = NULL;
return TRESULT;
}