Array bounds checks

Boehm, Hans
Thu Oct 26 12:33:00 GMT 2000

> Currently we can't implement that because our array header is attached
> directly to the data.  We'd have to add an indirection to make
> contiguous multidimensional arrays work.
I don't think I understand the problem.  You would allocate the same objects
as now, except all in one contiguous chunk.  I.e. you'd get something like

Main array header (includes a "contiguous" tag)
Main array (containing pointers to subarrays)
0th subarray header
0th subarray
1st subarray header

It should still be possible to locate the [i,j] element with a
multiplication and a couple of additions.  There are some slightly
unfortunate GC implications, but you could easily make this optional.  Even
if you make the decision at run-time, the main cost is dead code.

I suspect that in the long run it would actually be nice to discourage the
hand-coded linearization, since that makes it very hard to remove the
remaining subscript checks.  At the moment I'm not surprised that it helps

Am I missing something?


More information about the Java mailing list