summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.h
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-11-30 14:59:39 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-11-30 14:59:39 (GMT)
commit53c04f83d2b2ef25f90e34e7d05273f965790caa (patch)
tree1b07469f13d8ee2956bcb114e0992788298dc395 /generic/tclCompile.h
parentc3ae410bfd9c50b4b93c65bb20d96aca055c8c81 (diff)
downloadtcl-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.h')
-rw-r--r--generic/tclCompile.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index af25ace..21871aa 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -8,7 +8,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.h,v 1.60 2005/10/12 23:42:29 dkf Exp $
+ * RCS: @(#) $Id: tclCompile.h,v 1.61 2005/11/30 14:59:40 dkf Exp $
*/
#ifndef _TCLCOMPILATION
@@ -562,8 +562,15 @@ typedef struct ByteCode {
#define INST_DICT_UPDATE_START 119
#define INST_DICT_UPDATE_END 120
+/*
+ * Instruction to support jumps defined by tables (instead of the classic
+ * [switch] technique of chained comparisons).
+ */
+
+#define INST_JUMP_TABLE 121
+
/* The last opcode */
-#define LAST_INST_OPCODE 120
+#define LAST_INST_OPCODE 121
/*
* Table describing the Tcl bytecode instructions: their name (for displaying
@@ -694,7 +701,20 @@ typedef struct ForeachInfo {
* LAST FIELD IN THE STRUCTURE! */
} ForeachInfo;
-MODULE_SCOPE AuxDataType tclForeachInfoType;
+MODULE_SCOPE AuxDataType tclForeachInfoType;
+
+/*
+ * Structure used to hold information about a switch command that is needed
+ * during program execution. These structures are stored in CompileEnv and
+ * ByteCode structures as auxiliary data.
+ */
+
+typedef struct JumptableInfo {
+ Tcl_HashTable hashTable; /* Hash that maps strings to signed ints (PC
+ * offsets). */
+} JumptableInfo;
+
+MODULE_SCOPE AuxDataType tclJumptableInfoType;
/*
*----------------------------------------------------------------