Browse Source

v8: fix stack overflow in recursive method

HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock()
used to self-recurse before this commit, causing stack overflows on
systems with small stack sizes.  Make it non-recursive by storing
intermediate results in a heap-allocated list.

Fixes: https://github.com/nodejs/node/issues/11991
PR-URL: https://github.com/nodejs/node/pull/12460
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
v6
Ben Noordhuis 8 years ago
committed by Michaël Zasso
parent
commit
14dc300085
  1. 10
      deps/v8/src/crankshaft/hydrogen-gvn.cc

10
deps/v8/src/crankshaft/hydrogen-gvn.cc

@ -5,6 +5,8 @@
#include "src/crankshaft/hydrogen-gvn.h"
#include "src/crankshaft/hydrogen.h"
#include "src/list.h"
#include "src/list-inl.h"
#include "src/objects-inl.h"
#include "src/v8.h"
@ -651,6 +653,8 @@ SideEffects
HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock(
HBasicBlock* dominator, HBasicBlock* dominated) {
SideEffects side_effects;
List<HBasicBlock*> blocks;
for (;;) {
for (int i = 0; i < dominated->predecessors()->length(); ++i) {
HBasicBlock* block = dominated->predecessors()->at(i);
if (dominator->block_id() < block->block_id() &&
@ -661,10 +665,12 @@ HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock(
if (block->IsLoopHeader()) {
side_effects.Add(loop_side_effects_[block->block_id()]);
}
side_effects.Add(CollectSideEffectsOnPathsToDominatedBlock(
dominator, block));
blocks.Add(block);
}
}
if (blocks.is_empty()) break;
dominated = blocks.RemoveLast();
}
return side_effects;
}

Loading…
Cancel
Save