summaryrefslogtreecommitdiffstats
path: root/generic/tclBasic.c
diff options
context:
space:
mode:
authorescoffon <escoffon>1998-07-15 11:08:17 (GMT)
committerescoffon <escoffon>1998-07-15 11:08:17 (GMT)
commitf916e7601c396671e9dd7747b0d143673ae45c2b (patch)
treef12332afa1a5987e074292fc8185b5e7e05d197a /generic/tclBasic.c
parent383a24c0e1eb4e32a171bcd66addac9264206802 (diff)
downloadtcl-f916e7601c396671e9dd7747b0d143673ae45c2b.zip
tcl-f916e7601c396671e9dd7747b0d143673ae45c2b.tar.gz
tcl-f916e7601c396671e9dd7747b0d143673ae45c2b.tar.bz2
Added check for precompiled ByteCodes, to avoid recompilation if the epoch
has changed in the interpreter. Instead, reset the epoch in the ByteCode.
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r--generic/tclBasic.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 577c0ee..799611f 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.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.
*
- * SCCS: %Z% $Id: tclBasic.c,v 1.7 1998/07/06 22:37:35 welch Exp $
+ * SCCS: %Z% $Id: tclBasic.c,v 1.8 1998/07/15 11:09:11 escoffon Exp $
*/
#include "tclInt.h"
@@ -2508,6 +2508,9 @@ Tcl_EvalObj(interp, objPtr)
* necessary, convert the object to be a ByteCode object and compile it.
* Also, if the code was compiled in/for a different interpreter,
* we recompile it.
+ *
+ * Precompiled objects, however, are immutable and therefore
+ * they are not recompiled, even if the epoch has changed.
*/
if (objPtr->typePtr == &tclByteCodeType) {
@@ -2515,7 +2518,14 @@ Tcl_EvalObj(interp, objPtr)
if ((codePtr->iPtr != iPtr)
|| (codePtr->compileEpoch != iPtr->compileEpoch)) {
- tclByteCodeType.freeIntRepProc(objPtr);
+ if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
+ if (codePtr->iPtr != iPtr) {
+ panic("Tcl_EvalObj: compiled script jumped interps");
+ }
+ codePtr->compileEpoch = iPtr->compileEpoch;
+ } else {
+ tclByteCodeType.freeIntRepProc(objPtr);
+ }
}
}
if (objPtr->typePtr != &tclByteCodeType) {
@@ -3432,6 +3442,10 @@ Tcl_ExprObj(interp, objPtr, resultPtrPtr)
* necessary, convert the object to be a ByteCode object and compile it.
* Also, if the code was compiled in/for a different interpreter, we
* recompile it.
+ *
+ * Precompiled expressions, however, are immutable and therefore
+ * they are not recompiled, even if the epoch has changed.
+ *
* THIS FAILS IF THE OBJECT'S STRING REP HAS A NULL BYTE.
*/
@@ -3439,8 +3453,15 @@ Tcl_ExprObj(interp, objPtr, resultPtrPtr)
codePtr = (ByteCode *) objPtr->internalRep.otherValuePtr;
if ((codePtr->iPtr != iPtr)
|| (codePtr->compileEpoch != iPtr->compileEpoch)) {
- tclByteCodeType.freeIntRepProc(objPtr);
- objPtr->typePtr = (Tcl_ObjType *) NULL;
+ if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
+ if (codePtr->iPtr != iPtr) {
+ panic("Tcl_ExprObj: compiled expression jumped interps");
+ }
+ codePtr->compileEpoch = iPtr->compileEpoch;
+ } else {
+ tclByteCodeType.freeIntRepProc(objPtr);
+ objPtr->typePtr = (Tcl_ObjType *) NULL;
+ }
}
}
if (objPtr->typePtr != &tclByteCodeType) {