diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2005-03-15 19:20:10 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2005-03-15 19:20:10 (GMT) |
commit | b53c075fcb4c9c549cb5e614c5d0f125cabe13dd (patch) | |
tree | ab83e912370141d41e8ffd095dd09407e52db97f | |
parent | 7bdc628ac4cc6a7827f798899e90ae74849fe801 (diff) | |
download | tcl-b53c075fcb4c9c549cb5e614c5d0f125cabe13dd.zip tcl-b53c075fcb4c9c549cb5e614c5d0f125cabe13dd.tar.gz tcl-b53c075fcb4c9c549cb5e614c5d0f125cabe13dd.tar.bz2 |
Attempt at fixing 64b issues; as a result, now getting plenty of
warnings for formatting issues - will fix later
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | generic/tclCompile.c | 183 | ||||
-rw-r--r-- | generic/tclCompile.h | 4 | ||||
-rw-r--r-- | generic/tclExecute.c | 5 |
4 files changed, 115 insertions, 96 deletions
@@ -1,5 +1,24 @@ 2005-03-15 Miguel Sofer <msofer@users.sf.net> + * generic/tclCompile.c: + * generic/tclCompile.h: + * generic/tclExecute.c: + Attempt at fixing 64b issues; as a result, now getting plenty of + warnings for formatting issues - will fix later + +2005-03-15 Miguel Sofer <msofer@users.sf.net> + + * generic/tclCompCmds.c: + * generic/tclCompile.h: + * generic/tclExecute.c: + (1) new opt for the [return] compiler, can now emit INST_BREAK or + INST_CONTINUE + (2) changed logic of the [foreach] instructions, including loop + rotation optimisation + (3) newjump target in TEBC to restart without changing pc + +2005-03-15 Miguel Sofer <msofer@users.sf.net> + * generic/tclCompCmds.c: * generic/tclCompile.c: * generic/tclCompile.h: diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 3f6f399..0d5c770 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.81.2.5 2005/03/15 02:01:08 msofer Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.81.2.6 2005/03/15 19:20:14 msofer Exp $ */ #include "tclInt.h" @@ -62,187 +62,187 @@ InstructionDesc tclInstructionTable[] = { /* Pop the topmost stack object */ {"dup", +1, 0, {OPERAND_NONE}}, /* Duplicate the topmost stack object and push the result */ - {"concat", PINT_MIN, 1, {OPERAND_UINT}}, + {"concat", INT_MIN, 1, {OPERAND_UINT}}, /* Concatenate the top op1 items and push result */ - {"invokeStk", PINT_MIN, 1, {OPERAND_UINT}}, + {"invokeStk", INT_MIN, 1, {OPERAND_UINT}}, /* Invoke command named objv[0]; <objc,objv> = <op4,top op4> */ - {"evalStk", 0, 0, {OPERAND_NONE}}, + {"evalStk", 0, 0, {OPERAND_NONE}}, /* Evaluate command in stktop using Tcl_EvalObj. */ - {"exprStk", 0, 0, {OPERAND_NONE}}, + {"exprStk", 0, 0, {OPERAND_NONE}}, /* Execute expression in stktop using Tcl_ExprStringObj. */ - {"loadScalar", 1, 1, {OPERAND_UINT}}, + {"loadScalar", 1, 1, {OPERAND_UINT}}, /* Load scalar variable at index op1 >= 256 in call frame */ - {"loadScalarStk", 0, 0, {OPERAND_NONE}}, + {"loadScalarStk", 0, 0, {OPERAND_NONE}}, /* Load scalar variable; scalar's name is stktop */ - {"loadArray", 0, 1, {OPERAND_UINT}}, + {"loadArray", 0, 1, {OPERAND_UINT}}, /* Load array element; array at slot op1 > 255, element is stktop */ - {"loadArrayStk", -1, 0, {OPERAND_NONE}}, + {"loadArrayStk", -1, 0, {OPERAND_NONE}}, /* Load array element; element is stktop, array name is stknext */ - {"loadStk", 0, 0, {OPERAND_NONE}}, + {"loadStk", 0, 0, {OPERAND_NONE}}, /* Load general variable; unparsed variable name is stktop */ - {"storeScalar", 0, 1, {OPERAND_UINT}}, + {"storeScalar", 0, 1, {OPERAND_UINT}}, /* Store scalar variable at op1 > 255 in frame; value is stktop */ - {"storeScalarStk", -1, 0, {OPERAND_NONE}}, + {"storeScalarStk", -1, 0, {OPERAND_NONE}}, /* Store scalar; value is stktop, scalar name is stknext */ - {"storeArray", -1, 1, {OPERAND_UINT}}, + {"storeArray", -1, 1, {OPERAND_UINT}}, /* Store array element; array at op1>=256, value is top then elem */ - {"storeArrayStk", -2, 0, {OPERAND_NONE}}, + {"storeArrayStk", -2, 0, {OPERAND_NONE}}, /* Store array element; value is stktop, then elem, array names */ - {"storeStk", -1, 0, {OPERAND_NONE}}, + {"storeStk", -1, 0, {OPERAND_NONE}}, /* Store general variable; value is stktop, then unparsed name */ - {"incrScalar", 0, 1, {OPERAND_UINT}}, + {"incrScalar", 0, 1, {OPERAND_UINT}}, /* Incr scalar at index op1<=255 in frame; incr amount is stktop */ - {"incrScalarStk", -1, 0, {OPERAND_NONE}}, + {"incrScalarStk", -1, 0, {OPERAND_NONE}}, /* Incr scalar; incr amount is stktop, scalar's name is stknext */ - {"incrArray", -1, 1, {OPERAND_UINT}}, + {"incrArray", -1, 1, {OPERAND_UINT}}, /* Incr array elem; arr at slot op1<=255, amount is top then elem */ - {"incrArrayStk", -2, 0, {OPERAND_NONE}}, + {"incrArrayStk", -2, 0, {OPERAND_NONE}}, /* Incr array element; amount is top then elem then array names */ - {"incrStk", -1, 0, {OPERAND_NONE}}, + {"incrStk", -1, 0, {OPERAND_NONE}}, /* Incr general variable; amount is stktop then unparsed var name */ - {"incrScalarImm", +1, 2, {OPERAND_UINT, OPERAND_INT}}, + {"incrScalarImm", +1, 2, {OPERAND_UINT, OPERAND_INT}}, /* Incr scalar at slot op1 <= 255; amount is 2nd operand byte */ - {"incrScalarStkImm", 0, 1, {OPERAND_INT}}, + {"incrScalarStkImm", 0, 1, {OPERAND_INT}}, /* Incr scalar; scalar name is stktop; incr amount is op1 */ - {"incrArrayImm", 0, 2, {OPERAND_UINT, OPERAND_INT}}, + {"incrArrayImm", 0, 2, {OPERAND_UINT, OPERAND_INT}}, /* Incr array elem; array at slot op1 <= 255, elem is stktop, * amount is 2nd operand byte */ - {"incrArrayStkImm", -1, 1, {OPERAND_INT}}, + {"incrArrayStkImm", -1, 1, {OPERAND_INT}}, /* Incr array element; elem is top then array name, amount is op1 */ - {"incrStkImm", 0, 1, {OPERAND_INT}}, + {"incrStkImm", 0, 1, {OPERAND_INT}}, /* Incr general variable; unparsed name is top, amount is op1 */ - {"jump", 0, 1, {OPERAND_INT}}, + {"jump", 0, 1, {OPERAND_INT}}, /* Jump relative to (pc + op4) */ - {"jumpTrue", -1, 1, {OPERAND_INT}}, + {"jumpTrue", -1, 1, {OPERAND_INT}}, /* Jump relative to (pc + op4) if stktop expr object is true */ - {"jumpFalse", -1, 1, {OPERAND_INT}}, + {"jumpFalse", -1, 1, {OPERAND_INT}}, /* Jump relative to (pc + op4) if stktop expr object is false */ - {"bitor", -1, 0, {OPERAND_NONE}}, + {"bitor", -1, 0, {OPERAND_NONE}}, /* Bitwise or: push (stknext | stktop) */ - {"bitxor", -1, 0, {OPERAND_NONE}}, + {"bitxor", -1, 0, {OPERAND_NONE}}, /* Bitwise xor push (stknext ^ stktop) */ - {"bitand", -1, 0, {OPERAND_NONE}}, + {"bitand", -1, 0, {OPERAND_NONE}}, /* Bitwise and: push (stknext & stktop) */ - {"eq", -1, 0, {OPERAND_NONE}}, + {"eq", -1, 0, {OPERAND_NONE}}, /* Equal: push (stknext == stktop) */ - {"neq", -1, 0, {OPERAND_NONE}}, + {"neq", -1, 0, {OPERAND_NONE}}, /* Not equal: push (stknext != stktop) */ - {"lt", -1, 0, {OPERAND_NONE}}, + {"lt", -1, 0, {OPERAND_NONE}}, /* Less: push (stknext < stktop) */ - {"gt", -1, 0, {OPERAND_NONE}}, + {"gt", -1, 0, {OPERAND_NONE}}, /* Greater: push (stknext || stktop) */ - {"le", -1, 0, {OPERAND_NONE}}, + {"le", -1, 0, {OPERAND_NONE}}, /* Logical or: push (stknext || stktop) */ - {"ge", -1, 0, {OPERAND_NONE}}, + {"ge", -1, 0, {OPERAND_NONE}}, /* Logical or: push (stknext || stktop) */ - {"lshift", -1, 0, {OPERAND_NONE}}, + {"lshift", -1, 0, {OPERAND_NONE}}, /* Left shift: push (stknext << stktop) */ - {"rshift", -1, 0, {OPERAND_NONE}}, + {"rshift", -1, 0, {OPERAND_NONE}}, /* Right shift: push (stknext >> stktop) */ - {"add", -1, 0, {OPERAND_NONE}}, + {"add", -1, 0, {OPERAND_NONE}}, /* Add: push (stknext + stktop) */ - {"sub", -1, 0, {OPERAND_NONE}}, + {"sub", -1, 0, {OPERAND_NONE}}, /* Sub: push (stkext - stktop) */ - {"mult", -1, 0, {OPERAND_NONE}}, + {"mult", -1, 0, {OPERAND_NONE}}, /* Multiply: push (stknext * stktop) */ - {"div", -1, 0, {OPERAND_NONE}}, + {"div", -1, 0, {OPERAND_NONE}}, /* Divide: push (stknext / stktop) */ - {"mod", -1, 0, {OPERAND_NONE}}, + {"mod", -1, 0, {OPERAND_NONE}}, /* Mod: push (stknext % stktop) */ - {"uplus", 0, 0, {OPERAND_NONE}}, + {"uplus", 0, 0, {OPERAND_NONE}}, /* Unary plus: push +stktop */ - {"uminus", 0, 0, {OPERAND_NONE}}, + {"uminus", 0, 0, {OPERAND_NONE}}, /* Unary minus: push -stktop */ - {"bitnot", 0, 0, {OPERAND_NONE}}, + {"bitnot", 0, 0, {OPERAND_NONE}}, /* Bitwise not: push ~stktop */ - {"not", 0, 0, {OPERAND_NONE}}, + {"not", 0, 0, {OPERAND_NONE}}, /* Logical not: push !stktop */ - {"callBuiltinFunc", 1, 1, {OPERAND_UINT}}, + {"callBuiltinFunc", 1, 1, {OPERAND_UINT}}, /* Call builtin math function with index op1; any args are on stk */ - {"callFunc", PINT_MIN, 1, {OPERAND_UINT}}, + {"callFunc", INT_MIN, 1, {OPERAND_UINT}}, /* Call non-builtin func objv[0]; <objc,objv>=<op1,top op1> */ - {"tryCvtToNumeric", 0, 0, {OPERAND_NONE}}, + {"tryCvtToNumeric", 0, 0, {OPERAND_NONE}}, /* Try converting stktop to first int then double if possible. */ - {"break", 0, 0, {OPERAND_NONE}}, + {"break", 0, 0, {OPERAND_NONE}}, /* Abort closest enclosing loop; if none, return TCL_BREAK code. */ - {"continue", 0, 0, {OPERAND_NONE}}, + {"continue", 0, 0, {OPERAND_NONE}}, /* Skip to next iteration of closest enclosing loop; if none, * return TCL_CONTINUE code. */ - {"foreach_start4", 0, 1, {OPERAND_UINT}}, + {"foreach_start4", 0, 1, {OPERAND_UINT}}, /* Initialize execution of a foreach loop. Operand is aux data index * of the ForeachInfo structure for the foreach command. */ - {"foreach_step4", +1, 1, {OPERAND_UINT}}, + {"foreach_step4", +1, 1, {OPERAND_UINT}}, /* "Step" or begin next iteration of foreach loop. Push 0 if to * terminate loop, else push 1. */ - {"beginCatch4", 0, 1, {OPERAND_UINT}}, + {"beginCatch4", 0, 1, {OPERAND_UINT}}, /* Record start of catch with the operand's exception index. * Push the current stack depth onto a special catch stack. */ - {"endCatch", 0, 0, {OPERAND_NONE}}, + {"endCatch", 0, 0, {OPERAND_NONE}}, /* End of last catch. Pop the bytecode interpreter's catch stack. */ - {"pushResult", +1, 0, {OPERAND_NONE}}, + {"pushResult", +1, 0, {OPERAND_NONE}}, /* Push the interpreter's object result onto the stack. */ - {"pushReturnCode", +1, 0, {OPERAND_NONE}}, + {"pushReturnCode", +1, 0, {OPERAND_NONE}}, /* Push interpreter's return code (e.g. TCL_OK or TCL_ERROR) as * a new object onto the stack. */ - {"streq", -1, 0, {OPERAND_NONE}}, + {"streq", -1, 0, {OPERAND_NONE}}, /* Str Equal: push (stknext eq stktop) */ - {"strneq", -1, 0, {OPERAND_NONE}}, + {"strneq", -1, 0, {OPERAND_NONE}}, /* Str !Equal: push (stknext neq stktop) */ - {"strcmp", -1, 0, {OPERAND_NONE}}, + {"strcmp", -1, 0, {OPERAND_NONE}}, /* Str Compare: push (stknext cmp stktop) */ - {"strlen", 0, 0, {OPERAND_NONE}}, + {"strlen", 0, 0, {OPERAND_NONE}}, /* Str Length: push (strlen stktop) */ - {"strindex", -1, 0, {OPERAND_NONE}}, + {"strindex", -1, 0, {OPERAND_NONE}}, /* Str Index: push (strindex stknext stktop) */ - {"strmatch", -1, 1, {OPERAND_INT}}, + {"strmatch", -1, 1, {OPERAND_INT}}, /* Str Match: push (strmatch stknext stktop) opnd == nocase */ - {"list", PINT_MIN, 1, {OPERAND_UINT}}, + {"list", INT_MIN, 1, {OPERAND_UINT}}, /* List: push (stk1 stk2 ... stktop) */ - {"listIndex", -1, 0, {OPERAND_NONE}}, + {"listIndex", -1, 0, {OPERAND_NONE}}, /* List Index: push (listindex stknext stktop) */ - {"listLength", 0, 0, {OPERAND_NONE}}, + {"listLength", 0, 0, {OPERAND_NONE}}, /* List Len: push (listlength stktop) */ - {"appendScalar", 0, 1, {OPERAND_UINT}}, + {"appendScalar", 0, 1, {OPERAND_UINT}}, /* Append scalar variable at op1 > 255 in frame; value is stktop */ - {"appendArray", -1, 1, {OPERAND_UINT}}, + {"appendArray", -1, 1, {OPERAND_UINT}}, /* Append array element; array at op1>=256, value is top then elem */ - {"appendArrayStk", -2, 0, {OPERAND_NONE}}, + {"appendArrayStk", -2, 0, {OPERAND_NONE}}, /* Append array element; value is stktop, then elem, array names */ - {"appendStk", -1, 0, {OPERAND_NONE}}, + {"appendStk", -1, 0, {OPERAND_NONE}}, /* Append general variable; value is stktop, then unparsed name */ - {"lappendScalar", 0, 1, {OPERAND_UINT}}, + {"lappendScalar", 0, 1, {OPERAND_UINT}}, /* Lappend scalar variable at op1 > 255 in frame; value is stktop */ - {"lappendArray", -1, 1, {OPERAND_UINT}}, + {"lappendArray", -1, 1, {OPERAND_UINT}}, /* Lappend array element; array at op1>=256, value is top then elem */ - {"lappendArrayStk", -2, 0, {OPERAND_NONE}}, + {"lappendArrayStk", -2, 0, {OPERAND_NONE}}, /* Lappend array element; value is stktop, then elem, array names */ - {"lappendStk", -1, 0, {OPERAND_NONE}}, + {"lappendStk", -1, 0, {OPERAND_NONE}}, /* Lappend general variable; value is stktop, then unparsed name */ - {"lindexMulti", PINT_MIN, 1, {OPERAND_UINT}}, + {"lindexMulti", INT_MIN, 1, {OPERAND_UINT}}, /* Lindex with generalized args, operand is number of stacked objs * used: (operand-1) entries from stktop are the indices; then list * to process. */ - {"over", +1, 1, {OPERAND_UINT}}, + {"over", +1, 1, {OPERAND_UINT}}, /* Duplicate the arg-th element from top of stack (TOS=0) */ - {"lsetList", -2, 0, {OPERAND_NONE}}, + {"lsetList", -2, 0, {OPERAND_NONE}}, /* Four-arg version of 'lset'. stktop is old value; next is * new element value, next is the index list; pushes new value */ - {"lsetFlat", PINT_MIN, 1, {OPERAND_UINT}}, + {"lsetFlat", INT_MIN, 1, {OPERAND_UINT}}, /* Three- or >=5-arg version of 'lset', operand is number of * stacked objs: stktop is old value, next is new element value, next * come (operand-2) indices; pushes the new value. */ - {"return", -1, 2, {OPERAND_INT, OPERAND_UINT}}, + {"return", -1, 2, {OPERAND_INT, OPERAND_UINT}}, /* Compiled [return], code, level are operands; options and result * are on the stack. */ - {"expon", -1, 0, {OPERAND_NONE}}, + {"expon", -1, 0, {OPERAND_NONE}}, /* Binary exponentiation operator: push (stknext ** stktop) */ /* * NOTE: the stack effects of expandStkTop and invokeExpanded @@ -252,23 +252,23 @@ InstructionDesc tclInstructionTable[] = { * See the comments further down in this file, where INST_INVOKE_EXPANDED * is emitted. */ - {"expandStart", 0, 0, {OPERAND_NONE}}, + {"expandStart", 0, 0, {OPERAND_NONE}}, /* Start of command with {expand}ed arguments */ - {"expandStkTop", 0, 1, {OPERAND_INT}}, + {"expandStkTop", 0, 1, {OPERAND_INT}}, /* Expand the list at stacktop: push its elements on the stack */ - {"invokeExpanded", 0, 0, {OPERAND_NONE}}, + {"invokeExpanded", 0, 0, {OPERAND_NONE}}, /* Invoke the command marked by the last 'expandStart' */ - {"listIndexImm", 0, 1, {OPERAND_IDX}}, + {"listIndexImm", 0, 1, {OPERAND_IDX}}, /* List Index: push (lindex stktop op4) */ - {"listRangeImm", 0, 2, {OPERAND_IDX, OPERAND_IDX}}, + {"listRangeImm", 0, 2, {OPERAND_IDX, OPERAND_IDX}}, /* List Range: push (lrange stktop op4 op4) */ - {"startCommand", 0, 1, {OPERAND_UINT}}, + {"startCommand", 0, 1, {OPERAND_UINT}}, /* Start of bytecoded command: op is the length of the cmd's code */ - {"listIn", -1, 0, {OPERAND_NONE}}, + {"listIn", -1, 0, {OPERAND_NONE}}, /* List containment: push [lsearch stktop stknext]>=0) */ - {"listNotIn", -1, 0, {OPERAND_NONE}}, + {"listNotIn", -1, 0, {OPERAND_NONE}}, /* List negated containment: push [lsearch stktop stknext]<0) */ {0} }; @@ -2927,7 +2927,8 @@ TclPrintInstruction(codePtr, pc) register InstructionDesc *instDesc; TclVMWord *codeStart = codePtr->codeStart; ptrdiff_t pcOffset = (pc - codeStart); - int opnd, opnds[2], i, j; + TclPSizedInt opnd, opnds[2]; + int i, j; TclGetInstAndOpAtPtr(pc, opCode, opnd); instDesc = &tclInstructionTable[opCode]; diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 48ed37e..6f5c830 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.7 2005/03/15 14:55:28 msofer Exp $ + * RCS: @(#) $Id: tclCompile.h,v 1.53.2.8 2005/03/15 19:20:14 msofer Exp $ */ #ifndef _TCLCOMPILATION @@ -952,7 +952,7 @@ MODULE_SCOPE int TclWordKnownAtCompileTime _ANSI_ARGS_(( {\ int delta = tclInstructionTable[(op)].stackEffect;\ if (delta) {\ - if (delta == PINT_MIN) {\ + if (delta == INT_MIN) {\ delta = 1 - (i);\ }\ TclAdjustStackDepth(delta, envPtr);\ diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 83e8685..b74efb9 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.171.2.6 2005/03/15 14:55:29 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.171.2.7 2005/03/15 19:20:14 msofer Exp $ */ #include "tclInt.h" @@ -1120,7 +1120,7 @@ TclExecuteByteCode(interp, codePtr) * when to call Tcl_AsyncReady() */ Tcl_Obj *expandNestList = NULL; int inst; - int opnd; + TclPSizedInt opnd; /* * Transfer variables - needed only between opcodes, but not @@ -5048,7 +5048,6 @@ ValidatePcAndStackTop(codePtr, pc, stackTop, stackLowerBound, checkStack) TclVMWord *codeEnd = (codePtr->codeStart + codePtr->numCodeWords); unsigned int opCode = (unsigned int) (*pc).i; -fflush(stdout); if (( pc < codeStart) || (pc > codeEnd)) { fprintf(stderr, "\nBad instruction pc %p in TclExecuteByteCode\n", (VOID *) pc); |