summaryrefslogtreecommitdiffstats
path: root/generic
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
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')
-rw-r--r--generic/tclBasic.c29
-rw-r--r--generic/tclProc.c16
2 files changed, 38 insertions, 7 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) {
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 4c1a9a4..0679fc5 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -10,7 +10,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: tclProc.c,v 1.6 1998/07/14 10:34:43 escoffon Exp $
+ * SCCS: %Z% $Id: tclProc.c,v 1.7 1998/07/15 11:08:17 escoffon Exp $
*/
#include "tclInt.h"
@@ -694,6 +694,9 @@ TclObjInterpProc(clientData, interp, objc, objv)
* different interpreter, we recompile it. Note that compiling the body
* might increase procPtr->numCompiledLocals if new local variables are
* found while compiling.
+ *
+ * Precompiled procedure bodies, however, are immutable and therefore
+ * they are not recompiled, even if the epoch has changed.
*/
if (bodyPtr->typePtr == &tclByteCodeType) {
@@ -701,8 +704,15 @@ TclObjInterpProc(clientData, interp, objc, objv)
if ((codePtr->iPtr != iPtr)
|| (codePtr->compileEpoch != iPtr->compileEpoch)) {
- tclByteCodeType.freeIntRepProc(bodyPtr);
- bodyPtr->typePtr = (Tcl_ObjType *) NULL;
+ if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
+ if (codePtr->iPtr != iPtr) {
+ panic("TclObjInterpProc: compiled body jumped interps");
+ }
+ codePtr->compileEpoch = iPtr->compileEpoch;
+ } else {
+ tclByteCodeType.freeIntRepProc(bodyPtr);
+ bodyPtr->typePtr = (Tcl_ObjType *) NULL;
+ }
}
}
if (bodyPtr->typePtr != &tclByteCodeType) {