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