escape-analysis.h 2.66 KB
Newer Older
1 2 3 4 5 6 7 8
// 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"
9
#include "src/globals.h"
10 11 12 13 14 15 16

namespace v8 {
namespace internal {
namespace compiler {

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

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

29
  bool Run();
30

31
  Node* GetReplacement(Node* node);
32
  Node* ResolveReplacement(Node* node);
33 34
  bool IsVirtual(Node* node);
  bool IsEscaped(Node* node);
35 36
  bool CompareVirtualObjects(Node* left, Node* right);
  Node* GetOrCreateObjectState(Node* effect, Node* node);
37
  bool IsCyclicObjectState(Node* effect, Node* node);
38
  bool ExistsVirtualAllocate();
39
  bool SetReplacement(Node* node, Node* rep);
40
  bool AllObjectsComplete();
41 42

 private:
43
  void RunObjectAnalysis();
44 45 46
  bool Process(Node* node);
  void ProcessLoadField(Node* node);
  void ProcessStoreField(Node* node);
47 48
  void ProcessLoadElement(Node* node);
  void ProcessStoreElement(Node* node);
49
  void ProcessCheckMaps(Node* node);
50
  void ProcessAllocationUsers(Node* node);
51 52 53 54 55
  void ProcessAllocation(Node* node);
  void ProcessFinishRegion(Node* node);
  void ProcessCall(Node* node);
  void ProcessStart(Node* node);
  bool ProcessEffectPhi(Node* node);
56

57
  void ForwardVirtualState(Node* node);
58 59 60
  VirtualState* CopyForModificationAt(VirtualState* state, Node* node);
  VirtualObject* CopyForModificationAt(VirtualObject* obj, VirtualState* state,
                                       Node* node);
61

62 63
  Node* replacement(Node* node);
  bool UpdateReplacement(VirtualState* state, Node* node, Node* rep);
64

65 66
  VirtualObject* GetVirtualObject(VirtualState* state, Node* node);

67
  void DebugPrint();
68
  void DebugPrintState(VirtualState* state);
69 70 71

  Graph* graph() const;
  Zone* zone() const { return zone_; }
72
  CommonOperatorBuilder* common() const { return common_; }
73 74

  Zone* const zone_;
75
  Node* const slot_not_analyzed_;
76
  CommonOperatorBuilder* const common_;
77
  EscapeStatusAnalysis* status_analysis_;
78
  ZoneVector<VirtualState*> virtual_states_;
79
  ZoneVector<Node*> replacements_;
80
  ZoneSet<VirtualObject*> cycle_detection_;
81
  MergeCache* cache_;
82

83
  DISALLOW_COPY_AND_ASSIGN(EscapeAnalysis);
84 85 86 87 88 89 90
};

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

#endif  // V8_COMPILER_ESCAPE_ANALYSIS_H_