Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 46abe8b2d103be46d93a34eca2525fda8f90d733
Ticket: 483611ffffffffffffffffffffffffffffffffff
codePtr->maxStackDepth badly computed
User & Date: msofer on 2001-12-10 19:27:15
Changes

  1. icomment:
    
    
    File Added - 14437: fixLevels2.patch
    
    Logged In: YES 
    user_id=148712
    
    A new patch (fixLevels2.patch) that computes the tcl
    required stack almost perfectly (see below), does it
    automatically for code with no jumps and is not more
    expensive than the original implementation. The patch also
    includes the testing code (effective under
    TCL_COMPILE_DEBUG) of validate.patch.
    
    The way it works is:
    
    1. the instruction description table got a new int field
    stackEffect, populated at the start of tclCompile.c
    
    2. the macros that push instructions (in tclCompile.h) also
    manage the depth count. The computations are correct for
    linear code; commands that have non-linear flow have to take
    care to set the new field envPtr->currStackLevel correctly
    at the start of each basic block.
    
    3. the compile procs in (tclCompCmds.c, tclCompExpr.c) for
    all commands that emit jumps were adapted:
    TclCompileCatchCmd, TclCompileForCmd, TclCompileForeachCmd,
    TclCompileIfCmd, TclCompileWhileCmd, CompileLandOrLorExpr,
    CompileCondExpr. 
    
    The stack balance of two instructions is overestimated:
      - callBuiltinFunc1 is set to have a stack balance of +1,
    corresponding to inbuilt math functions with no arguments;
    the correct is (1-numArgs).
      - lindexMulti is set to have a stack balance of (1-opnd)
    instead of the correct (-opnd). This is the only instruction
    that has the stack balance "coded" in the first operand
    where the formula (1-opnd) is not correct ...
    
    Both could be corrected, at the cost of a slight code
    complication. As overestimates are safe, this was not deemed
    necessary.
    
    
  2. login: "msofer"
  3. mimetype: "text/plain"
  4. username: "msofer"