Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: cc13cd1870bf5a14f9935359a2395246576b3a57
Ticket: 458361ffffffffffffffffffffffffffffffffff
single word scripts get recompiled at each call
User & Date: msofer on 2001-09-04 12:02:38
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    (see also
    http://groups.google.com/groups?hl=en&safe=off&threadm=3B9458E6.93CEF15F%40ActiveState.com&prev=/groups%3Foi%3Ddjq%26as_ugroup%3Dcomp.lang.tcl)
    
    The output of
        proc testproc {args} {set x 1}
        proc test0 {} {puts "proc test0:  [time {testproc}
    100000]"}
        proc test1 {} {puts "proc test1:  [time {testproc }
    100000]"}
        proc test2 {} {eval {puts "proc test2:  [time
    {testproc} 100000]"}}
    
        puts "top level: [time {testproc } 100000]"
        test0
        test1
        test2
    is
        [mig@mini unix]$ tclsh test2
        top level: 4 microseconds per iteration
        proc test0:  20 microseconds per iteration
        proc test1:  4 microseconds per iteration
        proc test2:  4 microseconds per iteration
    
    I think that the problem in test0 is caused by
    shimmering of the literal
    "testproc":
      - it is converted to tclByteCodeType by Tcl_EvalObjEx
      - it is converted to tclCommandNameType by
    Tcl_ExecuteByteCode
    
    So, the difference would be:
       - in test0, "testproc" is parsed, compiled and
    looked up as a 
         command repeatedly
       - at top-level and in test2, "testproc" never
    becomes a 
         tclByteCodeType 
       - in test1, there are two different literals:
    "testproc " is always 
         tclByteCodeType, "testproc" is always
    tclCommandNameType
    
    This would explain why the difference only occurs at
    calls with no
    arguments.
    
    
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "msofer"
  9. subsystem changed to: "47. Bytecode Compiler"
  10. title changed to: "slow calls of cmds with no arguments"
  11. type changed to: "Bug"