On 11/16/2010 4:21 PM, Levente Uzonyi wrote:
On Tue, 16 Nov 2010, Eliot Miranda wrote:
Um, on Cog it sends a message if the method containing the #= has been jitted. But the issue is /not/ whether there is a send or not. The issue
Does it mean, that #= can't be used in "atomic" code anymore?
It never was. In the old (pre-closure) days you might have gotten away with using #= only because of the context cache which would avoid creating a new context if a previous one could be recycled. But code like:
obj := self someObject. [0 = obj nextObject] whileFalse:[count := count + 1].
really should never have worked to begin with because: * sending #= will create a context (unless recycled) * the plus in the counter will create a context (unless count is in SmallInt range) * the addition may create a new object (unless count in SmallInt range) * either one of the blocks should create contexts (unless optimized)
There's a long list of reasons why code such as the above is simply broken. You *must* use an end marker, i.e.,
last := Object new. "end marker" obj := self someObject. [last == obj] whileFalse:[ count := count + 1. obj := obj nextObject. ].
This will work because it counts between the beginning of memory and the (arbitrary) end marker. Anything else basically should not be relied on to work, jit or no.
Cheers, - Andreas