Just a simple question, can I include a section of asm.js code in a set of normal javascript, as a function or otherwise, similar to how I can put ASM code into a C program for areas that need special optimization?
1 Answer
Yes. Use the
"use asm";
prologue directive on top of the function block (i.e. function or file) that is asm. Full example:
function MyAsmModule() {
"use asm";
// module body
}
See http://asmjs.org/spec/latest/#introduction for more information
2 Comments
Ecksters
Could you show how to pass variables into a function like this, let's assume it was originally written in C++ and then compiled into ASM.
Willem Mulder
There's a good example in the link I posted. You should have a pretty good idea of the possibilities after reading the introduction part of that page.