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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 if (r.BothInputsAre(Type::PlainPrimitive())) { | 574 if (r.BothInputsAre(Type::PlainPrimitive())) { |
575 // JSModulus(x:plain-primitive, | 575 // JSModulus(x:plain-primitive, |
576 // y:plain-primitive) => NumberModulus(ToNumber(x), ToNumber(y)) | 576 // y:plain-primitive) => NumberModulus(ToNumber(x), ToNumber(y)) |
577 r.ConvertInputsToNumber(); | 577 r.ConvertInputsToNumber(); |
578 return r.ChangeToPureOperator(simplified()->NumberModulus(), | 578 return r.ChangeToPureOperator(simplified()->NumberModulus(), |
579 Type::Number()); | 579 Type::Number()); |
580 } | 580 } |
581 return NoChange(); | 581 return NoChange(); |
582 } | 582 } |
583 | 583 |
584 Reduction JSTypedLowering::ReduceInt32Binop(Node* node, const Operator* intOp) { | 584 Reduction JSTypedLowering::ReduceInt32Binop(Node* node, |
| 585 const Operator* int_op) { |
585 if (flags() & kDisableIntegerBinaryOpReduction) return NoChange(); | 586 if (flags() & kDisableIntegerBinaryOpReduction) return NoChange(); |
586 | |
587 JSBinopReduction r(this, node); | 587 JSBinopReduction r(this, node); |
| 588 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback(); |
| 589 if (feedback != BinaryOperationHints::kAny) { |
| 590 Operator const* speculative_op; |
| 591 if (int_op->opcode() == IrOpcode::kNumberBitwiseAnd) { |
| 592 speculative_op = simplified()->SpeculativeNumberBitwiseAnd(feedback); |
| 593 } else if (int_op->opcode() == IrOpcode::kNumberBitwiseOr) { |
| 594 speculative_op = simplified()->SpeculativeNumberBitwiseOr(feedback); |
| 595 } else { |
| 596 DCHECK_EQ(IrOpcode::kNumberBitwiseXor, int_op->opcode()); |
| 597 speculative_op = simplified()->SpeculativeNumberBitwiseXor(feedback); |
| 598 } |
| 599 return r.ChangeToSpeculativeOperator(speculative_op, Type::Signed32()); |
| 600 } |
588 r.ConvertInputsToNumber(); | 601 r.ConvertInputsToNumber(); |
589 r.ConvertInputsToUI32(kSigned, kSigned); | 602 r.ConvertInputsToUI32(kSigned, kSigned); |
590 return r.ChangeToPureOperator(intOp, Type::Integral32()); | 603 return r.ChangeToPureOperator(int_op, Type::Signed32()); |
591 } | 604 } |
592 | 605 |
593 Reduction JSTypedLowering::ReduceUI32Shift(Node* node, | 606 Reduction JSTypedLowering::ReduceUI32Shift(Node* node, |
594 Signedness left_signedness, | 607 Signedness left_signedness, |
595 const Operator* shift_op) { | 608 const Operator* shift_op) { |
596 JSBinopReduction r(this, node); | 609 JSBinopReduction r(this, node); |
597 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback(); | 610 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback(); |
598 if (feedback != BinaryOperationHints::kAny) { | 611 if (feedback != BinaryOperationHints::kAny) { |
599 Operator const* speculative_op; | 612 Operator const* speculative_op; |
600 if (shift_op->opcode() == IrOpcode::kNumberShiftLeft) { | 613 if (shift_op->opcode() == IrOpcode::kNumberShiftLeft) { |
601 speculative_op = simplified()->SpeculativeNumberShiftLeft(feedback); | 614 speculative_op = simplified()->SpeculativeNumberShiftLeft(feedback); |
602 } else if (shift_op->opcode() == IrOpcode::kNumberShiftRightLogical) { | 615 } else if (shift_op->opcode() == IrOpcode::kNumberShiftRightLogical) { |
603 speculative_op = | 616 speculative_op = |
604 simplified()->SpeculativeNumberShiftRightLogical(feedback); | 617 simplified()->SpeculativeNumberShiftRightLogical(feedback); |
605 } else { | 618 } else { |
606 DCHECK(shift_op->opcode() == IrOpcode::kNumberShiftRight); | 619 DCHECK_EQ(IrOpcode::kNumberShiftRight, shift_op->opcode()); |
607 speculative_op = simplified()->SpeculativeNumberShiftRight(feedback); | 620 speculative_op = simplified()->SpeculativeNumberShiftRight(feedback); |
608 } | 621 } |
609 return r.ChangeToSpeculativeOperator( | 622 return r.ChangeToSpeculativeOperator( |
610 speculative_op, shift_op->opcode() == IrOpcode::kNumberShiftRightLogical | 623 speculative_op, shift_op->opcode() == IrOpcode::kNumberShiftRightLogical |
611 ? Type::Unsigned32() | 624 ? Type::Unsigned32() |
612 : Type::Signed32()); | 625 : Type::Signed32()); |
613 } | 626 } |
614 | 627 |
615 // If deoptimization is enabled we rely on type feedback. | 628 // If deoptimization is enabled we rely on type feedback. |
616 if (r.BothInputsAre(Type::PlainPrimitive()) || | 629 if (r.BothInputsAre(Type::PlainPrimitive()) || |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 } | 2166 } |
2154 | 2167 |
2155 | 2168 |
2156 CompilationDependencies* JSTypedLowering::dependencies() const { | 2169 CompilationDependencies* JSTypedLowering::dependencies() const { |
2157 return dependencies_; | 2170 return dependencies_; |
2158 } | 2171 } |
2159 | 2172 |
2160 } // namespace compiler | 2173 } // namespace compiler |
2161 } // namespace internal | 2174 } // namespace internal |
2162 } // namespace v8 | 2175 } // namespace v8 |
OLD | NEW |