<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Feb 23, 2015, at 7:50 AM, Thierry Goubier &lt;<a href="mailto:thierry.goubier@gmail.com">thierry.goubier@gmail.com</a>&gt; wrote:</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-02-23 16:36 GMT+01:00 Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Thierry,<br>
<br>
&nbsp; &nbsp; &nbsp;there's an unadvertised primitive called Context&gt;&gt;#xRay (or ContextPart&gt;&gt;#xRay) that answers these questions for tests.&nbsp; I'm away from the system right now but I'll get you the source soon.&nbsp; Also, the limit on jutting methods, 60 literals, is a default. There's a command line option -maxcoglits (IIRC) that you can change.<br></blockquote><div><br></div><div>Thanks Eliot!<br><br></div><div>It's helping a lot to guide me, even if I have to work at the ast level and, as a result, I estimate the number of literals in the bytecode by counting the number of literal nodes in the AST, with the approximation that ~100 literal nodes will make it under the limit.<br><br></div><div>Making it under the limit shaves 30% of the execution time of a parse with SmaCC. And it avoids the too long methods as a side benefit.<br><br></div><div>I would dream of having precise ways of estimating things like that on the AST. It's interesting to hit those "I'd like to be able to predict the performance of that piece of code" issues.<br></div></div></div></div></div></blockquote><div><br></div>Alas two things other than the AST affect the number of literals. &nbsp;First is the specialSelectors; these are used for sends only. &nbsp;So if a method only sends one of the special selectors the selector will not occur in the method as a literal. &nbsp;Second is the bytecode set. &nbsp;While we only have one set now, Sista is introducing another, and Newspeak has its own. &nbsp;In the current set, -1, 0, 1 &amp; 2 and true and false have bytecodes to push these literals, so they don't occur as literals in methods. &nbsp;In both the&nbsp;<span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">Sista</span>&nbsp;and the&nbsp;<span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">Newspeak sets there are bytecodes that encode a much wider range of integers and characters as bytecodes (a push literal bytecode takes 1 byte for the bytecode and 4 or 8 bytes for the literal; a bytecode for the 16-bit integer range takes 3 bytes). &nbsp;</span><div><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);"><br></span></div><div><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);">Another thing that affects the number of literals is the compiler's decision to include selectors for optimized methods such as ifTrue: et al (which I think is a very good thing).</span></div><div><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);"><br></span></div><div><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);">If you could ask the back end which literal would be encoded as a literal (and if course the question is asked when bytecode is generated) you could get a more accurate count.</span></div><div><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);"><br></span></div><div><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);"><br></span></div><div><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);">HTH</span></div><div><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);"><br></span><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Thierry<br></div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Eliot (phone)<br>
<div class="HOEnZb"><div class="h5"><br>
On Feb 23, 2015, at 5:05 AM, Thierry Goubier &lt;<a href="mailto:thierry.goubier@gmail.com">thierry.goubier@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Hi All,<br>
&gt;<br>
&gt; anybody knows how to check if a method is jitted or not?<br>
&gt;<br>
&gt; I remember (maybe wrongly) that the Jit in Cog has a configurable limit on the number of bytecodes for a method to be jitted or not; I'm looking into the performance of generated code where I can, more or less, control the length of methods (SmaCC) and I'd like to find the optimum point.<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Thierry<br>
<br>
</div></div></blockquote></div><br></div></div>
</div></blockquote></div></body></html>