asm.js

Passing double arrays between functions in asm.js

坚强是说给别人听的谎言 提交于 2019-12-02 01:18:48
I have a C function compiled into asm.js with the following parameters: void myfunc(double v1[], double v2[], int v_size, double c) It takes in an array ( v1 ), applies a transformation, then fills another array of the same size ( v2 ) with the output. I compile it, and then run the following JS code: v1 = new Array(1.0, 1.5, 2.0); v2 = Module._malloc(8 * v1.length); Module.ccall("myfunc", null, ["array", "number", "number", "number"], [v1, v2, v1.length, 2]); However when I run getValue(v2, "double") I get 1.297703e-318 (which is wrong), and when I run getValue(v2 + 8, "double") or getValue

asm.js - How should function pointers be implemented

允我心安 提交于 2019-12-01 06:26:24
Note: This question is purely about asm.js not about C++ nor any other programming language. As the title already says: How should a function pointer be implemented in a efficient way? I couldn't find anything on the web, so I figured asking it here. Edit: I would like to implement virtual functions in the compiler I'm working on. In C++ I would do something like this to generate a vtable : #include <iostream> class Base { public: virtual void doSomething() = 0; }; class Derived : public Base { public: void doSomething() { std::cout << "I'm doing something..." << std::endl; } }; int main() {

asm.js - How should function pointers be implemented

家住魔仙堡 提交于 2019-12-01 04:38:20
问题 Note: This question is purely about asm.js not about C++ nor any other programming language. As the title already says: How should a function pointer be implemented in a efficient way? I couldn't find anything on the web, so I figured asking it here. Edit: I would like to implement virtual functions in the compiler I'm working on. In C++ I would do something like this to generate a vtable : #include <iostream> class Base { public: virtual void doSomething() = 0; }; class Derived : public Base

Can regular JavaScript be converted to asm.js, or is it only to speed up statically-typed low-level languages?

浪尽此生 提交于 2019-11-28 17:23:16
I have read the question How to test and develop with asm.js? , and the accepted answer gives a link to http://kripken.github.com/mloc_emscripten_talk/#/ . The conclusion of that slide show is that " Statically-typed languages and especially C/C++ can be compiled effectively to JavaScript ", so we can " expect the speed of compiled C/C++ to get to just 2X slower than native code, or better, later this year ". But what about non-statically-typed languages, such as regular JavaScript itself? Can it be compiled to asm.js? Bergi Can JavaScript itself be compiled to asm.js? Not really, because of

What is this asm style “x | 0” some javascript programmers are now using?

那年仲夏 提交于 2019-11-27 20:14:17
I've seen some performance critical javascript code, like the one on this project that makes extensive use of bitwise OR operations with 0. Ex: GameBoyAdvanceCPU.prototype.write8 = function (address, data) { address = address | 0; data = data | 0; this.memory.memoryWrite8(address | 0, data | 0); I know about the use case of flooring numbers with "|0", but that isn't the case here, as these are always int's. It looks a bit like asm.js, is this to tell the js engine that we are working with integers, allowing some optimizations? If so, which browsers will make those optimizations? Any pointers

Can regular JavaScript be converted to asm.js, or is it only to speed up statically-typed low-level languages?

邮差的信 提交于 2019-11-27 10:25:22
问题 I have read the question How to test and develop with asm.js?, and the accepted answer gives a link to http://kripken.github.com/mloc_emscripten_talk/#/. The conclusion of that slide show is that " Statically-typed languages and especially C/C++ can be compiled effectively to JavaScript ", so we can " expect the speed of compiled C/C++ to get to just 2X slower than native code, or better, later this year ". But what about non-statically-typed languages, such as regular JavaScript itself? Can

What is this asm style “x | 0” some javascript programmers are now using?

最后都变了- 提交于 2019-11-27 04:25:45
问题 I've seen some performance critical javascript code, like the one on this project that makes extensive use of bitwise OR operations with 0. Ex: GameBoyAdvanceCPU.prototype.write8 = function (address, data) { address = address | 0; data = data | 0; this.memory.memoryWrite8(address | 0, data | 0); I know about the use case of flooring numbers with "|0", but that isn't the case here, as these are always int's. It looks a bit like asm.js, is this to tell the js engine that we are working with