summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2008-09-08 03:55:18 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2008-09-08 03:55:18 (GMT)
commit45de3630bd989cb0e91f0c0b51a66b96dc6c2b28 (patch)
tree222c16181da490ba17331ea29ec66977776aa0bd /generic
parentd5aa3e39f59ee58bb742d5f195452a470b99f3f7 (diff)
downloadtcl-45de3630bd989cb0e91f0c0b51a66b96dc6c2b28.zip
tcl-45de3630bd989cb0e91f0c0b51a66b96dc6c2b28.tar.gz
tcl-45de3630bd989cb0e91f0c0b51a66b96dc6c2b28.tar.bz2
* generic/tclCompile.c (TclCompileTokens):
* generic/tclExecute.c (CompileExprObj): fix a perf bug (found by Alex Ferrieux) where some variables in the LVT where not being accessed by index. Fix missing localCache management in compiled expressions found while analyzing the bug.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompile.c26
-rw-r--r--generic/tclExecute.c14
2 files changed, 19 insertions, 21 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index d79ba9d..a0ab92b 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.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: tclCompile.c,v 1.155 2008/08/20 15:41:21 dkf Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.156 2008/09/08 03:55:18 msofer Exp $
*/
#include "tclInt.h"
@@ -1670,19 +1670,17 @@ TclCompileTokens(
name = tokenPtr[1].start;
nameBytes = tokenPtr[1].size;
- localVarName = -1;
- if (envPtr->procPtr != NULL) {
- localVarName = 1;
- for (i = 0, p = name; i < nameBytes; i++, p++) {
- if ((*p == ':') && (i < nameBytes-1) && (*(p+1) == ':')) {
- localVarName = -1;
- break;
- } else if ((*p == '(')
- && (tokenPtr->numComponents == 1)
- && (*(name + nameBytes - 1) == ')')) {
- localVarName = 0;
- break;
- }
+
+ localVarName = 1;
+ for (i = 0, p = name; i < nameBytes; i++, p++) {
+ if ((*p == ':') && (i < nameBytes-1) && (*(p+1) == ':')) {
+ localVarName = -1;
+ break;
+ } else if ((*p == '(')
+ && (tokenPtr->numComponents == 1)
+ && (*(name + nameBytes - 1) == ')')) {
+ localVarName = 0;
+ break;
}
}
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 308806c..326cc18 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.409 2008/09/04 16:34:52 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.410 2008/09/08 03:55:21 msofer Exp $
*/
#include "tclInt.h"
@@ -1291,7 +1291,8 @@ CompileExprObj(
if (((Interp *) *codePtr->interpHandle != iPtr)
|| (codePtr->compileEpoch != iPtr->compileEpoch)
|| (codePtr->nsPtr != namespacePtr)
- || (codePtr->nsEpoch != namespacePtr->resolverEpoch)) {
+ || (codePtr->nsEpoch != namespacePtr->resolverEpoch)
+ || (codePtr->localCachePtr != iPtr->varFramePtr->localCachePtr)) {
objPtr->typePtr->freeIntRepProc(objPtr);
objPtr->typePtr = (Tcl_ObjType *) NULL;
}
@@ -1328,6 +1329,10 @@ CompileExprObj(
objPtr->typePtr = &exprCodeType;
TclFreeCompileEnv(&compEnv);
codePtr = (ByteCode *) objPtr->internalRep.otherValuePtr;
+ if (iPtr->varFramePtr->localCachePtr) {
+ codePtr->localCachePtr = iPtr->varFramePtr->localCachePtr;
+ codePtr->localCachePtr->refCount++;
+ }
#ifdef TCL_COMPILE_DEBUG
if (tclTraceCompile == 2) {
TclPrintByteCodeObj(interp, objPtr);
@@ -1522,11 +1527,6 @@ TclCompileObj(
}
codePtr->compileEpoch = iPtr->compileEpoch;
} else {
- /*
- * This byteCode is invalid: free it and recompile.
- */
-
- objPtr->typePtr->freeIntRepProc(objPtr);
goto recompileObj;
}
}