<br><br><div class="gmail_quote">On Fri, Dec 3, 2010 at 5:21 PM, Andreas Raab <span dir="ltr">&lt;<a href="mailto:andreas.raab@gmx.de">andreas.raab@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 12/3/2010 4:18 PM, Eliot Miranda wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
BTW, Mariano&#39;s use of SmallIntegers rather than wrappers is an attempt<br>
to get a very compact image and seems a reasonable experiment.  Using<br>
wrappers would defeat his use-as-little-memory-as-possible purpose.<br>
</blockquote>
<br></div>
Not at all. The design of objects-as-methods was deliberately done such that one could use a single wrapper for multiple methods. The only thing you need is to map from selector to method being executed. For example:<br>

<br>
MethodSwapper&gt;&gt;run: aSelector with: argsArray in: aReceiver<br>
        &quot;Execute the given method&quot;<br>
        method:= methodMap at: aSelector.<br>
        ^aReceiver withArgs: argsArray executeMethod: method<br>
<br></blockquote><div><br></div><div>Ah, much nicer.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Then you install a single MethodSwapper instance like here:<br>
<br>
swapper := MethodSwapper new.<br>
Morph selectorsAndMethodsDo:[:sel :meth| swapper methodMap at: sel put: meth].<br>
Morph selectorsDo:[:sel| Morph addSelector: sel withMethod: swapper].<br>
<br>
At this point the only overhead you have is what&#39;s in the (single) MethodSwapper instance and even with a most naive implementation (looking up the index by selector) you&#39;d have 8 bytes per method in your image which I suspect is well below 5% of the image size.<br>

<br>
And then of course you can start *really* looking at getting the size down. Did you know that Dan once did a very neat hack where he replaced all symbols with integers? Works great and if you do that you not only reclaim the space for the symbols but also don&#39;t need a lookup at all :-)<br>
</blockquote><div><br></div><div>I didn&#39;t know that Dan had done this.  ActiveBook did this with the Smalltalk running on my BrouHaHa VM.   All the Smalltalk VMs I&#39;ve worked on have supported immediate selectors, and a good thing too :)</div>
<div><br></div><div>best</div><div>Eliot</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Cheers,<br><font color="#888888">
  - Andreas<br>
</font></blockquote></div><br>