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/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace compiler { | 12 namespace compiler { |
13 | 13 |
14 // Forward declarations. | 14 // Forward declarations. |
15 class CommonOperatorBuilder; | 15 class CommonOperatorBuilder; |
16 class EscapeStatusAnalysis; | 16 class EscapeStatusAnalysis; |
17 class MergeCache; | 17 class MergeCache; |
18 class VirtualState; | 18 class VirtualState; |
19 class VirtualObject; | 19 class VirtualObject; |
20 | 20 |
21 // EscapeObjectAnalysis simulates stores to determine values of loads if | 21 // EscapeObjectAnalysis simulates stores to determine values of loads if |
22 // an object is virtual and eliminated. | 22 // an object is virtual and eliminated. |
23 class EscapeAnalysis { | 23 class EscapeAnalysis { |
24 public: | 24 public: |
25 typedef NodeId Alias; | |
26 EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); | 25 EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); |
27 ~EscapeAnalysis(); | 26 ~EscapeAnalysis(); |
28 | 27 |
29 void Run(); | 28 void Run(); |
30 | 29 |
31 Node* GetReplacement(Node* node); | 30 Node* GetReplacement(Node* node); |
32 bool IsVirtual(Node* node); | 31 bool IsVirtual(Node* node); |
33 bool IsEscaped(Node* node); | 32 bool IsEscaped(Node* node); |
34 bool CompareVirtualObjects(Node* left, Node* right); | 33 bool CompareVirtualObjects(Node* left, Node* right); |
35 Node* GetOrCreateObjectState(Node* effect, Node* node); | 34 Node* GetOrCreateObjectState(Node* effect, Node* node); |
(...skipping 13 matching lines...) Expand all Loading... |
49 void ProcessStart(Node* node); | 48 void ProcessStart(Node* node); |
50 bool ProcessEffectPhi(Node* node); | 49 bool ProcessEffectPhi(Node* node); |
51 void ProcessLoadFromPhi(int offset, Node* from, Node* node, | 50 void ProcessLoadFromPhi(int offset, Node* from, Node* node, |
52 VirtualState* states); | 51 VirtualState* states); |
53 | 52 |
54 void ForwardVirtualState(Node* node); | 53 void ForwardVirtualState(Node* node); |
55 int OffsetFromAccess(Node* node); | 54 int OffsetFromAccess(Node* node); |
56 VirtualState* CopyForModificationAt(VirtualState* state, Node* node); | 55 VirtualState* CopyForModificationAt(VirtualState* state, Node* node); |
57 VirtualObject* CopyForModificationAt(VirtualObject* obj, VirtualState* state, | 56 VirtualObject* CopyForModificationAt(VirtualObject* obj, VirtualState* state, |
58 Node* node); | 57 Node* node); |
59 VirtualObject* GetVirtualObject(Node* at, NodeId id); | |
60 | 58 |
61 bool SetEscaped(Node* node); | |
62 Node* replacement(NodeId id); | |
63 Node* replacement(Node* node); | 59 Node* replacement(Node* node); |
64 Node* ResolveReplacement(Node* node); | 60 Node* ResolveReplacement(Node* node); |
65 Node* GetReplacement(NodeId id); | |
66 bool SetReplacement(Node* node, Node* rep); | 61 bool SetReplacement(Node* node, Node* rep); |
67 bool UpdateReplacement(VirtualState* state, Node* node, Node* rep); | 62 bool UpdateReplacement(VirtualState* state, Node* node, Node* rep); |
68 | 63 |
69 VirtualObject* GetVirtualObject(VirtualState* state, Node* node); | 64 VirtualObject* GetVirtualObject(VirtualState* state, Node* node); |
70 | 65 |
71 void DebugPrint(); | 66 void DebugPrint(); |
72 void DebugPrintState(VirtualState* state); | 67 void DebugPrintState(VirtualState* state); |
73 void DebugPrintObject(VirtualObject* state, Alias id); | |
74 | |
75 Alias GetAlias(NodeId id) const; | |
76 Alias AliasCount() const; | |
77 | 68 |
78 Graph* graph() const; | 69 Graph* graph() const; |
79 Zone* zone() const { return zone_; } | 70 Zone* zone() const { return zone_; } |
80 CommonOperatorBuilder* common() const { return common_; } | 71 CommonOperatorBuilder* common() const { return common_; } |
81 | 72 |
82 Zone* const zone_; | 73 Zone* const zone_; |
83 CommonOperatorBuilder* const common_; | 74 CommonOperatorBuilder* const common_; |
84 EscapeStatusAnalysis* status_analysis_; | 75 EscapeStatusAnalysis* status_analysis_; |
85 ZoneVector<VirtualState*> virtual_states_; | 76 ZoneVector<VirtualState*> virtual_states_; |
86 ZoneVector<Node*> replacements_; | 77 ZoneVector<Node*> replacements_; |
87 MergeCache* cache_; | 78 MergeCache* cache_; |
88 | 79 |
89 DISALLOW_COPY_AND_ASSIGN(EscapeAnalysis); | 80 DISALLOW_COPY_AND_ASSIGN(EscapeAnalysis); |
90 }; | 81 }; |
91 | 82 |
92 } // namespace compiler | 83 } // namespace compiler |
93 } // namespace internal | 84 } // namespace internal |
94 } // namespace v8 | 85 } // namespace v8 |
95 | 86 |
96 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_ | 87 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_ |
OLD | NEW |