Tcl Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: 931e4956b91b4545bb294a76faf82d13e11e74db
Title: Interpreter command count not always incremented
Type: Bug Version: 8.6.6
Submitter: apnadkarni Created on: 2017-01-12 17:41:38
Subsystem: 47. Bytecode Compiler Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2017-01-12 17:43:00
Resolution: None Closed By: nobody
    Closed on:
What exactly does [info cmdcount] count? Based on below, it does not seem to count either [incr] or [set] though it does count itself. (ip is a slave interp)

% ip eval {info cmdcount}  
% ip eval {incr i}         
% ip eval {incr i}         
% ip eval {incr i}         
% ip eval {incr i}         
% ip eval {incr i}         
% ip eval {info cmdcount}  
% ip eval {set x 1}        
% ip eval {set x 1}        
% ip eval {set x 1}        
% ip eval {set x 1}        
% ip eval {info cmdcount}  
User Comments: apnadkarni added on 2017-01-12 17:43:00:
Speculation by dgp on the chat:

[23:59]	apn	the [incr i] within the slave interpreter should increment cmdCount for that slave, no?
[23:59]	dgp	One increment happens in the "Dispatch" of any objCmdProc.
[23:59]	dgp	That captures all the "direct eval" of any command.
[00:00]	apn	That's in tclBasic.c
[00:00]	dgp	The other increment is in bytecode execution.
[00:00]	dgp	and has been #ifdef'ed to within an inch of its life.
[00:01]	dgp	and peepholed etc etc.
[00:01]	dgp	Quick, likely faulty analysis.....
[00:01]	dgp	Bytecode execution has given command counting task to INST_START_CMD
[00:02]	dgp	Over time INST_START_CMD was perceived as too much performance drag for too little value, so it's been suppressed in many situations.
[00:03]	dgp	So don't expect bytecode to get correct answers.
[00:03]	dgp	If not for the [interp limit], I'd say just ignore it.
[00:04]	dgp	take a look at the bytecode disassembly for more explorations.
[00:04]	apn	hmm, also turns out that [ip eval {set x 1; set x 1; info cmdcount}] does increment cmdCount correctly
[00:05]	apn	So it's almost like for a single command, INST_START_CMD gets skipped. Or something like that
[00:05]	dgp	"optimized"