summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/escape-analysis-reducer.h
blob: 61e7607a360470214710da2a5e0b8785cd7033e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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_REDUCER_H_
#define V8_COMPILER_ESCAPE_ANALYSIS_REDUCER_H_

#include "src/base/compiler-specific.h"
#include "src/bit-vector.h"
#include "src/compiler/escape-analysis.h"
#include "src/compiler/graph-reducer.h"
#include "src/globals.h"

namespace v8 {
namespace internal {
namespace compiler {

// Forward declarations.
class JSGraph;

class V8_EXPORT_PRIVATE EscapeAnalysisReducer final
    : public NON_EXPORTED_BASE(AdvancedReducer) {
 public:
  EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph,
                        EscapeAnalysis* escape_analysis, Zone* zone);

  Reduction Reduce(Node* node) final;

  // Verifies that all virtual allocation nodes have been dealt with. Run it
  // after this reducer has been applied. Has no effect in release mode.
  void VerifyReplacement() const;

  bool compilation_failed() const { return compilation_failed_; }

 private:
  Reduction ReduceLoad(Node* node);
  Reduction ReduceStore(Node* node);
  Reduction ReduceAllocate(Node* node);
  Reduction ReduceFinishRegion(Node* node);
  Reduction ReduceReferenceEqual(Node* node);
  Reduction ReduceObjectIsSmi(Node* node);
  Reduction ReduceFrameStateUses(Node* node);
  Node* ReduceDeoptState(Node* node, Node* effect, bool multiple_users);
  Node* ReduceStateValueInput(Node* node, int node_index, Node* effect,
                              bool node_multiused, bool already_cloned,
                              bool multiple_users);

  JSGraph* jsgraph() const { return jsgraph_; }
  EscapeAnalysis* escape_analysis() const { return escape_analysis_; }
  Zone* zone() const { return zone_; }
  Isolate* isolate() const;

  JSGraph* const jsgraph_;
  EscapeAnalysis* escape_analysis_;
  Zone* const zone_;
  // This bit vector marks nodes we already processed (allocs, loads, stores)
  // and nodes that do not need a visit from ReduceDeoptState etc.
  BitVector fully_reduced_;
  bool exists_virtual_allocate_;
  bool compilation_failed_ = false;

  DISALLOW_COPY_AND_ASSIGN(EscapeAnalysisReducer);
};

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

#endif  // V8_COMPILER_ESCAPE_ANALYSIS_REDUCER_H_