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 #include "src/compiler/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 JSCallReduction r(node); | 176 JSCallReduction r(node); |
177 if (r.InputsMatchOne(Type::NumberOrUndefined())) { | 177 if (r.InputsMatchOne(Type::NumberOrUndefined())) { |
178 // Math.fround(a:number) -> TruncateFloat64ToFloat32(a) | 178 // Math.fround(a:number) -> TruncateFloat64ToFloat32(a) |
179 Node* value = | 179 Node* value = |
180 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left()); | 180 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left()); |
181 return Replace(value); | 181 return Replace(value); |
182 } | 182 } |
183 return NoChange(); | 183 return NoChange(); |
184 } | 184 } |
185 | 185 |
| 186 // ES6 section 20.2.2.6 Math.atan ( x ) |
| 187 Reduction JSBuiltinReducer::ReduceMathAtan(Node* node) { |
| 188 JSCallReduction r(node); |
| 189 if (r.InputsMatchOne(Type::Number())) { |
| 190 // Math.atan(a:number) -> NumberAtan(a) |
| 191 Node* value = graph()->NewNode(simplified()->NumberAtan(), r.left()); |
| 192 return Replace(value); |
| 193 } |
| 194 return NoChange(); |
| 195 } |
| 196 |
| 197 // ES6 section 20.2.2.8 Math.atan2 ( y, x ) |
| 198 Reduction JSBuiltinReducer::ReduceMathAtan2(Node* node) { |
| 199 JSCallReduction r(node); |
| 200 if (r.InputsMatchTwo(Type::Number(), Type::Number())) { |
| 201 // Math.atan2(a:number, b:number) -> NumberAtan2(a, b) |
| 202 Node* value = |
| 203 graph()->NewNode(simplified()->NumberAtan2(), r.left(), r.right()); |
| 204 return Replace(value); |
| 205 } |
| 206 return NoChange(); |
| 207 } |
| 208 |
186 // ES6 section 20.2.2.20 Math.log ( x ) | 209 // ES6 section 20.2.2.20 Math.log ( x ) |
187 Reduction JSBuiltinReducer::ReduceMathLog(Node* node) { | 210 Reduction JSBuiltinReducer::ReduceMathLog(Node* node) { |
188 JSCallReduction r(node); | 211 JSCallReduction r(node); |
189 if (r.InputsMatchOne(Type::Number())) { | 212 if (r.InputsMatchOne(Type::Number())) { |
190 // Math.log(a:number) -> NumberLog(a) | 213 // Math.log(a:number) -> NumberLog(a) |
191 Node* value = graph()->NewNode(simplified()->NumberLog(), r.left()); | 214 Node* value = graph()->NewNode(simplified()->NumberLog(), r.left()); |
192 return Replace(value); | 215 return Replace(value); |
193 } | 216 } |
194 return NoChange(); | 217 return NoChange(); |
195 } | 218 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 break; | 291 break; |
269 case kMathCeil: | 292 case kMathCeil: |
270 reduction = ReduceMathCeil(node); | 293 reduction = ReduceMathCeil(node); |
271 break; | 294 break; |
272 case kMathFloor: | 295 case kMathFloor: |
273 reduction = ReduceMathFloor(node); | 296 reduction = ReduceMathFloor(node); |
274 break; | 297 break; |
275 case kMathFround: | 298 case kMathFround: |
276 reduction = ReduceMathFround(node); | 299 reduction = ReduceMathFround(node); |
277 break; | 300 break; |
| 301 case kMathAtan: |
| 302 reduction = ReduceMathAtan(node); |
| 303 break; |
| 304 case kMathAtan2: |
| 305 reduction = ReduceMathAtan2(node); |
| 306 break; |
278 case kMathLog: | 307 case kMathLog: |
279 reduction = ReduceMathLog(node); | 308 reduction = ReduceMathLog(node); |
280 break; | 309 break; |
281 case kMathLog1p: | 310 case kMathLog1p: |
282 reduction = ReduceMathLog1p(node); | 311 reduction = ReduceMathLog1p(node); |
283 break; | 312 break; |
284 case kMathRound: | 313 case kMathRound: |
285 reduction = ReduceMathRound(node); | 314 reduction = ReduceMathRound(node); |
286 break; | 315 break; |
287 case kMathSqrt: | 316 case kMathSqrt: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 350 } |
322 | 351 |
323 | 352 |
324 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 353 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
325 return jsgraph()->simplified(); | 354 return jsgraph()->simplified(); |
326 } | 355 } |
327 | 356 |
328 } // namespace compiler | 357 } // namespace compiler |
329 } // namespace internal | 358 } // namespace internal |
330 } // namespace v8 | 359 } // namespace v8 |
OLD | NEW |