summaryrefslogtreecommitdiffstats
path: root/generic/tclProc.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-06-30 08:10:15 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-06-30 08:10:15 (GMT)
commit68de044c4e43f457cf298983fc8dc0936aed9923 (patch)
treee963a357aeb17226cede5a09a53f75b86b353eab /generic/tclProc.c
parentcdbe969ea378527a9002c3a5ab21465c7a79fc4b (diff)
downloadtcl-68de044c4e43f457cf298983fc8dc0936aed9923.zip
tcl-68de044c4e43f457cf298983fc8dc0936aed9923.tar.gz
tcl-68de044c4e43f457cf298983fc8dc0936aed9923.tar.bz2
Use twoPtrValue in stead of ptrAndLongRep for implementation of some internal Obj types. On most platforms this doesn't make a difference,
as (void *) and (long) generially have the same size. The only exception where it makes a difference is win64, as we can now store 64 bits in this field in stead of only 32 bits, exactly what the processor is optimized for.
Diffstat (limited to 'generic/tclProc.c')
-rw-r--r--generic/tclProc.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c
index e0d6ec7..6ffbd90 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -69,9 +69,9 @@ const Tcl_ObjType tclProcBodyType = {
};
/*
- * The [upvar]/[uplevel] level reference type. Uses the ptrAndLongRep field,
+ * The [upvar]/[uplevel] level reference type. Uses the twoPtrValue field,
* encoding the type of level reference in ptr and the actual parsed out
- * offset in value.
+ * offset in ptr2.
*
* Uses the default behaviour throughout, and never disposes of the string
* rep; it's just a cache type.
@@ -823,10 +823,10 @@ TclObjGetFrame(
name = TclGetString(objPtr);
if (objPtr->typePtr == &levelReferenceType) {
- if (objPtr->internalRep.ptrAndLongRep.ptr != NULL) {
- level = curLevel - objPtr->internalRep.ptrAndLongRep.value;
+ if (objPtr->internalRep.twoPtrValue.ptr1) {
+ level = curLevel - PTR2INT(objPtr->internalRep.twoPtrValue.ptr2);
} else {
- level = objPtr->internalRep.ptrAndLongRep.value;
+ level = PTR2INT(objPtr->internalRep.twoPtrValue.ptr2);
}
if (level < 0) {
goto levelError;
@@ -848,14 +848,12 @@ TclObjGetFrame(
/*
* Cache for future reference.
- *
- * TODO: Use the new ptrAndLongRep intrep
*/
TclFreeIntRep(objPtr);
objPtr->typePtr = &levelReferenceType;
- objPtr->internalRep.ptrAndLongRep.ptr = NULL;
- objPtr->internalRep.ptrAndLongRep.value = level;
+ objPtr->internalRep.twoPtrValue.ptr1 = (void *) 0;
+ objPtr->internalRep.twoPtrValue.ptr2 = INT2PTR(level);
} else if (isdigit(UCHAR(*name))) { /* INTL: digit */
if (Tcl_GetInt(interp, name, &level) != TCL_OK) {
return -1;
@@ -863,14 +861,12 @@ TclObjGetFrame(
/*
* Cache for future reference.
- *
- * TODO: Use the new ptrAndLongRep intrep
*/
TclFreeIntRep(objPtr);
objPtr->typePtr = &levelReferenceType;
- objPtr->internalRep.ptrAndLongRep.ptr = (void *) 1; /* non-NULL */
- objPtr->internalRep.ptrAndLongRep.value = level;
+ objPtr->internalRep.twoPtrValue.ptr1 = (void *) 1;
+ objPtr->internalRep.twoPtrValue.ptr2 = INT2PTR(level);
level = curLevel - level;
} else {
/*
@@ -2450,8 +2446,7 @@ FreeLambdaInternalRep(
Proc *procPtr = objPtr->internalRep.twoPtrValue.ptr1;
Tcl_Obj *nsObjPtr = objPtr->internalRep.twoPtrValue.ptr2;
- procPtr->refCount--;
- if (procPtr->refCount == 0) {
+ if (procPtr->refCount-- == 1) {
TclProcCleanupProc(procPtr);
}
TclDecrRefCount(nsObjPtr);