summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-12-15 10:33:09 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-12-15 10:33:09 (GMT)
commitdf25840e9998ccae184ac0e650ea1857d1da6634 (patch)
tree51cc000ee2e6f9906b62e50a777252dfdfae82ad
parentf1d71456ca0ed0f306f2fdfbaf3668e506f41aa9 (diff)
downloadtcl-df25840e9998ccae184ac0e650ea1857d1da6634.zip
tcl-df25840e9998ccae184ac0e650ea1857d1da6634.tar.gz
tcl-df25840e9998ccae184ac0e650ea1857d1da6634.tar.bz2
Eliminate AuxDataType table: since this table only contains 4 constant entries, it is overkill to use a hash table for that.
-rw-r--r--generic/tclCompile.c156
-rw-r--r--generic/tclCompile.h2
-rw-r--r--generic/tclExecute.c2
3 files changed, 10 insertions, 150 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index f62ec14..6c4734d 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -17,15 +17,6 @@
#include <assert.h>
/*
- * Table of all AuxData types.
- */
-
-static Tcl_HashTable auxDataTypeTable;
-static int auxDataTypeTableInitialized; /* 0 means not yet initialized. */
-
-TCL_DECLARE_MUTEX(tableMutex)
-
-/*
* Variable that controls whether compilation tracing is enabled and, if so,
* what level of tracing is desired:
* 0: no compilation tracing
@@ -4221,59 +4212,6 @@ TclGetInstructionTable(void)
}
/*
- *--------------------------------------------------------------
- *
- * RegisterAuxDataType --
- *
- * This procedure is called to register a new AuxData type in the table
- * of all AuxData types supported by Tcl.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The type is registered in the AuxData type table. If there was already
- * a type with the same name as in typePtr, it is replaced with the new
- * type.
- *
- *--------------------------------------------------------------
- */
-
-static void
-RegisterAuxDataType(
- const AuxDataType *typePtr) /* Information about object type; storage must
- * be statically allocated (must live forever;
- * will not be deallocated). */
-{
- register Tcl_HashEntry *hPtr;
- int isNew;
-
- Tcl_MutexLock(&tableMutex);
- if (!auxDataTypeTableInitialized) {
- TclInitAuxDataTypeTable();
- }
-
- /*
- * If there's already a type with the given name, remove it.
- */
-
- hPtr = Tcl_FindHashEntry(&auxDataTypeTable, typePtr->name);
- if (hPtr != NULL) {
- Tcl_DeleteHashEntry(hPtr);
- }
-
- /*
- * Now insert the new object type.
- */
-
- hPtr = Tcl_CreateHashEntry(&auxDataTypeTable, typePtr->name, &isNew);
- if (isNew) {
- Tcl_SetHashValue(hPtr, typePtr);
- }
- Tcl_MutexUnlock(&tableMutex);
-}
-
-/*
*----------------------------------------------------------------------
*
* TclGetAuxDataType --
@@ -4294,90 +4232,16 @@ const AuxDataType *
TclGetAuxDataType(
const char *typeName) /* Name of AuxData type to look up. */
{
- register Tcl_HashEntry *hPtr;
- const AuxDataType *typePtr = NULL;
-
- Tcl_MutexLock(&tableMutex);
- if (!auxDataTypeTableInitialized) {
- TclInitAuxDataTypeTable();
- }
-
- hPtr = Tcl_FindHashEntry(&auxDataTypeTable, typeName);
- if (hPtr != NULL) {
- typePtr = Tcl_GetHashValue(hPtr);
- }
- Tcl_MutexUnlock(&tableMutex);
-
- return typePtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TclInitAuxDataTypeTable --
- *
- * This procedure is invoked to perform once-only initialization of the
- * AuxData type table. It also registers the AuxData types defined in
- * this file.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Initializes the table of defined AuxData types "auxDataTypeTable" with
- * builtin AuxData types defined in this file.
- *
- *--------------------------------------------------------------
- */
-
-void
-TclInitAuxDataTypeTable(void)
-{
- /*
- * The table mutex must already be held before this routine is invoked.
- */
-
- auxDataTypeTableInitialized = 1;
- Tcl_InitHashTable(&auxDataTypeTable, TCL_STRING_KEYS);
-
- /*
- * There are only four AuxData types at this time, so register them here.
- */
-
- RegisterAuxDataType(&tclForeachInfoType);
- RegisterAuxDataType(&tclNewForeachInfoType);
- RegisterAuxDataType(&tclJumptableInfoType);
- RegisterAuxDataType(&tclDictUpdateInfoType);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclFinalizeAuxDataTypeTable --
- *
- * This procedure is called by Tcl_Finalize after all exit handlers have
- * been run to free up storage associated with the table of AuxData
- * types. This procedure is called by TclFinalizeExecution() which is
- * called by Tcl_Finalize().
- *
- * Results:
- * None.
- *
- * Side effects:
- * Deletes all entries in the hash table of AuxData types.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclFinalizeAuxDataTypeTable(void)
-{
- Tcl_MutexLock(&tableMutex);
- if (auxDataTypeTableInitialized) {
- Tcl_DeleteHashTable(&auxDataTypeTable);
- auxDataTypeTableInitialized = 0;
- }
- Tcl_MutexUnlock(&tableMutex);
+ if (!strcmp(typeName, tclForeachInfoType.name)) {
+ return &tclForeachInfoType;
+ } else if (!strcmp(typeName, tclNewForeachInfoType.name)) {
+ return &tclNewForeachInfoType;
+ } else if (!strcmp(typeName, tclDictUpdateInfoType.name)) {
+ return &tclDictUpdateInfoType;
+ } else if (!strcmp(typeName, tclJumptableInfoType.name)) {
+ return &tclJumptableInfoType;
+ }
+ return NULL;
}
/*
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index b89346d..8811187 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -1123,7 +1123,6 @@ MODULE_SCOPE void TclExpandJumpFixupArray(JumpFixupArray *fixupArrayPtr);
MODULE_SCOPE int TclNRExecuteByteCode(Tcl_Interp *interp,
ByteCode *codePtr);
MODULE_SCOPE Tcl_Obj * TclFetchLiteral(CompileEnv *envPtr, unsigned int index);
-MODULE_SCOPE void TclFinalizeAuxDataTypeTable(void);
MODULE_SCOPE int TclFindCompiledLocal(const char *name, int nameChars,
int create, CompileEnv *envPtr);
MODULE_SCOPE int TclFixupForwardJump(CompileEnv *envPtr,
@@ -1131,7 +1130,6 @@ MODULE_SCOPE int TclFixupForwardJump(CompileEnv *envPtr,
int distThreshold);
MODULE_SCOPE void TclFreeCompileEnv(CompileEnv *envPtr);
MODULE_SCOPE void TclFreeJumpFixupArray(JumpFixupArray *fixupArrayPtr);
-MODULE_SCOPE void TclInitAuxDataTypeTable(void);
MODULE_SCOPE void TclInitByteCodeObj(Tcl_Obj *objPtr,
CompileEnv *envPtr);
MODULE_SCOPE void TclInitCompileEnv(Tcl_Interp *interp,
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index b10af65..dacc9e2 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -927,7 +927,6 @@ TclCreateExecEnv(
Tcl_MutexLock(&execMutex);
if (!execInitialized) {
- TclInitAuxDataTypeTable();
InitByteCodeExecution(interp);
execInitialized = 1;
}
@@ -1026,7 +1025,6 @@ TclFinalizeExecution(void)
Tcl_MutexLock(&execMutex);
execInitialized = 0;
Tcl_MutexUnlock(&execMutex);
- TclFinalizeAuxDataTypeTable();
}
/*