summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2009-12-08 04:20:23 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2009-12-08 04:20:23 (GMT)
commit1421cacb4e078cf96950f34ed3f3dabe6153ec26 (patch)
tree2e116db342c1da032e7be838de983f13d6fffc3f /generic
parent903848120ff87aaa29fd7b7cc21b37b097edefc1 (diff)
downloadtcl-1421cacb4e078cf96950f34ed3f3dabe6153ec26.zip
tcl-1421cacb4e078cf96950f34ed3f3dabe6153ec26.tar.gz
tcl-1421cacb4e078cf96950f34ed3f3dabe6153ec26.tar.bz2
* generic/tclExecute.c (TEBC): Grouping "slow" variables into
structs, to reduce register pressure and help the compiler with variable allocation.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclExecute.c646
1 files changed, 327 insertions, 319 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 05e40aa..5835792 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -14,7 +14,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.451 2009/12/08 01:34:05 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.452 2009/12/08 04:20:24 msofer Exp $
*/
#include "tclInt.h"
@@ -184,31 +184,27 @@ typedef struct BottomData {
} BottomData;
#define NR_DATA_INIT() \
- bottomPtr->prevBottomPtr = oldBottomPtr; \
- bottomPtr->rootPtr = TOP_CB(iPtr); \
- bottomPtr->codePtr = codePtr; \
+ BP->prevBottomPtr = OBP; \
+ BP->rootPtr = TOP_CB(iPtr); \
+ BP->codePtr = codePtr; \
#define NR_DATA_BURY() \
- bottomPtr->pc = pc; \
- bottomPtr->catchTop = catchTop; \
- bottomPtr->cleanup = cleanup; \
- bottomPtr->auxObjList = auxObjList; \
- oldBottomPtr = bottomPtr
+ BP->pc = pc; \
+ BP->cleanup = cleanup; \
+ OBP = BP
#define NR_DATA_DIG() \
- pc = bottomPtr->pc; \
- codePtr = bottomPtr->codePtr; \
- catchTop = bottomPtr->catchTop; \
- cleanup = bottomPtr->cleanup; \
- auxObjList = bottomPtr->auxObjList; \
- esPtr = iPtr->execEnvPtr->execStackPtr; \
- tosPtr = esPtr->tosPtr
-
-#define PUSH_AUX_OBJ(objPtr) \
+ pc = BP->pc; \
+ codePtr = BP->codePtr; \
+ cleanup = BP->cleanup; \
+ TAUX.esPtr = iPtr->execEnvPtr->execStackPtr; \
+ tosPtr = TAUX.esPtr->tosPtr
+
+#define PUSH_TAUX_OBJ(objPtr) \
objPtr->internalRep.twoPtrValue.ptr2 = auxObjList; \
auxObjList = objPtr
-#define POP_AUX_OBJ() \
+#define POP_TAUX_OBJ() \
{ \
Tcl_Obj *tmpPtr = auxObjList; \
auxObjList = (Tcl_Obj *) tmpPtr->internalRep.twoPtrValue.ptr2; \
@@ -307,11 +303,11 @@ VarHashCreateVar(
*/
#define CACHE_STACK_INFO() \
- checkInterp = 1
+ TAUX.checkInterp = 1
#define DECACHE_STACK_INFO() \
- esPtr->tosPtr = tosPtr; \
- iPtr->execEnvPtr->bottomPtr = bottomPtr
+ TAUX.esPtr->tosPtr = tosPtr; \
+ iPtr->execEnvPtr->bottomPtr = BP
/*
* Macros used to access items on the Tcl evaluation stack. PUSH_OBJECT
@@ -385,13 +381,13 @@ VarHashCreateVar(
#define TCL_DTRACE_INST_NEXT() \
if (TCL_DTRACE_INST_DONE_ENABLED()) {\
- if (curInstName) {\
- TCL_DTRACE_INST_DONE(curInstName, (int) CURR_DEPTH,\
+ if (TAUX.curInstName) {\
+ TCL_DTRACE_INST_DONE(TAUX.curInstName, (int) CURR_DEPTH,\
tosPtr);\
}\
- curInstName = tclInstructionTable[*pc].name;\
+ TAUX.curInstName = tclInstructionTable[*pc].name;\
if (TCL_DTRACE_INST_START_ENABLED()) {\
- TCL_DTRACE_INST_START(curInstName, (int) CURR_DEPTH,\
+ TCL_DTRACE_INST_START(TAUX.curInstName, (int) CURR_DEPTH,\
tosPtr);\
}\
} else if (TCL_DTRACE_INST_START_ENABLED()) {\
@@ -399,8 +395,8 @@ VarHashCreateVar(
(int) CURR_DEPTH, tosPtr);\
}
#define TCL_DTRACE_INST_LAST() \
- if (TCL_DTRACE_INST_DONE_ENABLED() && curInstName) {\
- TCL_DTRACE_INST_DONE(curInstName, (int) CURR_DEPTH, tosPtr);\
+ if (TCL_DTRACE_INST_DONE_ENABLED() && TAUX.curInstName) {\
+ TCL_DTRACE_INST_DONE(TAUX.curInstName, (int) CURR_DEPTH, tosPtr);\
}
/*
@@ -1869,54 +1865,73 @@ TclExecuteByteCode(
*/
/* NR_TEBC */
- BottomData *bottomPtr = NULL;
- BottomData *oldBottomPtr = NULL;
-
/*
* Constants: variables that do not change during the execution, used
- * sporadically.
+ * sporadically: no special need for speed.
*/
- ExecStack *esPtr = NULL;
- Tcl_Obj **initTosPtr = NULL; /* Stack top at start of execution. */
- ptrdiff_t *initCatchTop = NULL; /* Catch stack top at start of execution */
- Var *compiledLocals = NULL;
- CmdFrame *bcFramePtr = NULL; /* TIP #280 Structure for tracking lines */
- Tcl_Obj **constants = &iPtr->execEnvPtr->constants[0];
-
+ struct auxTEBCdata {
+ ExecStack *esPtr;
+ Var *compiledLocals;
+ BottomData *bottomPtr; /* Bottom of stack holds NR data */
+ BottomData *oldBottomPtr;
+ Tcl_Obj **constants;
+ int instructionCount; /* Counter that is used to work out when to
+ * call Tcl_AsyncReady() */
+ int checkInterp; /* Indicates when a check of interp readyness
+ * is necessary. Set by CACHE_STACK_INFO() */
+ const char *curInstName;
+ int result; /* Return code returned after execution.
+ * Result variable - needed only when going to
+ * checkForcatch or other error handlers; also
+ * used as local in some opcodes. */
+ } TAUX = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &iPtr->execEnvPtr->constants[0],
+ 0,
+ 0,
+ NULL,
+ TCL_OK
+ };
+
+#define LOCAL(i) (&(TAUX.compiledLocals[(i)]))
+#define TCONST(i) (TAUX.constants[(i)])
+#define BP (TAUX.bottomPtr)
+#define OBP (TAUX.oldBottomPtr)
+#define TRESULT (TAUX.result)
+
+ /*
+ * These macros are just meant to save some global variables that are not
+ * used too frequently
+ */
+#define bcFramePtr ((CmdFrame *) (BP + 1))
+#define initCatchTop (((ptrdiff_t *) (bcFramePtr + 1)) - 1)
+#define initTosPtr ((Tcl_Obj **) (initCatchTop + codePtr->maxExceptDepth))
+#define auxObjList (BP->auxObjList)
+#define catchTop (BP->catchTop)
+
/*
* Globals: variables that store state, must remain valid at all times.
*/
- ptrdiff_t *catchTop = 0;
- register Tcl_Obj **tosPtr = NULL;
+ Tcl_Obj **tosPtr = NULL;
/* Cached pointer to top of evaluation
* stack. */
- register const unsigned char *pc = NULL;
+ const unsigned char *pc = NULL;
/* The current program counter. */
- int instructionCount = 0; /* Counter that is used to work out when to
- * call Tcl_AsyncReady() */
- Tcl_Obj *auxObjList = NULL; /* Linked list of aux data, used for {*} and
- * for same-level NR calls. */
- int checkInterp = 0; /* Indicates when a check of interp readyness
- * is necessary. Set by CACHE_STACK_INFO() */
/*
* Transfer variables - needed only between opcodes, but not while
* executing an instruction.
*/
- register int cleanup = 0;
+ int cleanup = 0;
Tcl_Obj *objResultPtr;
/*
- * Result variable - needed only when going to checkForcatch or other
- * error handlers; also used as local in some opcodes.
- */
-
- int result = TCL_OK; /* Return code returned after execution. */
-
- /*
* Locals - variables that are used within opcodes or bounded sections of
* the file (jumps between opcodes within a family).
* NOTE: These are now defined locally where needed.
@@ -1926,7 +1941,6 @@ TclExecuteByteCode(
int traceInstructions = (tclTraceExec == 3);
char cmdNameBuf[21];
#endif
- const char *curInstName = NULL;
/*
* The execution uses a unified stack: first a BottomData, immediately
@@ -1950,34 +1964,31 @@ TclExecuteByteCode(
NRE_ASSERT(iPtr->execEnvPtr->corPtr->eePtr == iPtr->execEnvPtr);
NRE_ASSERT(COR_IS_SUSPENDED(iPtr->execEnvPtr->corPtr));
- oldBottomPtr = iPtr->execEnvPtr->bottomPtr;
- iPtr->execEnvPtr->corPtr->stackLevel = &bottomPtr;
+ OBP = iPtr->execEnvPtr->bottomPtr;
+ iPtr->execEnvPtr->corPtr->stackLevel = &TAUX;
if (iPtr->execEnvPtr->rewind) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
}
goto returnToCaller;
}
nonRecursiveCallStart:
codePtr->refCount++;
- bottomPtr = (BottomData *) GrowEvaluationStack(iPtr->execEnvPtr,
+ BP = (BottomData *) GrowEvaluationStack(iPtr->execEnvPtr,
sizeof(BottomData) + codePtr->maxExceptDepth + sizeof(CmdFrame)
+ codePtr->maxStackDepth, 0);
- curInstName = NULL;
+ TAUX.curInstName = NULL;
auxObjList = NULL;
NR_DATA_INIT(); /* record this level's data */
if (iPtr->execEnvPtr->corPtr && !iPtr->execEnvPtr->corPtr->stackLevel) {
- iPtr->execEnvPtr->corPtr->stackLevel = &bottomPtr;
+ iPtr->execEnvPtr->corPtr->stackLevel = &TAUX;
}
- iPtr->execEnvPtr->bottomPtr = bottomPtr;
- bcFramePtr = (CmdFrame *) (bottomPtr + 1);
- initCatchTop = ((ptrdiff_t *) (bcFramePtr + 1)) - 1;
- initTosPtr = (Tcl_Obj **) (initCatchTop + codePtr->maxExceptDepth);
- esPtr = iPtr->execEnvPtr->execStackPtr;
+ iPtr->execEnvPtr->bottomPtr = BP;
+ TAUX.esPtr = iPtr->execEnvPtr->execStackPtr;
- compiledLocals = iPtr->varFramePtr->compiledLocals;
+ TAUX.compiledLocals = iPtr->varFramePtr->compiledLocals;//
pc = codePtr->codeStart;
catchTop = initCatchTop;
@@ -2002,7 +2013,7 @@ TclExecuteByteCode(
bcFramePtr->cmd.str.len = 0;
if (iPtr->execEnvPtr->rewind) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto abnormalReturn;
}
@@ -2110,7 +2121,7 @@ TclExecuteByteCode(
* ASYNC_CHECK_COUNT_MASK instruction, of the form (2**n-1).
*/
- if ((instructionCount++ & ASYNC_CHECK_COUNT_MASK) == 0) {
+ if ((TAUX.instructionCount++ & ASYNC_CHECK_COUNT_MASK) == 0) {
/*
* Check for asynchronous handlers [Bug 746722]; we do the check every
* ASYNC_CHECK_COUNT_MASK instruction, of the form (2**n-<1).
@@ -2119,10 +2130,10 @@ TclExecuteByteCode(
if (TclAsyncReady(iPtr)) {
DECACHE_STACK_INFO();
- localResult = Tcl_AsyncInvoke(interp, result);
+ localResult = Tcl_AsyncInvoke(interp, TRESULT);
CACHE_STACK_INFO();
if (localResult == TCL_ERROR) {
- result = localResult;
+ TRESULT = localResult;
goto checkForCatch;
}
}
@@ -2132,7 +2143,7 @@ TclExecuteByteCode(
CACHE_STACK_INFO();
if (localResult == TCL_ERROR) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -2141,7 +2152,7 @@ TclExecuteByteCode(
localResult = Tcl_LimitCheck(interp);
CACHE_STACK_INFO();
if (localResult == TCL_ERROR) {
- result = localResult;
+ TRESULT = localResult;
goto checkForCatch;
}
}
@@ -2175,9 +2186,9 @@ TclExecuteByteCode(
*/
TRACE(("%u %u => ", code, level));
- result = TclProcessReturn(interp, code, level, OBJ_AT_TOS);
- if (result == TCL_OK) {
- TRACE_APPEND(("continuing to next instruction (result=\"%.30s\")",
+ TRESULT = TclProcessReturn(interp, code, level, OBJ_AT_TOS);
+ if (TRESULT == TCL_OK) {
+ TRACE_APPEND(("continuing to next instruction (TRESULT=\"%.30s\")",
O2S(objResultPtr)));
NEXT_INST_F(9, 1, 0);
} else {
@@ -2193,11 +2204,11 @@ TclExecuteByteCode(
case INST_RETURN_STK:
TRACE(("=> "));
objResultPtr = POP_OBJECT();
- result = Tcl_SetReturnOptions(interp, OBJ_AT_TOS);
+ TRESULT = Tcl_SetReturnOptions(interp, OBJ_AT_TOS);
Tcl_DecrRefCount(OBJ_AT_TOS);
OBJ_AT_TOS = objResultPtr;
- if (result == TCL_OK) {
- TRACE_APPEND(("continuing to next instruction (result=\"%.30s\")",
+ if (TRESULT == TCL_OK) {
+ TRACE_APPEND(("continuing to next instruction (TRESULT=\"%.30s\")",
O2S(objResultPtr)));
NEXT_INST_F(1, 0, 0);
} else {
@@ -2217,7 +2228,7 @@ TclExecuteByteCode(
Tcl_SetObjResult(interp, OBJ_AT_TOS);
#ifdef TCL_COMPILE_DEBUG
- TRACE_WITH_OBJ(("=> return code=%d, result=", result),
+ TRACE_WITH_OBJ(("=> return code=%d, result=", TRESULT),
iPtr->objResultPtr);
if (traceInstructions) {
fprintf(stdout, "\n");
@@ -2286,13 +2297,13 @@ TclExecuteByteCode(
*/
iPtr->cmdCount += TclGetUInt4AtPtr(pc+5);
- if (!checkInterp) {
+ if (!TAUX.checkInterp) {
instStartCmdOK:
NEXT_INST_F(9, 0, 0);
} else if (((codePtr->compileEpoch == iPtr->compileEpoch)
&& (codePtr->nsEpoch == iPtr->varFramePtr->nsPtr->resolverEpoch))
|| (codePtr->flags & TCL_BYTECODE_PRECOMPILED)) {
- checkInterp = 0;
+ TAUX.checkInterp = 0;
goto instStartCmdOK;
} else {
const char *bytes;
@@ -2301,11 +2312,11 @@ TclExecuteByteCode(
bytes = GetSrcInfoForPc(pc, codePtr, &length);
DECACHE_STACK_INFO();
- result = Tcl_EvalEx(interp, bytes, length, 0);
+ TRESULT = Tcl_EvalEx(interp, bytes, length, 0);
CACHE_STACK_INFO();
- if (result != TCL_OK) {
+ if (TRESULT != TCL_OK) {
cleanup = 0;
- if (result == TCL_ERROR) {
+ if (TRESULT == TCL_ERROR) {
/*
* Tcl_EvalEx already did the task of logging
* the error to the stack trace for us, so set
@@ -2527,7 +2538,7 @@ TclExecuteByteCode(
TclNewObj(objPtr);
objPtr->internalRep.twoPtrValue.ptr1 = (void *) CURR_DEPTH;
- PUSH_AUX_OBJ(objPtr);
+ PUSH_TAUX_OBJ(objPtr);
NEXT_INST_F(1, 0, 0);
}
@@ -2546,7 +2557,7 @@ TclExecuteByteCode(
if (TclListObjGetElements(interp, valuePtr, &objc, &objv) != TCL_OK){
TRACE_WITH_OBJ(("%.30s => ERROR: ", O2S(valuePtr)),
Tcl_GetObjResult(interp));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
(void) POP_OBJECT();
@@ -2561,7 +2572,7 @@ TclExecuteByteCode(
length = objc + (codePtr->maxStackDepth - TclGetInt4AtPtr(pc+1));
DECACHE_STACK_INFO();
moved = GrowEvaluationStack(iPtr->execEnvPtr, length, 1)
- - (Tcl_Obj **) bottomPtr;
+ - (Tcl_Obj **) BP;
if (moved) {
/*
@@ -2570,12 +2581,8 @@ TclExecuteByteCode(
* stack-allocated parameter, update the stack pointers.
*/
- bottomPtr = (BottomData *) (((Tcl_Obj **)bottomPtr) + moved);
-
- bcFramePtr = (CmdFrame *) (bottomPtr + 1);
- initCatchTop = ((ptrdiff_t *) (bcFramePtr + 1)) - 1;
- initTosPtr = (Tcl_Obj **) (initCatchTop + codePtr->maxExceptDepth);
- esPtr = iPtr->execEnvPtr->execStackPtr;
+ BP = (BottomData *) (((Tcl_Obj **)BP) + moved);
+ TAUX.esPtr = iPtr->execEnvPtr->execStackPtr;
catchTop += moved;
tosPtr += moved;
@@ -2685,7 +2692,7 @@ TclExecuteByteCode(
CLANG_ASSERT(auxObjList);
objc = CURR_DEPTH
- (ptrdiff_t) auxObjList->internalRep.twoPtrValue.ptr1;
- POP_AUX_OBJ();
+ POP_TAUX_OBJ();
}
if (objc) {
@@ -2750,20 +2757,20 @@ TclExecuteByteCode(
* for async stuff anyway while processing TclEvalObjv
*/
- instructionCount = 1;
+ TAUX.instructionCount = 1;
TclArgumentBCEnter((Tcl_Interp*) iPtr, objv, objc,
codePtr, bcFramePtr, pc - codePtr->codeStart);
DECACHE_STACK_INFO();
- result = TclNREvalObjv(interp, objc, objv,
+ TRESULT = TclNREvalObjv(interp, objc, objv,
(*pc == INST_EVAL_STK) ? 0 : TCL_EVAL_NOERR, NULL);
- result = TclNRRunCallbacks(interp, result, bottomPtr->rootPtr, 1);
+ TRESULT = TclNRRunCallbacks(interp, TRESULT, BP->rootPtr, 1);
CACHE_STACK_INFO();
- if (TOP_CB(interp) != bottomPtr->rootPtr) {
- NRE_ASSERT(result == TCL_OK);
+ if (TOP_CB(interp) != BP->rootPtr) {
+ NRE_ASSERT(TRESULT == TCL_OK);
pc += pcAdjustment;
nonRecursiveCallSetup: {
@@ -2771,7 +2778,7 @@ TclExecuteByteCode(
int type = PTR2INT(callbackPtr->data[0]);
ClientData param = callbackPtr->data[1];
- NRE_ASSERT(callbackPtr != bottomPtr->rootPtr);
+ NRE_ASSERT(callbackPtr != BP->rootPtr);
NRE_ASSERT(callbackPtr->procPtr == NRCallTEBC);
TOP_CB(interp) = callbackPtr->nextPtr;
@@ -2808,7 +2815,7 @@ TclExecuteByteCode(
TclClearTailcall(interp, tailcallPtr);
iPtr->varFramePtr->tailcallPtr = NULL;
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
Tcl_SetResult(interp,"Tailcall called from within a catch environment",
TCL_STATIC);
pc--;
@@ -2824,18 +2831,18 @@ TclExecuteByteCode(
"yield can only be called in a coroutine",
TCL_STATIC);
Tcl_SetErrorCode(interp, "COROUTINE_ILLEGAL_YIELD", NULL);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
pc--;
goto checkForCatch;
}
NRE_ASSERT(iPtr->execEnvPtr == corPtr->eePtr);
NRE_ASSERT(corPtr->stackLevel != NULL);
- NRE_ASSERT(bottomPtr == corPtr->eePtr->bottomPtr);
- if (corPtr->stackLevel != &bottomPtr) {
+ NRE_ASSERT(BP == corPtr->eePtr->bottomPtr);
+ if (corPtr->stackLevel != &TAUX) {
Tcl_SetResult(interp, "cannot yield: C stack busy",
TCL_STATIC);
Tcl_SetErrorCode(interp, "COROUTINE_CANT_YIELD", NULL);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
pc--;
goto checkForCatch;
}
@@ -2845,8 +2852,8 @@ TclExecuteByteCode(
*/
NR_DATA_BURY();
- esPtr->tosPtr = tosPtr;
- iPtr->execEnvPtr->bottomPtr = bottomPtr;
+ TAUX.esPtr->tosPtr = tosPtr;
+ iPtr->execEnvPtr->bottomPtr = BP;
return TCL_OK;
}
default:
@@ -2871,7 +2878,7 @@ TclExecuteByteCode(
if (catchTop != initCatchTop) {
TclClearTailcall(interp, iPtr->varFramePtr->tailcallPtr);
iPtr->varFramePtr->tailcallPtr = NULL;
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
Tcl_SetResult(interp,"Tailcall called from within a catch environment",
TCL_STATIC);
pc--;
@@ -2881,11 +2888,11 @@ TclExecuteByteCode(
}
if (iPtr->execEnvPtr->rewind) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto abnormalReturn;
}
- if (result == TCL_OK) {
+ if (TRESULT == TCL_OK) {
Tcl_Obj *objPtr;
#ifndef TCL_COMPILE_DEBUG
if (*pc == INST_POP) {
@@ -3036,7 +3043,7 @@ TclExecuteByteCode(
case INST_LOAD_SCALAR1:
instLoadScalar1:
opnd = TclGetUInt1AtPtr(pc+1);
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -3058,7 +3065,7 @@ TclExecuteByteCode(
case INST_LOAD_SCALAR4:
opnd = TclGetUInt4AtPtr(pc+1);
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -3090,7 +3097,7 @@ TclExecuteByteCode(
doLoadArray:
part1Ptr = NULL;
part2Ptr = OBJ_AT_TOS;
- arrayPtr = &(compiledLocals[opnd]);
+ arrayPtr = LOCAL(opnd);
while (TclIsVarLink(arrayPtr)) {
arrayPtr = arrayPtr->value.linkPtr;
}
@@ -3112,7 +3119,7 @@ TclExecuteByteCode(
if (varPtr == NULL) {
TRACE_APPEND(("ERROR: %.30s\n",
O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
cleanup = 1;
@@ -3152,7 +3159,7 @@ TclExecuteByteCode(
goto doCallPtrGetVar;
} else {
TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -3171,7 +3178,7 @@ TclExecuteByteCode(
NEXT_INST_V(pcAdjustment, cleanup, 1);
} else {
TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -3208,7 +3215,7 @@ TclExecuteByteCode(
doStoreArrayDirect:
valuePtr = OBJ_AT_TOS;
part2Ptr = OBJ_UNDER_TOS;
- arrayPtr = &(compiledLocals[opnd]);
+ arrayPtr = LOCAL(opnd);
TRACE(("%u \"%.30s\" <- \"%.30s\" => ", opnd, O2S(part2Ptr),
O2S(valuePtr)));
while (TclIsVarLink(arrayPtr)) {
@@ -3239,7 +3246,7 @@ TclExecuteByteCode(
doStoreScalarDirect:
valuePtr = OBJ_AT_TOS;
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
TRACE(("%u <- \"%.30s\" => ", opnd, O2S(valuePtr)));
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
@@ -3331,7 +3338,7 @@ TclExecuteByteCode(
goto doCallPtrSetVar;
} else {
TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -3364,7 +3371,7 @@ TclExecuteByteCode(
doStoreArray:
valuePtr = OBJ_AT_TOS;
part2Ptr = OBJ_UNDER_TOS;
- arrayPtr = &(compiledLocals[opnd]);
+ arrayPtr = LOCAL(opnd);
TRACE(("%u \"%.30s\" <- \"%.30s\" => ", opnd, O2S(part2Ptr),
O2S(valuePtr)));
while (TclIsVarLink(arrayPtr)) {
@@ -3380,7 +3387,7 @@ TclExecuteByteCode(
goto doCallPtrSetVar;
} else {
TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -3412,7 +3419,7 @@ TclExecuteByteCode(
doStoreScalar:
valuePtr = OBJ_AT_TOS;
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
TRACE(("%u <- \"%.30s\" => ", opnd, O2S(valuePtr)));
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
@@ -3436,7 +3443,7 @@ TclExecuteByteCode(
NEXT_INST_V(pcAdjustment, cleanup, 1);
} else {
TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -3517,7 +3524,7 @@ TclExecuteByteCode(
Tcl_AddObjErrorInfo(interp,
"\n (reading value of variable to increment)", -1);
TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
Tcl_DecrRefCount(incrPtr);
goto checkForCatch;
}
@@ -3532,7 +3539,7 @@ TclExecuteByteCode(
doIncrArray:
part1Ptr = NULL;
part2Ptr = OBJ_AT_TOS;
- arrayPtr = &(compiledLocals[opnd]);
+ arrayPtr = LOCAL(opnd);
cleanup = 1;
while (TclIsVarLink(arrayPtr)) {
arrayPtr = arrayPtr->value.linkPtr;
@@ -3544,7 +3551,7 @@ TclExecuteByteCode(
goto doIncrVar;
} else {
TRACE_APPEND(("ERROR: %.30s\n", O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
Tcl_DecrRefCount(incrPtr);
goto checkForCatch;
}
@@ -3554,7 +3561,7 @@ TclExecuteByteCode(
i = TclGetInt1AtPtr(pc+2);
pcAdjustment = 3;
cleanup = 0;
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -3655,9 +3662,9 @@ TclExecuteByteCode(
objResultPtr = objPtr;
}
TclNewLongObj(incrPtr, i);
- result = TclIncrObj(interp, objResultPtr, incrPtr);
+ TRESULT = TclIncrObj(interp, objResultPtr, incrPtr);
Tcl_DecrRefCount(incrPtr);
- if (result == TCL_OK) {
+ if (TRESULT == TCL_OK) {
goto doneIncr;
} else {
TRACE_APPEND(("ERROR: %.30s\n",
@@ -3674,7 +3681,7 @@ TclExecuteByteCode(
Tcl_IncrRefCount(incrPtr);
doIncrScalar:
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -3694,9 +3701,9 @@ TclExecuteByteCode(
} else {
objResultPtr = objPtr;
}
- result = TclIncrObj(interp, objResultPtr, incrPtr);
+ TRESULT = TclIncrObj(interp, objResultPtr, incrPtr);
Tcl_DecrRefCount(incrPtr);
- if (result == TCL_OK) {
+ if (TRESULT == TCL_OK) {
goto doneIncr;
} else {
TRACE_APPEND(("ERROR: %.30s\n",
@@ -3712,7 +3719,7 @@ TclExecuteByteCode(
if (objResultPtr == NULL) {
TRACE_APPEND(("ERROR: %.30s\n",
O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -3742,7 +3749,7 @@ TclExecuteByteCode(
case INST_EXIST_SCALAR: {
int opnd = TclGetUInt4AtPtr(pc+1);
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -3762,7 +3769,7 @@ TclExecuteByteCode(
* Tricky! Arrays always exist.
*/
- objResultPtr = constants[!varPtr || TclIsVarUndefined(varPtr) ? 0 : 1];
+ objResultPtr = TCONST(!varPtr || TclIsVarUndefined(varPtr) ? 0 : 1);
TRACE_APPEND(("%.30s\n", O2S(objResultPtr)));
NEXT_INST_F(5, 0, 1);
}
@@ -3771,7 +3778,7 @@ TclExecuteByteCode(
int opnd = TclGetUInt4AtPtr(pc+1);
part2Ptr = OBJ_AT_TOS;
- arrayPtr = &(compiledLocals[opnd]);
+ arrayPtr = LOCAL(opnd);
while (TclIsVarLink(arrayPtr)) {
arrayPtr = arrayPtr->value.linkPtr;
}
@@ -3797,7 +3804,7 @@ TclExecuteByteCode(
}
}
doneExistArray:
- objResultPtr = constants[!varPtr || TclIsVarUndefined(varPtr) ? 0 : 1];
+ objResultPtr = TCONST(!varPtr || TclIsVarUndefined(varPtr) ? 0 : 1);
TRACE_APPEND(("%.30s\n", O2S(objResultPtr)));
NEXT_INST_F(5, 1, 1);
}
@@ -3830,7 +3837,7 @@ TclExecuteByteCode(
varPtr = NULL;
}
}
- objResultPtr = constants[!varPtr || TclIsVarUndefined(varPtr) ? 0 : 1];
+ objResultPtr = TCONST(!varPtr || TclIsVarUndefined(varPtr) ? 0 : 1);
TRACE_APPEND(("%.30s\n", O2S(objResultPtr)));
NEXT_INST_V(1, cleanup, 1);
}
@@ -3849,8 +3856,8 @@ TclExecuteByteCode(
{
CallFrame *framePtr, *savedFramePtr;
- result = TclObjGetFrame(interp, OBJ_UNDER_TOS, &framePtr);
- if (result != -1) {
+ TRESULT = TclObjGetFrame(interp, OBJ_UNDER_TOS, &framePtr);
+ if (TRESULT != -1) {
/*
* Locate the other variable.
*/
@@ -3862,11 +3869,11 @@ TclExecuteByteCode(
/*createPart1*/ 1, /*createPart2*/ 1, &varPtr);
iPtr->varFramePtr = savedFramePtr;
if (otherPtr) {
- result = TCL_OK;
+ TRESULT = TCL_OK;
goto doLinkVars;
}
}
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -3881,10 +3888,10 @@ TclExecuteByteCode(
*/
TclSetVarNamespaceVar(otherPtr);
- result = TCL_OK;
+ TRESULT = TCL_OK;
goto doLinkVars;
}
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
case INST_NSUPVAR:
@@ -3893,8 +3900,8 @@ TclExecuteByteCode(
{
Tcl_Namespace *nsPtr, *savedNsPtr;
- result = TclGetNamespaceFromObj(interp, OBJ_UNDER_TOS, &nsPtr);
- if (result == TCL_OK) {
+ TRESULT = TclGetNamespaceFromObj(interp, OBJ_UNDER_TOS, &nsPtr);
+ if (TRESULT == TCL_OK) {
/*
* Locate the other variable.
*/
@@ -3909,7 +3916,7 @@ TclExecuteByteCode(
goto doLinkVars;
}
}
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -3922,7 +3929,7 @@ TclExecuteByteCode(
*/
opnd = TclGetInt4AtPtr(pc+1);;
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
if ((varPtr != otherPtr) && !TclIsVarTraced(varPtr)
&& (TclIsVarUndefined(varPtr) || TclIsVarLink(varPtr))) {
if (!TclIsVarUndefined(varPtr)) {
@@ -3948,8 +3955,8 @@ TclExecuteByteCode(
VarHashRefCount(otherPtr)++;
}
} else {
- result = TclPtrObjMakeUpvar(interp, otherPtr, NULL, 0, opnd);
- if (result != TCL_OK) {
+ TRESULT = TclPtrObjMakeUpvar(interp, otherPtr, NULL, 0, opnd);
+ if (TRESULT != TCL_OK) {
goto checkForCatch;
}
}
@@ -4009,8 +4016,8 @@ TclExecuteByteCode(
/* TODO - check claim that taking address of b harms performance */
/* TODO - consider optimization search for constants */
- result = TclGetBooleanFromObj(interp, valuePtr, &b);
- if (result != TCL_OK) {
+ TRESULT = TclGetBooleanFromObj(interp, valuePtr, &b);
+ if (TRESULT != TCL_OK) {
TRACE_WITH_OBJ(("%d => ERROR: ", jmpOffset[
((*pc == INST_JUMP_FALSE1) || (*pc == INST_JUMP_FALSE4))
? 0 : 1]), Tcl_GetObjResult(interp));
@@ -4081,16 +4088,16 @@ TclExecuteByteCode(
Tcl_Obj *value2Ptr = OBJ_AT_TOS;
Tcl_Obj *valuePtr = OBJ_UNDER_TOS;
- result = TclGetBooleanFromObj(NULL, valuePtr, &i1);
- if (result != TCL_OK) {
+ TRESULT = TclGetBooleanFromObj(NULL, valuePtr, &i1);
+ if (TRESULT != TCL_OK) {
TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(valuePtr),
(valuePtr->typePtr? valuePtr->typePtr->name : "null")));
IllegalExprOperandType(interp, pc, valuePtr);
goto checkForCatch;
}
- result = TclGetBooleanFromObj(NULL, value2Ptr, &i2);
- if (result != TCL_OK) {
+ TRESULT = TclGetBooleanFromObj(NULL, value2Ptr, &i2);
+ if (TRESULT != TCL_OK) {
TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(value2Ptr),
(value2Ptr->typePtr? value2Ptr->typePtr->name : "null")));
IllegalExprOperandType(interp, pc, value2Ptr);
@@ -4102,7 +4109,7 @@ TclExecuteByteCode(
} else {
iResult = (i1 && i2);
}
- objResultPtr = constants[iResult];
+ objResultPtr = TCONST(iResult);
TRACE(("%.20s %.20s => %d\n", O2S(valuePtr),O2S(value2Ptr),iResult));
NEXT_INST_F(1, 2, 1);
}
@@ -4132,8 +4139,8 @@ TclExecuteByteCode(
valuePtr = OBJ_AT_TOS;
- result = TclListObjLength(interp, valuePtr, &length);
- if (result == TCL_OK) {
+ TRESULT = TclListObjLength(interp, valuePtr, &length);
+ if (TRESULT == TCL_OK) {
TclNewIntObj(objResultPtr, length);
TRACE(("%.20s => %d\n", O2S(valuePtr), length));
NEXT_INST_F(1, 1, 1);
@@ -4164,8 +4171,8 @@ TclExecuteByteCode(
* Extract the desired list element.
*/
- result = TclListObjGetElements(interp, valuePtr, &listc, &listv);
- if ((result == TCL_OK) && (value2Ptr->typePtr != &tclListType)
+ TRESULT = TclListObjGetElements(interp, valuePtr, &listc, &listv);
+ if ((TRESULT == TCL_OK) && (value2Ptr->typePtr != &tclListType)
&& (TclGetIntForIndexM(NULL , value2Ptr, listc-1,
&idx) == TCL_OK)) {
TclDecrRefCount(value2Ptr);
@@ -4186,7 +4193,7 @@ TclExecuteByteCode(
} else {
TRACE_WITH_OBJ(("%.30s %.30s => ERROR: ", O2S(valuePtr),
O2S(value2Ptr)), Tcl_GetObjResult(interp));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -4207,9 +4214,9 @@ TclExecuteByteCode(
* in the process.
*/
- result = TclListObjGetElements(interp, valuePtr, &listc, &listv);
+ TRESULT = TclListObjGetElements(interp, valuePtr, &listc, &listv);
- if (result == TCL_OK) {
+ if (TRESULT == TCL_OK) {
/*
* Select the list item based on the index. Negative operand means
* end-based indexing.
@@ -4270,7 +4277,7 @@ TclExecuteByteCode(
NEXT_INST_V(5, opnd, -1);
} else {
TRACE_WITH_OBJ(("%d => ERROR: ", opnd), Tcl_GetObjResult(interp));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -4322,7 +4329,7 @@ TclExecuteByteCode(
NEXT_INST_V(5, (numIdx+1), -1);
} else {
TRACE_WITH_OBJ(("%d => ERROR: ", opnd), Tcl_GetObjResult(interp));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -4371,7 +4378,7 @@ TclExecuteByteCode(
} else {
TRACE_WITH_OBJ(("\"%.30s\" => ERROR: ", O2S(value2Ptr)),
Tcl_GetObjResult(interp));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -4394,14 +4401,14 @@ TclExecuteByteCode(
* Get the contents of the list, making sure that it really is a list
* in the process.
*/
- result = TclListObjGetElements(interp, valuePtr, &listc, &listv);
+ TRESULT = TclListObjGetElements(interp, valuePtr, &listc, &listv);
/*
* Skip a lot of work if we're about to throw the result away (common
* with uses of [lassign]).
*/
- if (result == TCL_OK) {
+ if (TRESULT == TCL_OK) {
#ifndef TCL_COMPILE_DEBUG
if (*(pc+9) == INST_POP) {
NEXT_INST_F(10, 1, 0);
@@ -4472,8 +4479,8 @@ TclExecuteByteCode(
/* TODO: Consider more efficient tests than strcmp() */
s1 = TclGetStringFromObj(valuePtr, &s1len);
- result = TclListObjLength(interp, value2Ptr, &llen);
- if (result != TCL_OK) {
+ TRESULT = TclListObjLength(interp, value2Ptr, &llen);
+ if (TRESULT != TCL_OK) {
TRACE_WITH_OBJ(("\"%.30s\" \"%.30s\" => ERROR: ", O2S(valuePtr),
O2S(value2Ptr)), Tcl_GetObjResult(interp));
goto checkForCatch;
@@ -4524,7 +4531,7 @@ TclExecuteByteCode(
NEXT_INST_F((found ? TclGetInt4AtPtr(pc+1) : 5), 2, 0);
}
#endif
- objResultPtr = constants[found];
+ objResultPtr = TCONST(found);
NEXT_INST_F(0, 2, 1);
}
@@ -4595,7 +4602,7 @@ TclExecuteByteCode(
NEXT_INST_F((iResult? TclGetInt4AtPtr(pc+1) : 5), 2, 0);
}
#endif
- objResultPtr = constants[iResult];
+ objResultPtr = TCONST(iResult);
NEXT_INST_F(0, 2, 1);
}
@@ -4700,7 +4707,7 @@ TclExecuteByteCode(
TclNewIntObj(objResultPtr, -1);
TRACE(("%.20s %.20s => %d\n", O2S(valuePtr), O2S(value2Ptr), -1));
} else {
- objResultPtr = constants[(iResult>0)];
+ objResultPtr = TCONST(iResult>0);
TRACE(("%.20s %.20s => %d\n", O2S(valuePtr), O2S(value2Ptr),
(iResult > 0)));
}
@@ -4735,8 +4742,8 @@ TclExecuteByteCode(
* Get char length to calulate what 'end' means.
*/
length = Tcl_GetCharLength(valuePtr);
- result = TclGetIntForIndexM(interp, value2Ptr, length - 1, &index);
- if (result != TCL_OK) {
+ TRESULT = TclGetIntForIndexM(interp, value2Ptr, length - 1, &index);
+ if (TRESULT != TCL_OK) {
goto checkForCatch;
}
@@ -4812,7 +4819,7 @@ TclExecuteByteCode(
*/
TRACE(("%.20s %.20s => %d\n", O2S(valuePtr), O2S(value2Ptr), match));
- objResultPtr = constants[match];
+ objResultPtr = TCONST(match);
NEXT_INST_F(2, 2, 1);
}
@@ -4840,12 +4847,12 @@ TclExecuteByteCode(
objResultPtr = Tcl_GetObjResult(interp);
TRACE_WITH_OBJ(("%.20s %.20s => ERROR: ",
O2S(valuePtr), O2S(value2Ptr)), objResultPtr);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
} else {
TRACE(("%.20s %.20s => %d\n",
O2S(valuePtr), O2S(value2Ptr), match));
- objResultPtr = constants[match];
+ objResultPtr = TCONST(match);
NEXT_INST_F(2, 2, 1);
}
}
@@ -5163,7 +5170,7 @@ TclExecuteByteCode(
NEXT_INST_F((iResult? TclGetInt4AtPtr(pc+1) : 5), 2, 0);
}
#endif
- objResultPtr = constants[iResult];
+ objResultPtr = TCONST(iResult);
NEXT_INST_F(0, 2, 1);
}
@@ -5176,10 +5183,10 @@ TclExecuteByteCode(
int invalid, shift, type1, type2;
long l1 = 0;
- result = GetNumberFromObj(NULL, valuePtr, &ptr1, &type1);
- if ((result != TCL_OK) || (type1 == TCL_NUMBER_DOUBLE)
+ TRESULT = GetNumberFromObj(NULL, valuePtr, &ptr1, &type1);
+ if ((TRESULT != TCL_OK) || (type1 == TCL_NUMBER_DOUBLE)
|| (type1 == TCL_NUMBER_NAN)) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("%.20s %.20s => ILLEGAL 1st TYPE %s\n", O2S(valuePtr),
O2S(value2Ptr), (valuePtr->typePtr?
valuePtr->typePtr->name : "null")));
@@ -5187,10 +5194,10 @@ TclExecuteByteCode(
goto checkForCatch;
}
- result = GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2);
- if ((result != TCL_OK) || (type2 == TCL_NUMBER_DOUBLE)
+ TRESULT = GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2);
+ if ((TRESULT != TCL_OK) || (type2 == TCL_NUMBER_DOUBLE)
|| (type2 == TCL_NUMBER_NAN)) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("%.20s %.20s => ILLEGAL 2nd TYPE %s\n", O2S(valuePtr),
O2S(value2Ptr), (value2Ptr->typePtr?
value2Ptr->typePtr->name : "null")));
@@ -5215,7 +5222,7 @@ TclExecuteByteCode(
* Div. by |1| always yields remainder of 0.
*/
- objResultPtr = constants[0];
+ objResultPtr = TCONST(0);
TRACE(("%s\n", O2S(objResultPtr)));
NEXT_INST_F(1, 2, 1);
}
@@ -5227,7 +5234,7 @@ TclExecuteByteCode(
* 0 % (non-zero) always yields remainder of 0.
*/
- objResultPtr = constants[0];
+ objResultPtr = TCONST(0);
TRACE(("%s\n", O2S(objResultPtr)));
NEXT_INST_F(1, 2, 1);
}
@@ -5429,7 +5436,7 @@ TclExecuteByteCode(
}
if (invalid) {
Tcl_SetResult(interp, "negative shift argument", TCL_STATIC);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -5439,7 +5446,7 @@ TclExecuteByteCode(
if ((type1==TCL_NUMBER_LONG) && (*((const long *)ptr1) == (long)0)) {
TRACE(("%s %s => ", O2S(valuePtr), O2S(value2Ptr)));
- objResultPtr = constants[0];
+ objResultPtr = TCONST(0);
TRACE(("%s\n", O2S(objResultPtr)));
NEXT_INST_F(1, 2, 1);
}
@@ -5463,7 +5470,7 @@ TclExecuteByteCode(
*/
Tcl_SetResult(interp, "integer value too large to represent", TCL_STATIC);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
shift = (int)(*((const long *)ptr2));
@@ -5540,7 +5547,7 @@ TclExecuteByteCode(
zero = 0;
}
if (zero) {
- objResultPtr = constants[0];
+ objResultPtr = TCONST(0);
} else {
TclNewIntObj(objResultPtr, -1);
}
@@ -5557,7 +5564,7 @@ TclExecuteByteCode(
l1 = *((const long *)ptr1);
if ((size_t)shift >= CHAR_BIT*sizeof(long)) {
if (l1 >= (long)0) {
- objResultPtr = constants[0];
+ objResultPtr = TCONST(0);
} else {
TclNewIntObj(objResultPtr, -1);
}
@@ -5578,7 +5585,7 @@ TclExecuteByteCode(
if ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideInt)) {
if (w >= (Tcl_WideInt)0) {
- objResultPtr = constants[0];
+ objResultPtr = TCONST(0);
} else {
TclNewIntObj(objResultPtr, -1);
}
@@ -5632,21 +5639,21 @@ TclExecuteByteCode(
Tcl_Obj *value2Ptr = OBJ_AT_TOS;
Tcl_Obj *valuePtr = OBJ_UNDER_TOS;
- result = GetNumberFromObj(NULL, valuePtr, &ptr1, &type1);
- if ((result != TCL_OK)
+ TRESULT = GetNumberFromObj(NULL, valuePtr, &ptr1, &type1);
+ if ((TRESULT != TCL_OK)
|| (type1 == TCL_NUMBER_NAN)
|| (type1 == TCL_NUMBER_DOUBLE)) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("%.20s %.20s => ILLEGAL 1st TYPE %s\n", O2S(valuePtr),
O2S(value2Ptr), (valuePtr->typePtr?
valuePtr->typePtr->name : "null")));
IllegalExprOperandType(interp, pc, valuePtr);
goto checkForCatch;
}
- result = GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2);
- if ((result != TCL_OK) || (type2 == TCL_NUMBER_NAN)
+ TRESULT = GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2);
+ if ((TRESULT != TCL_OK) || (type2 == TCL_NUMBER_NAN)
|| (type2 == TCL_NUMBER_DOUBLE)) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("%.20s %.20s => ILLEGAL 2nd TYPE %s\n", O2S(valuePtr),
O2S(value2Ptr), (value2Ptr->typePtr?
value2Ptr->typePtr->name : "null")));
@@ -5878,13 +5885,13 @@ TclExecuteByteCode(
Tcl_Obj *value2Ptr = OBJ_AT_TOS;
Tcl_Obj *valuePtr = OBJ_UNDER_TOS;
- result = GetNumberFromObj(NULL, valuePtr, &ptr1, &type1);
- if ((result != TCL_OK)
+ TRESULT = GetNumberFromObj(NULL, valuePtr, &ptr1, &type1);
+ if ((TRESULT != TCL_OK)
#ifndef ACCEPT_NAN
|| (type1 == TCL_NUMBER_NAN)
#endif
) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("%.20s %.20s => ILLEGAL 1st TYPE %s\n",
O2S(value2Ptr), O2S(valuePtr),
(valuePtr->typePtr? valuePtr->typePtr->name: "null")));
@@ -5902,13 +5909,13 @@ TclExecuteByteCode(
}
#endif
- result = GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2);
- if ((result != TCL_OK)
+ TRESULT = GetNumberFromObj(NULL, value2Ptr, &ptr2, &type2);
+ if ((TRESULT != TCL_OK)
#ifndef ACCEPT_NAN
|| (type2 == TCL_NUMBER_NAN)
#endif
) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("%.20s %.20s => ILLEGAL 2nd TYPE %s\n",
O2S(value2Ptr), O2S(valuePtr),
(value2Ptr->typePtr? value2Ptr->typePtr->name: "null")));
@@ -5984,7 +5991,7 @@ TclExecuteByteCode(
TRACE(("%.20s %.20s => IEEE FLOATING PT ERROR\n",
O2S(valuePtr), O2S(value2Ptr)));
TclExprFloatError(interp, dResult);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
#endif
@@ -6054,7 +6061,7 @@ TclExecuteByteCode(
* Anything to the zero power is 1.
*/
- objResultPtr = constants[1];
+ objResultPtr = TCONST(1);
NEXT_INST_F(1, 2, 1);
} else if (l2 == 1) {
/*
@@ -6109,7 +6116,7 @@ TclExecuteByteCode(
if (oddExponent) {
TclNewIntObj(objResultPtr, -1);
} else {
- objResultPtr = constants[1];
+ objResultPtr = TCONST(1);
}
NEXT_INST_F(1, 2, 1);
case 1:
@@ -6117,7 +6124,7 @@ TclExecuteByteCode(
* 1 to any power is 1.
*/
- objResultPtr = constants[1];
+ objResultPtr = TCONST(1);
NEXT_INST_F(1, 2, 1);
}
}
@@ -6127,7 +6134,7 @@ TclExecuteByteCode(
* power yield the answer zero (see TIP 123).
*/
- objResultPtr = constants[0];
+ objResultPtr = TCONST(0);
NEXT_INST_F(1, 2, 1);
}
@@ -6138,20 +6145,20 @@ TclExecuteByteCode(
* Zero to a positive power is zero.
*/
- objResultPtr = constants[0];
+ objResultPtr = TCONST(0);
NEXT_INST_F(1, 2, 1);
case 1:
/*
* 1 to any power is 1.
*/
- objResultPtr = constants[1];
+ objResultPtr = TCONST(1);
NEXT_INST_F(1, 2, 1);
case -1:
if (oddExponent) {
TclNewIntObj(objResultPtr, -1);
} else {
- objResultPtr = constants[1];
+ objResultPtr = TCONST(1);
}
NEXT_INST_F(1, 2, 1);
}
@@ -6167,7 +6174,7 @@ TclExecuteByteCode(
*/
if (type2 != TCL_NUMBER_LONG) {
Tcl_SetResult(interp, "exponent too large", TCL_STATIC);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
@@ -6606,7 +6613,7 @@ TclExecuteByteCode(
mp_clear(&big1);
mp_clear(&big2);
mp_clear(&bigResult);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
mp_expt_d(&big1, big2.dp[0], &bigResult);
@@ -6631,15 +6638,15 @@ TclExecuteByteCode(
/* TODO - check claim that taking address of b harms performance */
/* TODO - consider optimization search for constants */
- result = TclGetBooleanFromObj(NULL, valuePtr, &b);
- if (result != TCL_OK) {
+ TRESULT = TclGetBooleanFromObj(NULL, valuePtr, &b);
+ if (TRESULT != TCL_OK) {
TRACE(("\"%.20s\" => ILLEGAL TYPE %s\n", O2S(valuePtr),
(valuePtr->typePtr? valuePtr->typePtr->name : "null")));
IllegalExprOperandType(interp, pc, valuePtr);
goto checkForCatch;
}
/* TODO: Consider peephole opt. */
- objResultPtr = constants[!b];
+ objResultPtr = TCONST(!b);
NEXT_INST_F(1, 1, 1);
}
@@ -6649,14 +6656,14 @@ TclExecuteByteCode(
int type;
Tcl_Obj *valuePtr = OBJ_AT_TOS;
- result = GetNumberFromObj(NULL, valuePtr, &ptr, &type);
- if ((result != TCL_OK)
+ TRESULT = GetNumberFromObj(NULL, valuePtr, &ptr, &type);
+ if ((TRESULT != TCL_OK)
|| (type == TCL_NUMBER_NAN) || (type == TCL_NUMBER_DOUBLE)) {
/*
* ... ~$NonInteger => raise an error.
*/
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(valuePtr),
(valuePtr->typePtr? valuePtr->typePtr->name : "null")));
IllegalExprOperandType(interp, pc, valuePtr);
@@ -6701,13 +6708,13 @@ TclExecuteByteCode(
int type;
Tcl_Obj *valuePtr = OBJ_AT_TOS;
- result = GetNumberFromObj(NULL, valuePtr, &ptr, &type);
- if ((result != TCL_OK)
+ TRESULT = GetNumberFromObj(NULL, valuePtr, &ptr, &type);
+ if ((TRESULT != TCL_OK)
#ifndef ACCEPT_NAN
|| (type == TCL_NUMBER_NAN)
#endif
) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(valuePtr),
(valuePtr->typePtr? valuePtr->typePtr->name : "null")));
IllegalExprOperandType(interp, pc, valuePtr);
@@ -6806,7 +6813,7 @@ TclExecuteByteCode(
* ... +$NonNumeric => raise an error.
*/
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(valuePtr),
(valuePtr->typePtr? valuePtr->typePtr->name:"null")));
IllegalExprOperandType(interp, pc, valuePtr);
@@ -6819,7 +6826,7 @@ TclExecuteByteCode(
}
#ifndef ACCEPT_NAN
if (type == TCL_NUMBER_NAN) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
if (*pc == INST_UPLUS) {
/*
* ... +$NonNumeric => raise an error.
@@ -6880,7 +6887,7 @@ TclExecuteByteCode(
Tcl_ResetResult(interp);
CACHE_STACK_INFO();
*/
- result = TCL_BREAK;
+ TRESULT = TCL_BREAK;
cleanup = 0;
goto processExceptionReturn;
@@ -6890,7 +6897,7 @@ TclExecuteByteCode(
Tcl_ResetResult(interp);
CACHE_STACK_INFO();
*/
- result = TCL_CONTINUE;
+ TRESULT = TCL_CONTINUE;
cleanup = 0;
goto processExceptionReturn;
@@ -6908,7 +6915,7 @@ TclExecuteByteCode(
opnd = TclGetUInt4AtPtr(pc+1);
infoPtr = (ForeachInfo *) codePtr->auxDataArrayPtr[opnd].clientData;
iterTmpIndex = infoPtr->loopCtTemp;
- iterVarPtr = &(compiledLocals[iterTmpIndex]);
+ iterVarPtr = LOCAL(iterTmpIndex);
oldValuePtr = iterVarPtr->value.objPtr;
if (oldValuePtr == NULL) {
@@ -6955,7 +6962,7 @@ TclExecuteByteCode(
* Increment the temp holding the loop iteration number.
*/
- iterVarPtr = &(compiledLocals[infoPtr->loopCtTemp]);
+ iterVarPtr = LOCAL(infoPtr->loopCtTemp);
valuePtr = iterVarPtr->value.objPtr;
iterNum = (valuePtr->internalRep.longValue + 1);
TclSetLongObj(valuePtr, iterNum);
@@ -6971,10 +6978,10 @@ TclExecuteByteCode(
varListPtr = infoPtr->varLists[i];
numVars = varListPtr->numVars;
- listVarPtr = &(compiledLocals[listTmpIndex]);
+ listVarPtr = LOCAL(listTmpIndex);
listPtr = listVarPtr->value.objPtr;
- result = TclListObjLength(interp, listPtr, &listLen);
- if (result == TCL_OK) {
+ TRESULT = TclListObjLength(interp, listPtr, &listLen);
+ if (TRESULT == TCL_OK) {
if (listLen > (iterNum * numVars)) {
continueLoop = 1;
}
@@ -7001,7 +7008,7 @@ TclExecuteByteCode(
varListPtr = infoPtr->varLists[i];
numVars = varListPtr->numVars;
- listVarPtr = &(compiledLocals[listTmpIndex]);
+ listVarPtr = LOCAL(listTmpIndex);
listPtr = TclListObjCopy(NULL, listVarPtr->value.objPtr);
TclListObjGetElements(interp, listPtr, &listLen, &elements);
@@ -7014,7 +7021,7 @@ TclExecuteByteCode(
}
varIndex = varListPtr->varIndexes[j];
- varPtr = &(compiledLocals[varIndex]);
+ varPtr = LOCAL(varIndex);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -7036,7 +7043,7 @@ TclExecuteByteCode(
TRACE_WITH_OBJ((
"%u => ERROR init. index temp %d: ",
opnd,varIndex), Tcl_GetObjResult(interp));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
TclDecrRefCount(listPtr);
goto checkForCatch;
}
@@ -7080,7 +7087,7 @@ TclExecuteByteCode(
case INST_END_CATCH:
catchTop--;
Tcl_ResetResult(interp);
- result = TCL_OK;
+ TRESULT = TCL_OK;
TRACE(("=> catchTop=%d\n", (int) (catchTop - initCatchTop - 1)));
NEXT_INST_F(1, 0, 0);
@@ -7102,12 +7109,12 @@ TclExecuteByteCode(
NEXT_INST_F(1, 0, -1);
case INST_PUSH_RETURN_CODE:
- TclNewIntObj(objResultPtr, result);
- TRACE(("=> %u\n", result));
+ TclNewIntObj(objResultPtr, TRESULT);
+ TRACE(("=> %u\n", TRESULT));
NEXT_INST_F(1, 0, 1);
case INST_PUSH_RETURN_OPTIONS:
- objResultPtr = Tcl_GetReturnOptions(interp, result);
+ objResultPtr = Tcl_GetReturnOptions(interp, TRESULT);
TRACE_WITH_OBJ(("=> "), objResultPtr);
NEXT_INST_F(1, 0, 1);
@@ -7144,16 +7151,16 @@ TclExecuteByteCode(
"%u => ERROR tracing dictionary path into \"%s\": ",
opnd, O2S(OBJ_AT_DEPTH(opnd))),
Tcl_GetObjResult(interp));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
- result = Tcl_DictObjGet(interp, dictPtr, OBJ_AT_TOS, &objResultPtr);
- if ((result == TCL_OK) && objResultPtr) {
+ TRESULT = Tcl_DictObjGet(interp, dictPtr, OBJ_AT_TOS, &objResultPtr);
+ if ((TRESULT == TCL_OK) && objResultPtr) {
TRACE_APPEND(("%.30s\n", O2S(objResultPtr)));
NEXT_INST_V(5, opnd+1, 1);
}
- if (result != TCL_OK) {
+ if (TRESULT != TCL_OK) {
TRACE_WITH_OBJ((
"%u => ERROR reading leaf dictionary key \"%s\": ",
opnd, O2S(dictPtr)), Tcl_GetObjResult(interp));
@@ -7162,7 +7169,7 @@ TclExecuteByteCode(
Tcl_AppendResult(interp, "key \"", TclGetString(OBJ_AT_TOS),
"\" not known in dictionary", NULL);
TRACE_WITH_OBJ(("%u => ERROR ", opnd), Tcl_GetObjResult(interp));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
}
goto checkForCatch;
@@ -7172,7 +7179,7 @@ TclExecuteByteCode(
opnd = TclGetUInt4AtPtr(pc+1);
opnd2 = TclGetUInt4AtPtr(pc+5);
- varPtr = &(compiledLocals[opnd2]);
+ varPtr = LOCAL(opnd2);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -7197,14 +7204,14 @@ TclExecuteByteCode(
switch (*pc) {
case INST_DICT_SET:
cleanup = opnd + 1;
- result = Tcl_DictObjPutKeyList(interp, dictPtr, opnd,
+ TRESULT = Tcl_DictObjPutKeyList(interp, dictPtr, opnd,
&OBJ_AT_DEPTH(opnd), OBJ_AT_TOS);
break;
case INST_DICT_INCR_IMM:
cleanup = 1;
opnd = TclGetInt4AtPtr(pc+1);
- result = Tcl_DictObjGet(interp, dictPtr, OBJ_AT_TOS, &valPtr);
- if (result != TCL_OK) {
+ TRESULT = Tcl_DictObjGet(interp, dictPtr, OBJ_AT_TOS, &valPtr);
+ if (TRESULT != TCL_OK) {
break;
}
if (valPtr == NULL) {
@@ -7217,8 +7224,8 @@ TclExecuteByteCode(
valPtr = Tcl_DuplicateObj(valPtr);
Tcl_DictObjPut(NULL, dictPtr, OBJ_AT_TOS, valPtr);
}
- result = TclIncrObj(interp, valPtr, incrPtr);
- if (result == TCL_OK) {
+ TRESULT = TclIncrObj(interp, valPtr, incrPtr);
+ if (TRESULT == TCL_OK) {
Tcl_InvalidateStringRep(dictPtr);
}
TclDecrRefCount(incrPtr);
@@ -7226,7 +7233,7 @@ TclExecuteByteCode(
break;
case INST_DICT_UNSET:
cleanup = opnd;
- result = Tcl_DictObjRemoveKeyList(interp, dictPtr, opnd,
+ TRESULT = Tcl_DictObjRemoveKeyList(interp, dictPtr, opnd,
&OBJ_AT_DEPTH(opnd-1));
break;
default:
@@ -7234,7 +7241,7 @@ TclExecuteByteCode(
Tcl_Panic("Should not happen!");
}
- if (result != TCL_OK) {
+ if (TRESULT != TCL_OK) {
if (allocateDict) {
TclDecrRefCount(dictPtr);
}
@@ -7264,7 +7271,7 @@ TclExecuteByteCode(
if (objResultPtr == NULL) {
TRACE_APPEND(("ERROR: %.30s\n",
O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -7280,7 +7287,7 @@ TclExecuteByteCode(
case INST_DICT_LAPPEND:
opnd = TclGetUInt4AtPtr(pc+1);
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -7302,8 +7309,8 @@ TclExecuteByteCode(
}
}
- result = Tcl_DictObjGet(interp, dictPtr, OBJ_UNDER_TOS, &valPtr);
- if (result != TCL_OK) {
+ TRESULT = Tcl_DictObjGet(interp, dictPtr, OBJ_UNDER_TOS, &valPtr);
+ if (TRESULT != TCL_OK) {
if (allocateDict) {
TclDecrRefCount(dictPtr);
}
@@ -7336,8 +7343,8 @@ TclExecuteByteCode(
valPtr = Tcl_NewListObj(1, &OBJ_AT_TOS);
} else if (Tcl_IsShared(valPtr)) {
valPtr = Tcl_DuplicateObj(valPtr);
- result = Tcl_ListObjAppendElement(interp, valPtr, OBJ_AT_TOS);
- if (result != TCL_OK) {
+ TRESULT = Tcl_ListObjAppendElement(interp, valPtr, OBJ_AT_TOS);
+ if (TRESULT != TCL_OK) {
TclDecrRefCount(valPtr);
if (allocateDict) {
TclDecrRefCount(dictPtr);
@@ -7345,8 +7352,8 @@ TclExecuteByteCode(
goto checkForCatch;
}
} else {
- result = Tcl_ListObjAppendElement(interp, valPtr, OBJ_AT_TOS);
- if (result != TCL_OK) {
+ TRESULT = Tcl_ListObjAppendElement(interp, valPtr, OBJ_AT_TOS);
+ if (TRESULT != TCL_OK) {
if (allocateDict) {
TclDecrRefCount(dictPtr);
}
@@ -7381,7 +7388,7 @@ TclExecuteByteCode(
if (objResultPtr == NULL) {
TRACE_APPEND(("ERROR: %.30s\n",
O2S(Tcl_GetObjResult(interp))));
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -7405,9 +7412,9 @@ TclExecuteByteCode(
TRACE(("%u => ", opnd));
dictPtr = POP_OBJECT();
searchPtr = (Tcl_DictSearch *) ckalloc(sizeof(Tcl_DictSearch));
- result = Tcl_DictObjFirst(interp, dictPtr, searchPtr, &keyPtr,
+ TRESULT = Tcl_DictObjFirst(interp, dictPtr, searchPtr, &keyPtr,
&valuePtr, &done);
- if (result != TCL_OK) {
+ if (TRESULT != TCL_OK) {
ckfree((char *) searchPtr);
goto checkForCatch;
}
@@ -7415,7 +7422,7 @@ TclExecuteByteCode(
statePtr->typePtr = &dictIteratorType;
statePtr->internalRep.twoPtrValue.ptr1 = (void *) searchPtr;
statePtr->internalRep.twoPtrValue.ptr2 = (void *) dictPtr;
- varPtr = (compiledLocals + opnd);
+ varPtr = LOCAL(opnd);//
if (varPtr->value.objPtr) {
if (varPtr->value.objPtr->typePtr != &dictIteratorType) {
TclDecrRefCount(varPtr->value.objPtr);
@@ -7430,7 +7437,7 @@ TclExecuteByteCode(
case INST_DICT_NEXT:
opnd = TclGetUInt4AtPtr(pc+1);
TRACE(("%u => ", opnd));
- statePtr = compiledLocals[opnd].value.objPtr;
+ statePtr = (*LOCAL(opnd)).value.objPtr;
if (statePtr == NULL || statePtr->typePtr != &dictIteratorType) {
Tcl_Panic("mis-issued dictNext!");
}
@@ -7447,14 +7454,14 @@ TclExecuteByteCode(
}
TRACE_APPEND(("\"%.30s\" \"%.30s\" %d",
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), done));
- objResultPtr = constants[done];
+ objResultPtr = TCONST(done);
/* TODO: consider opt like INST_FOREACH_STEP4 */
NEXT_INST_F(5, 0, 1);
case INST_DICT_DONE:
opnd = TclGetUInt4AtPtr(pc+1);
TRACE(("%u => ", opnd));
- statePtr = compiledLocals[opnd].value.objPtr;
+ statePtr = (*LOCAL(opnd)).value.objPtr;
if (statePtr == NULL) {
Tcl_Panic("mis-issued dictDone!");
}
@@ -7480,7 +7487,7 @@ TclExecuteByteCode(
TclDecrRefCount(statePtr);
TclNewObj(emptyPtr);
- compiledLocals[opnd].value.objPtr = emptyPtr;
+ (*LOCAL(opnd)).value.objPtr = emptyPtr;
Tcl_IncrRefCount(emptyPtr);
}
NEXT_INST_F(5, 0, 0);
@@ -7495,7 +7502,7 @@ TclExecuteByteCode(
case INST_DICT_UPDATE_START:
opnd = TclGetUInt4AtPtr(pc+1);
opnd2 = TclGetUInt4AtPtr(pc+5);
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
duiPtr = codePtr->auxDataArrayPtr[opnd2].clientData;
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
@@ -7526,7 +7533,7 @@ TclExecuteByteCode(
&valPtr) != TCL_OK) {
goto dictUpdateStartFailed;
}
- varPtr = &(compiledLocals[duiPtr->varIndices[i]]);
+ varPtr = LOCAL(duiPtr->varIndices[i]);
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
}
@@ -7540,7 +7547,7 @@ TclExecuteByteCode(
duiPtr->varIndices[i]) == NULL) {
CACHE_STACK_INFO();
dictUpdateStartFailed:
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
CACHE_STACK_INFO();
@@ -7550,7 +7557,7 @@ TclExecuteByteCode(
case INST_DICT_UPDATE_END:
opnd = TclGetUInt4AtPtr(pc+1);
opnd2 = TclGetUInt4AtPtr(pc+5);
- varPtr = &(compiledLocals[opnd]);
+ varPtr = LOCAL(opnd);
duiPtr = codePtr->auxDataArrayPtr[opnd2].clientData;
while (TclIsVarLink(varPtr)) {
varPtr = varPtr->value.linkPtr;
@@ -7569,7 +7576,7 @@ TclExecuteByteCode(
if (Tcl_DictObjSize(interp, dictPtr, &length) != TCL_OK
|| TclListObjGetElements(interp, OBJ_AT_TOS, &length,
&keyPtrPtr) != TCL_OK) {
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
allocdict = Tcl_IsShared(dictPtr);
@@ -7580,7 +7587,7 @@ TclExecuteByteCode(
Tcl_Obj *valPtr;
Var *var2Ptr;
- var2Ptr = &(compiledLocals[duiPtr->varIndices[i]]);
+ var2Ptr = LOCAL(duiPtr->varIndices[i]);
while (TclIsVarLink(var2Ptr)) {
var2Ptr = var2Ptr->value.linkPtr;
}
@@ -7614,7 +7621,7 @@ TclExecuteByteCode(
if (allocdict) {
TclDecrRefCount(dictPtr);
}
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
}
}
@@ -7634,7 +7641,7 @@ TclExecuteByteCode(
Tcl_SetResult(interp, "divide by zero", TCL_STATIC);
Tcl_SetErrorCode(interp, "ARITH", "DIVZERO", "divide by zero", NULL);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
/*
@@ -7646,7 +7653,7 @@ TclExecuteByteCode(
Tcl_SetResult(interp, "exponentiation of zero by negative power", TCL_STATIC);
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"exponentiation of zero by negative power", NULL);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto checkForCatch;
/*
@@ -7695,52 +7702,52 @@ TclExecuteByteCode(
TRACE(("=> "));
}
#endif
- if ((result == TCL_CONTINUE) || (result == TCL_BREAK)) {
+ if ((TRESULT == TCL_CONTINUE) || (TRESULT == TCL_BREAK)) {
rangePtr = GetExceptRangeForPc(pc, /*catchOnly*/ 0, codePtr);
if (rangePtr == NULL) {
TRACE_APPEND(("no encl. loop or catch, returning %s\n",
- StringForResultCode(result)));
+ StringForResultCode(TRESULT)));
goto abnormalReturn;
}
if (rangePtr->type == CATCH_EXCEPTION_RANGE) {
- TRACE_APPEND(("%s ...\n", StringForResultCode(result)));
+ TRACE_APPEND(("%s ...\n", StringForResultCode(TRESULT)));
goto processCatch;
}
while (cleanup--) {
valuePtr = POP_OBJECT();
TclDecrRefCount(valuePtr);
}
- if (result == TCL_BREAK) {
- result = TCL_OK;
+ if (TRESULT == TCL_BREAK) {
+ TRESULT = TCL_OK;
pc = (codePtr->codeStart + rangePtr->breakOffset);
TRACE_APPEND(("%s, range at %d, new pc %d\n",
- StringForResultCode(result),
+ StringForResultCode(TRESULT),
rangePtr->codeOffset, rangePtr->breakOffset));
NEXT_INST_F(0, 0, 0);
} else {
if (rangePtr->continueOffset == -1) {
TRACE_APPEND((
"%s, loop w/o continue, checking for catch\n",
- StringForResultCode(result)));
+ StringForResultCode(TRESULT)));
goto checkForCatch;
}
- result = TCL_OK;
+ TRESULT = TCL_OK;
pc = (codePtr->codeStart + rangePtr->continueOffset);
TRACE_APPEND(("%s, range at %d, new pc %d\n",
- StringForResultCode(result),
+ StringForResultCode(TRESULT),
rangePtr->codeOffset, rangePtr->continueOffset));
NEXT_INST_F(0, 0, 0);
}
#if TCL_COMPILE_DEBUG
} else if (traceInstructions) {
- if ((result != TCL_ERROR) && (result != TCL_RETURN)) {
+ if ((TRESULT != TCL_ERROR) && (TRESULT != TCL_RETURN)) {
Tcl_Obj *objPtr = Tcl_GetObjResult(interp);
TRACE_APPEND(("OTHER RETURN CODE %d, result= \"%s\"\n ",
- result, O2S(objPtr)));
+ TRESULT, O2S(objPtr)));
} else {
Tcl_Obj *objPtr = Tcl_GetObjResult(interp);
TRACE_APPEND(("%s, result= \"%s\"\n",
- StringForResultCode(result), O2S(objPtr)));
+ StringForResultCode(TRESULT), O2S(objPtr)));
}
#endif
}
@@ -7757,7 +7764,7 @@ TclExecuteByteCode(
if (iPtr->execEnvPtr->rewind) {
goto abnormalReturn;
}
- if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) {
+ if ((TRESULT == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) {
bytes = GetSrcInfoForPc(pc, codePtr, &length);
if (bytes != NULL) {
DECACHE_STACK_INFO();
@@ -7778,7 +7785,7 @@ TclExecuteByteCode(
(ptrdiff_t) auxObjList->internalRep.twoPtrValue.ptr1)) {
break;
}
- POP_AUX_OBJ();
+ POP_TAUX_OBJ();
}
/*
@@ -7793,7 +7800,7 @@ TclExecuteByteCode(
#ifdef TCL_COMPILE_DEBUG
if (traceInstructions) {
fprintf(stdout, " ... cancel with unwind, returning %s\n",
- StringForResultCode(result));
+ StringForResultCode(TRESULT));
}
#endif
goto abnormalReturn;
@@ -7809,7 +7816,7 @@ TclExecuteByteCode(
#ifdef TCL_COMPILE_DEBUG
if (traceInstructions) {
fprintf(stdout, " ... limit exceeded, returning %s\n",
- StringForResultCode(result));
+ StringForResultCode(TRESULT));
}
#endif
goto abnormalReturn;
@@ -7818,7 +7825,7 @@ TclExecuteByteCode(
#ifdef TCL_COMPILE_DEBUG
if (traceInstructions) {
fprintf(stdout, " ... no enclosing catch, returning %s\n",
- StringForResultCode(result));
+ StringForResultCode(TRESULT));
}
#endif
goto abnormalReturn;
@@ -7834,7 +7841,7 @@ TclExecuteByteCode(
#ifdef TCL_COMPILE_DEBUG
if (traceInstructions) {
fprintf(stdout, " ... no enclosing catch, returning %s\n",
- StringForResultCode(result));
+ StringForResultCode(TRESULT));
}
#endif
goto abnormalReturn;
@@ -7881,10 +7888,10 @@ TclExecuteByteCode(
* Winding down: insure that all pending cleanups are done before
* dropping out of this bytecode.
*/
- if (TOP_CB(interp) != bottomPtr->rootPtr) {
- result = TclNRRunCallbacks(interp, result, bottomPtr->rootPtr, 1);
+ if (TOP_CB(interp) != BP->rootPtr) {
+ TRESULT = TclNRRunCallbacks(interp, TRESULT, BP->rootPtr, 1);
- if (TOP_CB(interp) != bottomPtr->rootPtr) {
+ if (TOP_CB(interp) != BP->rootPtr) {
Tcl_Panic("Abnormal return with busy callback stack");
}
}
@@ -7897,7 +7904,7 @@ TclExecuteByteCode(
*/
while (auxObjList) {
- POP_AUX_OBJ();
+ POP_TAUX_OBJ();
}
while (tosPtr > initTosPtr) {
Tcl_Obj *objPtr = POP_OBJECT();
@@ -7916,39 +7923,35 @@ TclExecuteByteCode(
CLANG_ASSERT(bcFramePtr);
}
- oldBottomPtr = bottomPtr->prevBottomPtr;
+ OBP = BP->prevBottomPtr;
iPtr->cmdFramePtr = bcFramePtr->nextPtr;
- TclStackFree(interp, bottomPtr); /* free my stack */
+ TclStackFree(interp, BP); /* free my stack */
if (--codePtr->refCount <= 0) {
TclCleanupByteCode(codePtr);
}
returnToCaller:
- if (oldBottomPtr) {
+ if (OBP) {
/*
* Restore the state to what it was previous to this bytecode, deal
* with tailcalls.
*/
- bottomPtr = oldBottomPtr; /* back to old bc */
+ BP = OBP; /* back to old bc */
rerunCallbacks:
- result = TclNRRunCallbacks(interp, result, bottomPtr->rootPtr, 1);
+ TRESULT = TclNRRunCallbacks(interp, TRESULT, BP->rootPtr, 1);
NR_DATA_DIG();
- if (TOP_CB(interp) == bottomPtr->rootPtr) {
+ if (TOP_CB(interp) == BP->rootPtr) {
/*
* The bytecode is returning, all callbacks were run. Remove the
* caller's arguments and keep processing the caller.
*/
- bcFramePtr = (CmdFrame *) (bottomPtr + 1);
- initCatchTop = ((ptrdiff_t *) (bcFramePtr + 1)) - 1;
- initTosPtr = (Tcl_Obj **) (initCatchTop + codePtr->maxExceptDepth);
- esPtr = iPtr->execEnvPtr->execStackPtr;
-
- compiledLocals = iPtr->varFramePtr->compiledLocals;
+ TAUX.esPtr = iPtr->execEnvPtr->execStackPtr;
+ TAUX.compiledLocals = iPtr->varFramePtr->compiledLocals;
goto nonRecursiveCallReturn;
} else {
@@ -7956,7 +7959,7 @@ TclExecuteByteCode(
int type = PTR2INT(callbackPtr->data[0]);
NRE_ASSERT(TOP_CB(interp)->procPtr == NRCallTEBC);
- NRE_ASSERT(result == TCL_OK);
+ NRE_ASSERT(TRESULT == TCL_OK);
switch (type) {
case TCL_NR_BC_TYPE:
@@ -7973,7 +7976,7 @@ TclExecuteByteCode(
Tcl_SetResult(interp,
"atProcExit/tailcall cannot be invoked recursively",
TCL_STATIC);
- result = TCL_ERROR;
+ TRESULT = TCL_ERROR;
goto rerunCallbacks;
default:
Tcl_Panic("TEBC: TRCB sent us a callback we cannot handle!");
@@ -7982,9 +7985,14 @@ TclExecuteByteCode(
}
iPtr->execEnvPtr->bottomPtr = NULL;
- return result;
+ return TRESULT;
}
#undef iPtr
+#undef bcFramePtr
+#undef initCatchTop
+#undef initTosPtr
+#undef auxObjList
+#undef catchTop
#ifdef TCL_COMPILE_DEBUG
/*