From 8301d699de81c99e8cbcb969648e30803f6d7c1b Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Thu, 13 Jun 2002 23:10:09 +0000 Subject: consolidated code for the conditional branch instructions. --- ChangeLog | 5 +++ generic/tclExecute.c | 87 ++++++++++++++++++++-------------------------------- 2 files changed, 39 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index 375d1f3..81b5f7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2002-06-13 Miguel Sofer + * generic/tclExecute.c (TclExecuteByteCode): consolidated code for + the conditional branch instructions. + +2002-06-13 Miguel Sofer + * generic/tclExecute.c (TclExecuteByteCode): fixed the previous patch - wouldn't compile with TCL_COMPILE_DEBUG set. diff --git a/generic/tclExecute.c b/generic/tclExecute.c index be1b51b..9c29d41 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.64 2002/06/13 21:37:15 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.65 2002/06/13 23:10:12 msofer Exp $ */ #include "tclInt.h" @@ -1842,14 +1842,24 @@ TclExecuteByteCode(interp, codePtr) (unsigned int)(pc + opnd - codePtr->codeStart))); ADJUST_PC(opnd); + case INST_JUMP_FALSE4: + opnd = 5; /* TRUE */ + pcAdjustment = TclGetInt4AtPtr(pc+1); /* FALSE */ + goto doJumpTrue; + case INST_JUMP_TRUE4: - opnd = TclGetInt4AtPtr(pc+1); - pcAdjustment = 5; + opnd = TclGetInt4AtPtr(pc+1); /* TRUE */ + pcAdjustment = 5; /* FALSE */ + goto doJumpTrue; + + case INST_JUMP_FALSE1: + opnd = 2; /* TRUE */ + pcAdjustment = TclGetInt1AtPtr(pc+1); /* FALSE */ goto doJumpTrue; case INST_JUMP_TRUE1: - opnd = TclGetInt1AtPtr(pc+1); - pcAdjustment = 2; + opnd = TclGetInt1AtPtr(pc+1); /* TRUE */ + pcAdjustment = 2; /* FALSE */ doJumpTrue: { @@ -1874,62 +1884,33 @@ TclExecuteByteCode(interp, codePtr) } } if (b) { - TRACE(("%d => %.20s true, new pc %u\n", - opnd, O2S(valuePtr), - (unsigned int)(pc+opnd - codePtr->codeStart))); +#ifdef TCL_COMPILE_DEBUG + if ((*pc == INST_JUMP_TRUE1) || (*pc == INST_JUMP_TRUE1)) { + TRACE(("%d => %.20s true, new pc %u\n", + opnd, O2S(valuePtr), + (unsigned int)(pc+opnd - codePtr->codeStart))); + } else { + TRACE(("%d => %.20s true\n", pcAdjustment, O2S(valuePtr))); + } +#endif TclDecrRefCount(valuePtr); ADJUST_PC(opnd); } else { - TRACE(("%d => %.20s false\n", opnd, O2S(valuePtr))); - TclDecrRefCount(valuePtr); - ADJUST_PC(pcAdjustment); - } - } - - case INST_JUMP_FALSE4: - opnd = TclGetInt4AtPtr(pc+1); - pcAdjustment = 5; - goto doJumpFalse; - - case INST_JUMP_FALSE1: - opnd = TclGetInt1AtPtr(pc+1); - pcAdjustment = 2; - - doJumpFalse: - { - int b; - - valuePtr = POP_OBJECT(); - if (valuePtr->typePtr == &tclIntType) { - b = (valuePtr->internalRep.longValue != 0); - } else if (valuePtr->typePtr == &tclDoubleType) { - b = (valuePtr->internalRep.doubleValue != 0.0); -#ifndef TCL_WIDE_INT_IS_LONG - } else if (valuePtr->typePtr == &tclWideIntType) { - b = (valuePtr->internalRep.wideValue != W0); -#endif /* TCL_WIDE_INT_IS_LONG */ - } else { - result = Tcl_GetBooleanFromObj(interp, valuePtr, &b); - if (result != TCL_OK) { - TRACE_WITH_OBJ(("%d => ERROR: ", opnd), - Tcl_GetObjResult(interp)); - TclDecrRefCount(valuePtr); - goto checkForCatch; +#ifdef TCL_COMPILE_DEBUG + if ((*pc == INST_JUMP_TRUE1) || (*pc == INST_JUMP_TRUE1)) { + TRACE(("%d => %.20s false\n", opnd, O2S(valuePtr))); + } else { + opnd = pcAdjustment; + TRACE(("%d => %.20s false, new pc %u\n", + opnd, O2S(valuePtr), + (unsigned int)(pc + opnd - codePtr->codeStart))); } - } - if (b) { - TRACE(("%d => %.20s true\n", opnd, O2S(valuePtr))); +#endif TclDecrRefCount(valuePtr); ADJUST_PC(pcAdjustment); - } else { - TRACE(("%d => %.20s false, new pc %u\n", - opnd, O2S(valuePtr), - (unsigned int)(pc + opnd - codePtr->codeStart))); - TclDecrRefCount(valuePtr); - ADJUST_PC(opnd); } } - + case INST_LOR: case INST_LAND: { -- cgit v0.12