Tcl Source Code

Artifact [9d09f61c99]
Login

Artifact 9d09f61c99c7a196948e55b7a3c9b9c86887e0c9fb18a0bf8e53f45c4fafca90:

Ticket change [9d09f61c99] - New ticket [552ed5eac5] Strange discrepancy regarding INST_START_CMD in body of cycles if compiled with or without invocation in condition/iterator.... by sebres 2018-04-20 20:33:30.
D 2018-04-20T20:33:30.281
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment During\sworking\son\smy\sperformance\sbranch\s(BTW\sinterim\sstate:\s8.6th\sis\sca.\s6-7\stimes\sfaster\snow,\sbut\sI'm\sconfident\sit'll\soutperform\s10x\splank\ssoon),\sI\sfound\sstrange\sdiscrepancy\sbetween\stwo\salmost\sequal\scode-pieces.\r\n\r\nIf\sone\stake\sa\slook\sinto\sthe\sbyte-code\sof\sfollowing\sscripts,\she\snotes\seach\sset-command\sin\sfirst\sbody\sreceives\sadditionally\sa\s9-byte\sinstruction\s"startCommand"\s(INST_START_CMD).\sThis\sis\sgood\sso\s(is\salso\svery\sfast\scommand),\sbut\sthe\ssecond\sbody\stotally\smisses\sit.\r\n\r\nJust\scompare\sboth\sdisassemble-outputs\sof:\r\n<code><verbatim>\r\nproc\sx\s{}\s{while\s{[t]}\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}};\stcl::unsupported::disassemble\sproc\sx\r\nproc\sx\s{}\s{while\s{$va}\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}};\stcl::unsupported::disassemble\sproc\sx\r\n</verbatim></code>\r\nTherefore\sit\sresults\sin:\r\n\r\n<code><verbatim>\r\nSource\s"while\s{[t]}\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}"\r\nCmds\s6,\ssrc\s52,\sinst\s68,\slitObjs\s6,\saux\s0,\sstkDepth\s1,\scode/src\s0.00\r\n...\r\nSource\s"while\s{$va}\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}"\r\nCmds\s5,\ssrc\s52,\sinst\s30,\slitObjs\s5,\saux\s0,\sstkDepth\s1,\scode/src\s0.00\r\n...\r\n</verbatim></code>\r\n\r\nThe\ssame\sis\svalid\sfor\sall\scycles\s(resp.\sbody\scompilations\sso\sdifferent\sif\sit\sdoes\sor\sdoes\snot\scontain\sinvocation),\se.\sg.\son\sfollowing\s"foreach":\r\n\r\n<code><verbatim>\r\nproc\sx\s{}\s{set\si1\s0;\sunset\si1;\sforeach\sa\s[test_itr]\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}};\stcl::unsupported::disassemble\sproc\sx\r\nproc\sx\s{}\s{set\si1\s0;\sunset\si1;\sforeach\sa\s{a1\sa2\sa3}\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}};\stcl::unsupported::disassemble\sproc\sx\r\n</verbatim></code>\r\n\r\nresults\sin:\r\n\r\n<code><verbatim>\r\nSource\s"set\si1\s0;\sunset\si1;\sforeach\sa\s[test_itr]\s{set\si0\s0;\sset..."\r\nCmds\s8,\ssrc\s81,\sinst\s102,\slitObjs\s6,\saux\s1,\sstkDepth\s4,\scode/src\s0.00\r\n...\r\nSource\s"set\si1\s0;\sunset\si1;\sforeach\sa\s{a1\sa2\sa3}\s{set\si0\s0;\sset..."\r\nCmds\s7,\ssrc\s81,\sinst\s46,\slitObjs\s6,\saux\s1,\sstkDepth\s4,\scode/src\s0.00\r\n...\r\n</verbatim></code>\r\n\r\nAnd\seach\s68\svs\s30\sresp.\s74\svs\s36\sbytes\sof\scode.\r\nThis\sis\swrong\s(and\sweird\sat\sall).\r\n\r\nBTW.\sStrange\sis\salso,\sin\s8.5\sas\swell\sas\sin\smy\s(own)\sanother\sTclSE-edition,\sI\scan't\ssee\sthe\ssame\sbehavior\s(but\ssome\stime\sago\sI've\srewritten\sthere\sthe\shandling\sround\sabout\s"startCommand",\sso\sfor\sexample\sI\sdon't\shave\sthere\s`envPtr->atCmdStart`\sat\sall,\sit\swas\simplemented\sother\sway).\r\n\r\nI'm\srelative\ssure,\sthis\s4\sextra\s"startCommand"\scommands\sin\sbody\sare\smissed\sin\sboth\ssecond\svariants\s(I'm\ssure\sthis\swill\swrong\scalculate\sthe\scount\sof\sinterpreted\scommand).\r\nSo\sfor\sexample\s"info\scmdcount"\sas\swell\sas\sinterpreter\slimit\swill\swork\stotally\swrong.\r\n\r\nFollowing\sexample\sillustrates\sthe\sissue:\r\n\r\n<code><verbatim>\r\nproc\sretv\s{v}\s{return\s$v}\r\nset\si\s0\r\nforeach\sc\s{\r\n\s\s\s\s{\sset\sj\s10;\swhile\s{[retv\s[incr\sj\s-1]]}\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}\s}\r\n\s\s\s\s{\sset\sj\s10;\swhile\s{\s\s\s\s\s\s[incr\sj\s-1]\s}\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}\s}\r\n\s\s\s\s{\sforeach\sj\s[retv\s{9\s8\s7\s6\s4\s3\s2\s1}]\s\s\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}\s}\r\n\s\s\s\s{\sforeach\sj\s\s\s\s\s\s\s{9\s8\s7\s6\s4\s3\s2\s1}\s\s\s\s{set\si0\s0;\sset\si1\s1;\sset\si2\s2;\sset\si3\s3}\s}\r\n}\s{\r\n\s\s\s\sproc\stest_[incr\si]\s{}\s$c\r\n}\r\nproc\stest\s{}\s{\r\n\s\s\s\sforeach\si\s{1\s2\s3\s4}\s{\r\n\s\s\s\s\s\s\s\sputs\s"[set\scc\s[info\scmdcount]]"\r\n\s\s\s\s\s\s\s\stest_$i\r\n\s\s\s\s\s\s\s\sputs\s"++\s[expr\s{[info\scmdcount]\s-\s$cc}]"\r\n\s\s\s\s}\r\n}\r\ntest\r\n</verbatim></code>\r\n\r\nResult\sshould\sbe:\r\n<code><verbatim>\r\n++\s62\r\n++\s52\r\n++\s38\r\n++\s37\r\n</verbatim></code>\r\nAnd\sin\scurrent\s8.6th\sit\sresults\sin:\r\n<code><verbatim>\r\n++\s62\r\n++\s5\s\s\s\s\s*WRONG*\r\n++\s38\r\n++\s5\s\s\s\s\s*WRONG*\r\n</verbatim></code>
J foundin 8.6
J is_private 0
J login sebres
J priority 5\sMedium
J resolution None
J severity Important
J status Open
J submitter sebres
J subsystem 47.\sBytecode\sCompiler
J title Strange\sdiscrepancy\sregarding\sINST_START_CMD\sin\sbody\sof\scycles\sif\scompiled\swith\sor\swithout\sinvocation\sin\scondition/iterator...
J type Bug
K 552ed5eac53ff5e4685badea56935871627aff34
U sebres
Z 1df2be09421b4c19c406df2bf2c0d8ed