effect-control-linearizer.h 10.8 KB
Newer Older
1 2 3 4 5 6 7 8
// 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"
9
#include "src/compiler/graph-assembler.h"
10 11
#include "src/compiler/node.h"
#include "src/compiler/simplified-operator.h"
12
#include "src/globals.h"
13 14 15 16

namespace v8 {
namespace internal {

17 18
// Forward declarations.
class Callable;
19 20 21 22 23 24 25 26 27 28
class Zone;

namespace compiler {

class CommonOperatorBuilder;
class SimplifiedOperatorBuilder;
class MachineOperatorBuilder;
class JSGraph;
class Graph;
class Schedule;
29
class SourcePositionTable;
30
class NodeOriginTable;
31

32
class V8_EXPORT_PRIVATE EffectControlLinearizer {
33
 public:
34 35
  enum MaskArrayIndexEnable { kDoNotMaskArrayIndex, kMaskArrayIndex };

36
  EffectControlLinearizer(JSGraph* graph, Schedule* schedule, Zone* temp_zone,
37
                          SourcePositionTable* source_positions,
38
                          NodeOriginTable* node_origins,
39
                          MaskArrayIndexEnable mask_array_index);
40 41 42 43

  void Run();

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

47 48
  bool TryWireInStateEffect(Node* node, Node* frame_state, Node** effect,
                            Node** control);
49 50 51
  Node* LowerChangeBitToTagged(Node* node);
  Node* LowerChangeInt31ToTaggedSigned(Node* node);
  Node* LowerChangeInt32ToTagged(Node* node);
52
  Node* LowerChangeInt64ToTagged(Node* node);
53
  Node* LowerChangeUint32ToTagged(Node* node);
54
  Node* LowerChangeUint64ToTagged(Node* node);
55 56 57
  Node* LowerChangeFloat64ToTagged(Node* node);
  Node* LowerChangeFloat64ToTaggedPointer(Node* node);
  Node* LowerChangeTaggedSignedToInt32(Node* node);
58
  Node* LowerChangeTaggedSignedToInt64(Node* node);
59 60 61
  Node* LowerChangeTaggedToBit(Node* node);
  Node* LowerChangeTaggedToInt32(Node* node);
  Node* LowerChangeTaggedToUint32(Node* node);
62
  Node* LowerChangeTaggedToInt64(Node* node);
63
  Node* LowerChangeTaggedToTaggedSigned(Node* node);
64
  Node* LowerPoisonIndex(Node* node);
65
  Node* LowerCheckInternalizedString(Node* node, Node* frame_state);
66
  void LowerCheckMaps(Node* node, Node* frame_state);
67
  Node* LowerCompareMaps(Node* node);
68
  Node* LowerCheckNumber(Node* node, Node* frame_state);
69
  Node* LowerCheckReceiver(Node* node, Node* frame_state);
70
  Node* LowerCheckReceiverOrNullOrUndefined(Node* node, Node* frame_state);
71
  Node* LowerCheckString(Node* node, Node* frame_state);
72
  Node* LowerCheckSymbol(Node* node, Node* frame_state);
73
  void LowerCheckIf(Node* node, Node* frame_state);
74 75 76 77 78 79 80 81
  Node* LowerCheckedInt32Add(Node* node, Node* frame_state);
  Node* LowerCheckedInt32Sub(Node* node, Node* frame_state);
  Node* LowerCheckedInt32Div(Node* node, Node* frame_state);
  Node* LowerCheckedInt32Mod(Node* node, Node* frame_state);
  Node* LowerCheckedUint32Div(Node* node, Node* frame_state);
  Node* LowerCheckedUint32Mod(Node* node, Node* frame_state);
  Node* LowerCheckedInt32Mul(Node* node, Node* frame_state);
  Node* LowerCheckedInt32ToTaggedSigned(Node* node, Node* frame_state);
82 83
  Node* LowerCheckedInt64ToInt32(Node* node, Node* frame_state);
  Node* LowerCheckedInt64ToTaggedSigned(Node* node, Node* frame_state);
84
  Node* LowerCheckedUint32Bounds(Node* node, Node* frame_state);
85 86
  Node* LowerCheckedUint32ToInt32(Node* node, Node* frame_state);
  Node* LowerCheckedUint32ToTaggedSigned(Node* node, Node* frame_state);
87
  Node* LowerCheckedUint64Bounds(Node* node, Node* frame_state);
88 89
  Node* LowerCheckedUint64ToInt32(Node* node, Node* frame_state);
  Node* LowerCheckedUint64ToTaggedSigned(Node* node, Node* frame_state);
90
  Node* LowerCheckedFloat64ToInt32(Node* node, Node* frame_state);
91
  Node* LowerCheckedFloat64ToInt64(Node* node, Node* frame_state);
92 93
  Node* LowerCheckedTaggedSignedToInt32(Node* node, Node* frame_state);
  Node* LowerCheckedTaggedToInt32(Node* node, Node* frame_state);
94
  Node* LowerCheckedTaggedToInt64(Node* node, Node* frame_state);
95 96 97 98
  Node* LowerCheckedTaggedToFloat64(Node* node, Node* frame_state);
  Node* LowerCheckedTaggedToTaggedSigned(Node* node, Node* frame_state);
  Node* LowerCheckedTaggedToTaggedPointer(Node* node, Node* frame_state);
  Node* LowerChangeTaggedToFloat64(Node* node);
99
  void TruncateTaggedPointerToBit(Node* node, GraphAssemblerLabel<1>* done);
100
  Node* LowerTruncateTaggedToBit(Node* node);
101
  Node* LowerTruncateTaggedPointerToBit(Node* node);
102 103 104
  Node* LowerTruncateTaggedToFloat64(Node* node);
  Node* LowerTruncateTaggedToWord32(Node* node);
  Node* LowerCheckedTruncateTaggedToWord32(Node* node, Node* frame_state);
105
  Node* LowerAllocate(Node* node);
106
  Node* LowerNumberToString(Node* node);
107
  Node* LowerObjectIsArrayBufferView(Node* node);
108
  Node* LowerObjectIsBigInt(Node* node);
109
  Node* LowerObjectIsCallable(Node* node);
110
  Node* LowerObjectIsConstructor(Node* node);
111
  Node* LowerObjectIsDetectableCallable(Node* node);
112
  Node* LowerObjectIsMinusZero(Node* node);
113
  Node* LowerNumberIsMinusZero(Node* node);
114
  Node* LowerObjectIsNaN(Node* node);
115
  Node* LowerNumberIsNaN(Node* node);
116
  Node* LowerObjectIsNonCallable(Node* node);
117 118 119 120
  Node* LowerObjectIsNumber(Node* node);
  Node* LowerObjectIsReceiver(Node* node);
  Node* LowerObjectIsSmi(Node* node);
  Node* LowerObjectIsString(Node* node);
121
  Node* LowerObjectIsSymbol(Node* node);
122
  Node* LowerObjectIsUndetectable(Node* node);
123
  Node* LowerNumberIsFloat64Hole(Node* node);
124 125
  Node* LowerNumberIsFinite(Node* node);
  Node* LowerObjectIsFiniteNumber(Node* node);
126 127
  Node* LowerNumberIsInteger(Node* node);
  Node* LowerObjectIsInteger(Node* node);
128 129
  Node* LowerNumberIsSafeInteger(Node* node);
  Node* LowerObjectIsSafeInteger(Node* node);
130 131
  Node* LowerArgumentsFrame(Node* node);
  Node* LowerArgumentsLength(Node* node);
132 133
  Node* LowerNewDoubleElements(Node* node);
  Node* LowerNewSmiOrObjectElements(Node* node);
134
  Node* LowerNewArgumentsElements(Node* node);
135
  Node* LowerNewConsString(Node* node);
136
  Node* LowerSameValue(Node* node);
137
  Node* LowerDeadValue(Node* node);
138
  Node* LowerStringConcat(Node* node);
139
  Node* LowerStringToNumber(Node* node);
140
  Node* LowerStringCharCodeAt(Node* node);
141
  Node* LowerStringCodePointAt(Node* node, UnicodeEncoding encoding);
142 143
  Node* LowerStringToLowerCaseIntl(Node* node);
  Node* LowerStringToUpperCaseIntl(Node* node);
144
  Node* LowerStringFromSingleCharCode(Node* node);
145
  Node* LowerStringFromSingleCodePoint(Node* node);
146
  Node* LowerStringIndexOf(Node* node);
147
  Node* LowerStringSubstring(Node* node);
148
  Node* LowerStringLength(Node* node);
149 150 151 152
  Node* LowerStringEqual(Node* node);
  Node* LowerStringLessThan(Node* node);
  Node* LowerStringLessThanOrEqual(Node* node);
  Node* LowerCheckFloat64Hole(Node* node, Node* frame_state);
153
  Node* LowerCheckNotTaggedHole(Node* node, Node* frame_state);
154
  Node* LowerConvertTaggedHoleToUndefined(Node* node);
155 156
  void LowerCheckEqualsInternalizedString(Node* node, Node* frame_state);
  void LowerCheckEqualsSymbol(Node* node, Node* frame_state);
157
  Node* LowerTypeOf(Node* node);
158
  Node* LowerToBoolean(Node* node);
159 160 161 162 163 164
  Node* LowerPlainPrimitiveToNumber(Node* node);
  Node* LowerPlainPrimitiveToWord32(Node* node);
  Node* LowerPlainPrimitiveToFloat64(Node* node);
  Node* LowerEnsureWritableFastElements(Node* node);
  Node* LowerMaybeGrowFastElements(Node* node, Node* frame_state);
  void LowerTransitionElementsKind(Node* node);
165
  Node* LowerLoadFieldByIndex(Node* node);
166
  Node* LowerLoadTypedElement(Node* node);
167
  Node* LowerLoadDataViewElement(Node* node);
168
  void LowerStoreTypedElement(Node* node);
169
  void LowerStoreDataViewElement(Node* node);
170
  void LowerStoreSignedSmallElement(Node* node);
171
  Node* LowerFindOrderedHashMapEntry(Node* node);
172
  Node* LowerFindOrderedHashMapEntryForInt32Key(Node* node);
173
  void LowerTransitionAndStoreElement(Node* node);
174 175
  void LowerTransitionAndStoreNumberElement(Node* node);
  void LowerTransitionAndStoreNonNumberElement(Node* node);
176
  void LowerRuntimeAbort(Node* node);
177
  Node* LowerConvertReceiver(Node* node);
178
  Node* LowerDateNow(Node* node);
179

180
  // Lowering of optional operators.
181 182 183 184 185 186
  Maybe<Node*> LowerFloat64RoundUp(Node* node);
  Maybe<Node*> LowerFloat64RoundDown(Node* node);
  Maybe<Node*> LowerFloat64RoundTiesEven(Node* node);
  Maybe<Node*> LowerFloat64RoundTruncate(Node* node);

