On Mon, Apr 8, 2013 at 6:02 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span> wrote:<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="gmail_quote"><div class="im">On Mon, Apr 8, 2013 at 9:32 AM, Alexandre Bergel <span dir="ltr">&lt;<a href="mailto:alexandre.bergel@me.com" target="_blank">alexandre.bergel@me.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word">What I had in mind, is something like:<div>-=-=-=-=-=-=-=-=-=-=</div><div>myMethodWithBranch</div><div><span style="white-space:pre-wrap">        </span>self foo.</div><div><span style="white-space:pre-wrap">        </span>v </div>
<div><span style="white-space:pre-wrap">                </span>ifTrue: [ ... ]</div><div><span style="white-space:pre-wrap">                </span>ifFalse: [ ... ]</div><div>-=-=-=-=-=-=-=-=-=-=</div><div><br></div><div>-=-=-=-=-=-=-=-=-=-=</div><div>
myMethodWithBranch<br><span style="white-space:pre-wrap">        </span>self foo.</div><div><span style="white-space:pre-wrap">        </span>v <br><span style="white-space:pre-wrap">                </span>ifTrue: [ <b>self checkPoint: 1.</b> ... ]<br>
<span style="white-space:pre-wrap">                </span>ifFalse: [ <b>self checkPoint: 2.</b> ... ].</div><div><span style="white-space:pre-wrap">        </span><b>self checkPoint: 3.</b></div><div>-=-=-=-=-=-=-=-=-=-=</div><div><br></div><div>
All these checkpoint will be inserted by manipulating the bytecode. You can then optimize a bit by removing checkpoints that have been reached.</div><div>The method #checkPoint: could then use some attributes to the CompiledMethod.</div>
<div><br></div><div>This is a common technique when (i) the VM does not give you what you need and (ii) when you do not want to change the VM.</div></div></blockquote><div><br></div></div><div>I just implemented something to this effect for our project at Cadence.  It works by</div>
<div>- an assembler/disassebler that can convert a method into a sequence of messages, one for each of its bytecodes and back</div><div>- using the disassembler to obtain labels which occur at the start of each basic block</div>
<div>- replacing the first bytecode in every basic block with an illegal bytecode, remembering the pc and its correct bytecode in the method properties</div><div>- implementing a method on MethodContext which receives the unknowBytecode message sent by the VM when it encounters an illegal bytecode</div>
<div>- the method replaces the illegal bytecode with the correct bytecode, removing the entry from properties, and continues</div><div><br></div><div>The JIT refuses to compile methods that contain illegal bytecodes so this runs at interpreter speed until a method no longer contains illegal bytecodes (has been completely covered).  But the illegal bytecode is executed at most once for each basic block, since it is replaced immediately it is executed.  The information remaining in properties is that of the basic blocks that have not been executed.</div>
<div> </div><div>In the Squeak/Pharo bytecode set there are three unknown bytecodes, 126, 127 &amp; 139.  I have a Monticello package and tests if you&#39;re interested.</div><div><div class="h5"></div></div></div></blockquote>
<br><div class="gmail_quote">On Mon, Apr 8, 2013 at 11:06 PM, Frank Shearar <span dir="ltr">&lt;<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a>&gt;</span> wrote:</div><div class="gmail_quote">
...<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I most definitely am!<br>
<span class="HOEnZb"><font color="#888888"><br>
frank</font></span></blockquote><div><br></div>On Tue, Apr 9, 2013 at 10:19 AM, Marcel Taeumel <span dir="ltr">&lt;<a href="mailto:marcel.taeumel@student.hpi.uni-potsdam.de" target="_blank">marcel.taeumel@student.hpi.uni-potsdam.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Me, too! :)<br>
</blockquote><div> </div><div>On Tue, Apr 9, 2013 at 12:32 PM, Alexandre Bergel <span dir="ltr">&lt;<a href="mailto:alexandre.bergel@me.com" target="_blank">alexandre.bergel@me.com</a>&gt;</span> wrote:<div>... </div><div>
<br></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Yes please. I am interested!<br>
</blockquote><br></div><div><br></div><div>OK, in <a href="http://ss3.gemstone.com/ss/MethodMassage">http://ss3.gemstone.com/ss/MethodMassage</a> are the two packages needed to make this work in Squeak trunk.  I added Frank and Alexandre as developers.  Marcel, I couldn&#39;t find you.  If you want to be added you&#39;ll have to register.  BytecodeCoverageTests is the place to start looking.</div>
<div><br></div><div>I&#39;d love to see someone use this to do fast shape change on class redefinition.</div></div>-- <br>cheers,<div>Eliot</div>