<div dir="ltr"><div dir="ltr">Hi Eliot!</div><div dir="ltr"><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>Hence the solution top your problem is to use FullBlocks.  The SistaV1 bytecode set supports full blocks, which means it is possible to use a separate CompiledBlock for every block in a method. In Squeak one has to set the Preferred bytecode set encoder class preference to EncoderForSistaV1 and recompile the system (the system supports up to two bytecode sets).</div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>What is FullBlocks? could you comment on that or point to some reading?</div><div>In the meantime I'll take a look at the code.</div><div>Also, could you send me a link to read about Sista? I don't remember the details of it.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>The support is in Squeak and fully tested there (my work image uses the SistaV1 bytyecode set).  Some of the support is in Pharo 7, but there is no preference and so no easy way to force the use of SistaV1 and Full Blocks.  I don't know if the support has been ported to Cuis from Squeak, but it should not be difficult to do.  </div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>Not it has not... I'll ask Juan what his plan is about it.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div> </div><div><br></div><div>Well it is difficult to explain.  But a key insight is that the Decompiler solves exactly this problem in mapping from bytecodes back to source, and that the Debugger solves this problem in displaying the temporary variables that are in scope.  So if you have a look at the code in DebuggerMethodMap you should find an API that provides what you want. </div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>yes yes, I have read it and that gives me all I need from the image point of view, but the problem is in the VM</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div> For example, these Context methods all use the relevant API for linearizing temps:</div><div><br></div><div><i>Context methods for debugger access</i></div><div><div><b>namedTempAt:</b> index</div><div><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>"<i>Answer the value of the temp at index in the receiver's sequence of tempNames.</i>"</div><div><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>^self debuggerMap namedTempAt: index in: self</div></div><div><br></div><div><div><b>namedTempAt:</b> index <b>put:</b> aValue</div><div><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">       </span>"<i>Set the value of the temp at index in the receiver's sequence of tempNames.</i></div><div><i><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">      </span> (Note that if the value is a copied value it is also set out along the lexical chain,</i></div><div><i><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>  but alas not in along the lexical chain.).</i>"</div><div><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>^self debuggerMap namedTempAt: index put: aValue in: self</div></div><div><br></div><div><div><b>tempNames</b></div><div><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>"<i>Answer a SequenceableCollection of the names of the receiver's temporary </i></div><div><i><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">       </span> variables, which are strings.</i>"</div><div><br></div><div><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>^ self debuggerMap tempNamesForContext: self</div></div><div><br></div><div><div><b>tempsAndValues</b></div><div><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>"<i>Return a string of the temporary variables and their current values</i>"</div><div><span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">     </span>^self debuggerMap tempsAndValuesForContext: self</div></div><div><br></div><div>So for example if I evaluate this:</div><div><br></div><div>    (1 to: 2) inject: 0 into: [:a :b| ^thisContext sender tempsAndValues]<br></div><div><br></div><div>I get this:</div><div><br></div><div><div>'thisValue: <span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">     </span>0</div><div>binaryBlock: <span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>[closure] in Context class>>DoIt</div><div>nextValue: <span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">      </span>0</div><div>each: <span class="gmail-m_3832181229746031464gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>1</div><div>'</div></div><div><br></div><div>So the simplified API is provided by DebuggerMethodMap.</div><div><br></div><div>But you want to do this in the VM.  That's a lot harder, and it makes the VM implementation very dependent on the specific compiler implementation.  If you go with Full Blocks things may not be too bad.  But moving things up to the image level will make everything a lot easier, faster to develop, and extensible.</div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>I try to do the least possible in the VM, in fact the changes I made are very simple and independent of the compiler/etc. Doing it on the image side (using meta-links for example in Pharo) is too slow and not really usable. What I did is usable and simple, I'm working with that VM/image all the time and works great.</div><div>I'll see what you suggest of FullBlocks and see how it can help... in the meantime I think I'll do the option 4) explained bellow. </div><div>I'll keep you posted</div><div><br></div><div>Thanks!</div><div>Hernan.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div> After a lot of ideas and possibilities, I found that the method/closure start pc could be use to decide the array's index to use (based on something similar to what CompiledMethod>>#startpcsToBlockExtents returns). <br></div><div> So, every time a new activation context is created (for example StackInterpreter>>#activateNewClosure:outer:method:numArgs:mayContextSwitch:, StackInterpreter>>#internalActivateNewMethod and so on) I can use the start pc to calculate the array's index.</div><div> So, let's say I have that solved too, now the problem is how can I access that index from the bytecode's code?. I have the following ideas:</div><div>1) Add an inst. var. to MethodContext that will have the index (or even better, the local's types array). So every time a new context is created, I calculate the index based on the PC and set that inst. var. </div><div>2) Do the same as in 1) but adding an inst. var. to BlockClosure (better than 1 because the closure is created once while the method context could be created more than once for the same closure)</div><div>3) Push the calculated index in the stack (as the IP, SP, etc. are pushed). Based on the num. args + num. temps., calculate the position in the stack of that index every time a type has to be saved.</div><div>4) Have an interpreter variable as 'method' but called, let's say, 'contextVarsTypes' that is set every time a new activation is created. The previous contextVarsTypes value is pushed in the stack and restore from it when exiting a context.</div><div><br></div><div>The problem with 1) and 2) is that MethodContext and BlockClosure can not be modified (at least not easily, a new image format would be needed, etc), but the advantage is that I don't have to worry about that value when a context is leaved. </div><div>Between 3) and 4) and think 4) is faster but I'm not sure that if a GC is executed and the array moved (let's say contextVarsTypes points directly to the types array), that contextVarsTypes will point to the new arrays position in memory (will that happen? how is 'method' changed if a GC is executed?)</div><div><br></div><div>Which one do you think is better/faster/possible?</div><div>Any advice/comment on this matter will be appreciated. </div><div>If there is an easier/different way to solve this problem, please help me :-)</div><div><br></div><div>Thanks!</div><div>Hernan </div><div><br></div><div><br></div>-- <br><div dir="ltr" class="gmail-m_3832181229746031464gmail-m_-3511358564796884147gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal"><span style="font-weight:bold">Hernán Wilkinson</span><br>Agile Software Development, Teaching & Coaching</span></font></span></span></span></strong></span></div><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal">Phone: +54-011</span></font></span></span></span></strong></span><font face="tahoma, sans-serif" size="2">-4893-2057</font></div><div><strong style="font-family:tahoma,sans-serif;font-size:xx-small"><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">Twitter: @HernanWilkinson</span></font></span></span></strong></div><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal">site: <a href="http://www.10pines.com/" style="color:rgb(17,65,112)" target="_blank">http://www.10Pines.com</a></span></font></span></span></span></strong></span></div><div><font face="tahoma, sans-serif"><span style="border-collapse:collapse">Address: Alem 896</span></font>, Floor 6, Buenos Aires, Argentina</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_3832181229746031464gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal"><span style="font-weight:bold">Hernán Wilkinson</span><br>Agile Software Development, Teaching & Coaching</span></font></span></span></span></strong></span></div><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal">Phone: +54-011</span></font></span></span></span></strong></span><font face="tahoma, sans-serif" size="2">-4893-2057</font></div><div><strong style="font-family:tahoma,sans-serif;font-size:xx-small"><span style="font-size:8pt"><span style="font-size:small"><font size="2"><span style="font-weight:normal">Twitter: @HernanWilkinson</span></font></span></span></strong></div><div><span style="font-family:tahoma,sans-serif;font-size:xx-small;border-collapse:collapse"><strong><span style="font-size:8pt"><span><span style="font-size:small"><font size="2"><span style="font-weight:normal">site: <a href="http://www.10pines.com/" style="color:rgb(17,65,112)" target="_blank">http://www.10Pines.com</a></span></font></span></span></span></strong></span></div><div><font face="tahoma, sans-serif"><span style="border-collapse:collapse">Address: Alem 896</span></font>, Floor 6, Buenos Aires, Argentina</div></div></div></div></div></div></div></div></div></div></div></div></div>