Tcl Source Code

View Ticket
Login
Ticket UUID: 2037611
Title: NRE: streamline Tcl's evaluation stacks?
Type: Bug Created on: 2008-08-04 13:56:28
Submitter: msofer Assigned to: msofer
Subsystem: 45. Parsing and Eval Severity:
Priority: 7 High Last modified: 2010-05-28 06:38:40
Status: Open Closed by:
Resolution: None Closed on:
Version: obsolete: 8.6a1
Description:
The different stacks that are kept by Tcl to manage the flow of evaluation include:

1. The C stack (much relieved since NRE)
2. The CallFrame stack 
3. The Tcl evaluation stack in iPtr->execEnvPtr
4. The CmdFrame stack (TIP #280)
5. The stack of bottomPtr structs in TEBC
6. NRE's callback stack

Each is managed separately in a subtle dance to maintain coordination. The whole thing looks a bit too complicated, it could use some study and maybe a redesign. In particular, 2-5 are related but not identical, maybe they could be merged.
User Comments:
msofer added on 2008-08-10 22:16:46:
Logged In: YES 
user_id=148712
Originator: YES

A big callFrameReform/procReform is called for: as is today, data is also redundant and causes strange bugs when it gets out of sync.
A notable example is that numCompiledLocals can be found in Proc, CallFrame and LocalCache.

The separation of concerns between Proc, CallFrame, ByteCode needs a careful redesign.

Changes here might break extensions that touch/alloc Proc and/or CallFrame directly. These include Itcl, XOTcl, tbcload.

msofer added on 2008-08-10 22:42:21:
Logged In: YES 
user_id=148712
Originator: YES

Note that at least since varReform the procPtr in CallFrame is not really needed: local variables are inspected at runtime from the LocalCache and not the Proc, the procPtr is only needed at frame-pushing time to read procPtr->cmdPtr->nsPtr.

[info frame] also reads procPtr->cmdPtr->nsPtr and procPtr->cmdPtr->clientData from the CmdFrame for "non-standard commands" (?).

msofer added on 2009-06-13 20:32:49:
Note that the current management of the bottomPtr stack (and the confusing state of TEBC) stand in the way of making coroutines NRE-aware.

msofer added on 2010-05-28 06:38:40:
That last comment is now outdated: coros are NRE-aware, and TEBC got a bit better in the meantime.