summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-07-01 13:12:57 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-07-01 13:12:57 (GMT)
commit7ea47b984acc172d762d97583ad57afb44a7e450 (patch)
tree9422a69eb8231a5b03115916dd4a3d8effb539a5
parent27ce2290a6e107aa7e2b8a5995fa32e32106546c (diff)
downloadtcl-7ea47b984acc172d762d97583ad57afb44a7e450.zip
tcl-7ea47b984acc172d762d97583ad57afb44a7e450.tar.gz
tcl-7ea47b984acc172d762d97583ad57afb44a7e450.tar.bz2
Don't use internalRep.otherValuePtr any more, twoPtrValue.ptr1 is always a better idea.
A few more consistancies in refcount management.
-rw-r--r--generic/tcl.h5
-rw-r--r--generic/tclExecute.c36
-rw-r--r--generic/tclInt.h4
-rw-r--r--generic/tclOOInt.h2
4 files changed, 24 insertions, 23 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index f0d7c9a..1f7b5cb 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -816,7 +816,8 @@ typedef struct Tcl_Obj {
union { /* The internal representation: */
long longValue; /* - an long integer value. */
double doubleValue; /* - a double-precision floating value. */
- void *otherValuePtr; /* - another, type-specific value. */
+ void *otherValuePtr; /* - another, type-specific value,
+ not used internally any more. */
Tcl_WideInt wideValue; /* - a long long value. */
struct { /* - internal rep as two pointers.
* the main use of which is a bignum's
@@ -2509,7 +2510,7 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr);
# define Tcl_DecrRefCount(objPtr) \
do { \
Tcl_Obj *_objPtr = (objPtr); \
- if (--(_objPtr)->refCount <= 0) { \
+ if ((_objPtr)->refCount-- <= 1) { \
TclFreeObj(_objPtr); \
} \
} while(0)
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 6fc6b6b..38f11f2 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1138,7 +1138,7 @@ GrowEvaluationStack(
}
needed = growth + moveWords + WALLOCALIGN;
-
+
/*
* Check if there is enough room in the next stack (if there is one, it
* should be both empty and the last one!)
@@ -1176,7 +1176,7 @@ GrowEvaluationStack(
#else
newElems = needed;
#endif
-
+
newBytes = sizeof(ExecStack) + (newElems-1) * sizeof(Tcl_Obj *);
oldPtr = esPtr;
@@ -2152,7 +2152,7 @@ TEBCresume(
const unsigned char *pc = data[1];
/* The current program counter. */
unsigned char inst; /* The currently running instruction */
-
+
/*
* Transfer variables - needed only between opcodes, but not while
* executing an instruction.
@@ -2357,7 +2357,7 @@ TEBCresume(
*/
inst = *pc;
-
+
peepholeStart:
#ifdef TCL_COMPILE_STATS
iPtr->stats.instructionCount[*pc]++;
@@ -2377,7 +2377,7 @@ TEBCresume(
#endif /* TCL_COMPILE_DEBUG */
TCL_DTRACE_INST_NEXT();
-
+
if (inst == INST_LOAD_SCALAR1) {
goto instLoadScalar1;
} else if (inst == INST_PUSH1) {
@@ -2389,7 +2389,7 @@ TEBCresume(
/*
* Peephole: do not run INST_START_CMD, just skip it
*/
-
+
iPtr->cmdCount += TclGetUInt4AtPtr(pc+5);
if (checkInterp) {
checkInterp = 0;
@@ -2410,7 +2410,7 @@ TEBCresume(
}
goto peepholeStart;
}
-
+
switch (inst) {
case INST_SYNTAX:
case INST_RETURN_IMM: {
@@ -2557,7 +2557,7 @@ TEBCresume(
/* TIP #280: Record the last piece of info needed by
* 'TclGetSrcInfoForPc', and push the frame.
*/
-
+
bcFramePtr->data.tebc.pc = (char *) pc;
iPtr->cmdFramePtr = bcFramePtr;
@@ -5763,7 +5763,7 @@ TEBCresume(
* at this point (post Tcl_GetUnicodeFromObj).
*/
- ((int *) objResultPtr->internalRep.otherValuePtr)[1] = 0;
+ ((int *) objResultPtr->internalRep.twoPtrValue.ptr1)[1] = 0;
}
Tcl_InvalidateStringRep(objResultPtr);
TclDecrRefCount(value3Ptr);
@@ -5790,7 +5790,7 @@ TEBCresume(
* at this point (post Tcl_GetUnicodeFromObj).
*/
- ((int *) objResultPtr->internalRep.otherValuePtr)[1] = 0;
+ ((int *) objResultPtr->internalRep.twoPtrValue.ptr1)[1] = 0;
}
Tcl_InvalidateStringRep(valuePtr);
TclDecrRefCount(value3Ptr);
@@ -7111,7 +7111,7 @@ TEBCresume(
*/
TclNewObj(tmpPtr);
- tmpPtr->internalRep.otherValuePtr = infoPtr;
+ tmpPtr->internalRep.twoPtrValue.ptr1 = infoPtr;
PUSH_OBJECT(tmpPtr); /* infoPtr object */
TRACE_APPEND(("jump to loop step\n"));
@@ -7129,7 +7129,7 @@ TEBCresume(
*/
tmpPtr = OBJ_AT_TOS;
- infoPtr = tmpPtr->internalRep.otherValuePtr;
+ infoPtr = tmpPtr->internalRep.twoPtrValue.ptr1;
numLists = infoPtr->numLists;
TRACE(("=> "));
@@ -7213,7 +7213,7 @@ TEBCresume(
case INST_FOREACH_END:
/* THIS INSTRUCTION IS ONLY CALLED AS A BREAK TARGET */
tmpPtr = OBJ_AT_TOS;
- infoPtr = tmpPtr->internalRep.otherValuePtr;
+ infoPtr = tmpPtr->internalRep.twoPtrValue.ptr1;
numLists = infoPtr->numLists;
TRACE(("=> loop terminated\n"));
NEXT_INST_V(1, numLists+2, 0);
@@ -7230,10 +7230,10 @@ TEBCresume(
*/
tmpPtr = OBJ_AT_DEPTH(1);
- infoPtr = tmpPtr->internalRep.otherValuePtr;
+ infoPtr = tmpPtr->internalRep.twoPtrValue.ptr1;
numLists = infoPtr->numLists;
TRACE_APPEND(("=> appending to list at depth %d\n", 3 + numLists));
-
+
objPtr = OBJ_AT_DEPTH(3 + numLists);
Tcl_ListObjAppendElement(NULL, objPtr, OBJ_AT_TOS);
NEXT_INST_F(1, 1, 0);
@@ -8195,7 +8195,7 @@ TEBCresume(
}
iPtr->cmdFramePtr = bcFramePtr->nextPtr;
- if (--codePtr->refCount <= 0) {
+ if (codePtr->refCount-- <= 1) {
TclCleanupByteCode(codePtr);
}
TclStackFree(interp, TD); /* free my stack */
@@ -9774,7 +9774,7 @@ ValidatePcAndStackTop(
(unsigned) opCode, relativePc);
Tcl_Panic("TclNRExecuteByteCode execution failure: bad opcode");
}
- if (checkStack &&
+ if (checkStack &&
((stackTop < 0) || (stackTop > stackUpperBound))) {
int numChars;
const char *cmd = GetSrcInfoForPc(pc, codePtr, &numChars, NULL, NULL);
@@ -9987,7 +9987,7 @@ GetSrcInfoForPc(
* where the current instruction starts.
* If NULL; no pointer is stored. */
int *cmdIdxPtr) /* If non-NULL, the location where the index
- * of the command containing the pc should
+ * of the command containing the pc should
* be stored. */
{
register int pcOffset = (pc - codePtr->codeStart);
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 2537ad8..356d250 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4039,7 +4039,7 @@ typedef const char *TclDTraceStr;
*/
# define TclDecrRefCount(objPtr) \
- if (--(objPtr)->refCount > 0) ; else { \
+ if ((objPtr)->refCount-- > 1) ; else { \
if (!(objPtr)->typePtr || !(objPtr)->typePtr->freeIntRepProc) { \
TCL_DTRACE_OBJ_FREE(objPtr); \
if ((objPtr)->bytes \
@@ -4679,7 +4679,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
*/
#define TclCleanupCommandMacro(cmdPtr) \
- if (--(cmdPtr)->refCount <= 0) { \
+ if ((cmdPtr)->refCount-- <= 1) { \
ckfree((char *) (cmdPtr));\
}
diff --git a/generic/tclOOInt.h b/generic/tclOOInt.h
index c0e4022..208e32c 100644
--- a/generic/tclOOInt.h
+++ b/generic/tclOOInt.h
@@ -588,7 +588,7 @@ MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr);
#define AddRef(ptr) ((ptr)->refCount++)
#define DelRef(ptr) do { \
- if (--(ptr)->refCount < 1) { \
+ if ((ptr)->refCount-- <= 1) { \
ckfree((char *) (ptr)); \
} \
} while(0)