summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2004-07-08 18:46:02 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2004-07-08 18:46:02 (GMT)
commit5f7664fb28c03bce899572a39a9e3b343c223f3a (patch)
tree83ca945a044386ae90882b24cb30d198aa440f7e /generic/tclCompile.c
parent2e5d02410d31161822705b1b28f1743b8af402fc (diff)
downloadtcl-5f7664fb28c03bce899572a39a9e3b343c223f3a.zip
tcl-5f7664fb28c03bce899572a39a9e3b343c223f3a.tar.gz
tcl-5f7664fb28c03bce899572a39a9e3b343c223f3a.tar.bz2
Modified the logic of literal table cleanup at interp deletion time,
insuring that the fix of [Bug 983660] does not have a negative perf impact.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 225b9cd..5376123 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.69 2004/07/07 22:05:59 msofer Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.70 2004/07/08 18:46:05 msofer Exp $
*/
#include "tclInt.h"
@@ -590,7 +590,7 @@ TclCleanupByteCode(codePtr)
Tcl_Interp *interp = (Tcl_Interp *) *codePtr->interpHandle;
int numLitObjects = codePtr->numLitObjects;
int numAuxDataItems = codePtr->numAuxDataItems;
- register Tcl_Obj **objArrayPtr;
+ register Tcl_Obj **objArrayPtr, *objPtr;
register AuxData *auxDataPtr;
int i;
#ifdef TCL_COMPILE_STATS
@@ -642,10 +642,17 @@ TclCleanupByteCode(codePtr)
* like those generated from tbcload) is special, as they doesn't
* make use of the global literal table. They instead maintain
* private references to their literals which must be decremented.
+ *
+ * In order to insure a proper and efficient cleanup of the literal
+ * array when it contains non-shared literals [Bug 983660], we also
+ * distinguish the case of an interpreter being deleted (signaled by
+ * interp == NULL). Also, as the interp deletion will remove the global
+ * literal table anyway, we avoid the extra cost of updating it for each
+ * literal being released.
*/
- if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
- register Tcl_Obj *objPtr;
+ if ((codePtr->flags & TCL_BYTECODE_PRECOMPILED)
+ || (interp == NULL)) {
objArrayPtr = codePtr->objArrayPtr;
for (i = 0; i < numLitObjects; i++) {
@@ -656,13 +663,7 @@ TclCleanupByteCode(codePtr)
objArrayPtr++;
}
codePtr->numLitObjects = 0;
- } else if (interp != NULL) {
- /*
- * If the interp has already been freed, then Tcl will have already
- * forcefully released all the literals used by ByteCodes compiled
- * with respect to that interp.
- */
-
+ } else {
objArrayPtr = codePtr->objArrayPtr;
for (i = 0; i < numLitObjects; i++) {
/*
@@ -670,8 +671,9 @@ TclCleanupByteCode(codePtr)
* indicate that it has already freed the literal.
*/
- if (*objArrayPtr != NULL) {
- TclReleaseLiteral(interp, *objArrayPtr);
+ objPtr = *objArrayPtr;
+ if (objPtr != NULL) {
+ TclReleaseLiteral(interp, objPtr);
}
objArrayPtr++;
}