summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-06-11 20:38:00 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-06-11 20:38:00 (GMT)
commit9ca9c6da3a55c6358a221f006c6cc846bd8d9922 (patch)
tree1ccd7d3634fc387a151f25f772012f52206e4774 /generic/tclCompile.c
parent236502157da38dfe3835d0daf426c2d2a0664160 (diff)
downloadtcl-9ca9c6da3a55c6358a221f006c6cc846bd8d9922.zip
tcl-9ca9c6da3a55c6358a221f006c6cc846bd8d9922.tar.gz
tcl-9ca9c6da3a55c6358a221f006c6cc846bd8d9922.tar.bz2
Select improvements in stack depth estimates brought over from mig-review.
Mostly these are just simplifications, removing code that wasn't needed. Some changes make the stack depth estimate more accurate instruction by instruction.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index f6e0554..be5bedf 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -2009,8 +2009,7 @@ TclCompileScript(
#ifdef TCL_COMPILE_DEBUG
int diff = envPtr->currStackDepth-startStackDepth;
- if (diff != 1 && (diff != 0 ||
- *(envPtr->codeNext-1) != INST_DONE)) {
+ if (diff != 1) {
Tcl_Panic("bad stack adjustment when compiling"
" %.*s (was %d instead of 1)",
parsePtr->tokenPtr->size,
@@ -2628,12 +2627,10 @@ TclCompileNoOp(
{
Tcl_Token *tokenPtr;
int i;
- int savedStackDepth = envPtr->currStackDepth;
tokenPtr = parsePtr->tokenPtr;
for (i = 1; i < parsePtr->numWords; i++) {
tokenPtr = tokenPtr + tokenPtr->numComponents + 1;
- envPtr->currStackDepth = savedStackDepth;
if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) {
TclCompileTokens(interp, tokenPtr+1, tokenPtr->numComponents,
@@ -2641,7 +2638,6 @@ TclCompileNoOp(
TclEmitOpcode(INST_POP, envPtr);
}
}
- envPtr->currStackDepth = savedStackDepth;
TclEmitPush(TclRegisterNewLiteral(envPtr, "", 0), envPtr);
return TCL_OK;
}
@@ -3439,6 +3435,7 @@ TclCleanupStackForBreakContinue(
CompileEnv *envPtr,
ExceptionAux *auxPtr)
{
+ int savedStackDepth = envPtr->currStackDepth;
int toPop = envPtr->expandCount - auxPtr->expandTarget;
if (toPop > 0) {
@@ -3446,20 +3443,21 @@ TclCleanupStackForBreakContinue(
TclEmitOpcode(INST_EXPAND_DROP, envPtr);
toPop--;
}
+ TclAdjustStackDepth(auxPtr->expandTargetDepth - envPtr->currStackDepth,
+ envPtr);
toPop = auxPtr->expandTargetDepth - auxPtr->stackDepth;
while (toPop > 0) {
TclEmitOpcode(INST_POP, envPtr);
- TclAdjustStackDepth(1, envPtr);
toPop--;
}
} else {
toPop = envPtr->currStackDepth - auxPtr->stackDepth;
while (toPop > 0) {
TclEmitOpcode(INST_POP, envPtr);
- TclAdjustStackDepth(1, envPtr);
toPop--;
}
}
+ envPtr->currStackDepth = savedStackDepth;
}
/*