escape-analysis.h 2.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_ESCAPE_ANALYSIS_H_
#define V8_COMPILER_ESCAPE_ANALYSIS_H_

#include "src/compiler/graph.h"

namespace v8 {
namespace internal {
namespace compiler {

// Forward declarations.
class CommonOperatorBuilder;
16 17
class EscapeStatusAnalysis;
class MergeCache;
18
class VirtualState;
19
class VirtualObject;
20 21 22

// EscapeObjectAnalysis simulates stores to determine values of loads if
// an object is virtual and eliminated.
23
class EscapeAnalysis {
24
 public:
25 26
  EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone);
  ~EscapeAnalysis();
27 28 29

  void Run();

30
  Node* GetReplacement(Node* node);
31 32
  bool IsVirtual(Node* node);
  bool IsEscaped(Node* node);
33 34
  bool CompareVirtualObjects(Node* left, Node* right);
  Node* GetOrCreateObjectState(Node* effect, Node* node);
35
  bool ExistsVirtualAllocate();
36 37

 private:
38
  void RunObjectAnalysis();
39 40 41
  bool Process(Node* node);
  void ProcessLoadField(Node* node);
  void ProcessStoreField(Node* node);
42 43 44
  void ProcessLoadElement(Node* node);
  void ProcessStoreElement(Node* node);
  void ProcessAllocationUsers(Node* node);
45 46 47 48 49
  void ProcessAllocation(Node* node);
  void ProcessFinishRegion(Node* node);
  void ProcessCall(Node* node);
  void ProcessStart(Node* node);
  bool ProcessEffectPhi(Node* node);
50 51 52
  void ProcessLoadFromPhi(int offset, Node* from, Node* node,
                          VirtualState* states);

53
  void ForwardVirtualState(Node* node);
54 55 56
  VirtualState* CopyForModificationAt(VirtualState* state, Node* node);
  VirtualObject* CopyForModificationAt(VirtualObject* obj, VirtualState* state,
                                       Node* node);
57

58 59 60 61
  Node* replacement(Node* node);
  Node* ResolveReplacement(Node* node);
  bool SetReplacement(Node* node, Node* rep);
  bool UpdateReplacement(VirtualState* state, Node* node, Node* rep);
62

63 64
  VirtualObject* GetVirtualObject(VirtualState* state, Node* node);

65
  void DebugPrint();
66
  void DebugPrintState(VirtualState* state);
67 68 69

  Graph* graph() const;
  Zone* zone() const { return zone_; }
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 84 85 86 87
};

}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_ESCAPE_ANALYSIS_H_