OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_REDUNDANCY_ELIMINATION_H_ | 5 #ifndef V8_COMPILER_REDUNDANCY_ELIMINATION_H_ |
6 #define V8_COMPILER_REDUNDANCY_ELIMINATION_H_ | 6 #define V8_COMPILER_REDUNDANCY_ELIMINATION_H_ |
7 | 7 |
8 #include "src/compiler/graph-reducer.h" | 8 #include "src/compiler/graph-reducer.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace compiler { | 12 namespace compiler { |
13 | 13 |
14 class RedundancyElimination final : public AdvancedReducer { | 14 class RedundancyElimination final : public AdvancedReducer { |
15 public: | 15 public: |
16 RedundancyElimination(Editor* editor, Zone* zone); | 16 RedundancyElimination(Editor* editor, Zone* zone); |
17 ~RedundancyElimination() final; | 17 ~RedundancyElimination() final; |
18 | 18 |
19 Reduction Reduce(Node* node) final; | 19 Reduction Reduce(Node* node) final; |
20 | 20 |
21 private: | 21 private: |
22 struct Check { | 22 struct Check { |
23 Check(Node* node, Check* next) : node(node), next(next) {} | 23 Check(Node* node, Check* next) : node(node), next(next) {} |
24 Node* node; | 24 Node* node; |
25 Check* next; | 25 Check* next; |
26 }; | 26 }; |
27 | 27 |
28 class EffectPathChecks final { | 28 class EffectPathChecks final { |
Jarin
2016/07/26 09:39:21
How about moving this class to the .cc file?
| |
29 public: | 29 public: |
30 static EffectPathChecks* Copy(Zone* zone, EffectPathChecks const* checks); | 30 static EffectPathChecks* Copy(Zone* zone, EffectPathChecks const* checks); |
31 static EffectPathChecks const* Empty(Zone* zone); | 31 static EffectPathChecks const* Empty(Zone* zone); |
32 bool Equals(EffectPathChecks const* that) const; | 32 bool Equals(EffectPathChecks const* that) const; |
33 void Merge(EffectPathChecks const* that); | 33 void Merge(EffectPathChecks const* that); |
34 | 34 |
35 EffectPathChecks const* AddCheck(Zone* zone, Node* node) const; | 35 EffectPathChecks const* AddCheck(Zone* zone, Node* node) const; |
36 Node* LookupCheck(Node* node) const; | 36 template <typename Predicate> |
37 V8_INLINE Node* LookupCheck(Node* node, Predicate predicate) const; | |
37 | 38 |
38 private: | 39 private: |
39 EffectPathChecks(Check* head, size_t size) : head_(head), size_(size) {} | 40 EffectPathChecks(Check* head, size_t size) : head_(head), size_(size) {} |
40 | 41 |
41 // We keep track of the list length so that we can find the longest | 42 // We keep track of the list length so that we can find the longest |
42 // common tail easily. | 43 // common tail easily. |
43 Check* head_; | 44 Check* head_; |
44 size_t size_; | 45 size_t size_; |
45 }; | 46 }; |
46 | 47 |
47 class PathChecksForEffectNodes final { | 48 class PathChecksForEffectNodes final { |
48 public: | 49 public: |
49 explicit PathChecksForEffectNodes(Zone* zone) : info_for_node_(zone) {} | 50 explicit PathChecksForEffectNodes(Zone* zone) : info_for_node_(zone) {} |
50 EffectPathChecks const* Get(Node* node) const; | 51 EffectPathChecks const* Get(Node* node) const; |
51 void Set(Node* node, EffectPathChecks const* checks); | 52 void Set(Node* node, EffectPathChecks const* checks); |
52 | 53 |
53 private: | 54 private: |
54 ZoneVector<EffectPathChecks const*> info_for_node_; | 55 ZoneVector<EffectPathChecks const*> info_for_node_; |
55 }; | 56 }; |
56 | 57 |
57 Reduction ReduceCheckNode(Node* node); | 58 Reduction ReduceCheckNode(Node* node); |
59 Reduction ReduceSpeculativeNode(Node* node); | |
58 Reduction ReduceEffectPhi(Node* node); | 60 Reduction ReduceEffectPhi(Node* node); |
59 Reduction ReduceStart(Node* node); | 61 Reduction ReduceStart(Node* node); |
60 Reduction ReduceOtherNode(Node* node); | 62 Reduction ReduceOtherNode(Node* node); |
61 | 63 |
62 Reduction TakeChecksFromFirstEffect(Node* node); | 64 Reduction TakeChecksFromFirstEffect(Node* node); |
63 Reduction UpdateChecks(Node* node, EffectPathChecks const* checks); | 65 Reduction UpdateChecks(Node* node, EffectPathChecks const* checks); |
64 | 66 |
65 Zone* zone() const { return zone_; } | 67 Zone* zone() const { return zone_; } |
66 | 68 |
67 PathChecksForEffectNodes node_checks_; | 69 PathChecksForEffectNodes node_checks_; |
68 Zone* const zone_; | 70 Zone* const zone_; |
69 | 71 |
70 DISALLOW_COPY_AND_ASSIGN(RedundancyElimination); | 72 DISALLOW_COPY_AND_ASSIGN(RedundancyElimination); |
71 }; | 73 }; |
72 | 74 |
73 } // namespace compiler | 75 } // namespace compiler |
74 } // namespace internal | 76 } // namespace internal |
75 } // namespace v8 | 77 } // namespace v8 |
76 | 78 |
77 #endif // V8_COMPILER_REDUNDANCY_ELIMINATION_H_ | 79 #endif // V8_COMPILER_REDUNDANCY_ELIMINATION_H_ |
OLD | NEW |