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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 value = graph()->NewNode( | 252 value = graph()->NewNode( |
253 common()->Select(MachineRepresentation::kNone), | 253 common()->Select(MachineRepresentation::kNone), |
254 graph()->NewNode(simplified()->NumberLessThan(), input, value), input, | 254 graph()->NewNode(simplified()->NumberLessThan(), input, value), input, |
255 value); | 255 value); |
256 } | 256 } |
257 return Replace(value); | 257 return Replace(value); |
258 } | 258 } |
259 return NoChange(); | 259 return NoChange(); |
260 } | 260 } |
261 | 261 |
| 262 // ES6 section 20.2.2.23 Math.log2 ( x ) |
| 263 Reduction JSBuiltinReducer::ReduceMathLog2(Node* node) { |
| 264 JSCallReduction r(node); |
| 265 if (r.InputsMatchOne(Type::Number())) { |
| 266 // Math.log2(a:number) -> NumberLog(a) |
| 267 Node* value = graph()->NewNode(simplified()->NumberLog2(), r.left()); |
| 268 return Replace(value); |
| 269 } |
| 270 return NoChange(); |
| 271 } |
| 272 |
| 273 // ES6 section 20.2.2.22 Math.log10 ( x ) |
| 274 Reduction JSBuiltinReducer::ReduceMathLog10(Node* node) { |
| 275 JSCallReduction r(node); |
| 276 if (r.InputsMatchOne(Type::Number())) { |
| 277 // Math.log10(a:number) -> NumberLog10(a) |
| 278 Node* value = graph()->NewNode(simplified()->NumberLog10(), r.left()); |
| 279 return Replace(value); |
| 280 } |
| 281 return NoChange(); |
| 282 } |
| 283 |
262 // ES6 section 20.2.2.28 Math.round ( x ) | 284 // ES6 section 20.2.2.28 Math.round ( x ) |
263 Reduction JSBuiltinReducer::ReduceMathRound(Node* node) { | 285 Reduction JSBuiltinReducer::ReduceMathRound(Node* node) { |
264 JSCallReduction r(node); | 286 JSCallReduction r(node); |
265 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 287 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
266 // Math.round(a:plain-primitive) -> NumberRound(ToNumber(a)) | 288 // Math.round(a:plain-primitive) -> NumberRound(ToNumber(a)) |
267 Node* input = ToNumber(r.GetJSCallInput(0)); | 289 Node* input = ToNumber(r.GetJSCallInput(0)); |
268 Node* value = graph()->NewNode(simplified()->NumberRound(), input); | 290 Node* value = graph()->NewNode(simplified()->NumberRound(), input); |
269 return Replace(value); | 291 return Replace(value); |
270 } | 292 } |
271 return NoChange(); | 293 return NoChange(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 break; | 356 break; |
335 case kMathImul: | 357 case kMathImul: |
336 reduction = ReduceMathImul(node); | 358 reduction = ReduceMathImul(node); |
337 break; | 359 break; |
338 case kMathLog: | 360 case kMathLog: |
339 reduction = ReduceMathLog(node); | 361 reduction = ReduceMathLog(node); |
340 break; | 362 break; |
341 case kMathLog1p: | 363 case kMathLog1p: |
342 reduction = ReduceMathLog1p(node); | 364 reduction = ReduceMathLog1p(node); |
343 break; | 365 break; |
| 366 case kMathLog2: |
| 367 reduction = ReduceMathLog2(node); |
| 368 break; |
| 369 case kMathLog10: |
| 370 reduction = ReduceMathLog10(node); |
| 371 break; |
344 case kMathMax: | 372 case kMathMax: |
345 reduction = ReduceMathMax(node); | 373 reduction = ReduceMathMax(node); |
346 break; | 374 break; |
347 case kMathMin: | 375 case kMathMin: |
348 reduction = ReduceMathMin(node); | 376 reduction = ReduceMathMin(node); |
349 break; | 377 break; |
350 case kMathRound: | 378 case kMathRound: |
351 reduction = ReduceMathRound(node); | 379 reduction = ReduceMathRound(node); |
352 break; | 380 break; |
353 case kMathSqrt: | 381 case kMathSqrt: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 } | 422 } |
395 | 423 |
396 | 424 |
397 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 425 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
398 return jsgraph()->simplified(); | 426 return jsgraph()->simplified(); |
399 } | 427 } |
400 | 428 |
401 } // namespace compiler | 429 } // namespace compiler |
402 } // namespace internal | 430 } // namespace internal |
403 } // namespace v8 | 431 } // namespace v8 |
OLD | NEW |