Skip to content
Tcl Source Code History Of Ticket 1101710fffffffffffffffffffffffffffffffff
Login

History Of Ticket 1101710fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 1101710fffffffffffffffffffffffffffffffff

  1. Ticket change [38f47a8fc2] (rid 112304) by robert_seeger on 2005-01-13 15:30:56:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      When bytecompiling [if $e ...] vs [if { [expr $e] }
      ..], the second version is faster, due to the
      bytecompiler for "if" not performing an optimization
      that it most likely could. Specifically, it can be seen
      in the information below that the "if" is just pushinhg
      "if" with the arguements and "invokeStk1", whereas the
      "expr" is adding the variable to the stack, then
      calling "exprStk", "tryCvtToNumeric", and "jumpFalse1".
      
      I believe the "if" command could benefit from doing the
      same as the "expr" command in this circumstance.
      
      
      ---- showing the problem ----
      #!/bin/sh
      # This line continues for Tcl, but is a single line for
      'sh' \
          exec tclsh "$0" ${1+"$@"}
      
      set expr1 { 1 < 2 }
      
      time { if $expr1 {} else {} } 10000
      time { if {[expr $expr1]} {} else {} } 10000
      
      load ~/cvs/bytecode/libbytecode.so
      
      proc withBrace {e} { if { [expr $e] } { return 1} else
      { return 2 } }
      proc withoutBrace {e} { if $e { return 1} else { return
      2 } }
      proc noVar {} { if { 1 < 2 } { return 1 } else { return
      2 } }
      
      puts "--- withBrace: [time {withBrace $expr1} 100000]"
      puts "--- withoutBrace: [time {withoutBrace $expr1}
      100000]"
      puts "--- noVar: [time {noVar } 100000]"
      
      puts "--- withBrace\n[bytecode::get withBrace]"
      puts "--- withoutBrace\n[bytecode::get withoutBrace]"
      puts "--- noVar\n[bytecode::get noVar]"
      
      return
      
      --- withBrace: 6 microseconds per iteration
      --- withoutBrace: 9 microseconds per iteration
      --- noVar: 3 microseconds per iteration
      
      --- withBrace
      Header {...} Procedure {
          ReferenceCount 1
          NumArgs 1
          CompiledLocals 1
          Slots {
              0 { Slot 0 Type {scalar arg} Name e}
          }
      } CompiledLiterals {
          0 1
          1 2
      } ExceptionRanges {} Commands {
          0 {Number 1 PC {0 13} Src {1 47}
             Code {"if { [expr $e] } { return 1} else {
      return 2 } "}}
          1 {Number 2 PC {0 2} Src {7 13} Code {"expr $e"}}
          2 {Number 3 PC {6 8} Src {20 27} Code {"return 1"}}
          3 {Number 4 PC {11 13} Src {37 45} Code {"return 2 "}}
      } ByteCodes {
          0  {Number  0 Name loadScalar1
              Operands {{Type OPERAND_UINT1 Value 0 Note {var
      "e"}}}}
          2  {Number  2 Name exprStk         Operands {}}
          3  {Number  3 Name tryCvtToNumeric Operands {}}
          4  {Number  4 Name jumpFalse1
              Operands {{Type OPERAND_INT1 Value 7 Note {pc
      11}}}}
          6  {Number  6 Name push1
              Operands {{Type OPERAND_UINT1 Value 0 Note {"1"}}}}
          8  {Number  8 Name done            Operands {}}
          9  {Number  9 Name jump1
              Operands {{Type OPERAND_INT1 Value 5 Note {pc
      14}}}}
          11 {Number 11 Name push1
              Operands {{Type OPERAND_UINT1 Value 1 Note {"2"}}}}
          13 {Number 13 Name done            Operands {}}
          14 {Number 14 Name done            Operands {}}
      }
      --- withoutBrace
      Header {...} Procedure {
          ReferenceCount 1 NumArgs 1 CompiledLocals 1 Slots {
              0 {Slot 0 Type {scalar arg} Name e}
          }
      } CompiledLiterals {
          0 if
          1 { return 1}
          2 else
          3 { return 2 }
      } ExceptionRanges {} Commands {
          0 {Number 1 PC {0 11} Src {1 36}
             Code {"if $e { return 1} else { return 2 } "}}
      } ByteCodes {
          0  {Number  0 Name push1
              Operands {{Type OPERAND_UINT1 Value 0 Note
      {"if"}}}}
          2  {Number  2 Name loadScalar1
              Operands {{Type OPERAND_UINT1 Value 0 Note {var
      "e"}}}}
          4  {Number  4 Name push1
              Operands {{Type OPERAND_UINT1 Value 1 Note {"
      return 1"}}}}
          6  {Number  6 Name push1
              Operands {{Type OPERAND_UINT1 Value 2 Note
      {"else"}}}}
          8  {Number  8 Name push1
              Operands {{Type OPERAND_UINT1 Value 3 Note {"
      return 2 "}}}}
          10 {Number 10 Name invokeStk1
              Operands {{Type OPERAND_UINT1 Value 5}}}
          12 {Number 12 Name done        Operands {}}
      }
      --- noVar
      Header {...} Procedure {
          ReferenceCount 1
          NumArgs 0
          CompiledLocals 0
      } CompiledLiterals {
          0 1
          1 2
      } ExceptionRanges {} Commands {
          0 {Number 1 PC {0 14} Src {1 44}
             Code {"if { 1 < 2 } { return 1 } else { return 2
      } "}}
          1 {Number 2 PC {7 9} Src {16 24} Code {"return 1 "}}
          2 {Number 3 PC {12 14} Src {34 42} Code {"return 2 "}}
      } ByteCodes {
          0 {Number 0 Name push1
             Operands {{Type OPERAND_UINT1 Value 0 Note {"1"}}}}
          2 {Number 2 Name push1
             Operands {{Type OPERAND_UINT1 Value 1 Note {"2"}}}}
          4 {Number 4 Name lt Operands {}}
          5 {Number 5 Name jumpFalse1
             Operands {{Type OPERAND_INT1 Value 7 Note {pc 12}}}}
          7 {Number 7 Name push1
             Operands {{Type OPERAND_UINT1 Value 0 Note {"1"}}}}
          9 {Number 9 Name done Operands {}}
          10 {Number 10 Name jump1
              Operands {{Type OPERAND_INT1 Value 5 Note {pc
      15}}}}
          12 {Number 12 Name push1
              Operands {{Type OPERAND_UINT1 Value 1 Note {"2"}}}}
          14 {Number 14 Name done Operands {}}
          15 {Number 15 Name done Operands {}}
      } 
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "robert_seeger"
    9. subsystem initialized to: "None"
    10. title initialized to: "Enhanced "if" bytecoding for [if $e ...]"
    11. type initialized to: "RFE"
  2. Ticket change [2c3620c00f] (rid 118860) by robert_seeger on 2005-01-13 22:41:30:

    1. priority changed to: "3 Low"
    2. subsystem changed to: "47. Bytecode Compiler"
  3. Ticket change [b706c81ea4] (rid 125517) by dkf on 2005-01-13 23:37:18:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Wouldn't it be wonderful if that was both possible and easy? :^(
      
       * [expr [rename expr expr2; subst 0]] compiles wrongly, but
      for thoroughly evil reasons.
       * [if {$e} { foo } elseif [set e 1] { bar }] means that you
      have to process expressions in a strange order even if you
      ignore the breakage noted above.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [768a6b9d5a] (rid 105606) by robert_seeger on 2005-01-13 23:57:19:

    1. icomment:
      Logged In: YES 
      user_id=1081558
      
      Indeed, it appears as if the [if { [expr $e] } ...] version
      is faster not because "if" doesn't bytecompile when it
      should, but because "expr" does when it shouldn't :(
      
      
    2. login: "robert_seeger"
    3. mimetype: "text/plain"
    4. username: "robert_seeger"
  5. Ticket change [6c52e6e92d] (rid 128485) by hobbs on 2005-05-31 08:58:57:

    1. assignee changed to: "msofer"
    2. priority changed to: "4"
  6. Ticket change [7522f284f5] (rid 105345) by msofer on 2005-11-26 18:13:15:

    1. closedate changed to: "2005-11-26T11:13:15"
    2. closer changed to: "msofer"
    3. resolution changed to: "Invalid"
    4. status changed to: "Pending"
  7. Ticket change [33fe86b197] (rid 106687) by sf-robot on 2006-01-09 22:31:01:

    1. status changed to: "Closed"
  8. Ticket change [60a14b2e9d] (rid 116032) by sf-robot on 2006-01-09 22:31:02:

    1. closedate changed to: "2006-01-09T15:31:02"
    2. closer changed to: "sf-robot"
    3. icomment:
      Logged In: YES 
      user_id=1312539
      
      This Tracker item was closed automatically by the system. It was
      previously set to a Pending status, and the original submitter
      did not respond within 14 days (the time period specified by
      the administrator of this Tracker).
      
      
    4. login: "sf-robot"
    5. mimetype: "text/plain"
    6. username: "sf-robot"