aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-19 20:30:03 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-19 20:36:02 -0700
commit31872fbd01ca23962d954ca40232c7b8bfde58fe (patch)
treecf05b59fb1451f137e0ff96ef56bc9c184329099 /src/runtime.js
parent9089dc78a6c7fd21be5fc115451996018779dd40 (diff)
support for Runtime.addFunction in asm.js
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) {