Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: src/hydrogen-gvn.h

Issue 17657004: Refactor Hydrogen GVN into an HPhase and use the phase zone. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 private: 69 private:
70 int capacity_; 70 int capacity_;
71 int length_; 71 int length_;
72 int* dense_; 72 int* dense_;
73 int* sparse_; 73 int* sparse_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(SparseSet); 75 DISALLOW_COPY_AND_ASSIGN(SparseSet);
76 }; 76 };
77 77
78 78
79 class HGlobalValueNumberer BASE_EMBEDDED { 79 // Perform common subexpression elimination and loop-invariant code motion.
80 class HGlobalValueNumberingPhase : public HPhase {
80 public: 81 public:
81 HGlobalValueNumberer(HGraph* graph, CompilationInfo* info); 82 HGlobalValueNumberingPhase(HGraph* graph, Zone* zone);
danno 2013/06/25 15:20:54 Why do you need to pass the zone in? Shouldn't you
Benedikt Meurer 2013/06/27 08:20:04 Done. Using the HPhase zone.
82 83
84 void Run() {
85 bool removed_side_effects = Analyze();
86 // Trigger a second analysis pass to further eliminate duplicate values that
87 // could only be discovered by removing side-effect-generating instructions
88 // during the first pass.
89 if (FLAG_smi_only_arrays && removed_side_effects) {
90 removed_side_effects = Analyze();
91 ASSERT(!removed_side_effects);
92 }
93 }
94
95 private:
83 // Returns true if values with side effects are removed. 96 // Returns true if values with side effects are removed.
84 bool Analyze(); 97 bool Analyze();
85
86 private:
87 GVNFlagSet CollectSideEffectsOnPathsToDominatedBlock( 98 GVNFlagSet CollectSideEffectsOnPathsToDominatedBlock(
88 HBasicBlock* dominator, 99 HBasicBlock* dominator,
89 HBasicBlock* dominated); 100 HBasicBlock* dominated);
90 void AnalyzeGraph(); 101 void AnalyzeGraph();
91 void ComputeBlockSideEffects(); 102 void ComputeBlockSideEffects();
92 void LoopInvariantCodeMotion(); 103 void LoopInvariantCodeMotion();
93 void ProcessLoopBlock(HBasicBlock* block, 104 void ProcessLoopBlock(HBasicBlock* block,
94 HBasicBlock* before_loop, 105 HBasicBlock* before_loop,
95 GVNFlagSet loop_kills, 106 GVNFlagSet loop_kills,
96 GVNFlagSet* accumulated_first_time_depends, 107 GVNFlagSet* accumulated_first_time_depends,
97 GVNFlagSet* accumulated_first_time_changes); 108 GVNFlagSet* accumulated_first_time_changes);
98 bool AllowCodeMotion(); 109 bool AllowCodeMotion();
99 bool ShouldMove(HInstruction* instr, HBasicBlock* loop_header); 110 bool ShouldMove(HInstruction* instr, HBasicBlock* loop_header);
100 111
101 HGraph* graph() { return graph_; } 112 CompilationInfo* info() { return graph()->info(); }
102 CompilationInfo* info() { return info_; }
103 Zone* phase_zone() const { return info_->phase_zone(); }
104 113
105 HGraph* graph_;
106 CompilationInfo* info_;
107 bool removed_side_effects_; 114 bool removed_side_effects_;
108 115
109 Zone* phase_zone_;
110 ZoneScope phase_zone_scope_;
111
112 // A map of block IDs to their side effects. 116 // A map of block IDs to their side effects.
113 ZoneList<GVNFlagSet> block_side_effects_; 117 ZoneList<GVNFlagSet> block_side_effects_;
114 118
115 // A map of loop header block IDs to their loop's side effects. 119 // A map of loop header block IDs to their loop's side effects.
116 ZoneList<GVNFlagSet> loop_side_effects_; 120 ZoneList<GVNFlagSet> loop_side_effects_;
117 121
118 // Used when collecting side effects on paths from dominator to 122 // Used when collecting side effects on paths from dominator to
119 // dominated. 123 // dominated.
120 SparseSet visited_on_paths_; 124 SparseSet visited_on_paths_;
125
126 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase);
121 }; 127 };
122 128
123 129
124 } } // namespace v8::internal 130 } } // namespace v8::internal
125 131
126 #endif // V8_HYDROGEN_GVN_H_ 132 #endif // V8_HYDROGEN_GVN_H_
OLDNEW
« src/hydrogen.h ('K') | « src/hydrogen.cc ('k') | src/hydrogen-gvn.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698