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 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_ESCAPE_ANALYSIS_H_ 6 #define V8_COMPILER_ESCAPE_ANALYSIS_H_ 7 8 #include "src/compiler/graph.h" 9 10 namespace v8 { 11 namespace internal { 12 namespace compiler { 13 14 // Forward declarations. 15 class CommonOperatorBuilder; 16 class EscapeStatusAnalysis; 17 class MergeCache; 18 class VirtualState; 19 class VirtualObject; 20 21 // EscapeObjectAnalysis simulates stores to determine values of loads if 22 // an object is virtual and eliminated. 23 class EscapeAnalysis { 24 public: 25 EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); 26 ~EscapeAnalysis(); 27 28 void Run(); 29 30 Node* GetReplacement(Node* node); 31 bool IsVirtual(Node* node); 32 bool IsEscaped(Node* node); 33 bool CompareVirtualObjects(Node* left, Node* right); 34 Node* GetOrCreateObjectState(Node* effect, Node* node); 35 bool ExistsVirtualAllocate(); 36 37 private: 38 void RunObjectAnalysis(); 39 bool Process(Node* node); 40 void ProcessLoadField(Node* node); 41 void ProcessStoreField(Node* node); 42 void ProcessLoadElement(Node* node); 43 void ProcessStoreElement(Node* node); 44 void ProcessAllocationUsers(Node* node); 45 void ProcessAllocation(Node* node); 46 void ProcessFinishRegion(Node* node); 47 void ProcessCall(Node* node); 48 void ProcessStart(Node* node); 49 bool ProcessEffectPhi(Node* node); 50 void ProcessLoadFromPhi(int offset, Node* from, Node* node, 51 VirtualState* states); 52 53 void ForwardVirtualState(Node* node); 54 VirtualState* CopyForModificationAt(VirtualState* state, Node* node); 55 VirtualObject* CopyForModificationAt(VirtualObject* obj, VirtualState* state, 56 Node* node); 57 58 Node* replacement(Node* node); 59 Node* ResolveReplacement(Node* node); 60 bool SetReplacement(Node* node, Node* rep); 61 bool UpdateReplacement(VirtualState* state, Node* node, Node* rep); 62 63 VirtualObject* GetVirtualObject(VirtualState* state, Node* node); 64 65 void DebugPrint(); 66 void DebugPrintState(VirtualState* state); 67 68 Graph* graph() const; zone()69 Zone* zone() const { return zone_; } common()70 CommonOperatorBuilder* common() const { return common_; } 71 72 Zone* const zone_; 73 Node* const slot_not_analyzed_; 74 CommonOperatorBuilder* const common_; 75 EscapeStatusAnalysis* status_analysis_; 76 ZoneVector<VirtualState*> virtual_states_; 77 ZoneVector<Node*> replacements_; 78 MergeCache* cache_; 79 80 DISALLOW_COPY_AND_ASSIGN(EscapeAnalysis); 81 }; 82 83 } // namespace compiler 84 } // namespace internal 85 } // namespace v8 86 87 #endif // V8_COMPILER_ESCAPE_ANALYSIS_H_ 88