summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2004-01-12 03:23:31 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2004-01-12 03:23:31 (GMT)
commitddebbb181a979f87cfae4b83623a50a83497cf40 (patch)
treebe0e583840c54a18c4ebac8852fcd49ca894568a /generic/tclExecute.c
parente7b6e827bfe3d6f5f569c678d1e547b07e6b3b57 (diff)
downloadtcl-ddebbb181a979f87cfae4b83623a50a83497cf40.zip
tcl-ddebbb181a979f87cfae4b83623a50a83497cf40.tar.gz
tcl-ddebbb181a979f87cfae4b83623a50a83497cf40.tar.bz2
* generic/tclCompExpr.c (CompileLandOrLorExpr): new logic, fewer
instructions. As a side effect, the instructions INST_LOR and INST_LAND are now never used. * generic/tclExecute.c (INST_JUMP*): small optimisation; fix a bug in debug code.
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index f12452b..61d444b 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.118 2003/12/24 04:18:19 davygrvy Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.119 2004/01/12 03:23:31 msofer Exp $
*/
#include "tclInt.h"
@@ -2275,7 +2275,16 @@ TclExecuteByteCode(interp, codePtr)
int b;
valuePtr = *tosPtr;
- if (valuePtr->typePtr == &tclIntType) {
+ /*
+ * The following will be partially resolved at compile
+ * time and optimised away.
+ */
+ if (((sizeof(long) == sizeof(int)) &&
+ (valuePtr->typePtr == &tclIntType))
+ || (valuePtr->typePtr == &tclBooleanType)) {
+ b = (int) valuePtr->internalRep.longValue;
+ } else if ((sizeof(long) != sizeof(int)) &&
+ (valuePtr->typePtr == &tclIntType)) {
b = (valuePtr->internalRep.longValue != 0);
} else if (valuePtr->typePtr == &tclDoubleType) {
b = (valuePtr->internalRep.doubleValue != 0.0);
@@ -2293,7 +2302,7 @@ TclExecuteByteCode(interp, codePtr)
NEXT_INST_F((b? opnd : pcAdjustment), 1, 0);
#else
if (b) {
- if ((*pc == INST_JUMP_TRUE1) || (*pc == INST_JUMP_TRUE1)) {
+ if ((*pc == INST_JUMP_TRUE1) || (*pc == INST_JUMP_TRUE4)) {
TRACE(("%d => %.20s true, new pc %u\n", opnd, O2S(valuePtr),
(unsigned int)(pc+opnd - codePtr->codeStart)));
} else {
@@ -2301,7 +2310,7 @@ TclExecuteByteCode(interp, codePtr)
}
NEXT_INST_F(opnd, 1, 0);
} else {
- if ((*pc == INST_JUMP_TRUE1) || (*pc == INST_JUMP_TRUE1)) {
+ if ((*pc == INST_JUMP_TRUE1) || (*pc == INST_JUMP_TRUE4)) {
TRACE(("%d => %.20s false\n", opnd, O2S(valuePtr)));
} else {
opnd = pcAdjustment;
@@ -2313,6 +2322,11 @@ TclExecuteByteCode(interp, codePtr)
#endif
}
+ /*
+ * These two instructions are now redundant: the complete logic of the
+ * LOR and LAND is now handled by the expression compiler.
+ */
+
case INST_LOR:
case INST_LAND:
{