| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 JSCallReduction r(node); | 170 JSCallReduction r(node); |
| 171 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 171 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 172 // Math.cos(a:plain-primitive) -> NumberCos(ToNumber(a)) | 172 // Math.cos(a:plain-primitive) -> NumberCos(ToNumber(a)) |
| 173 Node* input = ToNumber(r.GetJSCallInput(0)); | 173 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 174 Node* value = graph()->NewNode(simplified()->NumberCos(), input); | 174 Node* value = graph()->NewNode(simplified()->NumberCos(), input); |
| 175 return Replace(value); | 175 return Replace(value); |
| 176 } | 176 } |
| 177 return NoChange(); | 177 return NoChange(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // ES6 section 20.2.2.13 Math.cosh ( x ) |
| 181 Reduction JSBuiltinReducer::ReduceMathCosh(Node* node) { |
| 182 JSCallReduction r(node); |
| 183 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 184 // Math.cosh(a:plain-primitive) -> NumberCosh(ToNumber(a)) |
| 185 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 186 Node* value = graph()->NewNode(simplified()->NumberCosh(), input); |
| 187 return Replace(value); |
| 188 } |
| 189 return NoChange(); |
| 190 } |
| 191 |
| 180 // ES6 section 20.2.2.14 Math.exp ( x ) | 192 // ES6 section 20.2.2.14 Math.exp ( x ) |
| 181 Reduction JSBuiltinReducer::ReduceMathExp(Node* node) { | 193 Reduction JSBuiltinReducer::ReduceMathExp(Node* node) { |
| 182 JSCallReduction r(node); | 194 JSCallReduction r(node); |
| 183 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 195 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 184 // Math.exp(a:plain-primitive) -> NumberExp(ToNumber(a)) | 196 // Math.exp(a:plain-primitive) -> NumberExp(ToNumber(a)) |
| 185 Node* input = ToNumber(r.GetJSCallInput(0)); | 197 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 186 Node* value = graph()->NewNode(simplified()->NumberExp(), input); | 198 Node* value = graph()->NewNode(simplified()->NumberExp(), input); |
| 187 return Replace(value); | 199 return Replace(value); |
| 188 } | 200 } |
| 189 return NoChange(); | 201 return NoChange(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 JSCallReduction r(node); | 393 JSCallReduction r(node); |
| 382 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 394 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 383 // Math.sin(a:plain-primitive) -> NumberSin(ToNumber(a)) | 395 // Math.sin(a:plain-primitive) -> NumberSin(ToNumber(a)) |
| 384 Node* input = ToNumber(r.GetJSCallInput(0)); | 396 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 385 Node* value = graph()->NewNode(simplified()->NumberSin(), input); | 397 Node* value = graph()->NewNode(simplified()->NumberSin(), input); |
| 386 return Replace(value); | 398 return Replace(value); |
| 387 } | 399 } |
| 388 return NoChange(); | 400 return NoChange(); |
| 389 } | 401 } |
| 390 | 402 |
| 403 // ES6 section 20.2.2.31 Math.sinh ( x ) |
| 404 Reduction JSBuiltinReducer::ReduceMathSinh(Node* node) { |
| 405 JSCallReduction r(node); |
| 406 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 407 // Math.sinh(a:plain-primitive) -> NumberSinh(ToNumber(a)) |
| 408 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 409 Node* value = graph()->NewNode(simplified()->NumberSinh(), input); |
| 410 return Replace(value); |
| 411 } |
| 412 return NoChange(); |
| 413 } |
| 414 |
| 391 // ES6 section 20.2.2.32 Math.sqrt ( x ) | 415 // ES6 section 20.2.2.32 Math.sqrt ( x ) |
| 392 Reduction JSBuiltinReducer::ReduceMathSqrt(Node* node) { | 416 Reduction JSBuiltinReducer::ReduceMathSqrt(Node* node) { |
| 393 JSCallReduction r(node); | 417 JSCallReduction r(node); |
| 394 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 418 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 395 // Math.sqrt(a:plain-primitive) -> NumberSqrt(ToNumber(a)) | 419 // Math.sqrt(a:plain-primitive) -> NumberSqrt(ToNumber(a)) |
| 396 Node* input = ToNumber(r.GetJSCallInput(0)); | 420 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 397 Node* value = graph()->NewNode(simplified()->NumberSqrt(), input); | 421 Node* value = graph()->NewNode(simplified()->NumberSqrt(), input); |
| 398 return Replace(value); | 422 return Replace(value); |
| 399 } | 423 } |
| 400 return NoChange(); | 424 return NoChange(); |
| 401 } | 425 } |
| 402 | 426 |
| 403 // ES6 section 20.2.2.33 Math.tan ( x ) | 427 // ES6 section 20.2.2.33 Math.tan ( x ) |
| 404 Reduction JSBuiltinReducer::ReduceMathTan(Node* node) { | 428 Reduction JSBuiltinReducer::ReduceMathTan(Node* node) { |
| 405 JSCallReduction r(node); | 429 JSCallReduction r(node); |
| 406 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 430 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 407 // Math.tan(a:plain-primitive) -> NumberTan(ToNumber(a)) | 431 // Math.tan(a:plain-primitive) -> NumberTan(ToNumber(a)) |
| 408 Node* input = ToNumber(r.GetJSCallInput(0)); | 432 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 409 Node* value = graph()->NewNode(simplified()->NumberTan(), input); | 433 Node* value = graph()->NewNode(simplified()->NumberTan(), input); |
| 410 return Replace(value); | 434 return Replace(value); |
| 411 } | 435 } |
| 412 return NoChange(); | 436 return NoChange(); |
| 413 } | 437 } |
| 414 | 438 |
| 439 // ES6 section 20.2.2.34 Math.tanh ( x ) |
| 440 Reduction JSBuiltinReducer::ReduceMathTanh(Node* node) { |
| 441 JSCallReduction r(node); |
| 442 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 443 // Math.tanh(a:plain-primitive) -> NumberTanh(ToNumber(a)) |
| 444 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 445 Node* value = graph()->NewNode(simplified()->NumberTanh(), input); |
| 446 return Replace(value); |
| 447 } |
| 448 return NoChange(); |
| 449 } |
| 450 |
| 415 // ES6 section 20.2.2.35 Math.trunc ( x ) | 451 // ES6 section 20.2.2.35 Math.trunc ( x ) |
| 416 Reduction JSBuiltinReducer::ReduceMathTrunc(Node* node) { | 452 Reduction JSBuiltinReducer::ReduceMathTrunc(Node* node) { |
| 417 JSCallReduction r(node); | 453 JSCallReduction r(node); |
| 418 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 454 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| 419 // Math.trunc(a:plain-primitive) -> NumberTrunc(ToNumber(a)) | 455 // Math.trunc(a:plain-primitive) -> NumberTrunc(ToNumber(a)) |
| 420 Node* input = ToNumber(r.GetJSCallInput(0)); | 456 Node* input = ToNumber(r.GetJSCallInput(0)); |
| 421 Node* value = graph()->NewNode(simplified()->NumberTrunc(), input); | 457 Node* value = graph()->NewNode(simplified()->NumberTrunc(), input); |
| 422 return Replace(value); | 458 return Replace(value); |
| 423 } | 459 } |
| 424 return NoChange(); | 460 return NoChange(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 break; | 496 break; |
| 461 case kMathCeil: | 497 case kMathCeil: |
| 462 reduction = ReduceMathCeil(node); | 498 reduction = ReduceMathCeil(node); |
| 463 break; | 499 break; |
| 464 case kMathClz32: | 500 case kMathClz32: |
| 465 reduction = ReduceMathClz32(node); | 501 reduction = ReduceMathClz32(node); |
| 466 break; | 502 break; |
| 467 case kMathCos: | 503 case kMathCos: |
| 468 reduction = ReduceMathCos(node); | 504 reduction = ReduceMathCos(node); |
| 469 break; | 505 break; |
| 506 case kMathCosh: |
| 507 reduction = ReduceMathCosh(node); |
| 508 break; |
| 470 case kMathExp: | 509 case kMathExp: |
| 471 reduction = ReduceMathExp(node); | 510 reduction = ReduceMathExp(node); |
| 472 break; | 511 break; |
| 473 case kMathExpm1: | 512 case kMathExpm1: |
| 474 reduction = ReduceMathExpm1(node); | 513 reduction = ReduceMathExpm1(node); |
| 475 break; | 514 break; |
| 476 case kMathFloor: | 515 case kMathFloor: |
| 477 reduction = ReduceMathFloor(node); | 516 reduction = ReduceMathFloor(node); |
| 478 break; | 517 break; |
| 479 case kMathFround: | 518 case kMathFround: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 502 break; | 541 break; |
| 503 case kMathPow: | 542 case kMathPow: |
| 504 reduction = ReduceMathPow(node); | 543 reduction = ReduceMathPow(node); |
| 505 break; | 544 break; |
| 506 case kMathRound: | 545 case kMathRound: |
| 507 reduction = ReduceMathRound(node); | 546 reduction = ReduceMathRound(node); |
| 508 break; | 547 break; |
| 509 case kMathSin: | 548 case kMathSin: |
| 510 reduction = ReduceMathSin(node); | 549 reduction = ReduceMathSin(node); |
| 511 break; | 550 break; |
| 551 case kMathSinh: |
| 552 reduction = ReduceMathSinh(node); |
| 553 break; |
| 512 case kMathSqrt: | 554 case kMathSqrt: |
| 513 reduction = ReduceMathSqrt(node); | 555 reduction = ReduceMathSqrt(node); |
| 514 break; | 556 break; |
| 515 case kMathTan: | 557 case kMathTan: |
| 516 reduction = ReduceMathTan(node); | 558 reduction = ReduceMathTan(node); |
| 517 break; | 559 break; |
| 560 case kMathTanh: |
| 561 reduction = ReduceMathTanh(node); |
| 562 break; |
| 518 case kMathTrunc: | 563 case kMathTrunc: |
| 519 reduction = ReduceMathTrunc(node); | 564 reduction = ReduceMathTrunc(node); |
| 520 break; | 565 break; |
| 521 case kStringFromCharCode: | 566 case kStringFromCharCode: |
| 522 reduction = ReduceStringFromCharCode(node); | 567 reduction = ReduceStringFromCharCode(node); |
| 523 break; | 568 break; |
| 524 default: | 569 default: |
| 525 break; | 570 break; |
| 526 } | 571 } |
| 527 | 572 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 556 } | 601 } |
| 557 | 602 |
| 558 | 603 |
| 559 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 604 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
| 560 return jsgraph()->simplified(); | 605 return jsgraph()->simplified(); |
| 561 } | 606 } |
| 562 | 607 |
| 563 } // namespace compiler | 608 } // namespace compiler |
| 564 } // namespace internal | 609 } // namespace internal |
| 565 } // namespace v8 | 610 } // namespace v8 |
| OLD | NEW |