diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-06 17:55:44 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-06 17:55:44 -0800 |
commit | 27adc83bb2454fc71149b3efdae93d9c323d3bac (patch) | |
tree | 70c993a70ca3fa7ef1fbd6a12d177cf772c09463 /src/analyzer.js | |
parent | 638532d89fc586adc739eb535625971bd29c8a74 (diff) |
prevent stack from being exhausted due to allocas and byval arguments
Diffstat (limited to 'src/analyzer.js')
-rw-r--r-- | src/analyzer.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 4ff5d2d9..7d99ab69 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -785,6 +785,26 @@ function analyzer(data, sidePass) { delete item.allocatedSize; } func.initialStack = index; + // We need to note if stack allocations other than initial allocs can happen here + // (for example, via alloca). If so, we need to rewind the stack when we leave. + func.otherStackAllocations = false; + var finishedInitial = false; + for (var i = 0; i < lines.length; i++) { + var item = lines[i].value; + if (!item || item.intertype != 'alloca') { + finishedInitial = true; + continue; + } + if (item.intertype == 'alloca' && finishedInitial) { + func.otherStackAllocations = true; + } + } + // by-value params are also causes of additional allocas (although we could in theory make them normal allocas too) + func.params.forEach(function(param) { + if (param.byVal) { + func.otherStackAllocations = true; + } + }); }); this.forwardItem(data, 'Relooper'); } |