<br><br><div class="gmail_quote">On Thu, Dec 10, 2009 at 4:57 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@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;">
2009/12/11 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Hi Igor,<br>
&gt;<br>
&gt; On Thu, Dec 10, 2009 at 3:40 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; This question is mostly to Eliot,<br>
&gt;&gt; since he the last who dare to touch the Compiler deeply..<br>
&gt;&gt; My concern is use pattern:<br>
&gt;&gt;<br>
&gt;&gt;        method := methodNode generate: #(0 0 0 0).<br>
&gt;&gt;        ^method copyWithTempsFromMethodNode: methodNode<br>
&gt;&gt;<br>
&gt;&gt; the point of nitpicking is the need of generating a dummy<br>
&gt;&gt; CompiledMethod instance,<br>
&gt;&gt; which used for nothing else than making a copy and attachment of temp<br>
&gt;&gt; names.<br>
&gt;&gt;<br>
&gt;&gt; And, the question, is there a way to skip generating the dummy<br>
&gt;&gt; compiled method and just do:<br>
&gt;&gt;<br>
&gt;&gt;  method := methodNode generateWithTempNames.<br>
&gt;&gt;<br>
&gt;&gt; or:<br>
&gt;&gt;<br>
&gt;&gt;  method := methodNode generate: (methodNode tempsTrailer).<br>
&gt;&gt;<br>
&gt;&gt; ?<br>
&gt;&gt;<br>
&gt;<br>
&gt; I think so, but is it worth-while?  The temp names can only be generated<br>
&gt; correctly once the closure analysis is done, see ensureClosureAnalysisDone<br>
&gt; in generate:.  So you&#39;d have to pass in a flag to generate: saying you<br>
&gt; wanted to append temps, compute the temps after ensureClosureAnalysisDone,<br>
&gt; derive how many bytes they would compress to, and add that to the size of<br>
&gt; the method being computed.  But that would open up details of the<br>
&gt; compression scheme to the generate: method.  But saving one instantiation<br>
&gt; amongst hundreds, perhaps thousands, in an average compile is probably not<br>
&gt; worth it.<br>
&gt; I expect that more worth-while would be to rip out my hack of Dan&#39;s hack<br>
&gt; compression algorithm for temp names and replace it with the use of gzip,<br>
&gt; which is built into the system and does a far better job than my<br>
&gt; modification of Dan&#39;s scheme.<br>
<br>
</div></div>I doubt that gzip will be able to compress well anything which is less<br>
than 100 bytes long.Most of smalltalk methods contain very few temps,<br>
and gzip compression is not working well with very small portions of<br>
data<br></blockquote><div><br></div><div>OK, this is with Nicholas&#39; stream testing doit that crahsed the Cog JIT because it wasn&#39;t ignoring trailing bytes:</div><div><br></div><div>self tempNamesString &#39;timing (strm lineCount)[(strm lineCount)[(strm lineCount)]][(strm lineCount)][(strm lineCount)[(strm lineCount)]][(strm lineCount)][(strm lineCount)[(strm lineCount)]][(strm lineCount)][(strm lineCount)[(strm lineCount)]][(strm lineCount)]&#39;</div>
<div><br></div><div>((ZipWriteStream on: (ByteArray new: 1024))</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>nextPutAll: self tempNamesString asByteArray;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>close;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>encodedStream) contents size 35</div><div>self size - self endPC 167</div><div><br></div><div>(ZipReadStream on: ((ZipWriteStream on: (ByteArray new: 1024))</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>nextPutAll: self tempNamesString asByteArray;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>close;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>encodedStream) contents) contents asString &#39;timing (strm lineCount)[(strm lineCount)[(strm lineCount)]][(strm lineCount)][(strm lineCount)[(strm lineCount)]][(strm lineCount)][(strm lineCount)[(strm lineCount)]][(strm lineCount)][(strm lineCount)[(strm lineCount)]][(strm lineCount)]&#39;</div>
<div><br></div><div>i.e. my adaptation of Dan&#39;s algorithm uses 167 bytes but ZipRead/WriteStream uses 35 bytes.  I note that the empty string takes 2 bytes.  So pretty good :)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
|str|<br>
str := &#39;a b c d e f g h &#39;.<br>
{ str size.  str zipped size } &quot;print it&quot;<br>
<br>
okay, as you said its not possible to determine the right number of<br>
temps without generating the method (a more correct would be - hard ,<br>
not impossible ;) ) however , i think that hiding this behavior inside<br>
method node is worthwhile, because usage pattern, like:<br>
<br>
result := something foo.<br>
result := result bar: something.<br>
<br>
crying for being replaced with just:<br>
result := something zork.<br>
<br>
because otherwise it brings unnecessary detail out of scope of method<br>
generation, which forcing users to repeat same elaborate pattern in<br>
different places.<br>
<br>
The trailing bytes generation is a cryptic stuff.. for instance, why i<br>
see (#0 0 0 0) sent to #generate: everywhere?<br>
Any person who sees it, start asking questions, what if i send #(1 2 3<br>
4) instead , or send #(1).. and generally,<br>
is it safe to pass something else than #(0 0 0 0)?<br>
So, in order to reduce confusion, it is worthwhile to hide<br>
implementation detail from eyes of user.<br>
<br>
If one wants to put a method source pointer, then he should tell<br>
method node to generate method with it:<br>
<br>
methodNode generateWithSourcePointer: anInteger<br>
and if user wants to generate method with temp names, then he can do<br>
it by telling:<br>
methodNode generateWithTempNames<br>
<br>
and if user wants to generate method with arbitrary trailing bytes,<br>
then user should be exterminated and replaced by advanced version<br>
(iUser) :)<br>
<div class="im"><br></div></blockquote><div><br></div><div>Seems eminently reasonable :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">

<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Best regards,<br>
&gt;&gt; Igor Stasenko AKA sig.<br>
&gt;&gt;<br>
&gt;<br>
<br>
<br>
</div>--<br>
<div><div></div><div class="h5">Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</div></div></blockquote></div><br>