On 02/02/2012 04:45 AM, Mark Roos wrote:
> from Rémi
>
>         if you know it will never escape,you should use an int directly.
>
> Well I am trying to build a Smalltalk system which has no static types so
> I have to box the ints. Since the code I showed was programmer entered I
> need to stay with the boxes.
>
> There are cases where the compiler generates the index code and there 
> I do
> use static ints if I can be sure they are not passed.

or you can box only just before it's passed.

The MutableInteger trick only works because the VM does
the escape analysis for you but the escape analysis done
by the VM is more britlle than the one you can write,
by example, you know that increment() is a pure function,
the VM has to inline it to know. So if one call is not inlined in
the middle of the body of the loop, then the VM will
not remove your MutableInteger.

> It does cause some
> issues when I open a debugger on the stack so I may want to keep then 
> boxed
> anyway and thus the MutableInteger

??, yes your debugger has to support it, but if you
want a typed smalltalk you will need that anyway.

>
> mark
>

Rémi

_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to