aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-06 17:44:06 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-06 17:44:06 -0700
commit332325394c20bb4a3972344144803fcd93476b08 (patch)
treefeddd1057f85282d2c60fd97d5a0529fa0b18048 /src
parentc1dd12998fd862010c7c11e6fa9d003521923a3c (diff)
make EM_ASM use strings on the heap, so it works in asm, and cache the generated functions
Diffstat (limited to 'src')
-rw-r--r--src/library.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js
index 48f613e0..5e71b087 100644
--- a/src/library.js
+++ b/src/library.js
@@ -8613,6 +8613,15 @@ LibraryManager.library = {
Runtime.stackAlloc(-4*i); // free up the stack space we know is ok to free
},
+ emscripten_asm_const: function(code) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func();
+ func = Runtime.asmConstCache[code] = eval('(function(){ ' + Pointer_stringify(code) + ' })'); // new Function does not allow upvars in node
+ return func();
+ },
+
//============================
// i64 math
//============================