diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2004-03-30 19:17:55 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2004-03-30 19:17:55 (GMT) |
commit | 273d70e6d992c80dad69b0198cb21577ad7b3ba2 (patch) | |
tree | 401d39c51c9a5757c5b28a9c7fbb0085a8530b8c /generic/tclExecute.c | |
parent | d7342e95b8185e47c027ad6a573b4242e5ca67c9 (diff) | |
download | tcl-273d70e6d992c80dad69b0198cb21577ad7b3ba2.zip tcl-273d70e6d992c80dad69b0198cb21577ad7b3ba2.tar.gz tcl-273d70e6d992c80dad69b0198cb21577ad7b3ba2.tar.bz2 |
* generic/tclExecute.c (TEBC): reverting to the previous method
for async tests in TEBC, as the new method turned out to be too
costly. Async tests now run every 64 instructions.
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r-- | generic/tclExecute.c | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 3ff411d..5a13482 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -11,7 +11,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.122 2004/03/30 16:22:21 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.123 2004/03/30 19:17:57 msofer Exp $ */ #include "tclInt.h" @@ -61,6 +61,16 @@ int errno; # endif /* MAXDOUBLE */ #endif /* !DBL_MAX */ +/* + * A mask (should be 2**n-1) that is used to work out when the + * bytecode engine should call Tcl_AsyncReady() to see whether there + * is a signal that needs handling. + */ + +#ifndef ASYNC_CHECK_COUNT_MASK +# define ASYNC_CHECK_COUNT_MASK 63 +#endif /* !ASYNC_CHECK_COUNT_MASK */ + /* * Boolean flag indicating whether the Tcl bytecode interpreter has been @@ -1089,6 +1099,8 @@ TclExecuteByteCode(interp, codePtr) int traceInstructions = (tclTraceExec == 3); char cmdNameBuf[21]; #endif + int instructionCount = 0; /* Counter that is used to work out + * when to call Tcl_AsyncReady() */ Namespace *namespacePtr; int codeCompileEpoch = codePtr->compileEpoch; int codeNsEpoch = codePtr->nsEpoch; @@ -1213,21 +1225,23 @@ TclExecuteByteCode(interp, codePtr) iPtr->stats.instructionCount[*pc]++; #endif - switch (*pc) { - case INST_START_CMD: - /* - * Check for asynchronous handlers [Bug 746722]. - */ + /* + * Check for asynchronous handlers [Bug 746722]; we + * do the check every ASYNC_CHECK_COUNT_MASK instruction, + * of the form (2**n-1). + */ - if (Tcl_AsyncReady()) { - DECACHE_STACK_INFO(); - result = Tcl_AsyncInvoke(interp, result); - CACHE_STACK_INFO(); - if (result == TCL_ERROR) { - goto checkForCatch; - } + if (!(instructionCount++ & ASYNC_CHECK_COUNT_MASK) && Tcl_AsyncReady()) { + DECACHE_STACK_INFO(); + result = Tcl_AsyncInvoke(interp, result); + CACHE_STACK_INFO(); + if (result == TCL_ERROR) { + goto checkForCatch; } - + } + + switch (*pc) { + case INST_START_CMD: if ((!(iPtr->flags & DELETED) && (codeCompileEpoch == iPtr->compileEpoch) && (codeNsEpoch == namespacePtr->resolverEpoch)) @@ -1551,6 +1565,14 @@ TclExecuteByteCode(interp, codePtr) preservedStackRefCountPtr = (char **) (eePtr->stackPtr-1); ++*preservedStackRefCountPtr; + /* + * Reset the instructionCount variable, since we're about + * to check for async stuff anyway while processing + * TclEvalObjvInternal. + */ + + instructionCount = 1; + /* * Finally, let TclEvalObjvInternal handle the command. */ |