summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2009-12-08 21:44:56 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2009-12-08 21:44:56 (GMT)
commit8c26b3a75b9dd2609485169cd288ca77926bd8d6 (patch)
tree3d7346f879726d81a8fbb39c3e578ee435737adc /generic
parentb475ec90cf97e4e17e2fda2954e1983c882ab339 (diff)
downloadtcl-8c26b3a75b9dd2609485169cd288ca77926bd8d6.zip
tcl-8c26b3a75b9dd2609485169cd288ca77926bd8d6.tar.gz
tcl-8c26b3a75b9dd2609485169cd288ca77926bd8d6.tar.bz2
baby steps towards nre-enabling coroutine first run
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBasic.c36
-rw-r--r--generic/tclExecute.c18
2 files changed, 22 insertions, 32 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 3d777d3..072dfe3 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.418 2009/12/08 20:56:29 msofer Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.419 2009/12/08 21:44:56 msofer Exp $
*/
#include "tclInt.h"
@@ -8394,8 +8394,6 @@ static int RewindCoroutine(CoroutineData *corPtr, int result);
static void DeleteCoroutine(ClientData clientData);
static void PlugCoroutineChains(CoroutineData *corPtr);
-static int NRCoroutineFirstCallback(ClientData data[],
- Tcl_Interp *interp, int result);
static int NRCoroutineExitCallback(ClientData data[],
Tcl_Interp *interp, int result);
static int NRCoroutineCallerCallback(ClientData data[],
@@ -8590,26 +8588,6 @@ PlugCoroutineChains(
}
static int
-NRCoroutineFirstCallback(
- ClientData data[],
- Tcl_Interp *interp,
- int result)
-{
- CoroutineData *corPtr = data[0];
- register CmdFrame *tmpPtr = iPtr->cmdFramePtr;
-
- if (corPtr->eePtr) {
- while (tmpPtr->nextPtr != corPtr->caller.cmdFramePtr) {
- tmpPtr = tmpPtr->nextPtr;
- }
-
- corPtr->base.cmdFramePtr = tmpPtr;
- }
-
- return result;
-}
-
-static int
NRCoroutineCallerCallback(
ClientData data[],
Tcl_Interp *interp,
@@ -8674,9 +8652,7 @@ NRCoroutineExitCallback(
NRE_ASSERT(TOP_CB(interp) == NULL);
NRE_ASSERT(iPtr->execEnvPtr == corPtr->eePtr);
NRE_ASSERT(!COR_IS_SUSPENDED(corPtr));
- NRE_ASSERT((corPtr->callerEEPtr->callbackPtr->procPtr == NRCoroutineCallerCallback)
- || ((corPtr->callerEEPtr->callbackPtr->procPtr == NRCoroutineFirstCallback) &&
- (corPtr->callerEEPtr->callbackPtr->nextPtr->procPtr == NRCoroutineCallerCallback)));
+ NRE_ASSERT((corPtr->callerEEPtr->callbackPtr->procPtr == NRCoroutineCallerCallback));
NRE_ASSERT(iPtr->framePtr->compiledLocals == NULL);
TclPopStackFrame(interp);
@@ -8859,8 +8835,6 @@ TclNRCoroutineObjCmd(
TclNRAddCallback(interp, NRCoroutineCallerCallback, corPtr, NULL, NULL,
NULL);
- TclNRAddCallback(interp, NRCoroutineFirstCallback, corPtr, NULL, NULL,
- NULL);
SAVE_CONTEXT(corPtr->caller);
iPtr->execEnvPtr = corPtr->eePtr;
@@ -8880,6 +8854,12 @@ TclNRCoroutineObjCmd(
corPtr->running = NULL_CONTEXT;
/*
+ * Signal TEBC that it has to initialize the base cmdFramePtr.
+ */
+
+ corPtr->base.cmdFramePtr = NULL;
+
+ /*
* #280.
* Provide the new coroutine with its own copy of the lineLABCPtr
* hashtable for literal command arguments in bytecode. Note that that
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 039ad24..f54bb54 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.455 2009/12/08 20:56:29 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.456 2009/12/08 21:44:56 msofer Exp $
*/
#include "tclInt.h"
@@ -2031,9 +2031,19 @@ TclExecuteByteCode(
bcFramePtr->cmd.str.cmd = NULL;
bcFramePtr->cmd.str.len = 0;
- if (iPtr->execEnvPtr->rewind) {
- TRESULT = TCL_ERROR;
- goto abnormalReturn;
+ if (iPtr->execEnvPtr->corPtr) {
+ if (!iPtr->execEnvPtr->corPtr->base.cmdFramePtr) {
+ /*
+ * First coroutine run, the base cmdFramePtr has not yet been
+ * initialized. Do it now.
+ */
+
+ iPtr->execEnvPtr->corPtr->base.cmdFramePtr = bcFramePtr;
+ }
+ if (iPtr->execEnvPtr->rewind) {
+ TRESULT = TCL_ERROR;
+ goto abnormalReturn;
+ }
}
#ifdef TCL_COMPILE_DEBUG