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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 Type::Number()); | 532 Type::Number()); |
533 } | 533 } |
534 | 534 |
535 return NoChange(); | 535 return NoChange(); |
536 } | 536 } |
537 | 537 |
538 Reduction JSTypedLowering::ReduceJSDivide(Node* node) { | 538 Reduction JSTypedLowering::ReduceJSDivide(Node* node) { |
539 if (flags() & kDisableBinaryOpReduction) return NoChange(); | 539 if (flags() & kDisableBinaryOpReduction) return NoChange(); |
540 JSBinopReduction r(this, node); | 540 JSBinopReduction r(this, node); |
541 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback(); | 541 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback(); |
| 542 if (feedback == BinaryOperationHints::kNumberOrUndefined && |
| 543 r.BothInputsAre(Type::PlainPrimitive())) { |
| 544 // JSDivide(x:plain-primitive, |
| 545 // y:plain-primitive) => NumberDivide(ToNumber(x), ToNumber(y)) |
| 546 r.ConvertInputsToNumber(); |
| 547 return r.ChangeToPureOperator(simplified()->NumberDivide(), Type::Number()); |
| 548 } |
542 if (feedback != BinaryOperationHints::kAny) { | 549 if (feedback != BinaryOperationHints::kAny) { |
543 return r.ChangeToSpeculativeOperator( | 550 return r.ChangeToSpeculativeOperator( |
544 simplified()->SpeculativeNumberDivide(feedback), Type::Number()); | 551 simplified()->SpeculativeNumberDivide(feedback), Type::Number()); |
545 } | 552 } |
546 | 553 if (r.BothInputsAre(Type::PlainPrimitive())) { |
547 // If deoptimization is enabled we rely on type feedback. | 554 // JSDivide(x:plain-primitive, |
548 if (r.BothInputsAre(Type::PlainPrimitive()) || | 555 // y:plain-primitive) => NumberDivide(ToNumber(x), ToNumber(y)) |
549 !(flags() & kDeoptimizationEnabled)) { | |
550 r.ConvertInputsToNumber(); | 556 r.ConvertInputsToNumber(); |
551 return r.ChangeToPureOperator(simplified()->NumberDivide(), Type::Number()); | 557 return r.ChangeToPureOperator(simplified()->NumberDivide(), Type::Number()); |
552 } | 558 } |
553 | |
554 return NoChange(); | 559 return NoChange(); |
555 } | 560 } |
556 | 561 |
557 Reduction JSTypedLowering::ReduceJSModulus(Node* node) { | 562 Reduction JSTypedLowering::ReduceJSModulus(Node* node) { |
558 if (flags() & kDisableBinaryOpReduction) return NoChange(); | 563 if (flags() & kDisableBinaryOpReduction) return NoChange(); |
559 JSBinopReduction r(this, node); | 564 JSBinopReduction r(this, node); |
560 if (r.BothInputsAre(Type::Number())) { | 565 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback(); |
561 // JSModulus(x:number, x:number) => NumberModulus(x, y) | 566 if (feedback == BinaryOperationHints::kNumberOrUndefined && |
| 567 r.BothInputsAre(Type::PlainPrimitive())) { |
| 568 // JSModulus(x:plain-primitive, |
| 569 // y:plain-primitive) => NumberModulus(ToNumber(x), ToNumber(y)) |
| 570 r.ConvertInputsToNumber(); |
562 return r.ChangeToPureOperator(simplified()->NumberModulus(), | 571 return r.ChangeToPureOperator(simplified()->NumberModulus(), |
563 Type::Number()); | 572 Type::Number()); |
564 } | 573 } |
565 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback(); | |
566 if (feedback != BinaryOperationHints::kAny) { | 574 if (feedback != BinaryOperationHints::kAny) { |
567 return r.ChangeToSpeculativeOperator( | 575 return r.ChangeToSpeculativeOperator( |
568 simplified()->SpeculativeNumberModulus(feedback), Type::Number()); | 576 simplified()->SpeculativeNumberModulus(feedback), Type::Number()); |
569 } | 577 } |
| 578 if (r.BothInputsAre(Type::PlainPrimitive())) { |
| 579 // JSModulus(x:plain-primitive, |
| 580 // y:plain-primitive) => NumberModulus(ToNumber(x), ToNumber(y)) |
| 581 r.ConvertInputsToNumber(); |
| 582 return r.ChangeToPureOperator(simplified()->NumberModulus(), |
| 583 Type::Number()); |
| 584 } |
570 return NoChange(); | 585 return NoChange(); |
571 } | 586 } |
572 | 587 |
573 Reduction JSTypedLowering::ReduceInt32Binop(Node* node, const Operator* intOp) { | 588 Reduction JSTypedLowering::ReduceInt32Binop(Node* node, const Operator* intOp) { |
574 if (flags() & kDisableBinaryOpReduction) return NoChange(); | 589 if (flags() & kDisableBinaryOpReduction) return NoChange(); |
575 | 590 |
576 JSBinopReduction r(this, node); | 591 JSBinopReduction r(this, node); |
577 r.ConvertInputsToNumber(); | 592 r.ConvertInputsToNumber(); |
578 r.ConvertInputsToUI32(kSigned, kSigned); | 593 r.ConvertInputsToUI32(kSigned, kSigned); |
579 return r.ChangeToPureOperator(intOp, Type::Integral32()); | 594 return r.ChangeToPureOperator(intOp, Type::Integral32()); |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 } | 2069 } |
2055 | 2070 |
2056 | 2071 |
2057 CompilationDependencies* JSTypedLowering::dependencies() const { | 2072 CompilationDependencies* JSTypedLowering::dependencies() const { |
2058 return dependencies_; | 2073 return dependencies_; |
2059 } | 2074 } |
2060 | 2075 |
2061 } // namespace compiler | 2076 } // namespace compiler |
2062 } // namespace internal | 2077 } // namespace internal |
2063 } // namespace v8 | 2078 } // namespace v8 |
OLD | NEW |