aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 2a26db28..5b9a8134 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -305,18 +305,35 @@ var Runtime = {
}
},
- addFunction: function(func, sig) {
- //assert(sig); // TODO: support asm
- var table = FUNCTION_TABLE; // TODO: support asm
+#if ASM_JS
+ functionPointers: new Array(RESERVED_FUNCTION_POINTERS),
+#endif
+
+ addFunction: function(func) {
+#if ASM_JS
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2 + 2*i;
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+#else
+ var table = FUNCTION_TABLE;
var ret = table.length;
table.push(func);
table.push(0);
return ret;
+#endif
},
removeFunction: function(index) {
- var table = FUNCTION_TABLE; // TODO: support asm
+#if ASM_JS
+ Runtime.functionPointers[(index-2)/2] = null;
+#else
+ var table = FUNCTION_TABLE;
table[index] = null;
+#endif
},
warnOnce: function(text) {