summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2005-03-07 20:29:12 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2005-03-07 20:29:12 (GMT)
commit7d32638627feb45e86ae5187413f0b5c73c5ec4a (patch)
treee75bee92422d090dec595bd1fbd6b9ff4ab51f69
parentb06bf5d5528889d4da04ae524c75a3c4b318e143 (diff)
downloadtcl-7d32638627feb45e86ae5187413f0b5c73c5ec4a.zip
tcl-7d32638627feb45e86ae5187413f0b5c73c5ec4a.tar.gz
tcl-7d32638627feb45e86ae5187413f0b5c73c5ec4a.tar.bz2
* generic/tclExecute.c: new peephole optimisation for INST_PUSH1;
fixed the peephole opt in INST_POP so that it is not used when TCL_COMPILE_DEBUG is defined.
-rw-r--r--generic/tclExecute.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index b702a1d..f876063 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.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: tclExecute.c,v 1.170 2005/02/01 17:27:27 dgp Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.171 2005/03/07 20:29:12 msofer Exp $
*/
#include "tclInt.h"
@@ -1342,9 +1342,22 @@ TclExecuteByteCode(interp, codePtr)
goto checkForCatch;
case INST_PUSH1:
- objResultPtr = codePtr->objArrayPtr[TclGetUInt1AtPtr(pc+1)];
- TRACE_WITH_OBJ(("%u => ", TclGetInt1AtPtr(pc+1)), objResultPtr);
- NEXT_INST_F(2, 0, 1);
+#if !TCL_COMPILE_DEBUG
+ instPush1Peephole:
+#endif
+ PUSH_OBJECT(codePtr->objArrayPtr[TclGetUInt1AtPtr(pc+1)]);
+ TRACE_WITH_OBJ(("%u => ", TclGetInt1AtPtr(pc+1)), *(tosPtr-1));
+ pc += 2;
+#if !TCL_COMPILE_DEBUG
+ /*
+ * Runtime peephole optimisation: check if we are pushing again.
+ */
+
+ if (*pc == INST_PUSH1) {
+ goto instPush1Peephole;
+ }
+#endif
+ NEXT_INST_F(0, 0, 0);
case INST_PUSH4:
objResultPtr = codePtr->objArrayPtr[TclGetUInt4AtPtr(pc+1)];
@@ -1365,12 +1378,20 @@ TclExecuteByteCode(interp, codePtr)
* at the end of most commands. If the next instruction is an
* INST_START_CMD, fall through to it.
*/
+
pc++;
- if (*pc != INST_START_CMD) {
- NEXT_INST_F(0, 0, 0);
+#if !TCL_COMPILE_DEBUG
+ if (*pc == INST_START_CMD) {
+ goto instStartCmdPeephole;
}
+#endif
+ NEXT_INST_F(0, 0, 0);
+
case INST_START_CMD:
+#if !TCL_COMPILE_DEBUG
+ instStartCmdPeephole:
+#endif
/*
* Remark that if the interpreter is marked for deletion
* its compileEpoch is modified, so that the epoch