summaryrefslogtreecommitdiffstats
path: root/generic/tclObj.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-02-27 06:39:26 (GMT)
committerhobbs <hobbs>2002-02-27 06:39:26 (GMT)
commitb8243a4158d130a28312c6e3f5475855f48ed2dc (patch)
tree5bc7f593bb3bcaeae6b899706b2bd10b20b38b28 /generic/tclObj.c
parentc41330c9d6c97ddc3237c3216c6ea5c543893bfb (diff)
downloadtcl-b8243a4158d130a28312c6e3f5475855f48ed2dc.zip
tcl-b8243a4158d130a28312c6e3f5475855f48ed2dc.tar.gz
tcl-b8243a4158d130a28312c6e3f5475855f48ed2dc.tar.bz2
generic/tclCmdMZ.c
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r--generic/tclObj.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c
index a2eb282..8bf059b 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.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: tclObj.c,v 1.30 2002/02/22 22:36:09 dgp Exp $
+ * RCS: @(#) $Id: tclObj.c,v 1.31 2002/02/27 06:39:27 hobbs Exp $
*/
#include "tclInt.h"
@@ -30,15 +30,8 @@ TCL_DECLARE_MUTEX(tableMutex)
* Head of the list of free Tcl_Obj structs we maintain.
*/
+#ifndef TCL_THREADS
Tcl_Obj *tclFreeObjList = NULL;
-
-/*
- * The object allocator is single threaded. This mutex is referenced
- * by the TclNewObj macro, however, so must be visible.
- */
-
-#ifdef TCL_THREADS
-Tcl_Mutex tclObjMutex;
#endif
/*
@@ -246,7 +239,6 @@ TclInitObjSubsystem()
Tcl_RegisterObjType(&tclCmdNameType);
#ifdef TCL_COMPILE_STATS
- Tcl_MutexLock(&tclObjMutex);
tclObjsAlloced = 0;
tclObjsFreed = 0;
{
@@ -255,7 +247,6 @@ TclInitObjSubsystem()
tclObjsShared[i] = 0;
}
}
- Tcl_MutexUnlock(&tclObjMutex);
#endif
}
@@ -286,9 +277,9 @@ TclFinalizeCompExecEnv()
typeTableInitialized = 0;
}
Tcl_MutexUnlock(&tableMutex);
- Tcl_MutexLock(&tclObjMutex);
+#ifndef TCL_THREADS
tclFreeObjList = NULL;
- Tcl_MutexUnlock(&tclObjMutex);
+#endif
TclFinalizeCompilation();
TclFinalizeExecution();
@@ -520,9 +511,10 @@ Tcl_NewObj()
* we maintain.
*/
- Tcl_MutexLock(&tclObjMutex);
#ifdef PURIFY
objPtr = (Tcl_Obj *) Tcl_Ckalloc(sizeof(Tcl_Obj));
+#elif defined(TCL_THREADS)
+ objPtr = TclThreadAllocObj();
#else
if (tclFreeObjList == NULL) {
TclAllocateFreeObjects();
@@ -537,7 +529,6 @@ Tcl_NewObj()
#ifdef TCL_COMPILE_STATS
tclObjsAlloced++;
#endif /* TCL_COMPILE_STATS */
- Tcl_MutexUnlock(&tclObjMutex);
return objPtr;
}
#endif /* TCL_MEM_DEBUG */
@@ -592,9 +583,7 @@ Tcl_DbNewObj(file, line)
objPtr->length = 0;
objPtr->typePtr = NULL;
#ifdef TCL_COMPILE_STATS
- Tcl_MutexLock(&tclObjMutex);
tclObjsAlloced++;
- Tcl_MutexUnlock(&tclObjMutex);
#endif /* TCL_COMPILE_STATS */
return objPtr;
}
@@ -638,6 +627,7 @@ Tcl_DbNewObj(file, line)
void
TclAllocateFreeObjects()
{
+#ifndef TCL_THREADS
size_t bytesToAlloc = (OBJS_TO_ALLOC_EACH_TIME * sizeof(Tcl_Obj));
char *basePtr;
register Tcl_Obj *prevPtr, *objPtr;
@@ -661,6 +651,7 @@ TclAllocateFreeObjects()
objPtr++;
}
tclFreeObjList = prevPtr;
+#endif
}
#undef OBJS_TO_ALLOC_EACH_TIME
@@ -712,9 +703,10 @@ TclFreeObj(objPtr)
* Tcl_Obj structs we maintain.
*/
- Tcl_MutexLock(&tclObjMutex);
#if defined(TCL_MEM_DEBUG) || defined(PURIFY)
ckfree((char *) objPtr);
+#elif defined(TCL_THREADS)
+ TclThreadFreeObj(objPtr);
#else
objPtr->internalRep.otherValuePtr = (VOID *) tclFreeObjList;
tclFreeObjList = objPtr;
@@ -723,7 +715,6 @@ TclFreeObj(objPtr)
#ifdef TCL_COMPILE_STATS
tclObjsFreed++;
#endif /* TCL_COMPILE_STATS */
- Tcl_MutexUnlock(&tclObjMutex);
}
/*
@@ -2586,7 +2577,6 @@ Tcl_DbIsShared(objPtr, file, line)
}
#endif
#ifdef TCL_COMPILE_STATS
- Tcl_MutexLock(&tclObjMutex);
if ((objPtr)->refCount <= 1) {
tclObjsShared[1]++;
} else if ((objPtr)->refCount < TCL_MAX_SHARED_OBJ_STATS) {
@@ -2594,7 +2584,6 @@ Tcl_DbIsShared(objPtr, file, line)
} else {
tclObjsShared[0]++;
}
- Tcl_MutexUnlock(&tclObjMutex);
#endif
return ((objPtr)->refCount > 1);
}