summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-06-18 22:51:10 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-06-18 22:51:10 (GMT)
commit92b0317a2aee4e4cddd7870b828083db5e2f9d53 (patch)
tree18f20a232250658278a2d0c01dae4aa41a272dfe
parent1226c2ef3595f10f6ae34fc47c9d26706f4a4351 (diff)
downloadtcl-92b0317a2aee4e4cddd7870b828083db5e2f9d53.zip
tcl-92b0317a2aee4e4cddd7870b828083db5e2f9d53.tar.gz
tcl-92b0317a2aee4e4cddd7870b828083db5e2f9d53.tar.bz2
* generic/tclCmdIL.c (InfoFrameCmd):
* generic/tclCmdMZ.c (Tcl_SwitchObjCmd): * generic/tclCompile.c (TclInitCompileEnv): * generic/tclProc.c (Tcl_ProcObjCmd, SetLambdaFromAny): Moved the CmdFrame off the C stack and onto the Tcl stack.
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclCmdIL.c25
-rw-r--r--generic/tclCmdMZ.c40
-rw-r--r--generic/tclCompile.c22
-rw-r--r--generic/tclExecute.c6
-rw-r--r--generic/tclProc.c64
6 files changed, 94 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e8ceb4..af5ea32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2007-06-18 Miguel Sofer <msofer@users.sf.net>
+ * generic/tclCmdIL.c (InfoFrameCmd):
+ * generic/tclCmdMZ.c (Tcl_SwitchObjCmd):
+ * generic/tclCompile.c (TclInitCompileEnv):
+ * generic/tclProc.c (Tcl_ProcObjCmd, SetLambdaFromAny): Moved the
+ CmdFrame off the C stack and onto the Tcl stack.
+
* generic/tclExecute.c (TEBC): Moved the CmdFrame off the C stack
and onto the Tcl stack, between the catch and the execution stacks
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index b7a26bf..49ca22c 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdIL.c,v 1.116 2007/06/12 12:34:00 dkf Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.117 2007/06/18 22:51:11 msofer Exp $
*/
#include "tclInt.h"
@@ -1188,36 +1188,40 @@ InfoFrameCmd(
* Execution of bytecode. Talk to the BC engine to fill out the frame.
*/
- CmdFrame f = *framePtr;
- Proc *procPtr = f.framePtr ? f.framePtr->procPtr : NULL;
+ Proc *procPtr = framePtr->framePtr ? framePtr->framePtr->procPtr : NULL;
+ CmdFrame *fPtr;
+
+ fPtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame));
+ *fPtr = *framePtr;
/*
* Note:
* Type BC => f.data.eval.path is not used.
+
* f.data.tebc.codePtr is used instead.
*/
- TclGetSrcInfoForPc(&f);
+ TclGetSrcInfoForPc(fPtr);
/*
* Now filled: cmd.str.(cmd,len), line
* Possibly modified: type, path!
*/
- ADD_PAIR("type", Tcl_NewStringObj(typeString[f.type], -1));
- ADD_PAIR("line", Tcl_NewIntObj(f.line[0]));
+ ADD_PAIR("type", Tcl_NewStringObj(typeString[fPtr->type], -1));
+ ADD_PAIR("line", Tcl_NewIntObj(fPtr->line[0]));
- if (f.type == TCL_LOCATION_SOURCE) {
- ADD_PAIR("file", f.data.eval.path);
+ if (fPtr->type == TCL_LOCATION_SOURCE) {
+ ADD_PAIR("file", fPtr->data.eval.path);
/*
* Death of reference by TclGetSrcInfoForPc.
*/
- Tcl_DecrRefCount(f.data.eval.path);
+ Tcl_DecrRefCount(fPtr->data.eval.path);
}
- ADD_PAIR("cmd", Tcl_NewStringObj(f.cmd.str.cmd, f.cmd.str.len));
+ ADD_PAIR("cmd", Tcl_NewStringObj(fPtr->cmd.str.cmd, fPtr->cmd.str.len));
if (procPtr != NULL) {
Tcl_HashEntry *namePtr = procPtr->cmdPtr->hPtr;
@@ -1256,6 +1260,7 @@ InfoFrameCmd(
}
}
}
+ TclStackFree(interp); /* fPtr */
break;
}
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index f07fb78..2d06d46 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.151 2007/06/08 20:41:25 dkf Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.152 2007/06/18 22:51:11 msofer Exp $
*/
#include "tclInt.h"
@@ -2596,7 +2596,7 @@ Tcl_SwitchObjCmd(
int pc = 0;
int bidx = 0; /* Index of body argument. */
Tcl_Obj *blist = NULL; /* List obj which is the body */
- CmdFrame ctx; /* Copy of the topmost cmdframe, to allow us
+ CmdFrame *ctxPtr; /* Copy of the topmost cmdframe, to allow us
* to mess with the line information */
/*
@@ -2930,7 +2930,8 @@ Tcl_SwitchObjCmd(
*/
matchFound:
- ctx = *iPtr->cmdFramePtr;
+ ctxPtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame));
+ *ctxPtr = *iPtr->cmdFramePtr;
if (splitObjs) {
/*
@@ -2941,13 +2942,13 @@ Tcl_SwitchObjCmd(
* special handling done in 'info frame', or the bc compiler
*/
- if (ctx.type == TCL_LOCATION_BC) {
+ if (ctxPtr->type == TCL_LOCATION_BC) {
/*
- * Type BC => ctx.data.eval.path is not used.
- * ctx.data.tebc.codePtr is used instead.
+ * Type BC => ctxPtr->data.eval.path is not used.
+ * ctxPtr->data.tebc.codePtr is used instead.
*/
- TclGetSrcInfoForPc(&ctx);
+ TclGetSrcInfoForPc(ctxPtr);
pc = 1;
/*
@@ -2956,12 +2957,12 @@ Tcl_SwitchObjCmd(
*/
}
- if (ctx.type == TCL_LOCATION_SOURCE && ctx.line[bidx] >= 0) {
- int bline = ctx.line[bidx];
+ if (ctxPtr->type == TCL_LOCATION_SOURCE && ctxPtr->line[bidx] >= 0) {
+ int bline = ctxPtr->line[bidx];
- ctx.line = (int *) ckalloc(objc * sizeof(int));
- ctx.nline = objc;
- TclListLines(Tcl_GetString(blist), bline, objc, ctx.line);
+ ctxPtr->line = (int *) ckalloc(objc * sizeof(int));
+ ctxPtr->nline = objc;
+ TclListLines(Tcl_GetString(blist), bline, objc, ctxPtr->line);
} else {
/*
* This is either a dynamic code word, when all elements are
@@ -2973,10 +2974,10 @@ Tcl_SwitchObjCmd(
int k;
- ctx.line = (int *) ckalloc(objc * sizeof(int));
- ctx.nline = objc;
+ ctxPtr->line = (int *) ckalloc(objc * sizeof(int));
+ ctxPtr->nline = objc;
for (k=0; k < objc; k++) {
- ctx.line[k] = -1;
+ ctxPtr->line[k] = -1;
}
}
}
@@ -2999,15 +3000,15 @@ Tcl_SwitchObjCmd(
* TIP #280. Make invoking context available to switch branch.
*/
- result = TclEvalObjEx(interp, objv[j], 0, &ctx, j);
+ result = TclEvalObjEx(interp, objv[j], 0, ctxPtr, j);
if (splitObjs) {
- ckfree((char *) ctx.line);
- if (pc && (ctx.type == TCL_LOCATION_SOURCE)) {
+ ckfree((char *) ctxPtr->line);
+ if (pc && (ctxPtr->type == TCL_LOCATION_SOURCE)) {
/*
* Death of SrcInfo reference.
*/
- Tcl_DecrRefCount(ctx.data.eval.path);
+ Tcl_DecrRefCount(ctxPtr->data.eval.path);
}
}
@@ -3024,6 +3025,7 @@ Tcl_SwitchObjCmd(
(overflow ? limit : patternLength), pattern,
(overflow ? "..." : ""), interp->errorLine));
}
+ TclStackFree(interp); /* ctxPtr */
return result;
}
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index f3aa2e4..d00ee09 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.119 2007/06/14 15:56:05 dgp Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.120 2007/06/18 22:51:11 msofer Exp $
*/
#include "tclInt.h"
@@ -912,39 +912,43 @@ TclInitCompileEnv(
envPtr->extCmdMapPtr->type =
(envPtr->procPtr ? TCL_LOCATION_PROC : TCL_LOCATION_BC);
} else {
- CmdFrame ctx = *invoker;
+ CmdFrame *ctxPtr;
int pc = 0;
+ ctxPtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame));
+ *ctxPtr = *invoker;
+
if (invoker->type == TCL_LOCATION_BC) {
/*
* Note: Type BC => ctx.data.eval.path is not used.
* ctx.data.tebc.codePtr is used instead.
*/
- TclGetSrcInfoForPc(&ctx);
+ TclGetSrcInfoForPc(ctxPtr);
pc = 1;
}
- envPtr->line = ctx.line[word];
- envPtr->extCmdMapPtr->type = ctx.type;
+ envPtr->line = ctxPtr->line[word];
+ envPtr->extCmdMapPtr->type = ctxPtr->type;
- if (ctx.type == TCL_LOCATION_SOURCE) {
+ if (ctxPtr->type == TCL_LOCATION_SOURCE) {
if (pc) {
/*
* The reference 'TclGetSrcInfoForPc' made is transfered.
*/
- envPtr->extCmdMapPtr->path = ctx.data.eval.path;
- ctx.data.eval.path = NULL;
+ envPtr->extCmdMapPtr->path = ctxPtr->data.eval.path;
+ ctxPtr->data.eval.path = NULL;
} else {
/*
* We have a new reference here.
*/
- envPtr->extCmdMapPtr->path = ctx.data.eval.path;
+ envPtr->extCmdMapPtr->path = ctxPtr->data.eval.path;
Tcl_IncrRefCount(envPtr->extCmdMapPtr->path);
}
}
+ TclStackFree(interp);
}
}
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 0020474..1f2a3df 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -12,7 +12,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.297 2007/06/18 21:58:41 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.298 2007/06/18 22:51:11 msofer Exp $
*/
#include "tclInt.h"
@@ -1346,7 +1346,7 @@ TclExecuteByteCode(
ptrdiff_t *initCatchTop; /* Catch stack top at start of execution. */
Var *compiledLocals;
Namespace *namespacePtr;
- CmdFrame *bcFramePtr; /* TIP #280: Structure for tracking lines. */
+ CmdFrame *bcFramePtr; /* TIP #280: Structure for tracking lines. */
Tcl_Obj **constants = &iPtr->execEnvPtr->constants[0];
/*
@@ -7040,7 +7040,7 @@ IllegalExprOperandType(
* unchanged.
*
* Side effects:
- * None.
+ * The CmdFrame at *cfPtr is updated.
*
*----------------------------------------------------------------------
*/
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 0e4a171..5253e21 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.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: tclProc.c,v 1.123 2007/06/17 21:29:39 dkf Exp $
+ * RCS: @(#) $Id: tclProc.c,v 1.124 2007/06/18 22:51:12 msofer Exp $
*/
#include "tclInt.h"
@@ -210,9 +210,12 @@ Tcl_ProcObjCmd(
*/
if (iPtr->cmdFramePtr) {
- CmdFrame context = *iPtr->cmdFramePtr;
+ CmdFrame *contextPtr;
- if (context.type == TCL_LOCATION_BC) {
+ contextPtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame));
+ *contextPtr = *iPtr->cmdFramePtr;
+
+ if (contextPtr->type == TCL_LOCATION_BC) {
/*
* Retrieve source information from the bytecode, if possible. If
* the information is retrieved successfully, context.type will be
@@ -220,36 +223,36 @@ Tcl_ProcObjCmd(
* context.data.eval.path will be counted.
*/
- TclGetSrcInfoForPc(&context);
- } else if (context.type == TCL_LOCATION_SOURCE) {
+ TclGetSrcInfoForPc(contextPtr);
+ } else if (contextPtr->type == TCL_LOCATION_SOURCE) {
/*
* The copy into 'context' up above has created another reference
* to 'context.data.eval.path'; account for it.
*/
- Tcl_IncrRefCount(context.data.eval.path);
+ Tcl_IncrRefCount(contextPtr->data.eval.path);
}
- if (context.type == TCL_LOCATION_SOURCE) {
+ if (contextPtr->type == TCL_LOCATION_SOURCE) {
/*
* We can account for source location within a proc only if the
* proc body was not created by substitution.
*/
- if (context.line
- && (context.nline >= 4) && (context.line[3] >= 0)) {
+ if (contextPtr->line
+ && (contextPtr->nline >= 4) && (contextPtr->line[3] >= 0)) {
int isNew;
CmdFrame *cfPtr = (CmdFrame *) ckalloc(sizeof(CmdFrame));
cfPtr->level = -1;
- cfPtr->type = context.type;
+ cfPtr->type = contextPtr->type;
cfPtr->line = (int *) ckalloc(sizeof(int));
- cfPtr->line[0] = context.line[3];
+ cfPtr->line[0] = contextPtr->line[3];
cfPtr->nline = 1;
cfPtr->framePtr = NULL;
cfPtr->nextPtr = NULL;
- cfPtr->data.eval.path = context.data.eval.path;
+ cfPtr->data.eval.path = contextPtr->data.eval.path;
Tcl_IncrRefCount(cfPtr->data.eval.path);
cfPtr->cmd.str.cmd = NULL;
@@ -260,13 +263,14 @@ Tcl_ProcObjCmd(
}
/*
- * 'context' is going out of scope; account for the reference that
+ * 'contextPtr' is going out of scope; account for the reference that
* it's holding to the path name.
*/
- Tcl_DecrRefCount(context.data.eval.path);
- context.data.eval.path = NULL;
+ Tcl_DecrRefCount(contextPtr->data.eval.path);
+ contextPtr->data.eval.path = NULL;
}
+ TclStackFree(interp); /* contextPtr */
}
/*
@@ -2331,34 +2335,37 @@ SetLambdaFromAny(
*/
if (iPtr->cmdFramePtr) {
- CmdFrame context = *iPtr->cmdFramePtr;
+ CmdFrame *contextPtr;
+
+ contextPtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame));
+ *contextPtr = *iPtr->cmdFramePtr;
- if (context.type == TCL_LOCATION_BC) {
+ if (contextPtr->type == TCL_LOCATION_BC) {
/*
* Retrieve the source context from the bytecode. This call
* accounts for the reference to the source file, if any, held in
* 'context.data.eval.path'.
*/
- TclGetSrcInfoForPc(&context);
- } else if (context.type == TCL_LOCATION_SOURCE) {
+ TclGetSrcInfoForPc(contextPtr);
+ } else if (contextPtr->type == TCL_LOCATION_SOURCE) {
/*
* We created a new reference to the source file path name when we
* created 'context' above. Account for the reference.
*/
- Tcl_IncrRefCount(context.data.eval.path);
+ Tcl_IncrRefCount(contextPtr->data.eval.path);
}
- if (context.type == TCL_LOCATION_SOURCE) {
+ if (contextPtr->type == TCL_LOCATION_SOURCE) {
/*
* We can record source location within a lambda only if the body
* was not created by substitution.
*/
- if (context.line
- && (context.nline >= 2) && (context.line[1] >= 0)) {
+ if (contextPtr->line
+ && (contextPtr->nline >= 2) && (contextPtr->line[1] >= 0)) {
int isNew, buf[2];
CmdFrame *cfPtr = (CmdFrame *) ckalloc(sizeof(CmdFrame));
@@ -2367,17 +2374,17 @@ SetLambdaFromAny(
* location (line of 2nd list element).
*/
- TclListLines(name, context.line[1], 2, buf);
+ TclListLines(name, contextPtr->line[1], 2, buf);
cfPtr->level = -1;
- cfPtr->type = context.type;
+ cfPtr->type = contextPtr->type;
cfPtr->line = (int *) ckalloc(sizeof(int));
cfPtr->line[0] = buf[1];
cfPtr->nline = 1;
cfPtr->framePtr = NULL;
cfPtr->nextPtr = NULL;
- cfPtr->data.eval.path = context.data.eval.path;
+ cfPtr->data.eval.path = contextPtr->data.eval.path;
Tcl_IncrRefCount(cfPtr->data.eval.path);
cfPtr->cmd.str.cmd = NULL;
@@ -2388,12 +2395,13 @@ SetLambdaFromAny(
}
/*
- * 'context' is going out of scope. Release the reference that
+ * 'contextPtr' is going out of scope. Release the reference that
* it's holding to the source file path
*/
- Tcl_DecrRefCount(context.data.eval.path);
+ Tcl_DecrRefCount(contextPtr->data.eval.path);
}
+ TclStackFree(interp); /* contextPtr */
}
/*