  Node* AllocateHeapNumberWithValue(Node* node);
187 188
  Node* BuildCheckedFloat64ToInt32(CheckForMinusZeroMode mode,
                                   const VectorSlotPair& feedback, Node* value,
189
                                   Node* frame_state);
190 191 192
  Node* BuildCheckedFloat64ToInt64(CheckForMinusZeroMode mode,
                                   const VectorSlotPair& feedback, Node* value,
                                   Node* frame_state);
193
  Node* BuildCheckedHeapNumberOrOddballToFloat64(CheckTaggedInputMode mode,
194
                                                 const VectorSlotPair& feedback,
195 196
                                                 Node* value,
                                                 Node* frame_state);
197
  Node* BuildReverseBytes(ExternalArrayType type, Node* value);
198
  Node* BuildFloat64RoundDown(Node* value);
199
  Node* BuildFloat64RoundTruncate(Node* input);
200
  Node* BuildUint32Mod(Node* lhs, Node* rhs);
201
  Node* ComputeUnseededHash(Node* value);
202
  Node* LowerStringComparison(Callable const& callable, Node* node);
203
  Node* IsElementsKindGreaterThan(Node* kind, ElementsKind reference_kind);
204

205
  Node* ChangeInt32ToSmi(Node* value);
206
  Node* ChangeInt32ToIntPtr(Node* value);
207
  Node* ChangeInt64ToSmi(Node* value);
208
  Node* ChangeIntPtrToInt32(Node* value);
209
  Node* ChangeIntPtrToSmi(Node* value);
210
  Node* ChangeUint32ToUintPtr(Node* value);
211
  Node* ChangeUint32ToSmi(Node* value);
212
  Node* ChangeSmiToIntPtr(Node* value);
213
  Node* ChangeSmiToInt32(Node* value);
214
  Node* ChangeSmiToInt64(Node* value);
215
  Node* ObjectIsSmi(Node* value);
216
  Node* LoadFromSeqString(Node* receiver, Node* position, Node* is_one_byte);
217 218 219

  Node* SmiMaxValueConstant();
  Node* SmiShiftBitsConstant();
220 221
  void TransitionElementsTo(Node* node, Node* array, ElementsKind from,
                            ElementsKind to);
222

223 224
  Factory* factory() const;
  Isolate* isolate() const;
225 226 227 228 229 230 231 232
  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;

233
  GraphAssembler* gasm() { return &graph_assembler_; }
234

235 236 237
  JSGraph* js_graph_;
  Schedule* schedule_;
  Zone* temp_zone_;
238
  MaskArrayIndexEnable mask_array_index_;
239
  RegionObservability region_observability_ = RegionObservability::kObservable;
240
  SourcePositionTable* source_positions_;
241
  NodeOriginTable* node_origins_;
242
  GraphAssembler graph_assembler_;
243
  Node* frame_state_zapper_;  // For tracking down compiler::Node::New crashes.
244 245 246 247 248 249 250
};

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

#endif  // V8_COMPILER_EFFECT_CONTROL_LINEARIZER_H_