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/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 case MachineRepresentation::kFloat64: | 586 case MachineRepresentation::kFloat64: |
587 opcode = kCheckedLoadFloat64; | 587 opcode = kCheckedLoadFloat64; |
588 break; | 588 break; |
589 case MachineRepresentation::kBit: // Fall through. | 589 case MachineRepresentation::kBit: // Fall through. |
590 case MachineRepresentation::kTagged: // Fall through. | 590 case MachineRepresentation::kTagged: // Fall through. |
591 case MachineRepresentation::kSimd128: // Fall through. | 591 case MachineRepresentation::kSimd128: // Fall through. |
592 case MachineRepresentation::kNone: | 592 case MachineRepresentation::kNone: |
593 UNREACHABLE(); | 593 UNREACHABLE(); |
594 return; | 594 return; |
595 } | 595 } |
| 596 // If the length is a constant power of two, allow the code generator to |
| 597 // pick a more efficient bounds check sequence by passing the length as an |
| 598 // immediate. |
| 599 if (length->opcode() == IrOpcode::kInt32Constant) { |
| 600 Int32Matcher m(length); |
| 601 if (m.IsPowerOf2()) { |
| 602 Emit(opcode, g.DefineAsRegister(node), g.UseRegister(buffer), |
| 603 g.UseRegister(offset), g.UseImmediate(length)); |
| 604 return; |
| 605 } |
| 606 } |
596 Emit(opcode, g.DefineAsRegister(node), g.UseRegister(buffer), | 607 Emit(opcode, g.DefineAsRegister(node), g.UseRegister(buffer), |
597 g.UseRegister(offset), g.UseOperand(length, kArithmeticImm)); | 608 g.UseRegister(offset), g.UseOperand(length, kArithmeticImm)); |
598 } | 609 } |
599 | 610 |
600 | 611 |
601 void InstructionSelector::VisitCheckedStore(Node* node) { | 612 void InstructionSelector::VisitCheckedStore(Node* node) { |
602 MachineRepresentation rep = CheckedStoreRepresentationOf(node->op()); | 613 MachineRepresentation rep = CheckedStoreRepresentationOf(node->op()); |
603 Arm64OperandGenerator g(this); | 614 Arm64OperandGenerator g(this); |
604 Node* const buffer = node->InputAt(0); | 615 Node* const buffer = node->InputAt(0); |
605 Node* const offset = node->InputAt(1); | 616 Node* const offset = node->InputAt(1); |
(...skipping 19 matching lines...) Expand all Loading... |
625 case MachineRepresentation::kFloat64: | 636 case MachineRepresentation::kFloat64: |
626 opcode = kCheckedStoreFloat64; | 637 opcode = kCheckedStoreFloat64; |
627 break; | 638 break; |
628 case MachineRepresentation::kBit: // Fall through. | 639 case MachineRepresentation::kBit: // Fall through. |
629 case MachineRepresentation::kTagged: // Fall through. | 640 case MachineRepresentation::kTagged: // Fall through. |
630 case MachineRepresentation::kSimd128: // Fall through. | 641 case MachineRepresentation::kSimd128: // Fall through. |
631 case MachineRepresentation::kNone: | 642 case MachineRepresentation::kNone: |
632 UNREACHABLE(); | 643 UNREACHABLE(); |
633 return; | 644 return; |
634 } | 645 } |
| 646 // If the length is a constant power of two, allow the code generator to |
| 647 // pick a more efficient bounds check sequence by passing the length as an |
| 648 // immediate. |
| 649 if (length->opcode() == IrOpcode::kInt32Constant) { |
| 650 Int32Matcher m(length); |
| 651 if (m.IsPowerOf2()) { |
| 652 Emit(opcode, g.NoOutput(), g.UseRegister(buffer), g.UseRegister(offset), |
| 653 g.UseImmediate(length), g.UseRegisterOrImmediateZero(value)); |
| 654 return; |
| 655 } |
| 656 } |
635 Emit(opcode, g.NoOutput(), g.UseRegister(buffer), g.UseRegister(offset), | 657 Emit(opcode, g.NoOutput(), g.UseRegister(buffer), g.UseRegister(offset), |
636 g.UseOperand(length, kArithmeticImm), | 658 g.UseOperand(length, kArithmeticImm), |
637 g.UseRegisterOrImmediateZero(value)); | 659 g.UseRegisterOrImmediateZero(value)); |
638 } | 660 } |
639 | 661 |
640 | 662 |
641 template <typename Matcher> | 663 template <typename Matcher> |
642 static void VisitLogical(InstructionSelector* selector, Node* node, Matcher* m, | 664 static void VisitLogical(InstructionSelector* selector, Node* node, Matcher* m, |
643 ArchOpcode opcode, bool left_can_cover, | 665 ArchOpcode opcode, bool left_can_cover, |
644 bool right_can_cover, ImmediateMode imm_mode) { | 666 bool right_can_cover, ImmediateMode imm_mode) { |
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2455 // static | 2477 // static |
2456 MachineOperatorBuilder::AlignmentRequirements | 2478 MachineOperatorBuilder::AlignmentRequirements |
2457 InstructionSelector::AlignmentRequirements() { | 2479 InstructionSelector::AlignmentRequirements() { |
2458 return MachineOperatorBuilder::AlignmentRequirements:: | 2480 return MachineOperatorBuilder::AlignmentRequirements:: |
2459 FullUnalignedAccessSupport(); | 2481 FullUnalignedAccessSupport(); |
2460 } | 2482 } |
2461 | 2483 |
2462 } // namespace compiler | 2484 } // namespace compiler |
2463 } // namespace internal | 2485 } // namespace internal |
2464 } // namespace v8 | 2486 } // namespace v8 |
OLD | NEW |