[Vm-dev] Questions related to immutability in Cog
Das.Linux at gmx.de
Wed Nov 11 12:55:19 UTC 2015
On 11.11.2015, at 13:03, stephane ducasse <stephane.ducasse at gmail.com> wrote:
> Hi tobias
> I definitively would like to see the impact of having value classes.
> This is a topic I mention to seb krinsky for his PhD.
> I would like to know the impact of having value classes on containers.
> Now with a proper Mop and API why we could not have both
> temporarily and permanent immutable objects.
> On 11 Nov 2015, at 11:50, Tobias Pape <Das.Linux at gmx.de> wrote:
>> Hi all,
>> I just want to add my 2ct to this.
>> I'd rather like to habe the immutability bit be one-shot,
>> non-resettable, ie, an immutable object stays that way its entire lifetime.
>> I know that conflicts with the idea of the lightweight read barrier, but
>> I think this would be worthwhile for value classes :)
>> Can we find a compromise here?
>> Best regards
>> On 10.11.2015, at 17:35, Ryan Macnak <rmacnak at gmail.com> wrote:
>>> Hi Clement,
>>> Per object immutability was implemented in the old, pre-Cog Newspeak VM (NewspeakInterpreter). It has not yet been implemented current Cog Newspeak VM (Stack/CoInterpreter + NewspeakVM=true), but the necessary bit is reserved in the object header. It was used as part of an orthogonal synchronization scheme to detect changed objects: mark synchronized objects as immutable, trap on change attempt, add to dirty list and mark as mutable again. A marked object is only shallowly immutable, and its instance variables may contain mutable objects.
>>> On Tue, Nov 10, 2015 at 6:17 AM, Clément Bera <bera.clement at gmail.com> wrote:
>>> Hello everyone,
>>> I tried to understand how immutability is implemented in the CogVM (NewSpeak flavor). I have some questions:
>>> - Does it actually work and is it used ?
>>> - 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.
>>> - 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 ?
>>> Thanks !
More information about the Vm-dev