summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/effect-control-linearizer.h
blob: 98f08c7b12e75865ec3e80c6d5f15a5637b3008d (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// Copyright 2016 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_EFFECT_CONTROL_LINEARIZER_H_
#define V8_COMPILER_EFFECT_CONTROL_LINEARIZER_H_

#include "src/compiler/common-operator.h"
#include "src/compiler/node.h"
#include "src/compiler/simplified-operator.h"

namespace v8 {
namespace internal {

class Zone;

namespace compiler {

class CommonOperatorBuilder;
class SimplifiedOperatorBuilder;
class MachineOperatorBuilder;
class JSGraph;
class Graph;
class Schedule;

class EffectControlLinearizer {
 public:
  EffectControlLinearizer(JSGraph* graph, Schedule* schedule, Zone* temp_zone);

  void Run();

 private:
  void ProcessNode(Node* node, Node** frame_state, Node** effect,
                   Node** control);

  struct ValueEffectControl {
    Node* value;
    Node* effect;
    Node* control;
    ValueEffectControl(Node* value, Node* effect, Node* control)
        : value(value), effect(effect), control(control) {}
  };

  bool TryWireInStateEffect(Node* node, Node* frame_state, Node** effect,
                            Node** control);
  ValueEffectControl LowerChangeBitToTagged(Node* node, Node* effect,
                                            Node* control);
  ValueEffectControl LowerChangeInt31ToTaggedSigned(Node* node, Node* effect,
                                                    Node* control);
  ValueEffectControl LowerChangeInt32ToTagged(Node* node, Node* effect,
                                              Node* control);
  ValueEffectControl LowerChangeUint32ToTagged(Node* node, Node* effect,
                                               Node* control);
  ValueEffectControl LowerChangeFloat64ToTagged(Node* node, Node* effect,
                                                Node* control);
  ValueEffectControl LowerChangeTaggedSignedToInt32(Node* node, Node* effect,
                                                    Node* control);
  ValueEffectControl LowerChangeTaggedToBit(Node* node, Node* effect,
                                            Node* control);
  ValueEffectControl LowerChangeTaggedToInt32(Node* node, Node* effect,
                                              Node* control);
  ValueEffectControl LowerChangeTaggedToUint32(Node* node, Node* effect,
                                               Node* control);
  ValueEffectControl LowerCheckBounds(Node* node, Node* frame_state,
                                      Node* effect, Node* control);
  ValueEffectControl LowerCheckMaps(Node* node, Node* frame_state, Node* effect,
                                    Node* control);
  ValueEffectControl LowerCheckNumber(Node* node, Node* frame_state,
                                      Node* effect, Node* control);
  ValueEffectControl LowerCheckString(Node* node, Node* frame_state,
                                      Node* effect, Node* control);
  ValueEffectControl LowerCheckIf(Node* node, Node* frame_state, Node* effect,
                                  Node* control);
  ValueEffectControl LowerCheckTaggedPointer(Node* node, Node* frame_state,
                                             Node* effect, Node* control);
  ValueEffectControl LowerCheckTaggedSigned(Node* node, Node* frame_state,
                                            Node* effect, Node* control);
  ValueEffectControl LowerCheckedInt32Add(Node* node, Node* frame_state,
                                          Node* effect, Node* control);
  ValueEffectControl LowerCheckedInt32Sub(Node* node, Node* frame_state,
                                          Node* effect, Node* control);
  ValueEffectControl LowerCheckedInt32Div(Node* node, Node* frame_state,
                                          Node* effect, Node* control);
  ValueEffectControl LowerCheckedInt32Mod(Node* node, Node* frame_state,
                                          Node* effect, Node* control);
  ValueEffectControl LowerCheckedUint32Div(Node* node, Node* frame_state,
                                           Node* effect, Node* control);
  ValueEffectControl LowerCheckedUint32Mod(Node* node, Node* frame_state,
                                           Node* effect, Node* control);
  ValueEffectControl LowerCheckedInt32Mul(Node* node, Node* frame_state,
                                          Node* effect, Node* control);
  ValueEffectControl LowerCheckedUint32ToInt32(Node* node, Node* frame_state,
                                               Node* effect, Node* control);
  ValueEffectControl LowerCheckedFloat64ToInt32(Node* node, Node* frame_state,
                                                Node* effect, Node* control);
  ValueEffectControl LowerCheckedTaggedSignedToInt32(Node* node,
                                                     Node* frame_state,
                                                     Node* effect,
                                                     Node* control);
  ValueEffectControl LowerCheckedTaggedToInt32(Node* node, Node* frame_state,
                                               Node* effect, Node* control);
  ValueEffectControl LowerCheckedTaggedToFloat64(Node* node, Node* frame_state,
                                                 Node* effect, Node* control);
  ValueEffectControl LowerChangeTaggedToFloat64(Node* node, Node* effect,
                                                Node* control);
  ValueEffectControl LowerTruncateTaggedToFloat64(Node* node, Node* effect,
                                                  Node* control);
  ValueEffectControl LowerTruncateTaggedToWord32(Node* node, Node* effect,
                                                 Node* control);
  ValueEffectControl LowerCheckedTruncateTaggedToWord32(Node* node,
                                                        Node* frame_state,
                                                        Node* effect,
                                                        Node* control);
  ValueEffectControl LowerObjectIsCallable(Node* node, Node* effect,
                                           Node* control);
  ValueEffectControl LowerObjectIsNumber(Node* node, Node* effect,
                                         Node* control);
  ValueEffectControl LowerObjectIsReceiver(Node* node, Node* effect,
                                           Node* control);
  ValueEffectControl LowerObjectIsSmi(Node* node, Node* effect, Node* control);
  ValueEffectControl LowerObjectIsString(Node* node, Node* effect,
                                         Node* control);
  ValueEffectControl LowerObjectIsUndetectable(Node* node, Node* effect,
                                               Node* control);
  ValueEffectControl LowerStringCharCodeAt(Node* node, Node* effect,
                                           Node* control);
  ValueEffectControl LowerStringFromCharCode(Node* node, Node* effect,
                                             Node* control);
  ValueEffectControl LowerCheckFloat64Hole(Node* node, Node* frame_state,
                                           Node* effect, Node* control);
  ValueEffectControl LowerCheckTaggedHole(Node* node, Node* frame_state,
                                          Node* effect, Node* control);
  ValueEffectControl LowerConvertTaggedHoleToUndefined(Node* node, Node* effect,
                                                       Node* control);
  ValueEffectControl LowerPlainPrimitiveToNumber(Node* node, Node* effect,
                                                 Node* control);
  ValueEffectControl LowerPlainPrimitiveToWord32(Node* node, Node* effect,
                                                 Node* control);
  ValueEffectControl LowerPlainPrimitiveToFloat64(Node* node, Node* effect,
                                                  Node* control);
  ValueEffectControl LowerEnsureWritableFastElements(Node* node, Node* effect,
                                                     Node* control);
  ValueEffectControl LowerMaybeGrowFastElements(Node* node, Node* frame_state,
                                                Node* effect, Node* control);
  ValueEffectControl LowerTransitionElementsKind(Node* node, Node* effect,
                                                 Node* control);
  ValueEffectControl LowerLoadTypedElement(Node* node, Node* effect,
                                           Node* control);
  ValueEffectControl LowerStoreTypedElement(Node* node, Node* effect,
                                            Node* control);

  // Lowering of optional operators.
  ValueEffectControl LowerFloat64RoundUp(Node* node, Node* effect,
                                         Node* control);
  ValueEffectControl LowerFloat64RoundDown(Node* node, Node* effect,
                                           Node* control);
  ValueEffectControl LowerFloat64RoundTruncate(Node* node, Node* effect,
                                               Node* control);

  ValueEffectControl AllocateHeapNumberWithValue(Node* node, Node* effect,
                                                 Node* control);
  ValueEffectControl BuildCheckedFloat64ToInt32(CheckForMinusZeroMode mode,
                                                Node* value, Node* frame_state,
                                                Node* effect, Node* control);
  ValueEffectControl BuildCheckedHeapNumberOrOddballToFloat64(
      CheckTaggedInputMode mode, Node* value, Node* frame_state, Node* effect,
      Node* control);

  Node* ChangeInt32ToSmi(Node* value);
  Node* ChangeUint32ToSmi(Node* value);
  Node* ChangeInt32ToFloat64(Node* value);
  Node* ChangeUint32ToFloat64(Node* value);
  Node* ChangeSmiToInt32(Node* value);
  Node* ObjectIsSmi(Node* value);

  Node* SmiMaxValueConstant();
  Node* SmiShiftBitsConstant();

  Factory* factory() const;
  Isolate* isolate() const;
  JSGraph* jsgraph() const { return js_graph_; }
  Graph* graph() const;
  Schedule* schedule() const { return schedule_; }
  Zone* temp_zone() const { return temp_zone_; }
  CommonOperatorBuilder* common() const;
  SimplifiedOperatorBuilder* simplified() const;
  MachineOperatorBuilder* machine() const;

  Operator const* ToNumberOperator();

  JSGraph* js_graph_;
  Schedule* schedule_;
  Zone* temp_zone_;
  RegionObservability region_observability_ = RegionObservability::kObservable;

  SetOncePointer<Operator const> to_number_operator_;
};

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

#endif  // V8_COMPILER_EFFECT_CONTROL_LINEARIZER_H_