<br><br><div class="gmail_quote">On Thu, Dec 10, 2009 at 4:57 PM, Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>></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 <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hi Igor,<br>
><br>
> On Thu, Dec 10, 2009 at 3:40 PM, Igor Stasenko <<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>> wrote:<br>
>><br>
>> This question is mostly to Eliot,<br>
>> since he the last who dare to touch the Compiler deeply..<br>
>> My concern is use pattern:<br>
>><br>
>> method := methodNode generate: #(0 0 0 0).<br>
>> ^method copyWithTempsFromMethodNode: methodNode<br>
>><br>
>> the point of nitpicking is the need of generating a dummy<br>
>> CompiledMethod instance,<br>
>> which used for nothing else than making a copy and attachment of temp<br>
>> names.<br>
>><br>
>> And, the question, is there a way to skip generating the dummy<br>
>> compiled method and just do:<br>
>><br>
>> method := methodNode generateWithTempNames.<br>
>><br>
>> or:<br>
>><br>
>> method := methodNode generate: (methodNode tempsTrailer).<br>
>><br>
>> ?<br>
>><br>
><br>
> I think so, but is it worth-while? The temp names can only be generated<br>
> correctly once the closure analysis is done, see ensureClosureAnalysisDone<br>
> in generate:. So you'd have to pass in a flag to generate: saying you<br>
> wanted to append temps, compute the temps after ensureClosureAnalysisDone,<br>
> derive how many bytes they would compress to, and add that to the size of<br>
> the method being computed. But that would open up details of the<br>
> compression scheme to the generate: method. But saving one instantiation<br>
> amongst hundreds, perhaps thousands, in an average compile is probably not<br>
> worth it.<br>
> I expect that more worth-while would be to rip out my hack of Dan's hack<br>
> compression algorithm for temp names and replace it with the use of gzip,<br>
> which is built into the system and does a far better job than my<br>
> modification of Dan'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' stream testing doit that crahsed the Cog JIT because it wasn't ignoring trailing bytes:</div><div><br></div><div>self tempNamesString '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)]'</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 '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)]'</div>
<div><br></div><div>i.e. my adaptation of Dan'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 := 'a b c d e f g h '.<br>
{ str size. str zipped size } "print it"<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>
>><br>
>> --<br>
>> Best regards,<br>
>> Igor Stasenko AKA sig.<br>
>><br>
><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>