Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate Dataview usage for typed arrays == 2 #36

Closed
Dandandan opened this issue Jun 28, 2011 · 3 comments
Closed

Investigate Dataview usage for typed arrays == 2 #36

Dandandan opened this issue Jun 28, 2011 · 3 comments

Comments

@Dandandan
Copy link

If you use DataView, you are no longer required to divide the pointers (or bitshifting) with some constant but rather use [dataview].getInt32, getFloat64 and setInt32 etc. An other bonus is that you can support int8, int16, uints, float32 etc. and can provide better compability.
The question is of course of it is as fast as an array index at this moment, but likely will be in the future.

@Dandandan
Copy link
Author

hmmm... still not implemented in Firefox
bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=575688

@kripken
Copy link
Member

kripken commented Jun 28, 2011

I don't think it's implemented in Safari or Opera either. But in any case it would be interesting to do a benchmark to see if this is indeed fast. And if so, adding code to Emscripten to support it as an option would not be hard.

I wonder though if it will be. These are function calls, not indexings, which is a different kind of optimization for JS engines, that I suspect they don't do as well on. Making this fast isn't normal function call inlining either, it's inlining of native code into JS. I don't think any JS engine does that (things like PyPy do, though).

Also, there is the Binary Data proposal for JS, which would provide something similar to this. Firefox for example is starting to implement it. So it's not clear to me what the future of binary data access is, at the moment...

@Dandandan
Copy link
Author

I did a test in v8, was a little (few %) bit slower than array + bitshifting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants