diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-01-19 14:06:09 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-01-19 14:06:09 (GMT) |
commit | b1e9c1d4b650fea5e60a10b7beaad0c893848982 (patch) | |
tree | 1d6d0da8a00a3f7253a77e3051f23d247d1fa15d /generic | |
parent | 04752af27c73732b84dc81b8f2284d5ca83e3962 (diff) | |
download | tcl-b1e9c1d4b650fea5e60a10b7beaad0c893848982.zip tcl-b1e9c1d4b650fea5e60a10b7beaad0c893848982.tar.gz tcl-b1e9c1d4b650fea5e60a10b7beaad0c893848982.tar.bz2 |
More efficient issuing of INST_START_CMD instructions. See ChangeLog for discussion
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCompile.c | 11 | ||||
-rw-r--r-- | generic/tclCompile.h | 19 |
2 files changed, 21 insertions, 9 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 0dcfb32..2964e46 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.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: tclCompile.c,v 1.105 2007/01/18 23:17:07 dkf Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.106 2007/01/19 14:06:09 dkf Exp $ */ #include "tclInt.h" @@ -854,6 +854,7 @@ TclInitCompileEnv( envPtr->cmdMapPtr = envPtr->staticCmdMapSpace; envPtr->cmdMapEnd = COMPILEENV_INIT_CMD_MAP_SIZE; envPtr->mallocedCmdMap = 0; + envPtr->atCmdStart = 0; /* * TIP #280: Set up the extended command location information, based on @@ -1124,7 +1125,7 @@ TclCompileScript( Command *cmdPtr; Tcl_Token *tokenPtr; int bytesLeft, isFirstCmd, gotParse, wordIdx, currCmdIndex; - int commandLength, objIndex, code; + int commandLength, objIndex; Tcl_DString ds; /* TIP #280 */ ExtCmdLoc *eclPtr = envPtr->extCmdMapPtr; @@ -1468,6 +1469,7 @@ TclCompileScript( int savedNumCmds = envPtr->numCommands; unsigned int savedCodeNext = envPtr->codeNext - envPtr->codeStart; + int update = 0, code; /* * Mark the start of the command; the proper bytecode @@ -1479,14 +1481,15 @@ TclCompileScript( * (savedCodeNext == 0) */ - if (savedCodeNext != 0) { + if (savedCodeNext != 0 && !envPtr->atCmdStart) { TclEmitInstInt4(INST_START_CMD, 0, envPtr); + update = 1; } code = (cmdPtr->compileProc)(interp, &parse, envPtr); if (code == TCL_OK) { - if (savedCodeNext != 0) { + if (update) { /* * Fix the bytecode length. */ diff --git a/generic/tclCompile.h b/generic/tclCompile.h index a99f501..cba0888 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.67 2006/12/13 16:28:06 dkf Exp $ + * RCS: @(#) $Id: tclCompile.h,v 1.68 2007/01/19 14:06:10 dkf Exp $ */ #ifndef _TCLCOMPILATION @@ -281,11 +281,15 @@ typedef struct CompileEnv { AuxData staticAuxDataArraySpace[COMPILEENV_INIT_AUX_DATA_SIZE]; /* Initial storage for aux data array. */ /* TIP #280 */ - ExtCmdLoc* extCmdMapPtr; /* Extended command location information + ExtCmdLoc *extCmdMapPtr; /* Extended command location information * for 'info frame'. */ - int line; /* First line of the script, based on the + int line; /* First line of the script, based on the * invoking context, then the line of the * command currently compiled. */ + int atCmdStart; /* Flag to say whether an INST_START_CMD + * should be issued; they should never be + * issued repeatedly, as that is significantly + * inefficient. */ } CompileEnv; /* @@ -957,9 +961,11 @@ MODULE_SCOPE int TclWordSimpleExpansion(Tcl_Token *tokenPtr); */ #define TclEmitOpcode(op, envPtr) \ - if ((envPtr)->codeNext == (envPtr)->codeEnd) \ + if ((envPtr)->codeNext == (envPtr)->codeEnd) { \ TclExpandCodeArray(envPtr); \ + } \ *(envPtr)->codeNext++ = (unsigned char) (op);\ + (envPtr)->atCmdStart = ((op) == INST_START_CMD); \ TclUpdateStackReqs(op, 0, envPtr) /* @@ -971,8 +977,9 @@ MODULE_SCOPE int TclWordSimpleExpansion(Tcl_Token *tokenPtr); */ #define TclEmitInt1(i, envPtr) \ - if ((envPtr)->codeNext == (envPtr)->codeEnd) \ + if ((envPtr)->codeNext == (envPtr)->codeEnd) { \ TclExpandCodeArray(envPtr); \ + } \ *(envPtr)->codeNext++ = (unsigned char) ((unsigned int) (i)) #define TclEmitInt4(i, envPtr) \ @@ -1004,6 +1011,7 @@ MODULE_SCOPE int TclWordSimpleExpansion(Tcl_Token *tokenPtr); } \ *(envPtr)->codeNext++ = (unsigned char) (op); \ *(envPtr)->codeNext++ = (unsigned char) ((unsigned int) (i));\ + (envPtr)->atCmdStart = ((op) == INST_START_CMD); \ TclUpdateStackReqs(op, i, envPtr) #define TclEmitInstInt4(op, i, envPtr) \ @@ -1019,6 +1027,7 @@ MODULE_SCOPE int TclWordSimpleExpansion(Tcl_Token *tokenPtr); (unsigned char) ((unsigned int) (i) >> 8); \ *(envPtr)->codeNext++ = \ (unsigned char) ((unsigned int) (i) );\ + (envPtr)->atCmdStart = ((op) == INST_START_CMD); \ TclUpdateStackReqs(op, i, envPtr) /* |