[squeak-dev] Using #= for integer comparison instead of #==
eliot.miranda at gmail.com
Wed Nov 17 00:46:13 UTC 2010
On Tue, Nov 16, 2010 at 4:21 PM, Levente Uzonyi <leves at elte.hu> 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?
But it couldn't before. You could only use it if the classes and ranges
were just right. For example, #= isn't "atomic" for large integers, and the
#= primitive will fail for large integers > 64 bits. In assuming #= is
"atomic" for SmallInteger x Float you're relying on an optimization in the
Interpreter. Look at the Blue book and you won't see this behaviour. Read
the ANSI spec and you won't see this behaviour specified. So you're juts
getting away with it on one particular implementation. (IMO)
Again IMO, you /can/ assume that SmallInteger>#= and Float>#= won't fail if
their argument is of the same class as the receiver, but you can't assume
that there won't be a send.
> is what the behaviour of the primitive code is. In the interpreter #=
>> short-circuit (avoid the send) if both the receiver and the argument are
>> either a SmallInteger or a Float. In the JIT the primitive will not fail
>> the receiver and argument are both SmallIntegers or Floats or if the
>> receiver is a Float and the argument is an Integer, but will fail if the
>> receiver is a SmallInteger and the argument is a Float.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev