OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_ESCAPE_ANALYSIS_H_ | 5 #ifndef V8_COMPILER_ESCAPE_ANALYSIS_H_ |
6 #define V8_COMPILER_ESCAPE_ANALYSIS_H_ | 6 #define V8_COMPILER_ESCAPE_ANALYSIS_H_ |
7 | 7 |
8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 kUnknown = 0u, | 28 kUnknown = 0u, |
29 kVirtual = 1u << 0, | 29 kVirtual = 1u << 0, |
30 kEscaped = 1u << 1, | 30 kEscaped = 1u << 1, |
31 }; | 31 }; |
32 typedef base::Flags<EscapeStatusFlag> EscapeStatusFlags; | 32 typedef base::Flags<EscapeStatusFlag> EscapeStatusFlags; |
33 | 33 |
34 void Run(); | 34 void Run(); |
35 | 35 |
36 bool IsVirtual(Node* node); | 36 bool IsVirtual(Node* node); |
37 bool IsEscaped(Node* node); | 37 bool IsEscaped(Node* node); |
| 38 bool IsAllocation(Node* node); |
38 | 39 |
39 void DebugPrint(); | 40 void DebugPrint(); |
40 | 41 |
41 friend class EscapeAnalysis; | 42 friend class EscapeAnalysis; |
42 | 43 |
43 private: | 44 private: |
44 EscapeStatusAnalysis(EscapeAnalysis* object_analysis, Graph* graph, | 45 EscapeStatusAnalysis(EscapeAnalysis* object_analysis, Graph* graph, |
45 Zone* zone); | 46 Zone* zone); |
46 void Process(Node* node); | 47 void Process(Node* node); |
47 void ProcessAllocate(Node* node); | 48 void ProcessAllocate(Node* node); |
(...skipping 18 matching lines...) Expand all Loading... |
66 ZoneVector<EscapeStatusFlags> info_; | 67 ZoneVector<EscapeStatusFlags> info_; |
67 ZoneDeque<Node*> queue_; | 68 ZoneDeque<Node*> queue_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(EscapeStatusAnalysis); | 70 DISALLOW_COPY_AND_ASSIGN(EscapeStatusAnalysis); |
70 }; | 71 }; |
71 | 72 |
72 | 73 |
73 DEFINE_OPERATORS_FOR_FLAGS(EscapeStatusAnalysis::EscapeStatusFlags) | 74 DEFINE_OPERATORS_FOR_FLAGS(EscapeStatusAnalysis::EscapeStatusFlags) |
74 | 75 |
75 | 76 |
| 77 class MergeCache { |
| 78 public: |
| 79 explicit MergeCache(Zone* zone) |
| 80 : states_(zone), objects_(zone), fields_(zone) { |
| 81 states_.reserve(4); |
| 82 objects_.reserve(4); |
| 83 fields_.reserve(4); |
| 84 } |
| 85 ZoneVector<VirtualState*>& states() { return states_; } |
| 86 ZoneVector<VirtualObject*>& objects() { return objects_; } |
| 87 ZoneVector<Node*>& fields() { return fields_; } |
| 88 void Clear() { |
| 89 states_.clear(); |
| 90 objects_.clear(); |
| 91 fields_.clear(); |
| 92 } |
| 93 |
| 94 private: |
| 95 ZoneVector<VirtualState*> states_; |
| 96 ZoneVector<VirtualObject*> objects_; |
| 97 ZoneVector<Node*> fields_; |
| 98 }; |
| 99 |
| 100 |
76 // EscapeObjectAnalysis simulates stores to determine values of loads if | 101 // EscapeObjectAnalysis simulates stores to determine values of loads if |
77 // an object is virtual and eliminated. | 102 // an object is virtual and eliminated. |
78 class EscapeAnalysis { | 103 class EscapeAnalysis { |
79 public: | 104 public: |
80 EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); | 105 EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); |
81 ~EscapeAnalysis(); | 106 ~EscapeAnalysis(); |
82 | 107 |
83 void Run(); | 108 void Run(); |
84 | 109 |
85 Node* GetReplacement(Node* at, NodeId id); | 110 Node* GetReplacement(Node* at, NodeId id); |
(...skipping 17 matching lines...) Expand all Loading... |
103 VirtualState* states); | 128 VirtualState* states); |
104 | 129 |
105 void ForwardVirtualState(Node* node); | 130 void ForwardVirtualState(Node* node); |
106 | 131 |
107 bool IsEffectBranchPoint(Node* node); | 132 bool IsEffectBranchPoint(Node* node); |
108 bool IsDanglingEffectNode(Node* node); | 133 bool IsDanglingEffectNode(Node* node); |
109 int OffsetFromAccess(Node* node); | 134 int OffsetFromAccess(Node* node); |
110 | 135 |
111 VirtualObject* GetVirtualObject(Node* at, NodeId id); | 136 VirtualObject* GetVirtualObject(Node* at, NodeId id); |
112 | 137 |
| 138 bool SetEscaped(Node* node); |
| 139 |
113 void DebugPrint(); | 140 void DebugPrint(); |
114 void DebugPrintState(VirtualState* state); | 141 void DebugPrintState(VirtualState* state); |
115 void DebugPrintObject(VirtualObject* state, NodeId id); | 142 void DebugPrintObject(VirtualObject* state, NodeId id); |
116 | 143 |
117 Graph* graph() const { return graph_; } | 144 Graph* graph() const { return graph_; } |
118 CommonOperatorBuilder* common() const { return common_; } | 145 CommonOperatorBuilder* common() const { return common_; } |
119 Zone* zone() const { return zone_; } | 146 Zone* zone() const { return zone_; } |
120 | 147 |
121 Graph* const graph_; | 148 Graph* const graph_; |
122 CommonOperatorBuilder* const common_; | 149 CommonOperatorBuilder* const common_; |
123 Zone* const zone_; | 150 Zone* const zone_; |
124 ZoneVector<VirtualState*> virtual_states_; | 151 ZoneVector<VirtualState*> virtual_states_; |
125 EscapeStatusAnalysis escape_status_; | 152 EscapeStatusAnalysis escape_status_; |
| 153 MergeCache cache_; |
126 | 154 |
127 DISALLOW_COPY_AND_ASSIGN(EscapeAnalysis); | 155 DISALLOW_COPY_AND_ASSIGN(EscapeAnalysis); |
128 }; | 156 }; |
129 | 157 |
130 } // namespace compiler | 158 } // namespace compiler |
131 } // namespace internal | 159 } // namespace internal |
132 } // namespace v8 | 160 } // namespace v8 |
133 | 161 |
134 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_ | 162 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_ |
OLD | NEW |