[Vm-dev] Re: Immutability, newspeak (was: Vm-dev post from jbaptiste.arnaud@gmail.com requires approval)

Eliot Miranda eliot.miranda at gmail.com
Wed Jun 9 19:57:12 UTC 2010


On Wed, Jun 9, 2010 at 12:34 PM, Igor Stasenko <siguctua at gmail.com> wrote:

>
> On 9 June 2010 21:51, Andreas Raab <andreas.raab at gmx.de> wrote:
> >
> > On 6/8/2010 7:41 AM, David T. Lewis wrote:
> >>
> >> What do the VM developers think with respect adopting the VM changes?
> >> The immutability bit is a scarce resource. Is it OK to allocate it
> >> for this purpose or are there likely to be other projects interested
> >> in using it for other reasons?
> >
> > Oh, and one thing that I'm just realizing is that by far the biggest
> impact
> > of immutability is in primitives and plugins. All primitives in all
> plugins
> > must be rewritten to test for mutability of the objects they store into
> > before this can work reliably. Ouch.
> >
>
> Yeah. I told before, that i'm not a big fan of making VM more and more
> clever.
> It is because 'clever' is synonym to 'complexity'.
>
> I'd rather focus on providing immutability at language side, instead
> of implementing it
> primitively.
>
> However, i am thinking, if there could be good alternatives to
> immutability bit in object header.
> One idea is to add this bit on a per-class basis, not on a per-instance
> basis.
>
> Then VM could check immutability during a method lookup and throw
> exception before entering method(s) which can mutate
> an instance of such class. But then we should also divide
> primitives/methods on those which can and can't
> mutate the object's state, which is also a lot of work.
>

You think its cheap to scan methods for mutablity??  Remember you have to
identify inst var writes not just mutating primitives like at:put:.


> Checking before entering method potentially will have much less impact
> on performance, because it is not so fine granular as per each write.
>

I don't think so.  Not without a JIT to cache the scanning of methods for
mutators.  This scheme also only works for methods, not for code in plugins.

The above is speculation.  The immutability scheme I'm discussing is real
and known to work in practice.


BTW, I implemented a per-class scheme ages ago in above BrouHaHa (in a
Smalltalk-80 v2.3 derived image) to provide immutable literals.  It worked
badly for literals since 'foo' class ~~ 'foo' copy class (one needs an
ImmutableByteString class and a ByteString class for every class one wants
to make immutable).  Lots of the system was affected by the change since the
store string of a mutable string ends up being
    'the immutable string literal' copy
to get a mutable string.

Our experience with VisualWorks was different.  Lots of methods had to be
changed because they were attempting to update immutable literals.  There
were lots of
    stream := '' writeStream.
throughout the system which had not been noticed.  But unlike the BrouHaHa
experience the changes only affected violations of immutability.  In
BrouHaHa the changes were due to trying to accommodate the clumsy
class-based scheme.

cheers,
Eliot


> > Cheers,
> >  - Andreas
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100609/bb379d81/attachment-0001.htm


More information about the Vm-dev mailing list