OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/mips64/codegen-mips64.h" | 5 #include "src/mips64/codegen-mips64.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 // ------------------------------------------------------------------------- | 605 // ------------------------------------------------------------------------- |
606 // Code generators | 606 // Code generators |
607 | 607 |
608 #define __ ACCESS_MASM(masm) | 608 #define __ ACCESS_MASM(masm) |
609 | 609 |
610 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | 610 void StringCharLoadGenerator::Generate(MacroAssembler* masm, |
611 Register string, | 611 Register string, |
612 Register index, | 612 Register index, |
613 Register result, | 613 Register result, |
614 Label* call_runtime) { | 614 Label* call_runtime) { |
615 Label indirect_string_loaded; | |
616 __ bind(&indirect_string_loaded); | |
617 | |
618 // Fetch the instance type of the receiver into result register. | 615 // Fetch the instance type of the receiver into result register. |
619 __ ld(result, FieldMemOperand(string, HeapObject::kMapOffset)); | 616 __ ld(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
620 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); | 617 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
621 | 618 |
622 // We need special handling for indirect strings. | 619 // We need special handling for indirect strings. |
623 Label check_sequential; | 620 Label check_sequential; |
624 __ And(at, result, Operand(kIsIndirectStringMask)); | 621 __ And(at, result, Operand(kIsIndirectStringMask)); |
625 __ Branch(&check_sequential, eq, at, Operand(zero_reg)); | 622 __ Branch(&check_sequential, eq, at, Operand(zero_reg)); |
626 | 623 |
627 // Dispatch on the indirect string shape: slice or cons. | 624 // Dispatch on the indirect string shape: slice or cons. |
628 Label cons_string, thin_string; | 625 Label cons_string; |
629 __ And(at, result, Operand(kStringRepresentationMask)); | 626 __ And(at, result, Operand(kSlicedNotConsMask)); |
630 __ Branch(&cons_string, eq, at, Operand(kConsStringTag)); | 627 __ Branch(&cons_string, eq, at, Operand(zero_reg)); |
631 __ Branch(&thin_string, eq, at, Operand(kThinStringTag)); | |
632 | 628 |
633 // Handle slices. | 629 // Handle slices. |
| 630 Label indirect_string_loaded; |
634 __ ld(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); | 631 __ ld(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); |
635 __ ld(string, FieldMemOperand(string, SlicedString::kParentOffset)); | 632 __ ld(string, FieldMemOperand(string, SlicedString::kParentOffset)); |
636 __ dsra32(at, result, 0); | 633 __ dsra32(at, result, 0); |
637 __ Daddu(index, index, at); | 634 __ Daddu(index, index, at); |
638 __ jmp(&indirect_string_loaded); | 635 __ jmp(&indirect_string_loaded); |
639 | 636 |
640 // Handle thin strings. | |
641 __ bind(&thin_string); | |
642 __ ld(string, FieldMemOperand(string, ThinString::kActualOffset)); | |
643 __ jmp(&indirect_string_loaded); | |
644 | |
645 // Handle cons strings. | 637 // Handle cons strings. |
646 // Check whether the right hand side is the empty string (i.e. if | 638 // Check whether the right hand side is the empty string (i.e. if |
647 // this is really a flat string in a cons string). If that is not | 639 // this is really a flat string in a cons string). If that is not |
648 // the case we would rather go to the runtime system now to flatten | 640 // the case we would rather go to the runtime system now to flatten |
649 // the string. | 641 // the string. |
650 __ bind(&cons_string); | 642 __ bind(&cons_string); |
651 __ ld(result, FieldMemOperand(string, ConsString::kSecondOffset)); | 643 __ ld(result, FieldMemOperand(string, ConsString::kSecondOffset)); |
652 __ LoadRoot(at, Heap::kempty_stringRootIndex); | 644 __ LoadRoot(at, Heap::kempty_stringRootIndex); |
653 __ Branch(call_runtime, ne, result, Operand(at)); | 645 __ Branch(call_runtime, ne, result, Operand(at)); |
654 // Get the first of the two strings and load its instance type. | 646 // Get the first of the two strings and load its instance type. |
655 __ ld(string, FieldMemOperand(string, ConsString::kFirstOffset)); | 647 __ ld(string, FieldMemOperand(string, ConsString::kFirstOffset)); |
656 __ jmp(&indirect_string_loaded); | 648 |
| 649 __ bind(&indirect_string_loaded); |
| 650 __ ld(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 651 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
657 | 652 |
658 // Distinguish sequential and external strings. Only these two string | 653 // Distinguish sequential and external strings. Only these two string |
659 // representations can reach here (slices and flat cons strings have been | 654 // representations can reach here (slices and flat cons strings have been |
660 // reduced to the underlying sequential or external string). | 655 // reduced to the underlying sequential or external string). |
661 Label external_string, check_encoding; | 656 Label external_string, check_encoding; |
662 __ bind(&check_sequential); | 657 __ bind(&check_sequential); |
663 STATIC_ASSERT(kSeqStringTag == 0); | 658 STATIC_ASSERT(kSeqStringTag == 0); |
664 __ And(at, result, Operand(kStringRepresentationMask)); | 659 __ And(at, result, Operand(kStringRepresentationMask)); |
665 __ Branch(&external_string, ne, at, Operand(zero_reg)); | 660 __ Branch(&external_string, ne, at, Operand(zero_reg)); |
666 | 661 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 } | 769 } |
775 } | 770 } |
776 | 771 |
777 | 772 |
778 #undef __ | 773 #undef __ |
779 | 774 |
780 } // namespace internal | 775 } // namespace internal |
781 } // namespace v8 | 776 } // namespace v8 |
782 | 777 |
783 #endif // V8_TARGET_ARCH_MIPS64 | 778 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |