Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: src/mips/codegen-mips.cc

Issue 2549773002: Internalize strings in-place (Closed)
Patch Set: rebased Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | src/mips64/code-stubs-mips64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
613 // Fetch the instance type of the receiver into result register. 616 // Fetch the instance type of the receiver into result register.
614 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset)); 617 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset));
615 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); 618 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
616 619
617 // We need special handling for indirect strings. 620 // We need special handling for indirect strings.
618 Label check_sequential; 621 Label check_sequential;
619 __ And(at, result, Operand(kIsIndirectStringMask)); 622 __ And(at, result, Operand(kIsIndirectStringMask));
620 __ Branch(&check_sequential, eq, at, Operand(zero_reg)); 623 __ Branch(&check_sequential, eq, at, Operand(zero_reg));
621 624
622 // Dispatch on the indirect string shape: slice or cons. 625 // Dispatch on the indirect string shape: slice or cons.
623 Label cons_string; 626 Label cons_string, thin_string;
624 __ And(at, result, Operand(kSlicedNotConsMask)); 627 __ And(at, result, Operand(kStringRepresentationMask));
625 __ Branch(&cons_string, eq, at, Operand(zero_reg)); 628 __ Branch(&cons_string, eq, at, Operand(kConsStringTag));
629 __ Branch(&thin_string, eq, at, Operand(kThinStringTag));
626 630
627 // Handle slices. 631 // Handle slices.
628 Label indirect_string_loaded;
629 __ lw(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); 632 __ lw(result, FieldMemOperand(string, SlicedString::kOffsetOffset));
630 __ lw(string, FieldMemOperand(string, SlicedString::kParentOffset)); 633 __ lw(string, FieldMemOperand(string, SlicedString::kParentOffset));
631 __ sra(at, result, kSmiTagSize); 634 __ sra(at, result, kSmiTagSize);
632 __ Addu(index, index, at); 635 __ Addu(index, index, at);
633 __ jmp(&indirect_string_loaded); 636 __ jmp(&indirect_string_loaded);
634 637
638 // Handle thin strings.
639 __ bind(&thin_string);
640 __ lw(string, FieldMemOperand(string, ThinString::kActualOffset));
641 __ jmp(&indirect_string_loaded);
642
635 // Handle cons strings. 643 // Handle cons strings.
636 // Check whether the right hand side is the empty string (i.e. if 644 // Check whether the right hand side is the empty string (i.e. if
637 // this is really a flat string in a cons string). If that is not 645 // this is really a flat string in a cons string). If that is not
638 // the case we would rather go to the runtime system now to flatten 646 // the case we would rather go to the runtime system now to flatten
639 // the string. 647 // the string.
640 __ bind(&cons_string); 648 __ bind(&cons_string);
641 __ lw(result, FieldMemOperand(string, ConsString::kSecondOffset)); 649 __ lw(result, FieldMemOperand(string, ConsString::kSecondOffset));
642 __ LoadRoot(at, Heap::kempty_stringRootIndex); 650 __ LoadRoot(at, Heap::kempty_stringRootIndex);
643 __ Branch(call_runtime, ne, result, Operand(at)); 651 __ Branch(call_runtime, ne, result, Operand(at));
644 // Get the first of the two strings and load its instance type. 652 // Get the first of the two strings and load its instance type.
645 __ lw(string, FieldMemOperand(string, ConsString::kFirstOffset)); 653 __ lw(string, FieldMemOperand(string, ConsString::kFirstOffset));
646 654 __ jmp(&indirect_string_loaded);
647 __ bind(&indirect_string_loaded);
648 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset));
649 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
650 655
651 // Distinguish sequential and external strings. Only these two string 656 // Distinguish sequential and external strings. Only these two string
652 // representations can reach here (slices and flat cons strings have been 657 // representations can reach here (slices and flat cons strings have been
653 // reduced to the underlying sequential or external string). 658 // reduced to the underlying sequential or external string).
654 Label external_string, check_encoding; 659 Label external_string, check_encoding;
655 __ bind(&check_sequential); 660 __ bind(&check_sequential);
656 STATIC_ASSERT(kSeqStringTag == 0); 661 STATIC_ASSERT(kSeqStringTag == 0);
657 __ And(at, result, Operand(kStringRepresentationMask)); 662 __ And(at, result, Operand(kStringRepresentationMask));
658 __ Branch(&external_string, ne, at, Operand(zero_reg)); 663 __ Branch(&external_string, ne, at, Operand(zero_reg));
659 664
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 770 }
766 } 771 }
767 772
768 773
769 #undef __ 774 #undef __
770 775
771 } // namespace internal 776 } // namespace internal
772 } // namespace v8 777 } // namespace v8
773 778
774 #endif // V8_TARGET_ARCH_MIPS 779 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | src/mips64/code-stubs-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698