Artifacts Associated With Ticket 575194ffffffffff
Ticket change [46c8ff16b8] (rid 99573) by pspjuth on 2002-06-28 20:56:25:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
In compile code (e.g. tclCompCmds.c) the combo TclEmitPush and TclRegisterLiteral is rather common. Typically: TclEmitPush(TclRegisterLiteral(envPtr, valueTokenPtr[1].start, valueTokenPtr[1].size, /*onHeap*/ 0), envPtr); However, TclEmitPush is a macro which uses its first argument eight times and passes it at least three times, which makes the above statement rather wasteful. This is normally not any danger since TclRegisterLiteral can be called repeatedly without anything changing, if onHeap is 0 which is the normal case. With onHeap = 1, it becomes disaster since the successive calls deallocates the string. A naughty trap for an innocent coder who likes to copy code nearby :-) So, either a big warning sign should be placed on TclEmitPush and every use of the combo should be rewritten so the literal index is stored in a var first: objIndex = TclRegisterLiteral(envPtr, valueTokenPtr[1].start, valueTokenPtr[1].size, /*onHeap*/ 0); TclEmitPush(objIndex, envPtr); or, maybe TclEmitPush can be recoded to something better, like a function or e.g.: #define TclEmitPush(objIndex, envPtr) \ { register int __objIndex__ = (objIndex); \ if ((__objIndex__) <= 255) { \ TclEmitInstInt1(INST_PUSH1, (__objIndex__),\ (envPtr)); \ } else { \ TclEmitInstInt4(INST_PUSH4, (__objIndex__),\ (envPtr)); \ } \ } - foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "pspjuth"
- subsystem initialized to: "47. Bytecode Compiler"
- title initialized to: "Wasteful code in compile"
- type initialized to: "Bug"
Ticket change [7221f74cf8] (rid 100806) by andreas_kupries on 2002-06-29 04:01:18:
- icomment:
Logged In: YES user_id=75003 Recoding things to use RegisterLiteral only once should also speed up the compiler, as it doesn't have to call the function multiple times. Expensive calls I guess. Prio up.
- login: "andreas_kupries"
- mimetype: "text/plain"
- priority changed to: "7 High"
- username: "andreas_kupries"
- icomment:
Ticket change [e337a7af7e] (rid 87753) by msofer on 2002-06-29 04:25:54:
- closedate changed to: "2002-06-28T21:25:54"
- closer changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 Thanks for catching that; fixed.
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "msofer"