<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments for Cog Blog</title>
	<atom:link href="http://www.mirandabanda.org/cogblog/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mirandabanda.org/cogblog</link>
	<description>Speeding Up Croquet and Squeak with a new open-source VM from Qwaq</description>
	<pubDate>Wed, 07 Jan 2009 03:58:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>Comment on Closures Part II - the Bytecodes by Eliot Miranda</title>
		<link>http://www.mirandabanda.org/cogblog/2008/07/22/closures-part-ii-the-bytecodes/#comment-3966</link>
		<dc:creator>Eliot Miranda</dc:creator>
		<pubDate>Tue, 06 Jan 2009 21:12:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=11#comment-3966</guid>
		<description>Hi Michael,

    good catch!  I had written "Collection&#62;&#62;inject:into: inside an &#60;img src= ... tag.  Hence a lot of code was missing.

Thanks!</description>
		<content:encoded><![CDATA[<p>Hi Michael,</p>
<p>    good catch!  I had written &#8220;Collection&gt;&gt;inject:into: inside an &lt;img src= &#8230; tag.  Hence a lot of code was missing.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Closures Part II - the Bytecodes by Michael Haupt</title>
		<link>http://www.mirandabanda.org/cogblog/2008/07/22/closures-part-ii-the-bytecodes/#comment-3965</link>
		<dc:creator>Michael Haupt</dc:creator>
		<pubDate>Tue, 06 Jan 2009 14:33:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=11#comment-3965</guid>
		<description>Eliot,

thank you so much for this series of posts, which I finally came around to read today. Implicitly, it's a great tutorial on Squeak VM hacking, which I very much appreciate. :-)

In this post, I found a little glitch - just after the text saying "and now I can see what Collection&#62;&#62;inject:into: looks like:", some method implementations are given without mentioning where they belong. I believe they go to ContextPart. Is that right?

Best,

Michael</description>
		<content:encoded><![CDATA[<p>Eliot,</p>
<p>thank you so much for this series of posts, which I finally came around to read today. Implicitly, it&#8217;s a great tutorial on Squeak VM hacking, which I very much appreciate. <img src='http://www.mirandabanda.org/cogblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>In this post, I found a little glitch - just after the text saying &#8220;and now I can see what Collection&gt;&gt;inject:into: looks like:&#8221;, some method implementations are given without mentioning where they belong. I believe they go to ContextPart. Is that right?</p>
<p>Best,</p>
<p>Michael</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Idée Fixe and the Perfected Profiler by Eliot Miranda</title>
		<link>http://www.mirandabanda.org/cogblog/2008/12/30/the-idee-fixe-and-the-perfected-profiler/#comment-3964</link>
		<dc:creator>Eliot Miranda</dc:creator>
		<pubDate>Sun, 04 Jan 2009 01:00:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=16#comment-3964</guid>
		<description>Hi Richard,

    I remember being asked this at ParcPlace, where to an extent it was a standard question to ask of new members of the team.  Your idea has two sides.  One is as a space saving technique, the other as a jit performance technique.  Let me take the former first.

 It doesn't apply to Squeak which has Blue-book compiled methods which are half literals half bytecodes and hence don't have a separate byte code array to share.  But it does apply to VisualWorks and other Smalltalks where a method's byte codes are (at least notionally) stored in an instance variable.

It turns out that in VisualWorks at least the idea doesn't fly because there is another optimization for small methods.  In VisualWorks methods with 6 or less bytecodes have them encoded in two SmallIntegers, up to three bytecodes per integer, the first integer living in the bytecode instance variable, the other being an extra literal.  Because of this in VisualWorks your idea would apply only to methods of 7 bytecodes or more and by that time there is already such variance that the uniquing table occupies more space tha n it saves.

But I'm sure your idea would hold water for systems that have distinct byte code arrays but don't do the bytecode compression technique that VisualWorks uses, e.g. because the system mixes an interpreter with a JIT or is just an interpreter.

The second side of your question is, um, complex to discuss and I hope to get to it in a blog post on the jit.  One of the complications is having to record teh selector for any send site so that when methods are discarded or redefined send sites can be unlinked.

Suffice it to say that doing things like architecting polymorphic inline caches so that accessors can be stored there-in achieves what you're aiming at in a slightly more general way.  PICs can also optimize message-not-understood and, as I plan to do in Cog, interpret-method.  David Simmons does a lot more with PICs; something I hope he will write about some time.  I plan to do accessors, MNU and interpret-method.</description>
		<content:encoded><![CDATA[<p>Hi Richard,</p>
<p>    I remember being asked this at ParcPlace, where to an extent it was a standard question to ask of new members of the team.  Your idea has two sides.  One is as a space saving technique, the other as a jit performance technique.  Let me take the former first.</p>
<p> It doesn&#8217;t apply to Squeak which has Blue-book compiled methods which are half literals half bytecodes and hence don&#8217;t have a separate byte code array to share.  But it does apply to VisualWorks and other Smalltalks where a method&#8217;s byte codes are (at least notionally) stored in an instance variable.</p>
<p>It turns out that in VisualWorks at least the idea doesn&#8217;t fly because there is another optimization for small methods.  In VisualWorks methods with 6 or less bytecodes have them encoded in two SmallIntegers, up to three bytecodes per integer, the first integer living in the bytecode instance variable, the other being an extra literal.  Because of this in VisualWorks your idea would apply only to methods of 7 bytecodes or more and by that time there is already such variance that the uniquing table occupies more space tha n it saves.</p>
<p>But I&#8217;m sure your idea would hold water for systems that have distinct byte code arrays but don&#8217;t do the bytecode compression technique that VisualWorks uses, e.g. because the system mixes an interpreter with a JIT or is just an interpreter.</p>
<p>The second side of your question is, um, complex to discuss and I hope to get to it in a blog post on the jit.  One of the complications is having to record teh selector for any send site so that when methods are discarded or redefined send sites can be unlinked.</p>
<p>Suffice it to say that doing things like architecting polymorphic inline caches so that accessors can be stored there-in achieves what you&#8217;re aiming at in a slightly more general way.  PICs can also optimize message-not-understood and, as I plan to do in Cog, interpret-method.  David Simmons does a lot more with PICs; something I hope he will write about some time.  I plan to do accessors, MNU and interpret-method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Idée Fixe and the Perfected Profiler by Richard Sargent</title>
		<link>http://www.mirandabanda.org/cogblog/2008/12/30/the-idee-fixe-and-the-perfected-profiler/#comment-3963</link>
		<dc:creator>Richard Sargent</dc:creator>
		<pubDate>Sat, 03 Jan 2009 20:45:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=16#comment-3963</guid>
		<description>Hi Elliot, interesting reading. 

One thing I have been wondering recently is whether one could get a performance improvement by ensuring byte code arrays were unique (in the way that Symbols are). If all the "return instance variable #n", "set instance variable #n", and other common byte array patterns existed just once each, and were compiled to native code just once, that surely would help performance.

Perhaps you would have to impose a size limitation on that, so that only "small enough" methods were managed this way.

I suspect the "byte code array" would get replaced by a more elaborate structure which also includes some kind of link to the native code with the null pointer or whatever telling the JIT compiler this method needs to be JIT compiled.</description>
		<content:encoded><![CDATA[<p>Hi Elliot, interesting reading. </p>
<p>One thing I have been wondering recently is whether one could get a performance improvement by ensuring byte code arrays were unique (in the way that Symbols are). If all the &#8220;return instance variable #n&#8221;, &#8220;set instance variable #n&#8221;, and other common byte array patterns existed just once each, and were compiled to native code just once, that surely would help performance.</p>
<p>Perhaps you would have to impose a size limitation on that, so that only &#8220;small enough&#8221; methods were managed this way.</p>
<p>I suspect the &#8220;byte code array&#8221; would get replaced by a more elaborate structure which also includes some kind of link to the native code with the null pointer or whatever telling the JIT compiler this method needs to be JIT compiled.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The Idée Fixe and the Perfected Profiler by Kent Beck</title>
		<link>http://www.mirandabanda.org/cogblog/2008/12/30/the-idee-fixe-and-the-perfected-profiler/#comment-3962</link>
		<dc:creator>Kent Beck</dc:creator>
		<pubDate>Wed, 31 Dec 2008 15:07:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=16#comment-3962</guid>
		<description>Thank you so much for the gory details. I've always used the histogram approach, so I appreciate you blazing the trail on where to go next.

Best wishes to all for a peaceful and prosperous new year,

Kent</description>
		<content:encoded><![CDATA[<p>Thank you so much for the gory details. I&#8217;ve always used the histogram approach, so I appreciate you blazing the trail on where to go next.</p>
<p>Best wishes to all for a peaceful and prosperous new year,</p>
<p>Kent</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simulate Out Of The Bochs by Eliot Miranda</title>
		<link>http://www.mirandabanda.org/cogblog/2008/12/12/simulate-out-of-the-bochs/#comment-3961</link>
		<dc:creator>Eliot Miranda</dc:creator>
		<pubDate>Wed, 31 Dec 2008 03:09:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=15#comment-3961</guid>
		<description>Pete,

    Ouch ^2.  Yes I am lucky.  At least know that I'm hugely grateful to be able to follow the ST dream.  But well spotted that Unicode makes things more complicated.  Yes, most current Smalltalk implementations are Unicode savvy, and in fact Squeak's String&#62;&#62;asLowercase implementation looks like

&lt;code&gt;&lt;pre&gt;asLowercase
	"Answer a String made up from the receiver whose characters are all 
	lowercase."

	^ self copy asString translateToLowercase

translateToLowercase
	"Translate all characters to lowercase, in place"

	self translateWith: LowercasingTable&lt;/pre&gt;&lt;/code&gt;
Which looks a little over-complicated to me.  But its not my problem :)

Somebody give Pete a job ... doing Smalltalk!</description>
		<content:encoded><![CDATA[<p>Pete,</p>
<p>    Ouch ^2.  Yes I am lucky.  At least know that I&#8217;m hugely grateful to be able to follow the ST dream.  But well spotted that Unicode makes things more complicated.  Yes, most current Smalltalk implementations are Unicode savvy, and in fact Squeak&#8217;s String&gt;&gt;asLowercase implementation looks like</p>
<p><code>
<pre>asLowercase
	"Answer a String made up from the receiver whose characters are all
	lowercase."

	^ self copy asString translateToLowercase

translateToLowercase
	"Translate all characters to lowercase, in place"

	self translateWith: LowercasingTable</pre>
<p></code><br />
Which looks a little over-complicated to me.  But its not my problem <img src='http://www.mirandabanda.org/cogblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Somebody give Pete a job &#8230; doing Smalltalk!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simulate Out Of The Bochs by Pete Cockerell</title>
		<link>http://www.mirandabanda.org/cogblog/2008/12/12/simulate-out-of-the-bochs/#comment-3960</link>
		<dc:creator>Pete Cockerell</dc:creator>
		<pubDate>Tue, 30 Dec 2008 21:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=15#comment-3960</guid>
		<description>Thanks, Eliot :) Of course, you're one of the lucky ones, still being able to pursue the ST dream, while most of us have to think down to the level of C or (in my case) Java on a daily basis. Your example got me wondering, though: are current ST implementations Unicode-aware? Writing Character#asLowerCase would be quite interesting in a Unicode world...

Sorry, bit off-topic!</description>
		<content:encoded><![CDATA[<p>Thanks, Eliot <img src='http://www.mirandabanda.org/cogblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Of course, you&#8217;re one of the lucky ones, still being able to pursue the ST dream, while most of us have to think down to the level of C or (in my case) Java on a daily basis. Your example got me wondering, though: are current ST implementations Unicode-aware? Writing Character#asLowerCase would be quite interesting in a Unicode world&#8230;</p>
<p>Sorry, bit off-topic!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simulate Out Of The Bochs by admin</title>
		<link>http://www.mirandabanda.org/cogblog/2008/12/12/simulate-out-of-the-bochs/#comment-3959</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 30 Dec 2008 20:08:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=15#comment-3959</guid>
		<description>Pete,

    &lt;blush&gt;Ouch!&lt;/blush&gt;.  Forgive me, I wasn't thinking about the C, only about the Smalltalk output.  But I shouldn't be displaying bad examples all the same.

But this is interesting.  The equivalent Smalltalk code is simply
    aString asLowercase
but in C I had to write a function to do it.  There was no strtolower function to hand in the C library, a library routine that would be tried and tested and free of errors.  The Smalltalk code is something as simple as
    &lt;code&gt;&lt;pre&gt;asLowercase
        ^self collect: [:c&#124; c asLowercase]&lt;/pre&gt;&lt;/code&gt;
whereas the C code has - count 'em - 9 lines!
So C forces one to write more code, providing much more opportunity for mistakes, and makes it far harder to debug and correct (low level debuggers, no edit-and-continue).

I make mistakes.  I'm currently working on a JIT written in Smalltalk that will be transliterated into C.  Were I in C I would be making snail-like progress but in Smalltalk I feel like I'm flying along.  Programming systems should be designed for humans, with all their failings.  I put down my O(n^2) blunder to the paucity of the C development ecosystem and yet another example of why trying to implement a faster Smalltalk VM makes sense :)

That said, next time I'll be sure to write

&lt;code&gt;&lt;pre&gt;char *
lower(char *s)
{
    int i = strlen(s);
    buf[i] = 0;
    while (--i &gt;= 0)
        buf[i] = tolower(s[i]);
    return buf;
}&lt;/pre&gt;&lt;/code&gt;

;)</description>
		<content:encoded><![CDATA[<p>Pete,</p>
<p>    <blush>Ouch!</blush>.  Forgive me, I wasn&#8217;t thinking about the C, only about the Smalltalk output.  But I shouldn&#8217;t be displaying bad examples all the same.</p>
<p>But this is interesting.  The equivalent Smalltalk code is simply<br />
    aString asLowercase<br />
but in C I had to write a function to do it.  There was no strtolower function to hand in the C library, a library routine that would be tried and tested and free of errors.  The Smalltalk code is something as simple as<br />
    <code>
<pre>asLowercase
        ^self collect: [:c| c asLowercase]</pre>
<p></code><br />
whereas the C code has - count &#8216;em - 9 lines!<br />
So C forces one to write more code, providing much more opportunity for mistakes, and makes it far harder to debug and correct (low level debuggers, no edit-and-continue).</p>
<p>I make mistakes.  I&#8217;m currently working on a JIT written in Smalltalk that will be transliterated into C.  Were I in C I would be making snail-like progress but in Smalltalk I feel like I&#8217;m flying along.  Programming systems should be designed for humans, with all their failings.  I put down my O(n^2) blunder to the paucity of the C development ecosystem and yet another example of why trying to implement a faster Smalltalk VM makes sense <img src='http://www.mirandabanda.org/cogblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>That said, next time I&#8217;ll be sure to write</p>
<p><code>
<pre>char *
lower(char *s)
{
    int i = strlen(s);
    buf[i] = 0;
    while (&#8211;i >= 0)
        buf[i] = tolower(s[i]);
    return buf;
}</pre>
<p></code></p>
<p> <img src='http://www.mirandabanda.org/cogblog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simulate Out Of The Bochs by Pete Cockerell</title>
		<link>http://www.mirandabanda.org/cogblog/2008/12/12/simulate-out-of-the-bochs/#comment-3958</link>
		<dc:creator>Pete Cockerell</dc:creator>
		<pubDate>Tue, 30 Dec 2008 01:12:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=15#comment-3958</guid>
		<description>Interestingly I use the idiom exemplified by
&lt;pre&gt;
        for (i = 0; i &#60; strlen(s); i++)
                 buf[i] = tolower(s[i]);
&lt;/pre&gt;
as a "Whats's wrong with this code?" interview question. The answer is of course that it exhibits highly avoidable O(n^2) performance, since strlen(), which is O(n), is being called n times. You can certainly argue that performance hardly matters in this case (and n is rather small), but seeing that idiom out there in the wild still causes me to gasp a little :)</description>
		<content:encoded><![CDATA[<p>Interestingly I use the idiom exemplified by</p>
<pre>
        for (i = 0; i &lt; strlen(s); i++)
                 buf[i] = tolower(s[i]);
</pre>
<p>as a &#8220;Whats&#8217;s wrong with this code?&#8221; interview question. The answer is of course that it exhibits highly avoidable O(n^2) performance, since strlen(), which is O(n), is being called n times. You can certainly argue that performance hardly matters in this case (and n is rather small), but seeing that idiom out there in the wild still causes me to gasp a little <img src='http://www.mirandabanda.org/cogblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Simulate Out Of The Bochs by Stephen Pair</title>
		<link>http://www.mirandabanda.org/cogblog/2008/12/12/simulate-out-of-the-bochs/#comment-3946</link>
		<dc:creator>Stephen Pair</dc:creator>
		<pubDate>Sun, 14 Dec 2008 14:12:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.mirandabanda.org/cogblog/?p=15#comment-3946</guid>
		<description>Nice, I had totally forgotten about Bochs (I could use that for another project I've been working on).  But I still think you need to port it to Smalltalk.  ;))</description>
		<content:encoded><![CDATA[<p>Nice, I had totally forgotten about Bochs (I could use that for another project I&#8217;ve been working on).  But I still think you need to port it to Smalltalk.  ;))</p>
]]></content:encoded>
	</item>
</channel>
</rss>
