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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 UNREACHABLE(); | 101 UNREACHABLE(); |
102 return os; | 102 return os; |
103 } | 103 } |
104 | 104 |
105 // The {UseInfo} class is used to describe a use of an input of a node. | 105 // The {UseInfo} class is used to describe a use of an input of a node. |
106 // | 106 // |
107 // This information is used in two different ways, based on the phase: | 107 // This information is used in two different ways, based on the phase: |
108 // | 108 // |
109 // 1. During propagation, the use info is used to inform the input node | 109 // 1. During propagation, the use info is used to inform the input node |
110 // about what part of the input is used (we call this truncation) and what | 110 // about what part of the input is used (we call this truncation) and what |
111 // is the preferred representation. | 111 // is the preferred representation. For conversions that will require |
| 112 // checks, we also keep track of whether a minus zero check is needed. |
112 // | 113 // |
113 // 2. During lowering, the use info is used to properly convert the input | 114 // 2. During lowering, the use info is used to properly convert the input |
114 // to the preferred representation. The preferred representation might be | 115 // to the preferred representation. The preferred representation might be |
115 // insufficient to do the conversion (e.g. word32->float64 conv), so we also | 116 // insufficient to do the conversion (e.g. word32->float64 conv), so we also |
116 // need the signedness information to produce the correct value. | 117 // need the signedness information to produce the correct value. |
117 class UseInfo { | 118 class UseInfo { |
118 public: | 119 public: |
119 UseInfo(MachineRepresentation representation, Truncation truncation, | 120 UseInfo(MachineRepresentation representation, Truncation truncation, |
120 TypeCheckKind type_check = TypeCheckKind::kNone) | 121 TypeCheckKind type_check = TypeCheckKind::kNone, |
| 122 CheckForMinusZeroMode minus_zero_check = |
| 123 CheckForMinusZeroMode::kCheckForMinusZero) |
121 : representation_(representation), | 124 : representation_(representation), |
122 truncation_(truncation), | 125 truncation_(truncation), |
123 type_check_(type_check) {} | 126 type_check_(type_check), |
| 127 minus_zero_check_(minus_zero_check) {} |
124 static UseInfo TruncatingWord32() { | 128 static UseInfo TruncatingWord32() { |
125 return UseInfo(MachineRepresentation::kWord32, Truncation::Word32()); | 129 return UseInfo(MachineRepresentation::kWord32, Truncation::Word32()); |
126 } | 130 } |
127 static UseInfo TruncatingWord64() { | 131 static UseInfo TruncatingWord64() { |
128 return UseInfo(MachineRepresentation::kWord64, Truncation::Word64()); | 132 return UseInfo(MachineRepresentation::kWord64, Truncation::Word64()); |
129 } | 133 } |
130 static UseInfo Bool() { | 134 static UseInfo Bool() { |
131 return UseInfo(MachineRepresentation::kBit, Truncation::Bool()); | 135 return UseInfo(MachineRepresentation::kBit, Truncation::Bool()); |
132 } | 136 } |
133 static UseInfo TruncatingFloat32() { | 137 static UseInfo TruncatingFloat32() { |
(...skipping 13 matching lines...) Expand all Loading... |
147 } | 151 } |
148 static UseInfo TaggedPointer() { | 152 static UseInfo TaggedPointer() { |
149 return UseInfo(MachineRepresentation::kTaggedPointer, Truncation::Any()); | 153 return UseInfo(MachineRepresentation::kTaggedPointer, Truncation::Any()); |
150 } | 154 } |
151 | 155 |
152 // Possibly deoptimizing conversions. | 156 // Possibly deoptimizing conversions. |
153 static UseInfo CheckedSignedSmallAsTaggedSigned() { | 157 static UseInfo CheckedSignedSmallAsTaggedSigned() { |
154 return UseInfo(MachineRepresentation::kTaggedSigned, Truncation::Any(), | 158 return UseInfo(MachineRepresentation::kTaggedSigned, Truncation::Any(), |
155 TypeCheckKind::kSignedSmall); | 159 TypeCheckKind::kSignedSmall); |
156 } | 160 } |
157 static UseInfo CheckedSignedSmallAsWord32() { | 161 static UseInfo CheckedSignedSmallAsWord32( |
| 162 CheckForMinusZeroMode minus_zero_mode = |
| 163 CheckForMinusZeroMode::kCheckForMinusZero) { |
158 return UseInfo(MachineRepresentation::kWord32, Truncation::Any(), | 164 return UseInfo(MachineRepresentation::kWord32, Truncation::Any(), |
159 TypeCheckKind::kSignedSmall); | 165 TypeCheckKind::kSignedSmall, minus_zero_mode); |
160 } | 166 } |
161 static UseInfo CheckedSigned32AsWord32() { | 167 static UseInfo CheckedSigned32AsWord32( |
| 168 CheckForMinusZeroMode minus_zero_mode = |
| 169 CheckForMinusZeroMode::kCheckForMinusZero) { |
162 return UseInfo(MachineRepresentation::kWord32, Truncation::Any(), | 170 return UseInfo(MachineRepresentation::kWord32, Truncation::Any(), |
163 TypeCheckKind::kSigned32); | 171 TypeCheckKind::kSigned32, minus_zero_mode); |
164 } | 172 } |
165 static UseInfo CheckedNumberAsFloat64() { | 173 static UseInfo CheckedNumberAsFloat64() { |
166 return UseInfo(MachineRepresentation::kFloat64, Truncation::Float64(), | 174 return UseInfo(MachineRepresentation::kFloat64, Truncation::Float64(), |
167 TypeCheckKind::kNumber); | 175 TypeCheckKind::kNumber); |
168 } | 176 } |
169 static UseInfo CheckedNumberAsWord32() { | 177 static UseInfo CheckedNumberAsWord32() { |
170 return UseInfo(MachineRepresentation::kWord32, Truncation::Word32(), | 178 return UseInfo(MachineRepresentation::kWord32, Truncation::Word32(), |
171 TypeCheckKind::kNumber); | 179 TypeCheckKind::kNumber); |
172 } | 180 } |
173 static UseInfo CheckedNumberOrOddballAsFloat64() { | 181 static UseInfo CheckedNumberOrOddballAsFloat64() { |
(...skipping 14 matching lines...) Expand all Loading... |
188 } | 196 } |
189 | 197 |
190 // Value not used. | 198 // Value not used. |
191 static UseInfo None() { | 199 static UseInfo None() { |
192 return UseInfo(MachineRepresentation::kNone, Truncation::None()); | 200 return UseInfo(MachineRepresentation::kNone, Truncation::None()); |
193 } | 201 } |
194 | 202 |
195 MachineRepresentation representation() const { return representation_; } | 203 MachineRepresentation representation() const { return representation_; } |
196 Truncation truncation() const { return truncation_; } | 204 Truncation truncation() const { return truncation_; } |
197 TypeCheckKind type_check() const { return type_check_; } | 205 TypeCheckKind type_check() const { return type_check_; } |
| 206 CheckForMinusZeroMode minus_zero_check() const { return minus_zero_check_; } |
198 | 207 |
199 private: | 208 private: |
200 MachineRepresentation representation_; | 209 MachineRepresentation representation_; |
201 Truncation truncation_; | 210 Truncation truncation_; |
202 TypeCheckKind type_check_; | 211 TypeCheckKind type_check_; |
| 212 // TODO(jarin) Integrate with truncations. |
| 213 CheckForMinusZeroMode minus_zero_check_; |
203 }; | 214 }; |
204 | 215 |
205 // Contains logic related to changing the representation of values for constants | 216 // Contains logic related to changing the representation of values for constants |
206 // and other nodes, as well as lowering Simplified->Machine operators. | 217 // and other nodes, as well as lowering Simplified->Machine operators. |
207 // Eagerly folds any representation changes for constants. | 218 // Eagerly folds any representation changes for constants. |
208 class RepresentationChanger final { | 219 class RepresentationChanger final { |
209 public: | 220 public: |
210 RepresentationChanger(JSGraph* jsgraph, Isolate* isolate) | 221 RepresentationChanger(JSGraph* jsgraph, Isolate* isolate) |
211 : jsgraph_(jsgraph), | 222 : jsgraph_(jsgraph), |
212 isolate_(isolate), | 223 isolate_(isolate), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 Factory* factory() const { return isolate()->factory(); } | 296 Factory* factory() const { return isolate()->factory(); } |
286 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } | 297 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } |
287 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } | 298 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } |
288 }; | 299 }; |
289 | 300 |
290 } // namespace compiler | 301 } // namespace compiler |
291 } // namespace internal | 302 } // namespace internal |
292 } // namespace v8 | 303 } // namespace v8 |
293 | 304 |
294 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ | 305 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ |
OLD | NEW |