| 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 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 // Forward declarations. | 15 // Forward declarations. |
| 16 class CommonOperatorBuilder; | 16 class CommonOperatorBuilder; |
| 17 class EscapeAnalysis; | 17 class EscapeAnalysis; |
| 18 class VirtualState; | 18 class VirtualState; |
| 19 class VirtualObject; | 19 class VirtualObject; |
| 20 | 20 |
| 21 | |
| 22 // EscapeStatusAnalysis determines for each allocation whether it escapes. | 21 // EscapeStatusAnalysis determines for each allocation whether it escapes. |
| 23 class EscapeStatusAnalysis { | 22 class EscapeStatusAnalysis { |
| 24 public: | 23 public: |
| 25 typedef NodeId Alias; | 24 typedef NodeId Alias; |
| 26 ~EscapeStatusAnalysis(); | 25 ~EscapeStatusAnalysis(); |
| 27 | 26 |
| 28 enum Status { | 27 enum Status { |
| 29 kUnknown = 0u, | 28 kUnknown = 0u, |
| 30 kTracked = 1u << 0, | 29 kTracked = 1u << 0, |
| 31 kEscaped = 1u << 1, | 30 kEscaped = 1u << 1, |
| 32 kOnStack = 1u << 2, | 31 kOnStack = 1u << 2, |
| 33 kVisited = 1u << 3, | 32 kVisited = 1u << 3, |
| 34 // A node is dangling, if it is a load of some kind, and does not have | 33 // A node is dangling, if it is a load of some kind, and does not have |
| 35 // an effect successor. | 34 // an effect successor. |
| 36 kDanglingComputed = 1u << 4, | 35 kDanglingComputed = 1u << 4, |
| 37 kDangling = 1u << 5, | 36 kDangling = 1u << 5, |
| 38 // A node is is an effect branch point, if it has more than 2 non-dangling | 37 // A node is is an effect branch point, if it has more than 2 non-dangling |
| 39 // effect successors. | 38 // effect successors. |
| 40 kBranchPointComputed = 1u << 6, | 39 kBranchPointComputed = 1u << 6, |
| 41 kBranchPoint = 1u << 7, | 40 kBranchPoint = 1u << 7, |
| 41 kInQueue = 1u << 8 |
| 42 }; | 42 }; |
| 43 typedef base::Flags<Status, unsigned char> StatusFlags; | 43 typedef base::Flags<Status, uint16_t> StatusFlags; |
| 44 | 44 |
| 45 void RunStatusAnalysis(); | 45 void RunStatusAnalysis(); |
| 46 | 46 |
| 47 bool IsVirtual(Node* node); | 47 bool IsVirtual(Node* node); |
| 48 bool IsEscaped(Node* node); | 48 bool IsEscaped(Node* node); |
| 49 bool IsAllocation(Node* node); | 49 bool IsAllocation(Node* node); |
| 50 |
| 51 bool IsInQueue(NodeId id); |
| 52 void SetInQueue(NodeId id, bool on_stack); |
| 53 |
| 50 void DebugPrint(); | 54 void DebugPrint(); |
| 51 | 55 |
| 52 EscapeStatusAnalysis(EscapeAnalysis* object_analysis, Graph* graph, | 56 EscapeStatusAnalysis(EscapeAnalysis* object_analysis, Graph* graph, |
| 53 Zone* zone); | 57 Zone* zone); |
| 54 void EnqueueForStatusAnalysis(Node* node); | 58 void EnqueueForStatusAnalysis(Node* node); |
| 55 bool SetEscaped(Node* node); | 59 bool SetEscaped(Node* node); |
| 56 bool IsEffectBranchPoint(Node* node); | 60 bool IsEffectBranchPoint(Node* node); |
| 57 bool IsDanglingEffectNode(Node* node); | 61 bool IsDanglingEffectNode(Node* node); |
| 58 void ResizeStatusVector(); | 62 void ResizeStatusVector(); |
| 59 size_t GetStatusVectorSize(); | 63 size_t GetStatusVectorSize(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 Graph* const graph_; | 99 Graph* const graph_; |
| 96 Zone* const zone_; | 100 Zone* const zone_; |
| 97 ZoneVector<StatusFlags> status_; | 101 ZoneVector<StatusFlags> status_; |
| 98 Alias next_free_alias_; | 102 Alias next_free_alias_; |
| 99 ZoneVector<Node*> status_stack_; | 103 ZoneVector<Node*> status_stack_; |
| 100 ZoneVector<Alias> aliases_; | 104 ZoneVector<Alias> aliases_; |
| 101 | 105 |
| 102 DISALLOW_COPY_AND_ASSIGN(EscapeStatusAnalysis); | 106 DISALLOW_COPY_AND_ASSIGN(EscapeStatusAnalysis); |
| 103 }; | 107 }; |
| 104 | 108 |
| 105 | |
| 106 DEFINE_OPERATORS_FOR_FLAGS(EscapeStatusAnalysis::StatusFlags) | 109 DEFINE_OPERATORS_FOR_FLAGS(EscapeStatusAnalysis::StatusFlags) |
| 107 | 110 |
| 108 | |
| 109 // Forward Declaration. | 111 // Forward Declaration. |
| 110 class MergeCache; | 112 class MergeCache; |
| 111 | 113 |
| 112 | |
| 113 // EscapeObjectAnalysis simulates stores to determine values of loads if | 114 // EscapeObjectAnalysis simulates stores to determine values of loads if |
| 114 // an object is virtual and eliminated. | 115 // an object is virtual and eliminated. |
| 115 class EscapeAnalysis { | 116 class EscapeAnalysis { |
| 116 public: | 117 public: |
| 117 using Alias = EscapeStatusAnalysis::Alias; | 118 using Alias = EscapeStatusAnalysis::Alias; |
| 118 EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); | 119 EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); |
| 119 ~EscapeAnalysis(); | 120 ~EscapeAnalysis(); |
| 120 | 121 |
| 121 void Run(); | 122 void Run(); |
| 122 | 123 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 MergeCache* cache_; | 190 MergeCache* cache_; |
| 190 | 191 |
| 191 DISALLOW_COPY_AND_ASSIGN(EscapeAnalysis); | 192 DISALLOW_COPY_AND_ASSIGN(EscapeAnalysis); |
| 192 }; | 193 }; |
| 193 | 194 |
| 194 } // namespace compiler | 195 } // namespace compiler |
| 195 } // namespace internal | 196 } // namespace internal |
| 196 } // namespace v8 | 197 } // namespace v8 |
| 197 | 198 |
| 198 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_ | 199 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_ |
| OLD | NEW |