summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclBasic.c4
-rw-r--r--generic/tclExecute.c43
-rw-r--r--generic/tclInt.h9
3 files changed, 20 insertions, 36 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index d8a449b..79d76be 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBasic.c,v 1.429 2009/12/10 23:52:30 msofer Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.430 2009/12/11 04:47:13 msofer Exp $
*/
#include "tclInt.h"
@@ -8717,7 +8717,6 @@ NRInterpCoroutine(
TclNRAddCallback(interp, NRCoroutineCallerCallback, corPtr, NULL, NULL,
NULL);
- corPtr->callerBP = NULL;;
corPtr->callerEEPtr = iPtr->execEnvPtr;
iPtr->execEnvPtr = corPtr->eePtr;
@@ -8852,7 +8851,6 @@ TclNRCoroutineObjCmd(
corPtr->running = NULL_CONTEXT;
corPtr->stackLevel = NULL;
corPtr->auxNumLevels = iPtr->numLevels;
- corPtr->callerBP = NULL;
/*
* Create the command that will run at the bottom of the coroutine.
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;
}
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 91f301f..bf13446 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.452 2009/12/08 20:56:29 msofer Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.453 2009/12/11 04:47:13 msofer Exp $
*/
#ifndef _TCLINT
@@ -1405,9 +1405,10 @@ typedef struct CoroutineData {
* numLevels of the create/resume command is
* stored here; for suspended coroutines it
* holds the nesting numLevels at yield. */
- struct BottomData *callerBP;/* The caller's bottomPointer, if the coro is
- * running in the caller's TEBC instance. NULL
- * otherwise. */
+ struct BottomData **callerBPPtr;
+ /* Where to stash the caller's bottomPointer,
+ * if the coro is running in the caller's TEBC
+ * instance. Put a NULL in there otherwise. */
} CoroutineData;
typedef struct ExecEnv {