OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_ | 5 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_ |
6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ | 6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ |
7 | 7 |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 static TruncationKind Generalize(TruncationKind rep1, TruncationKind rep2); | 74 static TruncationKind Generalize(TruncationKind rep1, TruncationKind rep2); |
75 static bool LessGeneral(TruncationKind rep1, TruncationKind rep2); | 75 static bool LessGeneral(TruncationKind rep1, TruncationKind rep2); |
76 }; | 76 }; |
77 | 77 |
78 enum class TypeCheckKind : uint8_t { | 78 enum class TypeCheckKind : uint8_t { |
79 kNone, | 79 kNone, |
80 kSignedSmall, | 80 kSignedSmall, |
81 kSigned32, | 81 kSigned32, |
82 kNumber, | 82 kNumber, |
83 kNumberOrOddball | 83 kNumberOrOddball, |
| 84 kHeapObject |
84 }; | 85 }; |
85 | 86 |
86 inline std::ostream& operator<<(std::ostream& os, TypeCheckKind type_check) { | 87 inline std::ostream& operator<<(std::ostream& os, TypeCheckKind type_check) { |
87 switch (type_check) { | 88 switch (type_check) { |
88 case TypeCheckKind::kNone: | 89 case TypeCheckKind::kNone: |
89 return os << "None"; | 90 return os << "None"; |
90 case TypeCheckKind::kSignedSmall: | 91 case TypeCheckKind::kSignedSmall: |
91 return os << "SignedSmall"; | 92 return os << "SignedSmall"; |
92 case TypeCheckKind::kSigned32: | 93 case TypeCheckKind::kSigned32: |
93 return os << "Signed32"; | 94 return os << "Signed32"; |
94 case TypeCheckKind::kNumber: | 95 case TypeCheckKind::kNumber: |
95 return os << "Number"; | 96 return os << "Number"; |
96 case TypeCheckKind::kNumberOrOddball: | 97 case TypeCheckKind::kNumberOrOddball: |
97 return os << "NumberOrOddball"; | 98 return os << "NumberOrOddball"; |
| 99 case TypeCheckKind::kHeapObject: |
| 100 return os << "HeapObject"; |
98 } | 101 } |
99 UNREACHABLE(); | 102 UNREACHABLE(); |
100 return os; | 103 return os; |
101 } | 104 } |
102 | 105 |
103 // The {UseInfo} class is used to describe a use of an input of a node. | 106 // The {UseInfo} class is used to describe a use of an input of a node. |
104 // | 107 // |
105 // This information is used in two different ways, based on the phase: | 108 // This information is used in two different ways, based on the phase: |
106 // | 109 // |
107 // 1. During propagation, the use info is used to inform the input node | 110 // 1. During propagation, the use info is used to inform the input node |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return UseInfo(MachineRepresentation::kTagged, Truncation::Any()); | 148 return UseInfo(MachineRepresentation::kTagged, Truncation::Any()); |
146 } | 149 } |
147 static UseInfo TaggedSigned() { | 150 static UseInfo TaggedSigned() { |
148 return UseInfo(MachineRepresentation::kTaggedSigned, Truncation::Any()); | 151 return UseInfo(MachineRepresentation::kTaggedSigned, Truncation::Any()); |
149 } | 152 } |
150 static UseInfo TaggedPointer() { | 153 static UseInfo TaggedPointer() { |
151 return UseInfo(MachineRepresentation::kTaggedPointer, Truncation::Any()); | 154 return UseInfo(MachineRepresentation::kTaggedPointer, Truncation::Any()); |
152 } | 155 } |
153 | 156 |
154 // Possibly deoptimizing conversions. | 157 // Possibly deoptimizing conversions. |
| 158 static UseInfo CheckedHeapObjectAsTaggedPointer() { |
| 159 return UseInfo(MachineRepresentation::kTaggedPointer, Truncation::Any(), |
| 160 TypeCheckKind::kHeapObject); |
| 161 } |
155 static UseInfo CheckedSignedSmallAsTaggedSigned() { | 162 static UseInfo CheckedSignedSmallAsTaggedSigned() { |
156 return UseInfo(MachineRepresentation::kTaggedSigned, Truncation::Any(), | 163 return UseInfo(MachineRepresentation::kTaggedSigned, Truncation::Any(), |
157 TypeCheckKind::kSignedSmall); | 164 TypeCheckKind::kSignedSmall); |
158 } | 165 } |
159 static UseInfo CheckedSignedSmallAsWord32( | 166 static UseInfo CheckedSignedSmallAsWord32( |
160 CheckForMinusZeroMode minus_zero_mode = | 167 CheckForMinusZeroMode minus_zero_mode = |
161 CheckForMinusZeroMode::kCheckForMinusZero) { | 168 CheckForMinusZeroMode::kCheckForMinusZero) { |
162 return UseInfo(MachineRepresentation::kWord32, Truncation::Any(), | 169 return UseInfo(MachineRepresentation::kWord32, Truncation::Any(), |
163 TypeCheckKind::kSignedSmall, minus_zero_mode); | 170 TypeCheckKind::kSignedSmall, minus_zero_mode); |
164 } | 171 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 260 |
254 bool testing_type_errors_; // If {true}, don't abort on a type error. | 261 bool testing_type_errors_; // If {true}, don't abort on a type error. |
255 bool type_error_; // Set when a type error is detected. | 262 bool type_error_; // Set when a type error is detected. |
256 | 263 |
257 Node* GetTaggedSignedRepresentationFor(Node* node, | 264 Node* GetTaggedSignedRepresentationFor(Node* node, |
258 MachineRepresentation output_rep, | 265 MachineRepresentation output_rep, |
259 Type* output_type, Node* use_node, | 266 Type* output_type, Node* use_node, |
260 UseInfo use_info); | 267 UseInfo use_info); |
261 Node* GetTaggedPointerRepresentationFor(Node* node, | 268 Node* GetTaggedPointerRepresentationFor(Node* node, |
262 MachineRepresentation output_rep, | 269 MachineRepresentation output_rep, |
263 Type* output_type); | 270 Type* output_type, Node* use_node, |
| 271 UseInfo use_info); |
264 Node* GetTaggedRepresentationFor(Node* node, MachineRepresentation output_rep, | 272 Node* GetTaggedRepresentationFor(Node* node, MachineRepresentation output_rep, |
265 Type* output_type, Truncation truncation); | 273 Type* output_type, Truncation truncation); |
266 Node* GetFloat32RepresentationFor(Node* node, | 274 Node* GetFloat32RepresentationFor(Node* node, |
267 MachineRepresentation output_rep, | 275 MachineRepresentation output_rep, |
268 Type* output_type, Truncation truncation); | 276 Type* output_type, Truncation truncation); |
269 Node* GetFloat64RepresentationFor(Node* node, | 277 Node* GetFloat64RepresentationFor(Node* node, |
270 MachineRepresentation output_rep, | 278 MachineRepresentation output_rep, |
271 Type* output_type, Node* use_node, | 279 Type* output_type, Node* use_node, |
272 UseInfo use_info); | 280 UseInfo use_info); |
273 Node* GetWord32RepresentationFor(Node* node, MachineRepresentation output_rep, | 281 Node* GetWord32RepresentationFor(Node* node, MachineRepresentation output_rep, |
274 Type* output_type, Node* use_node, | 282 Type* output_type, Node* use_node, |
275 UseInfo use_info); | 283 UseInfo use_info); |
276 Node* GetBitRepresentationFor(Node* node, MachineRepresentation output_rep, | 284 Node* GetBitRepresentationFor(Node* node, MachineRepresentation output_rep, |
277 Type* output_type); | 285 Type* output_type); |
278 Node* GetWord64RepresentationFor(Node* node, MachineRepresentation output_rep, | 286 Node* GetWord64RepresentationFor(Node* node, MachineRepresentation output_rep, |
279 Type* output_type); | 287 Type* output_type); |
280 Node* TypeError(Node* node, MachineRepresentation output_rep, | 288 Node* TypeError(Node* node, MachineRepresentation output_rep, |
281 Type* output_type, MachineRepresentation use); | 289 Type* output_type, MachineRepresentation use); |
282 Node* MakeTruncatedInt32Constant(double value); | 290 Node* MakeTruncatedInt32Constant(double value); |
283 Node* InsertChangeBitToTagged(Node* node); | 291 Node* InsertChangeBitToTagged(Node* node); |
284 Node* InsertChangeFloat32ToFloat64(Node* node); | 292 Node* InsertChangeFloat32ToFloat64(Node* node); |
285 Node* InsertChangeFloat64ToInt32(Node* node); | 293 Node* InsertChangeFloat64ToInt32(Node* node); |
286 Node* InsertChangeFloat64ToUint32(Node* node); | 294 Node* InsertChangeFloat64ToUint32(Node* node); |
| 295 Node* InsertChangeInt32ToFloat64(Node* node); |
287 Node* InsertChangeTaggedSignedToInt32(Node* node); | 296 Node* InsertChangeTaggedSignedToInt32(Node* node); |
288 Node* InsertChangeTaggedToFloat64(Node* node); | 297 Node* InsertChangeTaggedToFloat64(Node* node); |
| 298 Node* InsertChangeUint32ToFloat64(Node* node); |
289 | 299 |
290 Node* InsertConversion(Node* node, const Operator* op, Node* use_node); | 300 Node* InsertConversion(Node* node, const Operator* op, Node* use_node); |
291 | 301 |
292 JSGraph* jsgraph() const { return jsgraph_; } | 302 JSGraph* jsgraph() const { return jsgraph_; } |
293 Isolate* isolate() const { return isolate_; } | 303 Isolate* isolate() const { return isolate_; } |
294 Factory* factory() const { return isolate()->factory(); } | 304 Factory* factory() const { return isolate()->factory(); } |
295 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } | 305 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } |
296 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } | 306 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } |
297 }; | 307 }; |
298 | 308 |
299 } // namespace compiler | 309 } // namespace compiler |
300 } // namespace internal | 310 } // namespace internal |
301 } // namespace v8 | 311 } // namespace v8 |
302 | 312 |
303 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ | 313 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ |
OLD | NEW |