Skip to content
Tcl Source Code View Ticket
Login

View Ticket

NRE: streamline Tcl's evaluation stacks?

Open2037611fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 17 years ago
Descriptionplain2008-08-04 13:56:28
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.
msoferplain2008-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.
msoferplain2008-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" (?).
msoferplain2009-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.
msoferplain2010-05-28 06:38:40
That last comment is now outdated: coros are NRE-aware, and TEBC got a bit better in the meantime.
Log in (anonymous is fine) to add a comment.