summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authormig <mig>2011-03-18 18:57:35 (GMT)
committermig <mig>2011-03-18 18:57:35 (GMT)
commit0c6e7852c9f3570adf39a45c72ad1e0b9850b470 (patch)
tree9c54fa4928475b373061cf0820b92124285fa7fd /generic
parentb1edda8715f1cab75c0f12e7ba71c6e8d5e6e0a7 (diff)
downloadtcl-0c6e7852c9f3570adf39a45c72ad1e0b9850b470.zip
tcl-0c6e7852c9f3570adf39a45c72ad1e0b9850b470.tar.gz
tcl-0c6e7852c9f3570adf39a45c72ad1e0b9850b470.tar.bz2
let TEBC also use TclAllocMaximize
Diffstat (limited to 'generic')
-rw-r--r--generic/tclExecute.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index b340144..2ed1537 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1535,6 +1535,12 @@ TclIncrObj(
#define catchStack (TD->stack)
#define initTosPtr ((Tcl_Obj **) &TD->stack[codePtr->maxExceptDepth - 1])
+#define capacity2size(cap) \
+ (sizeof(TEBCdata) + sizeof(void *)*(cap + codePtr->maxExceptDepth - 1))
+
+#define size2capacity(s) \
+ (((s - sizeof(TEBCdata))/sizeof(void *)) - codePtr->maxExceptDepth + 1)
+
int
TclNRExecuteByteCode(
Tcl_Interp *interp, /* Token for command interpreter. */
@@ -1542,8 +1548,7 @@ TclNRExecuteByteCode(
{
Interp *iPtr = (Interp *) interp;
TEBCdata *TD;
- unsigned int size = sizeof(TEBCdata) + sizeof(void *) *
- (codePtr->maxStackDepth + codePtr->maxExceptDepth - 1);
+ unsigned int size = capacity2size(codePtr->maxStackDepth);
if (iPtr->execEnvPtr->rewind) {
return TCL_ERROR;
@@ -1564,6 +1569,13 @@ TclNRExecuteByteCode(
*/
TD = ckalloc(size);
+ size = TclAllocMaximize(TD);
+ if (size == UINT_MAX) {
+ TD->capacity = codePtr->maxStackDepth;
+ } else {
+ TD->capacity = size2capacity(size);
+ }
+
TD->tosPtr = initTosPtr;
TD->codePtr = codePtr;
@@ -1572,7 +1584,6 @@ TclNRExecuteByteCode(
TD->cleanup = 0;
TD->auxObjList = NULL;
TD->checkInterp = 0;
- TD->capacity = codePtr->maxStackDepth;
/*
* TIP #280: Initialize the frame. Do not push it yet: it will be pushed
@@ -2284,13 +2295,17 @@ TEBCresume(
(void) POP_OBJECT();
if (reqWords > TD->capacity) {
ptrdiff_t depth;
- unsigned int size = sizeof(TEBCdata) + sizeof(void *) *
- + (reqWords + codePtr->maxExceptDepth - 1);
+ unsigned int size = capacity2size(reqWords);
depth = tosPtr - initTosPtr;
TD = ckrealloc(TD, size);
+ size = TclAllocMaximize(TD);
+ if (size == UINT_MAX) {
+ TD->capacity = reqWords;
+ } else {
+ TD->capacity = size2capacity(size);
+ }
tosPtr = initTosPtr + depth;
- TD->capacity = reqWords;
}
/*