From: <no...@so...> - 2002-11-29 09:07:03
|
Patches item #644819, was opened at 2002-11-27 16:36 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=310894&aid=644819&group_id=10894 Category: 44. Bytecode Compiler Group: None Status: Open Resolution: None Priority: 5 Submitted By: Donal K. Fellows (dkf) Assigned to: miguel sofer (msofer) Summary: Bytecompiled [switch] Command Initial Comment: Here's a first attempt at byte-compiling the [switch] command; it needs a lot more work doing, but this should be enough for people to see if I'm going about it the right way. ---------------------------------------------------------------------- >Comment By: Donal K. Fellows (dkf) Date: 2002-11-29 09:07 Message: Logged In: YES user_id=79902 Hmm. Something is still not right with the patch, given how many tests fail when it is applied. I think this needs going over by someone with more experience with the compiler side of things... ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2002-11-28 15:05 Message: Logged In: YES user_id=79902 Ooops! Comment in code was very misleading... ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2002-11-28 14:57 Message: Logged In: YES user_id=79902 Apart from the points Jeff raises (and which should be addressed by the new patch below), there were a great number of problems (relocation fixups and max stack depths were both broken!) (BTW, INST_STR_MATCH wasn't a straight slot-in replacement for INST_STR_EQ because it matters which argument is which. INST_OVER is our savour!) Performance wise on a 700MHz P3 Linux box: % proc foo s { set x 0; set y 0 foreach c [split $s {}] { switch -exact -- $c { a {incr x} b {incr y} } } return $x,$y } % proc bar s { set x 0; set y 0 foreach c [split $s {}] { switch -exact -- $c a {incr x} b {incr y} } return $x,$y } % time {foo shdgsdbcbcsjdsbvbsdjfvbsdbvsldfgsdfsvbsdhfbvlsdvsdbvldvxnvascv} 1000 275 microseconds per iteration % time {bar shdgsdbcbcsjdsbvbsdjfvbsdbvsldfgsdfsvbsdhfbvlsdvsdbvldvxnvascv} 1000 328 microseconds per iteration ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2002-11-27 23:26 Message: Logged In: YES user_id=72656 BTW, handling -glob would be easy - check for the -glob (and optionally --), and call TclEmitInst1(INST_STR_MATCH, 0 /* nocase */, envPtr); optionally instead of TclEmitOpcode (INST_STR_EQ, envPtr); You can look at TclCompileRegexpCmd to reuse some of that code. ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2002-11-27 23:17 Message: Logged In: YES user_id=72656 also the default case in the compiled command isn't checking to make sure that it is the last case, whereas the runtime one does. ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2002-11-27 23:14 Message: Logged In: YES user_id=72656 one thing that would need changing is that compiled commands should never throw an error - they should always throw TCL_OUT_LINE_COMPILE to let the error be raised at runtime (in the odd but possible situation that switch is overridden). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=310894&aid=644819&group_id=10894 |