<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 2, 2013, at 1:35 , Henrik Johansen &lt;<a href="mailto:henrik.s.johansen@veloxit.no">henrik.s.johansen@veloxit.no</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 1, 2013, at 10:17 , Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On Thu, Aug 1, 2013 at 10:15 AM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote">On Thu, Aug 1, 2013 at 1:21 AM, Clément Bera <span dir="ltr">&lt;<a href="mailto:bera.clement@gmail.com" target="_blank">bera.clement@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

&nbsp;<br><div dir="ltr">Hello Eliot,<div><br></div><div>So I implemented clean blocks with Opal in Pharo 3. I didn't know where to put the byte code of the clean block, so I put it at the end of the method.</div><div><br>

</div>

<div>ex:</div><div><div>exampleCleanBlock</div><div><span style="white-space:pre-wrap">        </span>^ [ 1 &nbsp;+ 2 ]&nbsp;</div>


</div><div><br></div><div><div>17 &lt;20&gt; pushConstant: [...]</div><div>18 &lt;7C&gt; returnTop</div><div>19 &lt;76&gt; pushConstant: 1</div><div>20 &lt;77&gt; pushConstant: 2</div><div>21 &lt;B0&gt; send: +</div><div>






22 &lt;7D&gt; blockReturn</div></div><div><br></div><div>having in the literal Array:</div><div>[ 1 + 2 ]</div>#exampleCleanBlock<div>OCOpalExamples</div><div><br></div><div>The startpc of the block is 19.</div>

<div>Its outerContext is a context with nil as receiver and the method OCOpalExamples&gt;&gt;#exampleCleanBlock.</div><div>Its numArgs is 0 and it has no copiedValues.</div><div><br></div><div>But it does not work with the JIT.<br>
</div></div></blockquote></div></blockquote><div><br></div><div>Thinking about it I'm pretty sure the problem is that the JIT scans for and counts pushClosure: bytecodes to know how many blocks a method contains, but clean blocks don't need pushClosure: bytecodes. &nbsp;So the JIT needs to look for clean blocks, e.g. either by scanning a method's literals or by looking at the arguments of pushLiteral: bytecodes. &nbsp;In any case the image will allow me to develop a fix.</div>
</div></blockquote><br></div><div>Hi!</div><div>Made a non-Opal version that works in 2.0, located at&nbsp;<a href="https://dl.dropboxusercontent.com/u/6751081/BlockTest.zip">https://dl.dropboxusercontent.com/u/6751081/BlockTest.zip</a> together with a startup script that loads the package, then crashes the image.</div><div>Note; all three clean block version in the .zip can be #value'd from a Workspace, it's first when you try to run those made by installClean/installCleanMinimal in a loop that the image crashes.</div><div><br></div><div>Cheers,</div><div>Henry</div></div></blockquote>Here's some sample benchmarks, the extra jump&nbsp;required&nbsp;to make it work currently seems to have an appreciable impact on performance:</div><div><br></div><div>{[BlockTest normal] bench . [BlockTest normal value] bench}&nbsp;</div><div>#('7,340,000 per second.' '7,090,000 per second.')</div><div>#('7,050,000 per second.' '7,130,000 per second.')</div><div><br></div><div>BlockTest installCleanWithClosureCreation.</div><div>{[BlockTest clean] bench . [BlockTest clean value] bench} &nbsp;</div><div>#('38,900,000 per second.' '32,600,000 per second.')</div><div>#('39,000,000 per second.' '33,100,000 per second.')</div><div><br></div><div>BlockTest installCleanMinimal.</div><div>{[BlockTest clean] bench . 'Cannot bench without crash'}&nbsp;</div><div>#('48,700,000 per second.' 'Cannot bench without crash') &nbsp;</div><div>#('49,700,000 per second.' 'Cannot bench without crash')</div><div><br></div><div>Cheers,</div><div>Henry</div></body></html>