Tcl Source Code

Check-in [248b0a0e0a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:let TEBC also use TclAllocMaximize
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mig-alloc-reform
Files: files | file ages | folders
SHA1: 248b0a0e0a2285fbf8682175ad759d239462da5c
User & Date: mig 2011-03-18 18:57:35
Context
2011-03-18
19:18
let TclAllocMaximize maintain zippys stats check-in: 9cb2f836cb user: mig tags: mig-alloc-reform
18:57
let TEBC also use TclAllocMaximize check-in: 248b0a0e0a user: mig tags: mig-alloc-reform
18:06
remove unused mutex check-in: a3f0c08c7f user: mig tags: mig-alloc-reform
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclExecute.c.

1531
1532
1533
1534
1535
1536
1537






1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566







1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
 *
 *----------------------------------------------------------------------
 */
#define	bcFramePtr	(&TD->cmdFrame)
#define	catchStack	(TD->stack)
#define	initTosPtr	((Tcl_Obj **) &TD->stack[codePtr->maxExceptDepth - 1])







int
TclNRExecuteByteCode(
    Tcl_Interp *interp,		/* Token for command interpreter. */
    ByteCode *codePtr)		/* The bytecode sequence to interpret. */
{
    Interp *iPtr = (Interp *) interp;
    TEBCdata *TD;
    unsigned int size = sizeof(TEBCdata) + sizeof(void *) *
	  (codePtr->maxStackDepth + codePtr->maxExceptDepth - 1);       
    
    if (iPtr->execEnvPtr->rewind) {
	return TCL_ERROR;
    }
    
    codePtr->refCount++;

    /*
     * Reserve the stack, setup the TEBCdataPtr (TD) and CallFrame
     *
     * The execution uses a unified stack: first a TEBCdata, immediately
     * above it a CmdFrame, then the catch stack, then the execution stack.
     *
     * Make sure the catch stack is large enough to hold the maximum number of
     * catch commands that could ever be executing at the same time (this will
     * be no more than the exception range array's depth). Make sure the
     * execution stack is large enough to execute this ByteCode.
     */

    TD = ckalloc(size);







    TD->tosPtr = initTosPtr;
    
    TD->codePtr     = codePtr;
    TD->pc          = codePtr->codeStart;
    TD->catchDepth  = -1;
    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
     * every time that we call out from this TD, popped when we return to it.
     */

    bcFramePtr->type = ((codePtr->flags & TCL_BYTECODE_PRECOMPILED)







>
>
>
>
>
>







<
|




















>
>
>
>
>
>
>








<







1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550

1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586

1587
1588
1589
1590
1591
1592
1593
 *
 *----------------------------------------------------------------------
 */
#define	bcFramePtr	(&TD->cmdFrame)
#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. */
    ByteCode *codePtr)		/* The bytecode sequence to interpret. */
{
    Interp *iPtr = (Interp *) interp;
    TEBCdata *TD;

    unsigned int size = capacity2size(codePtr->maxStackDepth);
    
    if (iPtr->execEnvPtr->rewind) {
	return TCL_ERROR;
    }
    
    codePtr->refCount++;

    /*
     * Reserve the stack, setup the TEBCdataPtr (TD) and CallFrame
     *
     * The execution uses a unified stack: first a TEBCdata, immediately
     * above it a CmdFrame, then the catch stack, then the execution stack.
     *
     * Make sure the catch stack is large enough to hold the maximum number of
     * catch commands that could ever be executing at the same time (this will
     * be no more than the exception range array's depth). Make sure the
     * execution stack is large enough to execute this ByteCode.
     */

    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;
    TD->pc          = codePtr->codeStart;
    TD->catchDepth  = -1;
    TD->cleanup     = 0;
    TD->auxObjList  = NULL;
    TD->checkInterp = 0;

    
    /*
     * TIP #280: Initialize the frame. Do not push it yet: it will be pushed
     * every time that we call out from this TD, popped when we return to it.
     */

    bcFramePtr->type = ((codePtr->flags & TCL_BYTECODE_PRECOMPILED)
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292

2293




2294
2295
2296
2297
2298
2299
2300
	    + (CURR_DEPTH - TclGetInt4AtPtr(pc+1))
	    /* plus how many are needed for this expansion */
	    + objc - 1;

	(void) POP_OBJECT();
	if (reqWords > TD->capacity) {
	    ptrdiff_t depth;
	    unsigned int size = sizeof(TEBCdata) + sizeof(void *) *
		+ (reqWords + codePtr->maxExceptDepth - 1);
	    
	    depth = tosPtr - initTosPtr;
	    TD = ckrealloc(TD, size);
	    tosPtr = initTosPtr + depth;

	    TD->capacity = reqWords;




	}
	
	/*
	 * Expand the list at stacktop onto the stack; free the list. Knowing
	 * that it has a freeIntRepProc we use Tcl_DecrRefCount().
	 */








|
<



|
>
|
>
>
>
>







2291
2292
2293
2294
2295
2296
2297
2298

2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
	    + (CURR_DEPTH - TclGetInt4AtPtr(pc+1))
	    /* plus how many are needed for this expansion */
	    + objc - 1;

	(void) POP_OBJECT();
	if (reqWords > TD->capacity) {
	    ptrdiff_t depth;
	    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;
	}
	
	/*
	 * Expand the list at stacktop onto the stack; free the list. Knowing
	 * that it has a freeIntRepProc we use Tcl_DecrRefCount().
	 */