2013-07-08 07:03:57 +00:00
|
|
|
// Copyright 2013 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-07-08 07:03:57 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/hydrogen-sce.h"
|
|
|
|
#include "src/v8.h"
|
2013-07-08 07:03:57 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
void HStackCheckEliminationPhase::Run() {
|
|
|
|
// For each loop block walk the dominator tree from the backwards branch to
|
|
|
|
// the loop header. If a call instruction is encountered the backwards branch
|
|
|
|
// is dominated by a call and the stack check in the backwards branch can be
|
|
|
|
// removed.
|
|
|
|
for (int i = 0; i < graph()->blocks()->length(); i++) {
|
|
|
|
HBasicBlock* block = graph()->blocks()->at(i);
|
|
|
|
if (block->IsLoopHeader()) {
|
|
|
|
HBasicBlock* back_edge = block->loop_information()->GetLastBackEdge();
|
|
|
|
HBasicBlock* dominator = back_edge;
|
|
|
|
while (true) {
|
|
|
|
for (HInstructionIterator it(dominator); !it.Done(); it.Advance()) {
|
2013-12-19 16:45:58 +00:00
|
|
|
if (it.Current()->HasStackCheck()) {
|
2013-07-08 07:03:57 +00:00
|
|
|
block->loop_information()->stack_check()->Eliminate();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done when the loop header is processed.
|
|
|
|
if (dominator == block) break;
|
|
|
|
|
|
|
|
// Move up the dominator tree.
|
|
|
|
dominator = dominator->dominator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|