[squeak-dev] Immutability, read-only objects
eliot.miranda at gmail.com
Tue Mar 29 20:15:01 UTC 2011
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
Interpreter methods for stack bytecodes
"Note: This code uses storePointerUnchecked:ofObject:withValue: and does
store check explicitly in order to help the translator produce better code."
| rcvr top |
"this bytecode will be expanded so that refs to currentBytecode below will
rcvr := receiver.
top := self internalStackTop.
self cppIf: Immutability
[(self internalIsImmutable: rcvr) ifTrue:
[self internalPop: 1.
self internalCannotAssign: top to: receiver withIndex: (currentBytecode
"cannot fetch next bytecode until after immutability check so pc is correct
following bytecode, not the bytecode after that) after
rcvr < youngStart ifTrue:
[self possibleRootStoreInto: rcvr value: top].
self storePointerUnchecked: (currentBytecode bitAnd: 7) ofObject: rcvr
self internalPop: 1
> Best regards
> Janko Mivšek
> Smalltalk Web Application Server
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev