[Vm-dev] Array new: SmallInteger maxVal

David T. Lewis lewis at mail.msen.com
Fri Oct 9 14:34:19 UTC 2009

On Tue, Oct 06, 2009 at 10:05:02PM +0200, Nicolas Cellier wrote:
> >From http://code.google.com/p/pharo/issues/detail?id=1282
> Is this known?

A performance / GC related question:

I found one part of the problem, but it is not a complete solution
(there must be more bugs).

Assume 32 bit object memory and assume that we are rigorously using
usqint rather than sqint for all OOP address calculations.

Then in Intepreter>>sufficientSpaceToInstantiate:indexableSize: if we are
trying to allocate an Array of size 16r3FFFFFFF (i.e. SmallInteger maxVal),
then we get an arithmetic overflow when we add 2500 at the end of the method.

Adding the 2500 is explained in the method comment:
   "Details: For speed, over-estimate space needed for fixed fields
    or literals; the low space threshold is a blurry line."

This addition was not present in the original Dan Ingalls version of
the method, so the overflow bug is a side effect of the optimization.

The fix would be to either a) add a check to fail the primitive if requested
size is too great, or b) remove the "add 2500" speed optimization.

Can anyone suggest which solution would be the least harmful for overall
performance? I suspect that adding the size check would be best, but I
have no data.


More information about the Vm-dev mailing list