diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-29 12:24:37 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:20 -0800 |
commit | 5a51da6c1c3f96606c90a217349b25c6f6566865 (patch) | |
tree | 127aedc114980d9b1bd8b59065184798bd61225c /src/runtime.js | |
parent | 18e2c1f8add758844474f2adf931d54626785d4f (diff) |
make stack operations asm-friendly
Diffstat (limited to 'src/runtime.js')
-rw-r--r-- | src/runtime.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/runtime.js b/src/runtime.js index 5c579aaa..57867917 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -13,7 +13,7 @@ var RuntimeGenerator = { if (init) { ret += sep + '_memset(' + type + 'TOP, 0, ' + size + ')'; } - ret += sep + type + 'TOP += ' + size; + ret += sep + type + 'TOP = (' + type + 'TOP + ' + size + ')|0'; if ({{{ QUANTUM_SIZE }}} > 1 && !ignoreAlign) { ret += sep + RuntimeGenerator.alignMemory(type + 'TOP', {{{ QUANTUM_SIZE }}}); } @@ -23,11 +23,11 @@ var RuntimeGenerator = { // An allocation that lives as long as the current function call stackAlloc: function(size, sep) { sep = sep || ';'; - if (USE_TYPED_ARRAYS === 2) 'STACKTOP += STACKTOP % ' + ({{{ QUANTUM_SIZE }}} - (isNumber(size) ? Math.min(size, {{{ QUANTUM_SIZE }}}) : {{{ QUANTUM_SIZE }}})) + sep; + if (USE_TYPED_ARRAYS === 2) 'STACKTOP = (STACKTOP + STACKTOP|0 % ' + ({{{ QUANTUM_SIZE }}} - (isNumber(size) ? Math.min(size, {{{ QUANTUM_SIZE }}}) : {{{ QUANTUM_SIZE }}})) + ')' + sep; // The stack is always QUANTUM SIZE aligned, so we may not need to force alignment here var ret = RuntimeGenerator.alloc(size, 'STACK', INIT_STACK, sep, USE_TYPED_ARRAYS != 2 || (isNumber(size) && parseInt(size) % {{{ QUANTUM_SIZE }}} == 0)); if (ASSERTIONS) { - ret += sep + 'assert(STACKTOP < STACK_ROOT + STACK_MAX)'; + ret += sep + 'assert(STACKTOP < (STACK_ROOT + STACK_MAX)|0)'; } return ret; }, @@ -35,11 +35,11 @@ var RuntimeGenerator = { stackEnter: function(initial, force) { if (initial === 0 && SKIP_STACK_IN_SMALL && !force) return ''; var ret = 'var __stackBase__ = STACKTOP'; - if (initial > 0) ret += '; STACKTOP += ' + initial; + if (initial > 0) ret += '; STACKTOP = (STACKTOP + ' + initial + ')|0'; if (USE_TYPED_ARRAYS == 2) { assert(initial % QUANTUM_SIZE == 0); if (ASSERTIONS) { - ret += '; assert(STACKTOP % {{{ QUANTUM_SIZE }}} == 0)'; + ret += '; assert(STACKTOP|0 % {{{ QUANTUM_SIZE }}} == 0)'; } } if (ASSERTIONS) { |