[Vm-dev] Questions related to immutability in Cog

stephane ducasse stephane.ducasse at gmail.com
Wed Nov 11 10:30:24 UTC 2015

>> - 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.
> When implemented, the VM  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.  So the bit protects an object from any write.
> The bit can also be checked before a become.  In VW the bit protects two-way become but not one-way become IIRC.

eliot why the become?
is it when the become tackles instance variables of an object and that such object should be immutable?

> If the bit is set when a write bytecode is executed the VM sends attemptToWrite: aValue atIndex: index to the immutable object.  If the bit is set when a write in a primitive is attempted the primitive fails with a suitable error code (#'no modification' ?).

Like that we can use it for write barrier. 

>> - 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 ?

I think that sebastian could have a look at that with clement. 


More information about the Vm-dev mailing list