summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-06-01 21:05:55 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-06-01 21:05:55 (GMT)
commitd09727e7ff46a2abd069caac727159c92f6c9436 (patch)
treef513d78c6d5a0417959e2f49d777012a853850e7 /generic/tclCompile.c
parent8d03d462d4d27ee4a2d6fec72a8d2efe9e90f94a (diff)
downloadtcl-d09727e7ff46a2abd069caac727159c92f6c9436.zip
tcl-d09727e7ff46a2abd069caac727159c92f6c9436.tar.gz
tcl-d09727e7ff46a2abd069caac727159c92f6c9436.tar.bz2
Getting better at doing more efficient break/continue instruction handling.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 54946ee..c56b67f 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -1523,6 +1523,7 @@ TclInitCompileEnv(
envPtr->cmdMapEnd = COMPILEENV_INIT_CMD_MAP_SIZE;
envPtr->mallocedCmdMap = 0;
envPtr->atCmdStart = 1;
+ envPtr->expandCount = 0;
/*
* TIP #280: Set up the extended command location information, based on
@@ -2060,6 +2061,7 @@ TclCompileScript(
if (expand) {
TclEmitOpcode(INST_EXPAND_START, envPtr);
+ envPtr->expandCount++;
}
/*
@@ -2279,6 +2281,7 @@ TclCompileScript(
*/
TclEmitOpcode(INST_INVOKE_EXPANDED, envPtr);
+ envPtr->expandCount--;
TclAdjustStackDepth(1 - wordIdx, envPtr);
} else if (wordIdx > 0) {
/*
@@ -3463,6 +3466,45 @@ TclCreateExceptRange(
}
/*
+ * ---------------------------------------------------------------------
+ *
+ * TclGetInnermostExceptionRange --
+ *
+ * Returns the innermost exception range that covers the current code
+ * creation point, and (optionally) the stack depth that is expected at
+ * that point. Relies on the fact that the range has a numCodeBytes = -1
+ * when it is being populated and that inner ranges come after outer
+ * ranges.
+ *
+ * ---------------------------------------------------------------------
+ */
+
+ExceptionRange *
+TclGetInnermostExceptionRange(
+ CompileEnv *envPtr,
+ int *stackDepthPtr)
+{
+ int exnIdx = -1, i;
+
+ for (i=0 ; i<envPtr->exceptArrayNext ; i++) {
+ ExceptionRange *rangePtr = &envPtr->exceptArrayPtr[i];
+
+ if (CurrentOffset(envPtr) >= rangePtr->codeOffset &&
+ (rangePtr->numCodeBytes == -1 || CurrentOffset(envPtr) <
+ rangePtr->codeOffset+rangePtr->numCodeBytes)) {
+ exnIdx = i;
+ }
+ }
+ if (exnIdx == -1) {
+ return NULL;
+ }
+ if (stackDepthPtr) {
+ *stackDepthPtr = envPtr->exnStackDepthArrayPtr[exnIdx];
+ }
+ return &envPtr->exceptArrayPtr[exnIdx];
+}
+
+/*
*----------------------------------------------------------------------
*
* TclCreateAuxData --