Re: [TCLCORE] Tcl through X rays
by Miguel Sofer other posts by this author
May 28 2007 2:56PM messages near this date
Re: [TCLCORE] Tcl through X rays
|
Re: [TCLCORE] Tcl through X rays
Donal K. Fellows wrote:
> Mo DeJong wrote:
> > The short answer is that you can't really scan a Tcl proc to figure out
> > if it does not make use of upvar or
> > other linked variables. You can write a compiler that assumes that a
> > proc does not deal with linked variables,
> > but it is trivial to create a test case that breaks this optimization.
>
> You can do it, but it's not at all easy. It depends on collecting
> information on each procedure to find out if it uses tricky commands.
> Initially, you only get to determine what "leaf" procedures are up to,
> but with the leaves figured out, you'll be able to go further up the
> call tree and optimize things further (a procedure is non-tricky if it
> does not call anything tricky). I suspect that much code will do quite
> well from this technique, and everything else will be right where we are
> now. (Getting rid of the current strategy is likely to be impossible,
> even if we add new ones on top.)
Even leaves are not trivial (non-proc commands): if a command is coded
in C, it is not so simple to determine its trickyness - eval and
friends. We would probably need the extension author (and core
maintainer) to signal the non-trickyness of his commands, ie, an api
change in Tcl_Create*Command. Or maybe Tcl_CreateNonTrickyObjCommand.
Note also that trickyness has degrees: it would be important to know how
far up the call stack a certain command can reach with [upvar]. Doing
this would allow to determine that a procedure is non-tricky if it only
calls commands of trickyness <= 1. More generally, the trickyness of a
proc is one less than the maximal trickyness of the commands it calls.
Note however that [eval] and [uplevel] and [trace] must have infinite
trickyness - except if we analyse the trickyness of their respective
scripts too.
Note the nastyness of traces too: would any script that accesses a
global/namespace variable be tricky? What if the variable is traced?
Would we have to analyze the trace script, and keep trace epochs to
determine the need of recompilation?
Another difficulty lies in commands whose names are read from variables,
possibly including methods in (any? some?) OO extension ...
Or maybe you have something else in mind? I certainly would not classify
*you* as non-tricky ;)
Miguel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Tcl-Core mailing list
Tcl-Core@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-core
Thread:
Alexandre Ferrieux
Donal K. Fellows
Alexandre Ferrieux
Mo DeJong
Alexandre Ferrieux
Mo DeJong
Jeff Hobbs
Andreas Leitgeb
Donal K. Fellows
Alexandre Ferrieux
Larry McVoy
Donal K. Fellows
Donal K. Fellows
Alexandre Ferrieux
Miguel Sofer
Rna020
Donal K. Fellows
Donal K. Fellows
Gerald W. Lester
Donal K. Fellows
|