Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f2bfaa2def716cc287d459b89623eedc643473aa365662c8781a38914ea33498
Ticket: 1095bf7f756f9aed6bdef5b6f36e3f42f4dc372e
ensembles seem to be not compiled in safe interp
User & Date: sebres on 2024-06-13 12:44:41
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    <blockquote><i>
    JulianNoble (via tclchat) 2024-06-13 07:29:42 UTC:
    
    Hi all. Are there some known differences in how compilation works in a safe interp?  I am looking into performance differences and notice from tcl::unsupported::disassemble that no jump tables seem to be generated for switch statements within a 'dict for' script in safe base interps - yet they are in a normal interp.
    </i></blockquote>
    
    My PoC (see below) shows that it is indeed not compiled...
    
    But I'd use the command directly (without ensemble) it works as expected.
    
    So it looks like ensembles compilation is avoided in safe interpreters in 8.6+ for whatever reasons.
    
    PoC:
    <code><pre style="padding-left:10pt">
    % proc test {d} { <b>dict for</b> {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test
      ...
      Command 1: "<b>dict for</b> {k v} $d { something $k $v } "
        <span style="color:green">(0) loadScalar1 %v0         # var "d"
        (2) beginCatch4 0
        <b>(7) dictFirst %v3   # temp var 3</b></span>
        (12) jumpTrue4 +42  # pc 54
      ...
    
    % interp create -safe si
    % <b>si eval</b> { proc test {d} { <b>dict for</b> {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test }
      ...
      Command 1: "<b>dict for</b> {k v} $d { something $k $v } "
        <span style="color:red">(0) push1 0         # "dict"
        (2) push1 1         # "for"
        (4) push1 2         # "k v"
        (6) loadScalar1 %v0         # var "d"
        (8) push1 3         # " something $k $v "
        <b>(10) invokeStk1 5</b></span>
        (12) done
    
    % # test with direct command not ensemble...
    % <b>si eval</b> { proc test {d} { <b>tcl::dict::for</b> {k v} $d { something $k $v } }; tcl::unsupported::disassemble proc test }
      ...
      Command 1: "<b>tcl::dict::for</b> {k v} $d { something $k $v } "
        <span style="color:green">(0) loadScalar1 %v0         # var "d"
        (2) beginCatch4 0
        <b>(7) dictFirst %v3   # temp var 3</b></span>
        (12) jumpTrue4 +42  # pc 54
      ...
    <pre></code>
    
    However it works in 8.5 as expected.
    
  5. foundin changed to: "8.6+"
  6. is_private changed to: "0"
  7. login: "sebres"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "50e9528765c18296566374b3fde2df942c394efd"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "sebres"
  14. subsystem changed to: "47. Bytecode Compiler"
  15. title changed to: "ensembles seem to be not compiled in safe interp"
  16. type changed to: "Bug"