sq / JSIL

CIL to Javascript Compiler
http://jsil.org/
Other
1.73k stars 240 forks source link

boolean arrays should use a Uint8Array typed array instead of a regular javascript array #250

Open jrmuizel opened 11 years ago

jrmuizel commented 11 years ago

This would help save memory

jrmuizel commented 11 years ago

FWIW, making the change from boolean arrays to byte arrays manually improves the performance of NSieve converted to js by about 30%

kg commented 11 years ago

Good idea. I think I'd need to introduce a Boolean() cast when reading out of the array...

kg commented 11 years ago

Can you provide the code to nsieve? Can't find it.

kg commented 11 years ago

Interestingly, I fiddled with this a bit, and while it produces a speedup in spidermonkey it doesn't make a difference at all in V8. I think V8 must have a trick where an Array of Booleans gets the same representation as Uint8Array.

kg commented 11 years ago

This seems to address things for the basic test case I created; hard to be sure because suddenly both test cases got faster - I guess suddenly SpiderMonkey understood the type information better.

kg commented 11 years ago

Bleahhhhhhhh. V8 bug: https://code.google.com/p/chromium/issues/detail?id=287773 Spidermonkey bug to do better without the Uint8Array optimization: https://bugzilla.mozilla.org/show_bug.cgi?id=913892