FloatArrayPlugin & 64bitting

Ian Piumarta ian.piumarta at inria.fr
Fri Apr 29 19:26:27 UTC 2005


On Apr 29, 2005, at 12:09, Dave Mason wrote:

> should really be a lot more like:
>
> 	{sqInt argOop = 
> oopForPointer(interpreterProxy->firstIndexableField(arg));
> 	for (i = 0; i <= (length - 1); i += 1) {
> 		if ((floatAt(argOop + i)) == 0.0) {
> 			return interpreterProxy->primitiveFail();
> 		}
> 	}

I think argPtr should be left as a float *:

1) it's not really beneficial to convert the answer from 
1stIndexableField to an oop and then back to a pointer each time the 
array is accessed (IOW, floatAtPointer() with a raw pointer would be 
better than floatAt() with an oop);

2) floats are of the right size already, so the pointer arithmetic will 
scale the index properly (in the code above it would fail since argOop 
+ 1 doesn't point to anything useful);

3) the floats will all be minimally aligned on multiple of their 
widths, so there isn't any reason to worry about correcting for 
alignment -- just let the pointer arithmetic do the right thing 
(assuming whatever creates the float array isn't screwing up on 64-bit 
machines by aligning on twice their width)

For those reasons I think I'll stand by the (untested, improvised, 
hand-waving) code I posted earlier. ;)

Cheers,
Ian




More information about the Vm-dev mailing list