Comments (9)
No reason, we talked about it even, just need to get around to writing it up I think.
from validator.
I'd like to use this for a project of mine which will dynamically generate asm.js code. As typed arrays can't be made at odd offsets (other than Int8) it is very messy without DataViews. I'd love for this to be part of the spec before OdinMonkey gets included in a stable release.
from validator.
Note that DataViews pose problems for some archs, like ARM where unaligned reads cause SIGILL. So it is not trivial to just support DataViews, but as I said, I think there is agreement this is worth investigating and doing.
from validator.
Hasn't the cross-arch work already been done for regular JS DataView? Or would you need to do it all again?
Or would 'shimming' DataView in my asm code not degrade its performance too much?
from validator.
DataView works on ARM. But it is slower there. In asm, we could do the same, but it sort of goes against the spirit of asm, which is to generate very simple and fast machine code. There is no simple and fast machine code for unaligned reads/writes on ARM, sadly.
from validator.
I'm with you, but I'll push just a bit more. I know you do want to do it, I'm just sharing more reasons why I consider it important.
Ideally DataView would really just be some sugar around the appropriate machine code, as most of asm.js is, just it will likely be much more involved.
If DataView isn't available I will have to do something like this, as I do for IE compatibility now:
function getUint16( i ) { return array[i] << 8 + array[i + 1]; }
Ideally this would be inlined, and the performance would be about as good as we would all love. But will it be inlined? Will the JIT do a whole bunch of unsigned to signed to unsigned conversions? What about the cases when a constant even address is used, or, what about if it works out faster to getUint32 and then select the appropriate bits from that?
If DataView is supported then the burden of performance is put on the VM developers, who can know all these answers, rather than the user, who won't. Anyone using DataView will know it won't be as fast as nice uniform arrays, but then if they could avoid DataView, they would.
from validator.
I don't think DataView is appropriate -- you would need to do the same thing you need to do in C/C++ to perform unaligned reads on platforms that don't support them; that's exactly like your getUint16 function. But of course I'd write it as an asm.js function inside your asm block instead of an external...
from validator.
What are the chances that this will get into Firefox before OdinMonkey is in a stable release?
from validator.
The whole unaligned SIGILL business I think can be handled by using a signal handler, so that's not the issue. The more pressing issue is that DataView isn't optimized anywhere so any non-Odin compiler would run 10-100x slower, which definitely violates a current prime directive of asm.js. In a future where more browsers are optimizing asm.js, we could consider adding it (which would be an optimization over the current state since it'd allow us to avoid the alignment mask required for typed arrays).
Note: DataView requires a gnarly pattern in asm.js because we can't rely on the getInt32 property lookup along the prototype chain to succeed. Also, because of the terrible terrible default of isBigEndian = true. It requires something like:
function f(global, foreign, buffer) {
"use asm";
var getInt32Pre = global.Object.getOwnPropertyDescriptor(global.DataView.prototype, 'getInt32').get;
var getInt32 = function(i) { return getInt32Pre(i, false) }
}
I'm hoping we can extend Function.prototype.bind to allow pass-through place-holders since that would avoid the lambda and by binding 'false' to the second arg of getInt32.
from validator.
Related Issues (20)
- Request: Fast integer overflow checks HOT 1
- is this repository maintained? HOT 4
- Accept comma-separated function table declarations HOT 2
- Command line utility? HOT 1
- Validator accepts code that it shouldn't HOT 4
- congrats HOT 1
- Allow constants in case blocks
- undefined cannot "flow freely" but can "escape"
- Spec allows standard library functions to be exported HOT 1
- Heap indexing expressions should be subtypes of intish
- Fround annotations break hoisting semantics HOT 1
- If doesn't work? HOT 4
- Mentioned on The Changelog "#189: JSON API with Yehuda Katz"
- Assignment operators are not validated HOT 1
- Foreign function invocations do not validate HOT 1
- Consider allowing x|=0 as a valid Parameter Type Annotation
- Byte Addressing for TypedArray views of heaps - why, and what does it accomplish? HOT 4
- anything with fround doesn't validate
- Warning Chrome : Invalid asm.js: Unexpected token
- Grammar incorrect in document
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from validator.