diff options
-rw-r--r-- | src/jsifier.js | 7 | ||||
-rw-r--r-- | src/parseTools.js | 15 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 9b7e9dc7..0d962dc9 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -541,6 +541,13 @@ function JSify(data, functionsOnly, givenFunctions) { func.JS += 'function ' + func.ident + '(' + paramIdents.join(', ') + ') {\n'; + if (ASM_JS) { + // spell out argument types + func.params.forEach(function(param) { + func.JS += ' ' + param.ident + ' = ' + asmCoercion(param.ident, param.type) + ';\n'; + }); + } + if (PROFILE) { func.JS += ' if (PROFILING) { ' + 'var __parentProfilingNode__ = PROFILING_NODE; PROFILING_NODE = PROFILING_NODE.children["' + func.ident + '"]; ' diff --git a/src/parseTools.js b/src/parseTools.js index 0a86abc1..7a8637a0 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -930,6 +930,7 @@ if (ASM_JS) { var decMemoryMask = (TOTAL_MEMORY-1).toString(); var memoryMask = hexMemoryMask.length <= decMemoryMask.length ? hexMemoryMask : decMemoryMask; } + function getHeapOffset(offset, type) { if (USE_TYPED_ARRAYS !== 2) { return offset; @@ -948,6 +949,14 @@ function getHeapOffset(offset, type) { } } +function asmCoercion(value, type) { + if (type in Runtime.INT_TYPES) { + return value + '|0'; + } else { + return '+' + value; + } +} + // See makeSetValue function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSafe) { noticePtr(ptr); @@ -1005,11 +1014,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa } else { var ret = makeGetSlabs(ptr, type, false, unsigned)[0] + '[' + getHeapOffset(offset, type) + ']'; if (ASM_JS && phase == 'funcs') { - if (type in Runtime.INT_TYPES) { - ret = ret + '|0'; - } else { - ret = '+' + ret; - } + ret = asmCoercion(ret, type); } return ret; } |