diff options
author | alon@honor <none@none> | 2010-10-16 12:27:22 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-10-16 12:27:22 -0700 |
commit | 9290e904560e8994d8c657a771150de0d86a4b49 (patch) | |
tree | bcbfe00c73d0e8e9bf3759e3b9ddc0b405cc3fa8 /src | |
parent | 5612c15553f50272c269d760aad3e12183f8c059 (diff) |
optimize stack winding with local var; 5% speedup
Diffstat (limited to 'src')
-rw-r--r-- | src/analyzer.js | 2 | ||||
-rw-r--r-- | src/jsifier.js | 2 | ||||
-rw-r--r-- | src/preamble.js | 1 | ||||
-rw-r--r-- | src/runtime.js | 4 |
4 files changed, 4 insertions, 5 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 09f5f6f8..4175abfa 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -325,8 +325,8 @@ function analyzer(data) { for (var i = 0; i < lines.length; i++) { var item = lines[i].value; if (!item || item.intertype != 'alloca') break; - index += item.allocatedSize; item.allocatedIndex = index; + index += item.allocatedSize; delete item.allocatedSize; } }); diff --git a/src/jsifier.js b/src/jsifier.js index 1f432afc..8b67818a 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -586,7 +586,7 @@ function JSify(data) { makeFuncLineZyme('alloca', function(item) { assert(typeof item.allocatedIndex === 'number'); // or, return RuntimeGenerator.stackAlloc(calcAllocatedSize(item.allocatedType, TYPES)); if (item.allocatedSize === 0) return ''; // This will not actually be shown - it's nativized - return getFastValue('STACKTOP', '-', item.allocatedIndex.toString()); + return getFastValue('__stackBase__', '+', item.allocatedIndex.toString()); }); makeFuncLineZyme('phi', function(item) { return '__lastLabel__ == ' + getLabelId(item.label1) + ' ? ' + toNiceIdent(item.value1) + ' : ' + toNiceIdent(item.value2); diff --git a/src/preamble.js b/src/preamble.js index c930bb77..0416a25d 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -152,7 +152,6 @@ function __initializeRuntime__() { IHEAP = HEAP; // We use that name in our runtime code that processes strings etc., see library.js #endif - STACK_STACK = []; STACK_ROOT = STACKTOP = alignMemoryPage(10); if (!this['TOTAL_STACK']) TOTAL_STACK = 1024*1024; // Reserved room for stack STACK_MAX = STACK_ROOT + TOTAL_STACK; diff --git a/src/runtime.js b/src/runtime.js index d6a545c2..43a522e4 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -30,7 +30,7 @@ RuntimeGenerator = { // means that we don't clear stack allocations done in this function // until the parent unwinds its stack. So potentially if we are in // a loop, we can use a lot of memory. - var ret = 'STACK_STACK.push(STACKTOP); STACKTOP += ' + initial; + var ret = 'var __stackBase__ = STACKTOP; STACKTOP += ' + initial; if (GUARD_MEMORY) { ret += '; assert(STACKTOP < STACK_MAX)'; } @@ -39,7 +39,7 @@ RuntimeGenerator = { stackExit: function(initial) { if (initial === 0) return ''; // XXX See comment in stackEnter - return 'STACKTOP = STACK_STACK.pop();'; + return 'STACKTOP = __stackBase__'; }, // An allocation that cannot be free'd |