<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Clément,</div><div><br>On Nov 11, 2015, at 2:03 AM, Clément Bera &lt;<a href="mailto:bera.clement@gmail.com">bera.clement@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><span></span></div></blockquote><blockquote type="cite"><div><div dir="ltr">Thanks for your answers.<div><br></div><div>The implementation implies:</div><div>- adding support for the callback<span style="font-size:12.8px">&nbsp;</span><span style="font-size:12.8px">attemptToWrite: aValue atIndex: index</span>&nbsp;which is partially done&nbsp;</div><div>- checking for immutability at each write (at:put:, bytecoded inst var access, instVarAt:put:, become: , ... ). both in the interpreter and jitted code</div><div>- I guess adding 2 primitives to mark the object as immutable and mark it back as mutable.</div></div></div></blockquote><div><br></div>Right. &nbsp;Note that the newspeak interpreter VM has many primitives already rewritten but some may be obsolete.<div><br><blockquote type="cite"><div><div dir="ltr"><div><br><div>I believe it's not a lot of work. If no one has done that before May (a phd student was interested at some point, he may do it) I could try to supervise an intern on this task. When he finishes the implementation he could work in actually using the immutability in the image.</div></div></div></div></blockquote><div><br></div>That would be gr8!</div><div><br><blockquote type="cite"><div><div dir="ltr"><div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-11-11 4:46 GMT-03:00 Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Clément,<br>
<span class=""><br>
&gt; On Nov 10, 2015, at 6:17 AM, Clément Bera &lt;<a href="mailto:bera.clement@gmail.com">bera.clement@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hello everyone,<br>
&gt;<br>
&gt; I tried to understand how immutability is implemented in the CogVM (NewSpeak flavor). I have some questions:<br>
<br>
</span>Ryan's answers are good, but I'll give a little more detail.<br>
<span class="">&gt;<br>
&gt; - Does it actually work and is it used ?<br>
<br>
</span>The scheme is identical to the VisualWorks one, and the VW version has been in use for over ten years, so the scheme definitely works.&nbsp; But it's not yet implemented in Cog.<br>
<span class=""><br>
&gt; - Does an object being immutable means that you can't edit its variable fields only or that you can't either edit its instance variables ? Because I don't see any code checking for instance variable stores in the Newspeak interpreter.<br>
<br>
</span>When implemented, the VM&nbsp; checks the immutability bit before each write, which means before writing to an inst var or global variable when executing an inst var write bytecode or global var write bytecode, or when writing to an object in a primitive.&nbsp; So the bit protects an object from any write.<br>
<br>
The bit can also be checked before a become.&nbsp; In VW the bit protects two-way become but not one-way become IIRC.<br>
<br>
If the bit is set when a write bytecode is executed the VM sends attemptToWrite: aValue atIndex: index to the immutable object.&nbsp; If the bit is set when a write in a primitive is attempted the primitive fails with a suitable error code (#'no modification' ?).<br>
<span class=""><br>
&gt; - How does the immutability check works in machine code ? In the Newspeak interpreter there is an immutability check in #at:put: . In the at:put: generated by the JIT (for example CogObjectRepresentationFor32BitSpur) I don't see any immutability check. Did I miss some clever bit trick ? Does the Newspeak spur VMs use the #at:put: machine code version of the primitive ?<br>
<br>
</span>It's not implemented yet.&nbsp; The code to perform the checks and the send back need to be implemented.&nbsp; It is not a lot of work.&nbsp; Perhaps two weeks.<br>
<br>
&gt;<br>
&gt; Thanks !<br>
<br>
_,,,^..^,,,_ (phone)</blockquote></div><br></div>
</div></blockquote></div></body></html>