.
D 2010-05-31T00:46:35
J icomment Without\syet\slooking\sat\sthe\stracing\scode,\swhat\sSHOULD\shappen\sin\sthat\nsimplest\sscript\sin\sterms\sof\sCF\sand\sTcl\sstack\smanagement\sis\s[1]:\n\n1.\sinterp\sis\screated\swith\sits\smain\sTcl\sstack\s(execEnv0)\sand\sCF\sptr\srootFramePtr\s(frame0);\sboth\sthings\sare\sallocated\son\sthe\sheap.\sThe\sscript\sis\sevaluated\sin\sthis\s"context"\n\n2.\sWhen\s[boom]\sis\sinvoked\sat\sthe\send\sof\sthe\sscript:\n.\s\s\s\s-\sa\sframe1\s(allocated\sin\sexecEnv0)\sis\spushed:\s[boom]'s\sCF\n.\s\s\s\s-\s[boom]'s\sbody\sis\sevaluated\n.\s\s\s\s-\s[cc]\sis\sinvoked\sin\sframe1\n\n3.\sWhen\s[cc]\sis\sinvoked\sfrom\s[boom]'s\sbody:\n.\s\s\s\s-\sa\sframe2\s(allocated\sin\sexecEnv0)\sis\spushed:\s[cc]'s\sCF\n.\s\s\s\s-\s[cc]'s\sbody\sis\sevaluated\n.\s\s\s\s-\s[coroutine]\sis\sinvoked\sin\sframe2\n\n4.\sWhen\s[coroutine]\sis\sinvoked\sfrom\s[cc]'s\sbody:\n.\s\s\s\s-\sthe\scoroutineData\s(CD)\sstruct\sis\sallocated\son\sthe\sheap,\sthe\scommand\n[C]\sis\screated\n.\s\s\s\s-\sframe2\sis\ssaved\sin\sCD\sas\sthe\scaller\scontext;\sthe\srunning\scontext\sis\nset\sto\sNULL\n.\s\s\s\s-\sa\snew\sTcl\sstack\s(execEnv1)\sis\screated\sfor\sthe\scoroutine;\sthe\ninterp's\sexecEnv\sis\sset\sto\sexecEnv1\sso\sthat\sall\snew\sstack\sallocs\swill\nhappen\shere.\sThe\sold\sexecEnv0\sis\ssaved\sin\sCD->callerEEPtr\n.\s\s\s\s-\sthe\scoroutine\scommand\s"c"\sis\sevaluated\sAS\sA\sSCRIPT\s[2]\sin\sframe2:\sit\nis\sfirst\scompiled,\sthen\sthe\sbytecodes\sare\ssent\sto\sTEBC\n.\s\s\s\s-\sTEBC\ssees\sthat\sthis\sis\sa\scoroutine's\sfirst\srun,\sand\ssets\sthe\ninterp's\sCF\scontext\sto\sthe\sroot\sframe0\s(so\sthat\sthe\scoro\sruns\sin\suplevel\n#0)\n.\s\s\s\s-\sthe\scommand\s[c]\sis\sinvoked\sin\sframe0\n\n5.\sWhen\s[c]\sis\sinvoked\sfrom\s[coroutine]'s\sC\simplementation:\n.\s\s\s\s-\sa\sframe3\s(allocated\sin\sexecEnv1)\sis\spushed:\s[c]'s\sCF\n.\s\s\s\s-\s[c]'s\sbody\sis\sevaluated\sin\sframe3\n.\s\s\s\s-\s[yield]\sis\sinvoked\sin\sframe\s3\n\n6.\sWhen\s[yield]\sis\sinvoked\sfrom\s[c]'s\sbody:\n.\s\s\s\s-\sTEBC\ssuspends\sexecution\sof\s[c]'s\sbytecodes,\ssaves\sits\sinternal\sstate\nin\sexecEnv1\sand\sthen\sresets\sthe\sinterp's\sexecEnv\sto\sexecEnv0\n.\s\s\s\s-\sNRCoroutineCallerCallback\s(the\slast\scallback\sin\sexecEnv0's\snre\nstack)\ssaves\sthe\scoroutine's\srunning\sCF\s"context"\s(frame3)\sin\sthe\sCD\nstruct,\sthen\srestores\sthe\sinterp's\sCF\scontext\sto\sthe\scaller's\s(frame2)\n.\s\s\s\s-\sthe\scaller\sscript\s([cc]'s\sbody)\sresumes\sevaluation;\snothing\sleft\sto\ndo,\sTEBC\sreturns\n.\s\s\s\s-\sInterpProcNR2\spops\sframe2\sfrom\sexecEnv0's\sTcl\sstack;\sinterp\sis\sback\nto\s(execEnv0,\sframe1)\n.\s\s\s\s-\scontrol\sis\sback\sto\s[boom]'s\sscript:\s[C]\sis\sinvoked\sin\sframe1\n\n7.\sWhen\s[C]\sis\sinvoked\sfrom\s[boom]'s\sbody:\n.\s\s\s\s-\sthe\scurrent\scontext\sframe1\sis\ssaved\sin\sCD->caller\n.\s\s\s\s-\sCD->running\s(frame3)\sis\sset\sas\sthe\sinterp's\scurrent\sCF\scontext\n.\s\s\s\s-\sexecEnv1\sis\sset\sas\sthe\scurrent\stcl\sstack,\sexecEnv0\sis\ssaved\sin\sCD->callerEEPtr\n.\s\s\s\s-\sTEBC\sresumes\sexecution\sof\s[c]'\sbytecodes:\snothing\sleft\sto\sdo,\sit\nreturns\n.\s\s\s\s-\sInterpProcNR2\spops\sframe3\sfrom\sexecEnv1's\sTcl\sstack;\sinterp\sis\snow\nat\s(execEnv1,\srootFramePtr)\n\n8.\sThe\sreturn\scauses\sexecEnv1\sto\swind\sdown\scompletely:\s[c]\sreturns,\sthe\nfirst\snre\scallback\sin\sexecEnv1\s(NRCoroutineExitCallback)\sis\srun:\n.\s\s\s\s-\sthe\s[C]\scommand\sis\sdeleted\n.\s\s\s\s-\sexecEnv1\sis\sfreed,\sinterp's\sexecEnv\sis\sset\sexecEnv0\n.\s\s\s\s-\sthe\scontext\sis\sset\sto\sCD->caller\s(ie,\sframe1)\n\n9.\sControl\sreturns\sto\sexecEnv0's\snre\sstack:\sNRCoroutineCallerCallback\nnotices\sthat\sthe\scoro\sis\sdead,\sit\sfrees\sthe\sCD\sstruct\n\n10.\sTEBC\scontinues\sexecution\sof\s[boom]'s\sbody\n.\s\s\s\s-\snothing\sleft\sto\sdo,\sit\sreturns\n.\s\s\s\s-\sInterpProcNR2\spops\sframe1\sfrom\sexecEnv0's\sTcl\sstack\sand\sfrees\sit\n.\s\s\s\s-\sframe0\sis\sback\sto\sbeing\sthe\scurrent\sCF\n\nStep\s7.\sis\sthe\scrucial\sone:\sthe\sCF\sstack\sis\sleft\sin\sa\s"very\sdifficult\sto\nnavigate"\sstate,\sthe\sexpectation\sis\sthat\snobody\sshould\snavigate\sit.\sMy\nguess\sis\sthat\sthe\scrash\sprobably\shappens\son\serror,\swhen\sthe\sTip\s348\nmechanism\sdoes\stry\sto\smake\sit\sthrough\sthe\schasm.\sThe\scoro\smechanism\sdoes\sa\nlot\sof\sthe\sactual\sstack\smanagement\sthrough\snre\scallbacks,\ssaving\sdata\sin\sthe\sCD\nstruct;\sthis\sis\snot\sreflected\sdirectly\sin\sthe\sCF\sstack.\n\n[1]\sthe\sNRE\scallback\sstack\splays\san\simportant\srole\stoo,\sit\sis\spartially\nomitted\sfrom\sthis\sdescription\sto\sclarify\sthe\shappenings\sin\sthe\sCF\sand\nexecEnv\ssubworlds\n\n[2]\stechnical\sdetail:\swe\sneed\sto\sevaluate\sit\sas\sa\scompiled\sscript\sin\sorder\nto\sinsure\sthat\sTEBC\sis\srunning;\sthis\sis\sneeded\sfor\sproper\smanagement\sof\nyet-another\sstack\sof\sstructs\sthat\sis\smaintained\sby\sTEBC.\sYou\sdon't\s(yet?)\nwant\sto\sknow.\n
J login msofer
J mimetype text/plain
J username msofer
K 3008307fffffffffffffffffffffffffffffffff
U msofer
Z 24efb3f2ad0ec3c006c662639764fd7e