<br><br><div class="gmail_quote">On Thu, Jul 3, 2008 at 2:56 PM,  &lt;<a href="mailto:bryce@kampjes.demon.co.uk">bryce@kampjes.demon.co.uk</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">Eliot Miranda writes:<br>
&nbsp;&gt; &gt; P.S. That&#39;s one reason I don&#39;t like the idea of a write protect bit in<br>
&nbsp;&gt; &gt; the object header. It adds yet another thing to check for every single<br>
&nbsp;&gt; &gt; write into an object. Small costs add up on common basic operations.<br>
&nbsp;&gt;<br>
&nbsp;&gt;<br>
&nbsp;&gt; Actually one can be clever about this. &nbsp;yes one has to check for inst var<br>
&nbsp;&gt; assignment. &nbsp;But for at:put: one can fold the check into other activities.<br>
&nbsp;&gt; &nbsp;For example, in my VisualWorks implementation the write-protect bit was put<br>
&nbsp;&gt; very close to and more significant than the size field in the object header.<br>
<br>
</div>&lt;snip, neat optimisation&gt;<br>
<div class="Ih2E3d"><br>
&nbsp;&gt; &gt; Write protection could be implemented using similar tricks to the<br>
&nbsp;&gt; &gt; write barrier. Then send optimisation will help reduce the costs when<br>
&nbsp;&gt; &gt; it&#39;s used. When it&#39;s not used, there&#39;s no cost.<br>
&nbsp;&gt;<br>
&nbsp;&gt;<br>
&nbsp;&gt; I don&#39;t understand this. &nbsp;Can you explain the write-barrier tricks and the<br>
&nbsp;&gt; send optimization that eliminates them?<br>
<br>
</div>Automatically create a new hidden subclass of the class that acts<br>
appropriately for every write. The write protection can then be<br>
encoded in the class. The only overhead is that required by dynamic<br>
dispatch which we&#39;re already paying for.</blockquote><div><br>Ah, ok. &nbsp;This doesn&#39;t work in general. &nbsp;e.g. one can&#39;t turn on immutablity in the middle of a method that assigns to inst vars. &nbsp;The method in the subclass would need to be different and mapping pcs at runtime is, uh, decidely nontrivial. &nbsp;It works for access to arrays but not to objects in general. &nbsp;<br>
<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="Ih2E3d">&nbsp;&gt; I think per-object write-protection is very useful. &nbsp;Its very useful for<br>
&nbsp;&gt; read-only literals, OODBs, proxies (distributed objects), debugging, etc.<br>
&nbsp;&gt; &nbsp;Amongst Smalltalks I think VisualAge had it first and I did it for VW round<br>
&nbsp;&gt; about 2002. &nbsp;I did it again for Squeak at Cadence. &nbsp;In both the VW and<br>
&nbsp;&gt; Squeak cases the performance degradation was less than 5% for standard<br>
&nbsp;&gt; benchmarks. &nbsp;Its cheap enough not to be noticed and there&#39;s lots more fat in<br>
&nbsp;&gt; the Squeak VM one can cut to more than regain performance.<br>
&nbsp;&gt;<br>
&nbsp;&gt; So unlike, say, named primitives for the core primitives, this is something<br>
&nbsp;&gt; I am in favour of. &nbsp;It is a cost well worth paying for the added<br>
&nbsp;&gt; functionality.<br>
<br>
</div>And when we&#39;re twice as fast as VisualWorks is now it&#39;ll be a 10%<br>
overhead. Twice as fast as VisualWorks is the original goal for<br>
Exupery.<br></blockquote><div><br>Where are you on that?<br>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Immutability or change tracking can be provided more efficiently purely<br>

inside the image when it&#39;s needed.<br>
<br>
Bryce<br>
<br>
</blockquote></div><br>