typed array strawman proposal

Brendan Eich brendan at mozilla.com
Wed Jan 27 10:06:03 PST 2010


On Jan 27, 2010, at 9:32 AM, P T Withington wrote:

> On 2010-01-27, at 12:17, Brendan Eich wrote:
>
>> On Jan 27, 2010, at 8:16 AM, Peter van der Zee wrote:
>>
>>> new ArrayMapping(arrBuf, intBits, intStart, intFinish);
>>
>> The WebGL use-case cannot tolerate scaling by a variable "intBits"  
>> element width. It wants constant (compile-time) element size.
>
> Really?

Yes, really.


> In these days of the JIT-compiler, when is compile-time?

It's when the C++ compiler compiles and optimizes the native code that  
actually stuffs memory with machine-typed ints, more efficiently than  
any JIT. You can't write such code in JS, anyway (unsafe), and if you  
could we would still want ahead-of-time compilation.

Ok, say you implemented these types using an unsafe JS dialect, with  
AOT compilation. Then you'd still want constants. TraceMonkey can make  
such parameters constant on trace, but not all implementations can.

Anyway, we do not want to require exotic techniques. We want to allow C 
++ implementations, which require constants to avoid obvious  
performance hits for no good reason. Competition will kill any browser  
foolish enough to take such hits.

/be

> I'd rather see a simple interface like the above, or like Lisp's  
> displaced arrays, and just know that if I pick "normal" byte-sizes  
> and offsets that I'm likely to trigger an optimization that turns my  
> indirect array access into just a few hardware instructions (just a  
> load if I am lucky, otherwise load/shift/mask).



More information about the es-discuss mailing list