aboutsummaryrefslogtreecommitdiff
path: root/src/modules.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-19 12:32:05 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-19 12:32:05 -0800
commit8a816f70aa3b07098761557b5b57cfaee498c204 (patch)
tree30dad7bff1336a299277f7b787e5510ffb944aee /src/modules.js
parentb961c328f28daff5d1824ad4d04e076ab0ac7f34 (diff)
do not wrap function table functions in non-asm mode
Diffstat (limited to 'src/modules.js')
-rw-r--r--src/modules.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/modules.js b/src/modules.js
index a08d6f1a..9d516707 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -297,21 +297,23 @@ var Functions = {
table[i] = (libName.indexOf('.') < 0 ? '_' : '') + libName;
}
}
- var curr = table[i];
- if (curr && Functions.unimplementedFunctions[table[i]]) {
- // This is a library function, we can't just put it in the function table, need a wrapper
- if (!wrapped[curr]) {
- var args = '', arg_coercions = '', call = curr + '(', ret = t[0] == 'v' ? '' : ('return ' + (t[0] == 'f' ? '+0' : '0'));
- for (var i = 1; i < t.length; i++) {
- args += (i > 1 ? ',' : '') + 'a' + i;
- arg_coercions += 'a' + i + '=' + asmCoercion('a' + i, t[i] == 'f' ? 'float' : 'i32') + ';';
- call += (i > 1 ? ',' : '') + asmCoercion('a' + i, t[i] == 'f' ? 'float' : 'i32');
+ if (ASM_JS) {
+ var curr = table[i];
+ if (curr && Functions.unimplementedFunctions[table[i]]) {
+ // This is a library function, we can't just put it in the function table, need a wrapper
+ if (!wrapped[curr]) {
+ var args = '', arg_coercions = '', call = curr + '(', ret = t[0] == 'v' ? '' : ('return ' + (t[0] == 'f' ? '+0' : '0'));
+ for (var i = 1; i < t.length; i++) {
+ args += (i > 1 ? ',' : '') + 'a' + i;
+ arg_coercions += 'a' + i + '=' + asmCoercion('a' + i, t[i] == 'f' ? 'float' : 'i32') + ';';
+ call += (i > 1 ? ',' : '') + asmCoercion('a' + i, t[i] == 'f' ? 'float' : 'i32');
+ }
+ call += ')';
+ tables.pre += 'function ' + curr + '__wrapper(' + args + ') { ' + arg_coercions + ' ; ' + call + ' ; ' + ret + ' }\n';
+ wrapped[curr] = 1;
}
- call += ')';
- tables.pre += 'function ' + curr + '__wrapper(' + args + ') { ' + arg_coercions + ' ; ' + call + ' ; ' + ret + ' }\n';
- wrapped[curr] = 1;
+ table[i] = curr + '__wrapper';
}
- table[i] = curr + '__wrapper';
}
}
var indices = table.toString().replace('"', '');