| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 JSCallReduction r(node); | 367 JSCallReduction r(node); |
| 368 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 368 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 369 // Math.sqrt(a:plain-primitive) -> NumberSqrt(ToNumber(a)) | 369 // Math.sqrt(a:plain-primitive) -> NumberSqrt(ToNumber(a)) |
| 370 Node* input = ToNumber(r.GetJSCallInput(0)); | 370 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 371 Node* value = graph()->NewNode(simplified()->NumberSqrt(), input); | 371 Node* value = graph()->NewNode(simplified()->NumberSqrt(), input); |
| 372 return Replace(value); | 372 return Replace(value); |
| 373 } | 373 } |
| 374 return NoChange(); | 374 return NoChange(); |
| 375 } | 375 } |
| 376 | 376 |
| 377 // ES6 section 20.2.2.33 Math.tan ( x ) |
| 378 Reduction JSBuiltinReducer::ReduceMathTan(Node* node) { |
| 379 JSCallReduction r(node); |
| 380 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 381 // Math.tan(a:plain-primitive) -> NumberTan(ToNumber(a)) |
| 382 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 383 Node* value = graph()->NewNode(simplified()->NumberTan(), input); |
| 384 return Replace(value); |
| 385 } |
| 386 return NoChange(); |
| 387 } |
| 388 |
| 377 // ES6 section 20.2.2.35 Math.trunc ( x ) | 389 // ES6 section 20.2.2.35 Math.trunc ( x ) |
| 378 Reduction JSBuiltinReducer::ReduceMathTrunc(Node* node) { | 390 Reduction JSBuiltinReducer::ReduceMathTrunc(Node* node) { |
| 379 JSCallReduction r(node); | 391 JSCallReduction r(node); |
| 380 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 392 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 381 // Math.trunc(a:plain-primitive) -> NumberTrunc(ToNumber(a)) | 393 // Math.trunc(a:plain-primitive) -> NumberTrunc(ToNumber(a)) |
| 382 Node* input = ToNumber(r.GetJSCallInput(0)); | 394 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 383 Node* value = graph()->NewNode(simplified()->NumberTrunc(), input); | 395 Node* value = graph()->NewNode(simplified()->NumberTrunc(), input); |
| 384 return Replace(value); | 396 return Replace(value); |
| 385 } | 397 } |
| 386 return NoChange(); | 398 return NoChange(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 break; | 473 break; |
| 462 case kMathRound: | 474 case kMathRound: |
| 463 reduction = ReduceMathRound(node); | 475 reduction = ReduceMathRound(node); |
| 464 break; | 476 break; |
| 465 case kMathSin: | 477 case kMathSin: |
| 466 reduction = ReduceMathSin(node); | 478 reduction = ReduceMathSin(node); |
| 467 break; | 479 break; |
| 468 case kMathSqrt: | 480 case kMathSqrt: |
| 469 reduction = ReduceMathSqrt(node); | 481 reduction = ReduceMathSqrt(node); |
| 470 break; | 482 break; |
| 483 case kMathTan: |
| 484 reduction = ReduceMathTan(node); |
| 485 break; |
| 471 case kMathTrunc: | 486 case kMathTrunc: |
| 472 reduction = ReduceMathTrunc(node); | 487 reduction = ReduceMathTrunc(node); |
| 473 break; | 488 break; |
| 474 case kStringFromCharCode: | 489 case kStringFromCharCode: |
| 475 reduction = ReduceStringFromCharCode(node); | 490 reduction = ReduceStringFromCharCode(node); |
| 476 break; | 491 break; |
| 477 default: | 492 default: |
| 478 break; | 493 break; |
| 479 } | 494 } |
| 480 | 495 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 509 } | 524 } |
| 510 | 525 |
| 511 | 526 |
| 512 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 527 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
| 513 return jsgraph()->simplified(); | 528 return jsgraph()->simplified(); |
| 514 } | 529 } |
| 515 | 530 |
| 516 } // namespace compiler | 531 } // namespace compiler |
| 517 } // namespace internal | 532 } // namespace internal |
| 518 } // namespace v8 | 533 } // namespace v8 |
| OLD | NEW |