aboutsummaryrefslogtreecommitdiff
path: root/src/analyzer.js
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-10-11 21:10:02 -0700
committeralon@honor <none@none>2010-10-11 21:10:02 -0700
commitcb9319ec92505750d2e1a17dd230141aba9edcf7 (patch)
treebe0af9b260a5ba9fa894a5be1fbd6110b31bd977 /src/analyzer.js
parent425295d786880c7741a9eab9768d5aa32a7c3faf (diff)
increment stack all at once; 2% speedup
Diffstat (limited to 'src/analyzer.js')
-rw-r--r--src/analyzer.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index ce4a99af..2418170c 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -300,7 +300,34 @@ function analyzer(data) {
});
});
});
- this.forwardItem(item, 'Relooper');
+ this.forwardItem(item, 'StackAnalyzer');
+ },
+ });
+
+ // Stack analyzer - calculate the base stack usage
+ substrate.addZyme('StackAnalyzer', {
+ processItem: function(data) {
+ data.functions.forEach(function(func) {
+ var total = 0;
+ var lines = func.labels[0].lines;
+ for (var i = 0; i < lines.length; i++) {
+ var item = lines[i].value;
+ if (!item || item.intertype != 'alloca') break;
+ // FIXME: This ignores nativized variables, but probably negligible
+ item.allocatedSize = calcAllocatedSize(item.allocatedType, data.types);
+ total += item.allocatedSize;
+ }
+ func.initialStack = total;
+ var index = 0;
+ 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;
+ delete item.allocatedSize;
+ }
+ });
+ this.forwardItem(data, 'Relooper');
},
});