diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2005-11-30 14:59:39 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2005-11-30 14:59:39 (GMT) |
commit | 53c04f83d2b2ef25f90e34e7d05273f965790caa (patch) | |
tree | 1b07469f13d8ee2956bcb114e0992788298dc395 /generic/tclCompile.c | |
parent | c3ae410bfd9c50b4b93c65bb20d96aca055c8c81 (diff) | |
download | tcl-53c04f83d2b2ef25f90e34e7d05273f965790caa.zip tcl-53c04f83d2b2ef25f90e34e7d05273f965790caa.tar.gz tcl-53c04f83d2b2ef25f90e34e7d05273f965790caa.tar.bz2 |
New TEBC opcode, INST_JUMP_TABLE, for compiling the simple (and common) case of
[switch] into a jump-table. Much faster for long switches.
Also compiler support for generating the new instruction where appropriate.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r-- | generic/tclCompile.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c index d58e18f..659a611 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.92 2005/11/07 15:23:56 dkf Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.93 2005/11/30 14:59:40 dkf Exp $ */ #include "tclInt.h" @@ -362,6 +362,13 @@ InstructionDesc tclInstructionTable[] = { * dictionary in the variable referred to by the immediate argument. * Stack: ... keyList LVTindexList => ... * Same notes as in "dictUpdateStart" apply here. */ + {"jumpTable", 5, -1, 1, {OPERAND_UINT4}}, + /* Jump according to the jump-table (in AuxData as indicated by the + * operand) and the argument popped from the list. Always executes the + * next instruction if no match against the table's entries was found. + * Stack: ... value => ... + * Note that the jump table contains offsets relative to the PC when + * it points to this instruction; the code is relocatable. */ {0} }; @@ -2500,7 +2507,7 @@ TclFixupForwardJump( */ void * /* == InstructionDesc* == */ -TclGetInstructionTable() +TclGetInstructionTable(void) { return &tclInstructionTable[0]; } @@ -2616,7 +2623,7 @@ TclGetAuxDataType( */ void -TclInitAuxDataTypeTable() +TclInitAuxDataTypeTable(void) { /* * The table mutex must already be held before this routine is invoked. @@ -2626,10 +2633,11 @@ TclInitAuxDataTypeTable() Tcl_InitHashTable(&auxDataTypeTable, TCL_STRING_KEYS); /* - * There is only one AuxData type at this time, so register it here. + * There are only two AuxData type at this time, so register them here. */ TclRegisterAuxDataType(&tclForeachInfoType); + TclRegisterAuxDataType(&tclJumptableInfoType); } /* @@ -2652,7 +2660,7 @@ TclInitAuxDataTypeTable() */ void -TclFinalizeAuxDataTypeTable() +TclFinalizeAuxDataTypeTable(void) { Tcl_MutexLock(&tableMutex); if (auxDataTypeTableInitialized) { |