Comments (4)
You can copy them in now using typed array .set()
. (Also, you likely anyhow do not want to do processing on a clamped array for speed purposes, I think?)
asm.js currently wants to bind tightly to its typed array, for speed purposes, so passing over a new one each call would not fit that model.
from validator.
Not acceptable. Man ctypes, actually useful FFI. Passing in arrays is a mandatory feature.
asm.js currently wants to bind tightly to its typed array, for speed purposes, so passing over a new one each call would not fit that model.
The fuck?!
from validator.
The asm.js model is very simple: a singleton typed array for data storage. This is what makes it super-easy to optimize to native-like speeds.
If the asm spec allowed passing in typed arrays, accessing them would necessary entail the usual type checks, bound checks, bailouts, etc. - meaning it would not run at typical asm.js speed. It could still run pretty fast, because modern JS engines are fast. But it couldn't benefit from the predictable level of performance you can expect from asm.js.
But the important thing is that the singleton typed array in asm.js is not owned by it - it's a normal typed array, accessible from outside the asm module as well. That means you can access other typed arrays in outside code, and that code can also access the asm.js typed array,
var asm = (function asmModule(buffer, stdlib, ffi) {
"use asm";
// ...
})(buffer, stdlib, ffi);
function extFunction(newArray) {
// operations on both buffer and newArray
}
That extFunction can run very quickly. Not typical asm.js speed, but still, if all it does is access some typed arrays and so basic math, that is stuff that modern JS engines can optimize well. And that speed is basically the limit - you couldn't get better from writing that code in asm.
Therefore, there isn't a strong reason to add passing in new arrays to asm code.
from validator.
With non-trivial effort (and thus significant justification required), asm.js modules could have a second heap:
function f(stdlib, ffis, buffer1, buffer2) { "use asm"; ... }
The existing change heap asm.js extension could then be used to arbitrarily swap buffer1 and buffer2. Thus, you could change-heap buffer2 to the result of getImageData() and then pound on this in a subsequent asm.js function call.
I'm not sure how this would be reflected in C++/Emscripten, though. In particular, every heap access would need to statically know which heap to load from and there is no natural way I know of to express this in C++ since the memory model assumes a single linear address space. Some sort of extra annotations would be required (or a bunch of EM_ASM).
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.