summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2005-03-16 21:29:14 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2005-03-16 21:29:14 (GMT)
commit96d954cfc836a51c814bb2f14572d06054cdc77a (patch)
treed228e36f3ecebbb7bc30266bc7ac74b21c7c7781
parent70f9f39df51dc1c82c73b62de1c51fe426e199b2 (diff)
downloadtcl-96d954cfc836a51c814bb2f14572d06054cdc77a.zip
tcl-96d954cfc836a51c814bb2f14572d06054cdc77a.tar.gz
tcl-96d954cfc836a51c814bb2f14572d06054cdc77a.tar.bz2
Enabled new packed mode: (inst+opnd) are packed in 32 bits. To
enable, set the env var CFLAGS_DEBUG="-DVM_PACKED" (resp "-g -DVM_PACKED") for the call to 'make'. If the flag is not set uses the wordcodes, where (inst+opnd) take the size of 2 pointers.
-rw-r--r--ChangeLog9
-rw-r--r--generic/tclCompile.h82
2 files changed, 79 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 48b5503..e2e32a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2005-03-15 Miguel Sofer <msofer@users.sf.net>
+ * generic/tclCompile.h:
+ Enabled new packed mode: (inst+opnd) are packed in 32 bits. To
+ enable, set the env var
+ CFLAGS_DEBUG="-DVM_PACKED" (resp "-g -DVM_PACKED")
+ for the call to 'make'. If the flag is not set uses the wordcodes,
+ where (inst+opnd) take the size of 2 pointers.
+
+2005-03-15 Miguel Sofer <msofer@users.sf.net>
+
* generic/tclCompile.c:
* generic/tclCompile.h:
* generic/tclExecute.c:
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 31482cc..6377338 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.53.2.11 2005/03/16 10:07:56 msofer Exp $
+ * RCS: @(#) $Id: tclCompile.h,v 1.53.2.12 2005/03/16 21:29:15 msofer Exp $
*/
#ifndef _TCLCOMPILATION
@@ -156,7 +156,7 @@ typedef struct AuxData {
* objective is:
* - an instruction has the width of a pointer - in preparation for it
* really being a pointer to a jump target
- * - an instruction's operands are pointer-sized, and can beone of : a
+ * - an instruction's operands are pointer-sized, and can be one of: a
* pointer, a pointer-sized integer, or (one signed and one unsigned)
* integers of half-pointer size.
*
@@ -177,8 +177,14 @@ typedef struct AuxData {
* pointers). If this design is adopted, a portable compact code will be
* designed. In principle it can be generated by the same compiler, with a
* different second stage to replace the optimiser.
+ *
+ * There is another option to store each (instruction+operands) in 32 bits; it
+ * is implemented below, and chosen by setting
+ * COMPILE_DEBUG_FLAGS="-DVM_USE_PACKED"
*/
+#ifndef VM_USE_PACKED
+
#if defined(__WIN32_)
#define TclPSizedInt int
#define TclHalfPSizedInt short
@@ -186,26 +192,26 @@ typedef struct AuxData {
#define TclPSizedInt Tcl_WideInt
#define TclHalfPSizedInt int
#else /* start of NOT WIN */
-#if ((SIZEOF_LONG <= SIZEOF_VOID_P) && (SIZEOF_LONG != SIZEOF_INT))
+#if ((SIZEOF_LONG_ <= SIZEOF_VOID_P_) && (SIZEOF_LONG_ != SIZEOF_INT_))
#define TclPSizedInt long
-#elif (SIZEOF_INT <= SIZEOF_VOID_P)
+#elif (SIZEOF_INT_ <= SIZEOF_VOID_P_)
#define TclPSizedInt int
-#elif (SIZEOF_SHORT <= SIZEOF_VOID_P)
+#elif (SIZEOF_SHORT_ <= SIZEOF_VOID_P_)
#define TclPSizedInt short
#else
Should not happen
(this text here to make the compiler barf)
#endif /* Define TclPSizedInt */
-#if ((2*SIZEOF_LONG <= SIZEOF_VOID_P) && (SIZEOF_LONG != SIZEOF_INT))
+#if ((2*SIZEOF_LONG_ <= SIZEOF_VOID_P_) && (SIZEOF_LONG_ != SIZEOF_INT_))
#define TclHalfPSizedInt long
-#elif (2*SIZEOF_INT <= SIZEOF_VOID_P)
+#elif (2*SIZEOF_INT_ <= SIZEOF_VOID_P_)
#define TclHalfPSizedInt int
-#elif (2*SIZEOF_SHORT <= SIZEOF_VOID_P)
+#elif (2*SIZEOF_SHORT_ <= SIZEOF_VOID_P_)
#define TclHalfPSizedInt short
#else
#define NO_HALFP_SIZED_INT
#endif /* Define TclHaldPSizedInt */
-#endif
+#endif /* Not WIN */
typedef union TclVMOpnd {
void *p;
@@ -232,13 +238,11 @@ typedef struct TclVMWord {
#define HPINT_MIN (-HPINT_MAX-1)
#define HP_STASH(full, n, u) \
- (full) = ((((TclPSizedInt) n) << HP_SHIFT) | (u))
+ (full) = ((((TclPSizedInt) (n)) << HP_SHIFT) | (u))
#define HP_EXTRACT(full, n, u)\
(n) = ((full) >> HP_SHIFT);\
(u) = ((full) & HP_MASK)
-
-
#define TclVMGetInstAtPtr(p) (*(p)).inst
#define TclVMGetOpndAtPtr(p) (*(p)).opnd.i
@@ -258,6 +262,60 @@ typedef struct TclVMWord {
(*(p)).inst = (TclPSizedInt) (instruction);\
(*(p)).opnd.i = (TclPSizedInt) (operand)
+#else /* USE_WORDCODES */
+/*
+ * Pack every (instruction+operands) in 32 bits; the possible combinations are
+ * - uint8 instruction, int24 operand
+ * - uint8 instruction, uint8 operand, int16 operand
+ */
+
+#if (SIZEOF_INT_ == 4)
+#define TclPSizedInt int
+#elif (SIZEOF_LONG_ == 4)
+#define TclPSizedInt long
+#elif (SIZEOF_SHORT_ == 4)
+#define TclPSizedInt short
+#else
+FIXME
+#endif
+
+#define TclVMWord TclPSizedInt
+#define TclVMOpnd TclPSizedInt
+
+#define PINT_MAX 0x8FFFFFFF
+#define PINT_MIN (-PINT_MAX -1)
+
+#define HP_SHIFT 8
+#define HP_MASK 0xFF
+
+#define HPUINT_MAX 0xFF
+#define HPINT_MAX 0x8FFFFF
+#define HPINT_MIN (-HPINT_MAX-1)
+
+#define HP_STASH(full, n, u) \
+ (full) = ((((TclPSizedInt) (n)) << HP_SHIFT) | (u))
+
+#define HP_EXTRACT(full, n, u)\
+ (n) = ((full) >> HP_SHIFT);\
+ (u) = ((full) & HP_MASK)
+
+#define TclVMGetInstAtPtr(p) (*(p) & HP_MASK)
+#define TclVMGetOpndAtPtr(p) (*(p) >> HP_SHIFT)
+
+#define TclVMStoreInstAtPtr(instruction, p) \
+ *(p) = ((*(p) & ~HP_MASK) | (instruction))
+
+#define TclVMStoreOpndAtPtr(operand, p) \
+ *(p) = ((*(p) & HP_MASK) | ((operand) << HP_SHIFT))
+
+#define TclVMGetInstAndOpAtPtr(p, instruction, operand) \
+ (instruction) = TclVMGetInstAtPtr(p);\
+ (operand) = TclVMGetOpndAtPtr(p)
+
+#define TclVMStoreWordAtPtr(instruction, operand, p) \
+ HP_STASH(*(p), (operand), (instruction))
+
+#endif /* USE_WORDCODES */
/*