[Vm-dev] Re: [squeak-dev] Immutability, read-only objects

Eliot Miranda eliot.miranda at gmail.com
Tue Mar 29 20:15:01 UTC 2011


Hi Janko,

2011/3/27 Janko Mivšek <janko.mivsek at eranova.si>

> Dear all,
>
> What is current status of immutable/read-only support in VM? Or more
> broader, object instvar change catching support (for which I mostly need
> immutability anyway)?
>

My understanding is that this exists only in the Newspeak VM sources.  It is
now reasonably easy to port to the standard and Cog VMs and the necessary
primitive error code support is in the VMs and the image.  I'm currently
working in Newspeak at Cadence expect that this summer I will have the
opportunity to port the Cog VM under Newspeak.  At that point I'll be able
to add the support to Cog and the standard VM.

There are now mechanisms in the VM which would allow one to include the
immutability support conditionally, in which case the source could be
included in the base VMs, and not have to live in a fork, which would be my
preference.  e.g.

Interpreter methods for stack bytecodes
storeAndPopReceiverVariableBytecode
"Note: This code uses storePointerUnchecked:ofObject:withValue: and does
the
store check explicitly in order to help the translator produce better code."
| rcvr top |
<expandInCase: 'currentBytecode'>
"this bytecode will be expanded so that refs to currentBytecode below will
be constant"
rcvr := receiver.
top := self internalStackTop.
self cppIf: Immutability
 ifTrue:
 [(self internalIsImmutable: rcvr) ifTrue:
  [self internalPop: 1.
  self internalCannotAssign: top to: receiver withIndex: (currentBytecode
bitAnd: 7)].
 "cannot fetch next bytecode until after immutability check so pc is correct
(set to
  following bytecode, not the bytecode after that) after
attemptToAssign:withIndex:"].
self fetchNextBytecode.
rcvr < youngStart ifTrue:
[self possibleRootStoreInto: rcvr value: top].
self storePointerUnchecked: (currentBytecode bitAnd: 7) ofObject: rcvr
withValue: top.
self internalPop: 1

best,
Eliot


>
> Best regards
> Janko
>
> --
> Janko Mivšek
> Aida/Web
> Smalltalk Web Application Server
> http://www.aidaweb.si
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110329/79283265/attachment.htm


More information about the Vm-dev mailing list