That looks like it should work. Can you make a standalone testcase i can run and investigate?
- Alon On Tue, Jun 10, 2014 at 7:05 AM, Stéphane Letz <[email protected]> wrote: > Here is the code I've tested : > > function Module(stdlib, foreign, heap) { > > "use asm"; > > > > function bar(b) { > > b = +b; > > var a = 10.0; > > return +(a*b); > > } > > > // Export section. > > return { bar: bar }; > > } > > > > var code = "(function asm_module() { return function > Module(stdlib, foreign, heap) { \"use asm\"; function bar(b) { b = +(b); > var a = 10.0; return +(a*b); } return { bar: bar }; } }())"; > > > > $(function () { > > > > var module1 = Module(window, {}, new ArrayBuffer(4 * 1024)); > > > > console.log(module1); > > console.log(module1.bar(20)); > > > > console.log(code); > > var eval_code = eval(code); > > console.log(eval_code); > > var module2 = eval_code(window, {}, new ArrayBuffer(4 * 1024 > )); > > console.log(module2); > > console.log(module2.bar(20)); > > > > }); > > First "module1" gets correctly asm.js compiled (tested with Firefox 29 > which print "Successfully compiled asm.js code"), second one created by > evaluating the "string" code does noes seems to to asm.js compile (no > "Successfully compiled asm.js code" in the console…) > > Any idea? Thanks. > > Stéphane > > Le lundi 9 juin 2014 21:54:39 UTC+2, Alon Zakai a écrit : >> >> In principle yes, you can generate asm.js on the fly, and if you have >> "use asm" in the body then the browser has the option to try to optimize it >> using the asm.js type system (nothing special about asm.js here, of >> course). Do you see a warning or error in the firefox console, saying it >> succeeded or did not succeed? >> >> - Alon >> >> >> >> On Mon, Jun 9, 2014 at 9:34 AM, Stéphane Letz <[email protected]> wrote: >> >>> Hi, >>> >>> We have successfully ported our Faust (audio DSP) compiler to JS using >>> emscripten. We then added an "asm.js" backend in the Faust compiler so that >>> we can do: >>> >>> DSP source ==> Faust (in JS) ==> asm.js ==> evaluate and run the >>> "asm.js" DSP in the web (using the Web Audio API). >>> >>> This basically works, but the "asm.js" generated code does not seems to >>> be compiled in asm.js. It runs quite slow so I guess as regular JS code. >>> Maybe the generated code is still not correct (typing issues probably….) >>> but before going further, is dynamically compiling and evaluating asm.js >>> code actually possible? >>> >>> Thanks. >>> >>> Stéphane Letz >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "emscripten-discuss" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
