Artifacts Associated With Ticket 1661637
Ticket change [394c114588] (rid 112366) by dgp on 2007-02-16 16:09:00:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The attached patch modifies TclSetBytecodeFromAny() so that when the value we are compiling is already a pure list, we produce bytecode directly, and don't go through the waste of reparsing the string rep, and recreating word values out of the tokens produced by parsing. This means we don't shimmer away any possibly valuable internal reps in the elements of the list. As a simple example: set ns ::foo namespace eval $ns {} namespace exists $ns namespace eval [list namespace exists $ns] The first [namespace exists] caches converts value "::foo" to the "nsName" Tcl_ObjType with a cached reference to the Namespace that name represents. Without this patch, that internal rep data is lost when [namespace eval] bytecode compiles the second [namespace exists] command, and the namespace has to be looked up from string value again. With this patch, the value $ns compiles directly into the bytecode, and when INST_INVOKE_STK1 executes the compiled [namespace exists] command, it gets the cached intrep data. This is just a simple example to illustrate the general principle that we ought to keep intreps if it's reasonably easy and there's not a reason not to. This principle has already proved its worth for TCL_EVAL_DIRECT compiles, and inspired lots of [list $cmd $arg] coding style out there. It's strange that the same style has not until now been supported in the bytecompiling branches. - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "47. Bytecode Compiler"
- title initialized to: "direct compile of pure list scripts"
- type initialized to: "RFE"
Ticket change [d189398d95] (rid 113369) by dgp on 2007-02-16 23:09:00:
- icomment:
File Added - 216320: compList.patch
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Add attachment "compList.patch" [2a831a46b2] (rid 118592) by dgp on 2007-02-16 23:09:00.
Add attachment "1661637.patch" [aa72f19d56] (rid 100929) by dgp on 2007-02-17 05:11:57.
Ticket change [821bb64afe] (rid 117174) by dgp on 2007-02-17 05:11:57:
- icomment:
File Added - 216364: 1661637.patch
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [90b2d5dd63] (rid 120494) by dgp on 2007-02-17 05:11:58:
- icomment:
Logged In: YES user_id=80530 Originator: YES miguel observes that most (all?) of these issues can be addressed by intercepting earlier in TclCompEvalObj. The second patch attached takes that approach. Either patch, or even both patches could be committed. File Added: 1661637.patch
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [025fdf637d] (rid 119637) by msofer on 2007-09-13 08:26:41:
- priority changed to: "8"
Ticket change [e5eda3490e] (rid 104213) by msofer on 2008-06-02 22:45:39:
- icomment:
File Added - 279884: 1661637-2.patch Logged In: YES user_id=148712 Originator: NO New patch that intercepts even earlier, in TclEvalObjEx: enable the canonical list optimisation also when TCL_EVAL_DIRECT has not been set. In this way, the compiler isn't ever called on canonical lists. File Added: 1661637-2.patch
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Add attachment "1661637-2.patch" [191cf41ab2] (rid 122766) by msofer on 2008-06-02 22:45:39.
Ticket change [d627d758a4] (rid 123757) by nijtmans on 2008-06-03 03:13:31:
- icomment:
Logged In: YES user_id=61031 Originator: NO The only thing we should worry about is when a list element contains a ';', and it is not constructed using 'list'. E.g.: >set x {puts stdout a;puts stdout b};# string containing two commands puts stdout a;puts stdout b >lindex $x 2;# now $x will become a list, but the string rep is not adapted a;puts > eval $x a b Will this still function the same after applying this patch? A way out of this problem is simply disallowing that string elements contain ';'. Then the 'lindex $x 2' should simply give an error that the string cannot be converted to a valid list. Then, still, it is a slight incompatibility, but at least the user is pointed to the place where the real problem is: Trying to convert such kind of string to a list, which changes the semantics. This can be shown as well by: >lappend x c puts stdout {a;puts} stdout b Now magically, curly braces appear around the "a;puts" For the record: I agree with this patch, but the consequence for the list behavior should be well considered. Regards, Jan Nijtmans - login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [c3a6ef82d4] (rid 111702) by dgp on 2008-06-03 03:17:11:
- icomment:
Logged In: YES user_id=80530 Originator: YES Not to worry, Jan; we've been successfully distinguishing the 'pure' or canonical lists from other lists since the days of 8.3.0.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [192e38ca13] (rid 122773) by dkf on 2008-06-03 05:36:59:
- icomment:
Logged In: YES user_id=79902 Originator: NO To be exact, the current logic distinguishes between lists in "proven canonical form" and everything else. A list is "proven canonical" when it either doesn't have a string representation at all, or when the string representation is derived from the list representation using UpdateStringOfList (IIRC). This avoids all the traps with things like semicolons, newlines, square brackets, etc. while remaining relatively robust in the face of things like debugging (unlike the previously used "pure list" concept). Non-canonical lists (well, they might be canonical, but we can't prove it cheaply) go through the other handling routes, which should be semantically the same even if less efficient in this case.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [f055f865a4] (rid 109176) by msofer on 2008-06-08 10:23:24:
- closedate changed to: "2008-06-08T03:23:24"
- closer changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 Originator: NO The third approach has been committed as part of Patch #1973096
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Accepted"
- status changed to: "Closed"
- username: "msofer"