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