| Index: src/hydrogen-gvn.cc
|
| diff --git a/src/hydrogen-gvn.cc b/src/hydrogen-gvn.cc
|
| index 9d5e866de443ce226d331fa5ecb1054542c01828..aa43c7b86310a942ff6eb2af450af5421fd6873a 100644
|
| --- a/src/hydrogen-gvn.cc
|
| +++ b/src/hydrogen-gvn.cc
|
| @@ -361,23 +361,19 @@ void HSideEffectMap::Store(GVNFlagSet flags, HInstruction* instr) {
|
| }
|
|
|
|
|
| -HGlobalValueNumberer::HGlobalValueNumberer(HGraph* graph, CompilationInfo* info)
|
| - : graph_(graph),
|
| - info_(info),
|
| +HGlobalValueNumberingPhase::HGlobalValueNumberingPhase(HGraph* graph,
|
| + Zone* zone)
|
| + : HPhase("H_Global value numbering", graph, zone),
|
| removed_side_effects_(false),
|
| - phase_zone_(info->phase_zone()),
|
| - phase_zone_scope_(phase_zone_, DELETE_ON_EXIT),
|
| - block_side_effects_(graph->blocks()->length(), phase_zone_),
|
| - loop_side_effects_(graph->blocks()->length(), phase_zone_),
|
| - visited_on_paths_(phase_zone_, graph->blocks()->length()) {
|
| + block_side_effects_(graph->blocks()->length(), zone),
|
| + loop_side_effects_(graph->blocks()->length(), zone),
|
| + visited_on_paths_(zone, graph->blocks()->length()) {
|
| ASSERT(!AllowHandleAllocation::IsAllowed());
|
| - block_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
|
| - phase_zone_);
|
| - loop_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
|
| - phase_zone_);
|
| + block_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(), zone);
|
| + loop_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(), zone);
|
| }
|
|
|
| -bool HGlobalValueNumberer::Analyze() {
|
| +bool HGlobalValueNumberingPhase::Analyze() {
|
| removed_side_effects_ = false;
|
| ComputeBlockSideEffects();
|
| if (FLAG_loop_invariant_code_motion) {
|
| @@ -388,16 +384,16 @@ bool HGlobalValueNumberer::Analyze() {
|
| }
|
|
|
|
|
| -void HGlobalValueNumberer::ComputeBlockSideEffects() {
|
| +void HGlobalValueNumberingPhase::ComputeBlockSideEffects() {
|
| // The Analyze phase of GVN can be called multiple times. Clear loop side
|
| // effects before computing them to erase the contents from previous Analyze
|
| // passes.
|
| for (int i = 0; i < loop_side_effects_.length(); ++i) {
|
| loop_side_effects_[i].RemoveAll();
|
| }
|
| - for (int i = graph_->blocks()->length() - 1; i >= 0; --i) {
|
| + for (int i = graph()->blocks()->length() - 1; i >= 0; --i) {
|
| // Compute side effects for the block.
|
| - HBasicBlock* block = graph_->blocks()->at(i);
|
| + HBasicBlock* block = graph()->blocks()->at(i);
|
| HInstruction* instr = block->first();
|
| int id = block->block_id();
|
| GVNFlagSet side_effects;
|
| @@ -514,11 +510,11 @@ GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG)
|
| }
|
|
|
|
|
| -void HGlobalValueNumberer::LoopInvariantCodeMotion() {
|
| +void HGlobalValueNumberingPhase::LoopInvariantCodeMotion() {
|
| TRACE_GVN_1("Using optimistic loop invariant code motion: %s\n",
|
| - graph_->use_optimistic_licm() ? "yes" : "no");
|
| - for (int i = graph_->blocks()->length() - 1; i >= 0; --i) {
|
| - HBasicBlock* block = graph_->blocks()->at(i);
|
| + graph()->use_optimistic_licm() ? "yes" : "no");
|
| + for (int i = graph()->blocks()->length() - 1; i >= 0; --i) {
|
| + HBasicBlock* block = graph()->blocks()->at(i);
|
| if (block->IsLoopHeader()) {
|
| GVNFlagSet side_effects = loop_side_effects_[block->block_id()];
|
| TRACE_GVN_2("Try loop invariant motion for block B%d %s\n",
|
| @@ -529,7 +525,7 @@ void HGlobalValueNumberer::LoopInvariantCodeMotion() {
|
| GVNFlagSet accumulated_first_time_changes;
|
| HBasicBlock* last = block->loop_information()->GetLastBackEdge();
|
| for (int j = block->block_id(); j <= last->block_id(); ++j) {
|
| - ProcessLoopBlock(graph_->blocks()->at(j), block, side_effects,
|
| + ProcessLoopBlock(graph()->blocks()->at(j), block, side_effects,
|
| &accumulated_first_time_depends,
|
| &accumulated_first_time_changes);
|
| }
|
| @@ -538,7 +534,7 @@ void HGlobalValueNumberer::LoopInvariantCodeMotion() {
|
| }
|
|
|
|
|
| -void HGlobalValueNumberer::ProcessLoopBlock(
|
| +void HGlobalValueNumberingPhase::ProcessLoopBlock(
|
| HBasicBlock* block,
|
| HBasicBlock* loop_header,
|
| GVNFlagSet loop_kills,
|
| @@ -603,21 +599,21 @@ void HGlobalValueNumberer::ProcessLoopBlock(
|
| }
|
|
|
|
|
| -bool HGlobalValueNumberer::AllowCodeMotion() {
|
| +bool HGlobalValueNumberingPhase::AllowCodeMotion() {
|
| return info()->IsStub() || info()->opt_count() + 1 < FLAG_max_opt_count;
|
| }
|
|
|
|
|
| -bool HGlobalValueNumberer::ShouldMove(HInstruction* instr,
|
| - HBasicBlock* loop_header) {
|
| +bool HGlobalValueNumberingPhase::ShouldMove(HInstruction* instr,
|
| + HBasicBlock* loop_header) {
|
| // If we've disabled code motion or we're in a block that unconditionally
|
| // deoptimizes, don't move any instructions.
|
| return AllowCodeMotion() && !instr->block()->IsDeoptimizing();
|
| }
|
|
|
|
|
| -GVNFlagSet HGlobalValueNumberer::CollectSideEffectsOnPathsToDominatedBlock(
|
| - HBasicBlock* dominator, HBasicBlock* dominated) {
|
| +GVNFlagSet HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock
|
| +(HBasicBlock* dominator, HBasicBlock* dominated) {
|
| GVNFlagSet side_effects;
|
| for (int i = 0; i < dominated->predecessors()->length(); ++i) {
|
| HBasicBlock* block = dominated->predecessors()->at(i);
|
| @@ -756,11 +752,11 @@ class GvnBasicBlockState: public ZoneObject {
|
| // into a loop to avoid stack overflows.
|
| // The logical "stack frames" of the recursion are kept in a list of
|
| // GvnBasicBlockState instances.
|
| -void HGlobalValueNumberer::AnalyzeGraph() {
|
| - HBasicBlock* entry_block = graph_->entry_block();
|
| - HValueMap* entry_map = new(phase_zone()) HValueMap(phase_zone());
|
| +void HGlobalValueNumberingPhase::AnalyzeGraph() {
|
| + HBasicBlock* entry_block = graph()->entry_block();
|
| + HValueMap* entry_map = new(zone()) HValueMap(zone());
|
| GvnBasicBlockState* current =
|
| - GvnBasicBlockState::CreateEntry(phase_zone(), entry_block, entry_map);
|
| + GvnBasicBlockState::CreateEntry(zone(), entry_block, entry_map);
|
|
|
| while (current != NULL) {
|
| HBasicBlock* block = current->block();
|
| @@ -802,7 +798,7 @@ void HGlobalValueNumberer::AnalyzeGraph() {
|
| if (instr->HasSideEffects()) removed_side_effects_ = true;
|
| instr->DeleteAndReplaceWith(other);
|
| } else {
|
| - map->Add(instr, phase_zone());
|
| + map->Add(instr, zone());
|
| }
|
| }
|
| if (instr->IsLinked() &&
|
| @@ -828,7 +824,7 @@ void HGlobalValueNumberer::AnalyzeGraph() {
|
|
|
| HBasicBlock* dominator_block;
|
| GvnBasicBlockState* next =
|
| - current->next_in_dominator_tree_traversal(phase_zone(),
|
| + current->next_in_dominator_tree_traversal(zone(),
|
| &dominator_block);
|
|
|
| if (next != NULL) {
|
|
|