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

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 144023009: Get rid of the unused native code StringAddStub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove obsolete StringHelper methods. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/mips/code-stubs-mips.h ('k') | src/mips/full-codegen-mips.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 Isolate* isolate, 344 Isolate* isolate,
345 CodeStubInterfaceDescriptor* descriptor) { 345 CodeStubInterfaceDescriptor* descriptor) {
346 static Register registers[] = { a2, a1, a0 }; 346 static Register registers[] = { a2, a1, a0 };
347 descriptor->register_param_count_ = 3; 347 descriptor->register_param_count_ = 3;
348 descriptor->register_params_ = registers; 348 descriptor->register_params_ = registers;
349 descriptor->deoptimization_handler_ = 349 descriptor->deoptimization_handler_ =
350 FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite); 350 FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite);
351 } 351 }
352 352
353 353
354 void NewStringAddStub::InitializeInterfaceDescriptor( 354 void StringAddStub::InitializeInterfaceDescriptor(
355 Isolate* isolate, 355 Isolate* isolate,
356 CodeStubInterfaceDescriptor* descriptor) { 356 CodeStubInterfaceDescriptor* descriptor) {
357 static Register registers[] = { a1, a0 }; 357 static Register registers[] = { a1, a0 };
358 descriptor->register_param_count_ = 2; 358 descriptor->register_param_count_ = 2;
359 descriptor->register_params_ = registers; 359 descriptor->register_params_ = registers;
360 descriptor->deoptimization_handler_ = 360 descriptor->deoptimization_handler_ =
361 Runtime::FunctionForId(Runtime::kStringAdd)->entry; 361 Runtime::FunctionForId(Runtime::kStringAdd)->entry;
362 } 362 }
363 363
364 364
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 __ CallRuntime(Runtime::kCharFromCode, 1); 3614 __ CallRuntime(Runtime::kCharFromCode, 1);
3615 __ Move(result_, v0); 3615 __ Move(result_, v0);
3616 3616
3617 call_helper.AfterCall(masm); 3617 call_helper.AfterCall(masm);
3618 __ Branch(&exit_); 3618 __ Branch(&exit_);
3619 3619
3620 __ Abort(kUnexpectedFallthroughFromCharFromCodeSlowCase); 3620 __ Abort(kUnexpectedFallthroughFromCharFromCodeSlowCase);
3621 } 3621 }
3622 3622
3623 3623
3624 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm,
3625 Register dest,
3626 Register src,
3627 Register count,
3628 Register scratch,
3629 bool ascii) {
3630 Label loop;
3631 Label done;
3632 // This loop just copies one character at a time, as it is only used for
3633 // very short strings.
3634 if (!ascii) {
3635 __ addu(count, count, count);
3636 }
3637 __ Branch(&done, eq, count, Operand(zero_reg));
3638 __ addu(count, dest, count); // Count now points to the last dest byte.
3639
3640 __ bind(&loop);
3641 __ lbu(scratch, MemOperand(src));
3642 __ addiu(src, src, 1);
3643 __ sb(scratch, MemOperand(dest));
3644 __ addiu(dest, dest, 1);
3645 __ Branch(&loop, lt, dest, Operand(count));
3646
3647 __ bind(&done);
3648 }
3649
3650
3651 enum CopyCharactersFlags { 3624 enum CopyCharactersFlags {
3652 COPY_ASCII = 1, 3625 COPY_ASCII = 1,
3653 DEST_ALWAYS_ALIGNED = 2 3626 DEST_ALWAYS_ALIGNED = 2
3654 }; 3627 };
3655 3628
3656 3629
3657 void StringHelper::GenerateCopyCharactersLong(MacroAssembler* masm, 3630 void StringHelper::GenerateCopyCharactersLong(MacroAssembler* masm,
3658 Register dest, 3631 Register dest,
3659 Register src, 3632 Register src,
3660 Register count, 3633 Register count,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3759 __ lbu(scratch1, MemOperand(src)); 3732 __ lbu(scratch1, MemOperand(src));
3760 __ addiu(src, src, 1); 3733 __ addiu(src, src, 1);
3761 __ sb(scratch1, MemOperand(dest)); 3734 __ sb(scratch1, MemOperand(dest));
3762 __ addiu(dest, dest, 1); 3735 __ addiu(dest, dest, 1);
3763 __ Branch(&byte_loop); 3736 __ Branch(&byte_loop);
3764 3737
3765 __ bind(&done); 3738 __ bind(&done);
3766 } 3739 }
3767 3740
3768 3741
3769 void StringHelper::GenerateTwoCharacterStringTableProbe(MacroAssembler* masm,
3770 Register c1,
3771 Register c2,
3772 Register scratch1,
3773 Register scratch2,
3774 Register scratch3,
3775 Register scratch4,
3776 Register scratch5,
3777 Label* not_found) {
3778 // Register scratch3 is the general scratch register in this function.
3779 Register scratch = scratch3;
3780
3781 // Make sure that both characters are not digits as such strings has a
3782 // different hash algorithm. Don't try to look for these in the string table.
3783 Label not_array_index;
3784 __ Subu(scratch, c1, Operand(static_cast<int>('0')));
3785 __ Branch(&not_array_index,
3786 Ugreater,
3787 scratch,
3788 Operand(static_cast<int>('9' - '0')));
3789 __ Subu(scratch, c2, Operand(static_cast<int>('0')));
3790
3791 // If check failed combine both characters into single halfword.
3792 // This is required by the contract of the method: code at the
3793 // not_found branch expects this combination in c1 register.
3794 Label tmp;
3795 __ sll(scratch1, c2, kBitsPerByte);
3796 __ Branch(&tmp, Ugreater, scratch, Operand(static_cast<int>('9' - '0')));
3797 __ Or(c1, c1, scratch1);
3798 __ bind(&tmp);
3799 __ Branch(
3800 not_found, Uless_equal, scratch, Operand(static_cast<int>('9' - '0')));
3801
3802 __ bind(&not_array_index);
3803 // Calculate the two character string hash.
3804 Register hash = scratch1;
3805 StringHelper::GenerateHashInit(masm, hash, c1);
3806 StringHelper::GenerateHashAddCharacter(masm, hash, c2);
3807 StringHelper::GenerateHashGetHash(masm, hash);
3808
3809 // Collect the two characters in a register.
3810 Register chars = c1;
3811 __ sll(scratch, c2, kBitsPerByte);
3812 __ Or(chars, chars, scratch);
3813
3814 // chars: two character string, char 1 in byte 0 and char 2 in byte 1.
3815 // hash: hash of two character string.
3816
3817 // Load string table.
3818 // Load address of first element of the string table.
3819 Register string_table = c2;
3820 __ LoadRoot(string_table, Heap::kStringTableRootIndex);
3821
3822 Register undefined = scratch4;
3823 __ LoadRoot(undefined, Heap::kUndefinedValueRootIndex);
3824
3825 // Calculate capacity mask from the string table capacity.
3826 Register mask = scratch2;
3827 __ lw(mask, FieldMemOperand(string_table, StringTable::kCapacityOffset));
3828 __ sra(mask, mask, 1);
3829 __ Addu(mask, mask, -1);
3830
3831 // Calculate untagged address of the first element of the string table.
3832 Register first_string_table_element = string_table;
3833 __ Addu(first_string_table_element, string_table,
3834 Operand(StringTable::kElementsStartOffset - kHeapObjectTag));
3835
3836 // Registers.
3837 // chars: two character string, char 1 in byte 0 and char 2 in byte 1.
3838 // hash: hash of two character string
3839 // mask: capacity mask
3840 // first_string_table_element: address of the first element of
3841 // the string table
3842 // undefined: the undefined object
3843 // scratch: -
3844
3845 // Perform a number of probes in the string table.
3846 const int kProbes = 4;
3847 Label found_in_string_table;
3848 Label next_probe[kProbes];
3849 Register candidate = scratch5; // Scratch register contains candidate.
3850 for (int i = 0; i < kProbes; i++) {
3851 // Calculate entry in string table.
3852 if (i > 0) {
3853 __ Addu(candidate, hash, Operand(StringTable::GetProbeOffset(i)));
3854 } else {
3855 __ mov(candidate, hash);
3856 }
3857
3858 __ And(candidate, candidate, Operand(mask));
3859
3860 // Load the entry from the symble table.
3861 STATIC_ASSERT(StringTable::kEntrySize == 1);
3862 __ sll(scratch, candidate, kPointerSizeLog2);
3863 __ Addu(scratch, scratch, first_string_table_element);
3864 __ lw(candidate, MemOperand(scratch));
3865
3866 // If entry is undefined no string with this hash can be found.
3867 Label is_string;
3868 __ GetObjectType(candidate, scratch, scratch);
3869 __ Branch(&is_string, ne, scratch, Operand(ODDBALL_TYPE));
3870
3871 __ Branch(not_found, eq, undefined, Operand(candidate));
3872 // Must be the hole (deleted entry).
3873 if (FLAG_debug_code) {
3874 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex);
3875 __ Assert(eq, kOddballInStringTableIsNotUndefinedOrTheHole,
3876 scratch, Operand(candidate));
3877 }
3878 __ jmp(&next_probe[i]);
3879
3880 __ bind(&is_string);
3881
3882 // Check that the candidate is a non-external ASCII string. The instance
3883 // type is still in the scratch register from the CompareObjectType
3884 // operation.
3885 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &next_probe[i]);
3886
3887 // If length is not 2 the string is not a candidate.
3888 __ lw(scratch, FieldMemOperand(candidate, String::kLengthOffset));
3889 __ Branch(&next_probe[i], ne, scratch, Operand(Smi::FromInt(2)));
3890
3891 // Check if the two characters match.
3892 // Assumes that word load is little endian.
3893 __ lhu(scratch, FieldMemOperand(candidate, SeqOneByteString::kHeaderSize));
3894 __ Branch(&found_in_string_table, eq, chars, Operand(scratch));
3895 __ bind(&next_probe[i]);
3896 }
3897
3898 // No matching 2 character string found by probing.
3899 __ jmp(not_found);
3900
3901 // Scratch register contains result when we fall through to here.
3902 Register result = candidate;
3903 __ bind(&found_in_string_table);
3904 __ mov(v0, result);
3905 }
3906
3907
3908 void StringHelper::GenerateHashInit(MacroAssembler* masm, 3742 void StringHelper::GenerateHashInit(MacroAssembler* masm,
3909 Register hash, 3743 Register hash,
3910 Register character) { 3744 Register character) {
3911 // hash = seed + character + ((seed + character) << 10); 3745 // hash = seed + character + ((seed + character) << 10);
3912 __ LoadRoot(hash, Heap::kHashSeedRootIndex); 3746 __ LoadRoot(hash, Heap::kHashSeedRootIndex);
3913 // Untag smi seed and add the character. 3747 // Untag smi seed and add the character.
3914 __ SmiUntag(hash); 3748 __ SmiUntag(hash);
3915 __ addu(hash, hash, character); 3749 __ addu(hash, hash, character);
3916 __ sll(at, hash, 10); 3750 __ sll(at, hash, 10);
3917 __ addu(hash, hash, at); 3751 __ addu(hash, hash, at);
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
4554 __ Assert(eq, kExpectedAllocationSite, t0, Operand(at)); 4388 __ Assert(eq, kExpectedAllocationSite, t0, Operand(at));
4555 } 4389 }
4556 4390
4557 // Tail call into the stub that handles binary operations with allocation 4391 // Tail call into the stub that handles binary operations with allocation
4558 // sites. 4392 // sites.
4559 BinaryOpWithAllocationSiteStub stub(state_); 4393 BinaryOpWithAllocationSiteStub stub(state_);
4560 __ TailCallStub(&stub); 4394 __ TailCallStub(&stub);
4561 } 4395 }
4562 4396
4563 4397
4564 void StringAddStub::Generate(MacroAssembler* masm) {
4565 Label call_runtime, call_builtin;
4566 Builtins::JavaScript builtin_id = Builtins::ADD;
4567
4568 Counters* counters = masm->isolate()->counters();
4569
4570 // Stack on entry:
4571 // sp[0]: second argument (right).
4572 // sp[4]: first argument (left).
4573
4574 // Load the two arguments.
4575 __ lw(a0, MemOperand(sp, 1 * kPointerSize)); // First argument.
4576 __ lw(a1, MemOperand(sp, 0 * kPointerSize)); // Second argument.
4577
4578 // Make sure that both arguments are strings if not known in advance.
4579 // Otherwise, at least one of the arguments is definitely a string,
4580 // and we convert the one that is not known to be a string.
4581 if ((flags_ & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
4582 ASSERT((flags_ & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT);
4583 ASSERT((flags_ & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT);
4584 __ JumpIfEitherSmi(a0, a1, &call_runtime);
4585 // Load instance types.
4586 __ lw(t0, FieldMemOperand(a0, HeapObject::kMapOffset));
4587 __ lw(t1, FieldMemOperand(a1, HeapObject::kMapOffset));
4588 __ lbu(t0, FieldMemOperand(t0, Map::kInstanceTypeOffset));
4589 __ lbu(t1, FieldMemOperand(t1, Map::kInstanceTypeOffset));
4590 STATIC_ASSERT(kStringTag == 0);
4591 // If either is not a string, go to runtime.
4592 __ Or(t4, t0, Operand(t1));
4593 __ And(t4, t4, Operand(kIsNotStringMask));
4594 __ Branch(&call_runtime, ne, t4, Operand(zero_reg));
4595 } else if ((flags_ & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
4596 ASSERT((flags_ & STRING_ADD_CHECK_RIGHT) == 0);
4597 GenerateConvertArgument(
4598 masm, 1 * kPointerSize, a0, a2, a3, t0, t1, &call_builtin);
4599 builtin_id = Builtins::STRING_ADD_RIGHT;
4600 } else if ((flags_ & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
4601 ASSERT((flags_ & STRING_ADD_CHECK_LEFT) == 0);
4602 GenerateConvertArgument(
4603 masm, 0 * kPointerSize, a1, a2, a3, t0, t1, &call_builtin);
4604 builtin_id = Builtins::STRING_ADD_LEFT;
4605 }
4606
4607 // Both arguments are strings.
4608 // a0: first string
4609 // a1: second string
4610 // t0: first string instance type (if flags_ == NO_STRING_ADD_FLAGS)
4611 // t1: second string instance type (if flags_ == NO_STRING_ADD_FLAGS)
4612 {
4613 Label strings_not_empty;
4614 // Check if either of the strings are empty. In that case return the other.
4615 // These tests use zero-length check on string-length whch is an Smi.
4616 // Assert that Smi::FromInt(0) is really 0.
4617 STATIC_ASSERT(kSmiTag == 0);
4618 ASSERT(Smi::FromInt(0) == 0);
4619 __ lw(a2, FieldMemOperand(a0, String::kLengthOffset));
4620 __ lw(a3, FieldMemOperand(a1, String::kLengthOffset));
4621 __ mov(v0, a0); // Assume we'll return first string (from a0).
4622 __ Movz(v0, a1, a2); // If first is empty, return second (from a1).
4623 __ slt(t4, zero_reg, a2); // if (a2 > 0) t4 = 1.
4624 __ slt(t5, zero_reg, a3); // if (a3 > 0) t5 = 1.
4625 __ and_(t4, t4, t5); // Branch if both strings were non-empty.
4626 __ Branch(&strings_not_empty, ne, t4, Operand(zero_reg));
4627
4628 __ IncrementCounter(counters->string_add_native(), 1, a2, a3);
4629 __ DropAndRet(2);
4630
4631 __ bind(&strings_not_empty);
4632 }
4633
4634 // Untag both string-lengths.
4635 __ sra(a2, a2, kSmiTagSize);
4636 __ sra(a3, a3, kSmiTagSize);
4637
4638 // Both strings are non-empty.
4639 // a0: first string
4640 // a1: second string
4641 // a2: length of first string
4642 // a3: length of second string
4643 // t0: first string instance type (if flags_ == NO_STRING_ADD_FLAGS)
4644 // t1: second string instance type (if flags_ == NO_STRING_ADD_FLAGS)
4645 // Look at the length of the result of adding the two strings.
4646 Label string_add_flat_result, longer_than_two;
4647 // Adding two lengths can't overflow.
4648 STATIC_ASSERT(String::kMaxLength < String::kMaxLength * 2);
4649 __ Addu(t2, a2, Operand(a3));
4650 // Use the string table when adding two one character strings, as it
4651 // helps later optimizations to return a string here.
4652 __ Branch(&longer_than_two, ne, t2, Operand(2));
4653
4654 // Check that both strings are non-external ASCII strings.
4655 if ((flags_ & STRING_ADD_CHECK_BOTH) != STRING_ADD_CHECK_BOTH) {
4656 __ lw(t0, FieldMemOperand(a0, HeapObject::kMapOffset));
4657 __ lw(t1, FieldMemOperand(a1, HeapObject::kMapOffset));
4658 __ lbu(t0, FieldMemOperand(t0, Map::kInstanceTypeOffset));
4659 __ lbu(t1, FieldMemOperand(t1, Map::kInstanceTypeOffset));
4660 }
4661 __ JumpIfBothInstanceTypesAreNotSequentialAscii(t0, t1, t2, t3,
4662 &call_runtime);
4663
4664 // Get the two characters forming the sub string.
4665 __ lbu(a2, FieldMemOperand(a0, SeqOneByteString::kHeaderSize));
4666 __ lbu(a3, FieldMemOperand(a1, SeqOneByteString::kHeaderSize));
4667
4668 // Try to lookup two character string in string table. If it is not found
4669 // just allocate a new one.
4670 Label make_two_character_string;
4671 StringHelper::GenerateTwoCharacterStringTableProbe(
4672 masm, a2, a3, t2, t3, t0, t1, t5, &make_two_character_string);
4673 __ IncrementCounter(counters->string_add_native(), 1, a2, a3);
4674 __ DropAndRet(2);
4675
4676 __ bind(&make_two_character_string);
4677 // Resulting string has length 2 and first chars of two strings
4678 // are combined into single halfword in a2 register.
4679 // So we can fill resulting string without two loops by a single
4680 // halfword store instruction (which assumes that processor is
4681 // in a little endian mode).
4682 __ li(t2, Operand(2));
4683 __ AllocateAsciiString(v0, t2, t0, t1, t5, &call_runtime);
4684 __ sh(a2, FieldMemOperand(v0, SeqOneByteString::kHeaderSize));
4685 __ IncrementCounter(counters->string_add_native(), 1, a2, a3);
4686 __ DropAndRet(2);
4687
4688 __ bind(&longer_than_two);
4689 // Check if resulting string will be flat.
4690 __ Branch(&string_add_flat_result, lt, t2, Operand(ConsString::kMinLength));
4691 // Handle exceptionally long strings in the runtime system.
4692 STATIC_ASSERT((String::kMaxLength & 0x80000000) == 0);
4693 ASSERT(IsPowerOf2(String::kMaxLength + 1));
4694 // kMaxLength + 1 is representable as shifted literal, kMaxLength is not.
4695 __ Branch(&call_runtime, hs, t2, Operand(String::kMaxLength + 1));
4696
4697 // If result is not supposed to be flat, allocate a cons string object.
4698 // If both strings are ASCII the result is an ASCII cons string.
4699 if ((flags_ & STRING_ADD_CHECK_BOTH) != STRING_ADD_CHECK_BOTH) {
4700 __ lw(t0, FieldMemOperand(a0, HeapObject::kMapOffset));
4701 __ lw(t1, FieldMemOperand(a1, HeapObject::kMapOffset));
4702 __ lbu(t0, FieldMemOperand(t0, Map::kInstanceTypeOffset));
4703 __ lbu(t1, FieldMemOperand(t1, Map::kInstanceTypeOffset));
4704 }
4705 Label non_ascii, allocated, ascii_data;
4706 STATIC_ASSERT(kTwoByteStringTag == 0);
4707 // Branch to non_ascii if either string-encoding field is zero (non-ASCII).
4708 __ And(t4, t0, Operand(t1));
4709 __ And(t4, t4, Operand(kStringEncodingMask));
4710 __ Branch(&non_ascii, eq, t4, Operand(zero_reg));
4711
4712 // Allocate an ASCII cons string.
4713 __ bind(&ascii_data);
4714 __ AllocateAsciiConsString(v0, t2, t0, t1, &call_runtime);
4715 __ bind(&allocated);
4716 // Fill the fields of the cons string.
4717 Label skip_write_barrier, after_writing;
4718 ExternalReference high_promotion_mode = ExternalReference::
4719 new_space_high_promotion_mode_active_address(masm->isolate());
4720 __ li(t0, Operand(high_promotion_mode));
4721 __ lw(t0, MemOperand(t0, 0));
4722 __ Branch(&skip_write_barrier, eq, t0, Operand(zero_reg));
4723
4724 __ mov(t3, v0);
4725 __ sw(a0, FieldMemOperand(t3, ConsString::kFirstOffset));
4726 __ RecordWriteField(t3,
4727 ConsString::kFirstOffset,
4728 a0,
4729 t0,
4730 kRAHasNotBeenSaved,
4731 kDontSaveFPRegs);
4732 __ sw(a1, FieldMemOperand(t3, ConsString::kSecondOffset));
4733 __ RecordWriteField(t3,
4734 ConsString::kSecondOffset,
4735 a1,
4736 t0,
4737 kRAHasNotBeenSaved,
4738 kDontSaveFPRegs);
4739 __ jmp(&after_writing);
4740
4741 __ bind(&skip_write_barrier);
4742 __ sw(a0, FieldMemOperand(v0, ConsString::kFirstOffset));
4743 __ sw(a1, FieldMemOperand(v0, ConsString::kSecondOffset));
4744
4745 __ bind(&after_writing);
4746
4747 __ IncrementCounter(counters->string_add_native(), 1, a2, a3);
4748 __ DropAndRet(2);
4749
4750 __ bind(&non_ascii);
4751 // At least one of the strings is two-byte. Check whether it happens
4752 // to contain only one byte characters.
4753 // t0: first instance type.
4754 // t1: second instance type.
4755 // Branch to if _both_ instances have kOneByteDataHintMask set.
4756 __ And(at, t0, Operand(kOneByteDataHintMask));
4757 __ and_(at, at, t1);
4758 __ Branch(&ascii_data, ne, at, Operand(zero_reg));
4759 __ Xor(t0, t0, Operand(t1));
4760 STATIC_ASSERT(kOneByteStringTag != 0 && kOneByteDataHintTag != 0);
4761 __ And(t0, t0, Operand(kOneByteStringTag | kOneByteDataHintTag));
4762 __ Branch(&ascii_data, eq, t0,
4763 Operand(kOneByteStringTag | kOneByteDataHintTag));
4764
4765 // Allocate a two byte cons string.
4766 __ AllocateTwoByteConsString(v0, t2, t0, t1, &call_runtime);
4767 __ Branch(&allocated);
4768
4769 // We cannot encounter sliced strings or cons strings here since:
4770 STATIC_ASSERT(SlicedString::kMinLength >= ConsString::kMinLength);
4771 // Handle creating a flat result from either external or sequential strings.
4772 // Locate the first characters' locations.
4773 // a0: first string
4774 // a1: second string
4775 // a2: length of first string
4776 // a3: length of second string
4777 // t0: first string instance type (if flags_ == NO_STRING_ADD_FLAGS)
4778 // t1: second string instance type (if flags_ == NO_STRING_ADD_FLAGS)
4779 // t2: sum of lengths.
4780 Label first_prepared, second_prepared;
4781 __ bind(&string_add_flat_result);
4782 if ((flags_ & STRING_ADD_CHECK_BOTH) != STRING_ADD_CHECK_BOTH) {
4783 __ lw(t0, FieldMemOperand(a0, HeapObject::kMapOffset));
4784 __ lw(t1, FieldMemOperand(a1, HeapObject::kMapOffset));
4785 __ lbu(t0, FieldMemOperand(t0, Map::kInstanceTypeOffset));
4786 __ lbu(t1, FieldMemOperand(t1, Map::kInstanceTypeOffset));
4787 }
4788 // Check whether both strings have same encoding
4789 __ Xor(t3, t0, Operand(t1));
4790 __ And(t3, t3, Operand(kStringEncodingMask));
4791 __ Branch(&call_runtime, ne, t3, Operand(zero_reg));
4792
4793 STATIC_ASSERT(kSeqStringTag == 0);
4794 __ And(t4, t0, Operand(kStringRepresentationMask));
4795
4796 STATIC_ASSERT(SeqOneByteString::kHeaderSize == SeqTwoByteString::kHeaderSize);
4797 Label skip_first_add;
4798 __ Branch(&skip_first_add, ne, t4, Operand(zero_reg));
4799 __ Branch(USE_DELAY_SLOT, &first_prepared);
4800 __ addiu(t3, a0, SeqOneByteString::kHeaderSize - kHeapObjectTag);
4801 __ bind(&skip_first_add);
4802 // External string: rule out short external string and load string resource.
4803 STATIC_ASSERT(kShortExternalStringTag != 0);
4804 __ And(t4, t0, Operand(kShortExternalStringMask));
4805 __ Branch(&call_runtime, ne, t4, Operand(zero_reg));
4806 __ lw(t3, FieldMemOperand(a0, ExternalString::kResourceDataOffset));
4807 __ bind(&first_prepared);
4808
4809 STATIC_ASSERT(kSeqStringTag == 0);
4810 __ And(t4, t1, Operand(kStringRepresentationMask));
4811 STATIC_ASSERT(SeqOneByteString::kHeaderSize == SeqTwoByteString::kHeaderSize);
4812 Label skip_second_add;
4813 __ Branch(&skip_second_add, ne, t4, Operand(zero_reg));
4814 __ Branch(USE_DELAY_SLOT, &second_prepared);
4815 __ addiu(a1, a1, SeqOneByteString::kHeaderSize - kHeapObjectTag);
4816 __ bind(&skip_second_add);
4817 // External string: rule out short external string and load string resource.
4818 STATIC_ASSERT(kShortExternalStringTag != 0);
4819 __ And(t4, t1, Operand(kShortExternalStringMask));
4820 __ Branch(&call_runtime, ne, t4, Operand(zero_reg));
4821 __ lw(a1, FieldMemOperand(a1, ExternalString::kResourceDataOffset));
4822 __ bind(&second_prepared);
4823
4824 Label non_ascii_string_add_flat_result;
4825 // t3: first character of first string
4826 // a1: first character of second string
4827 // a2: length of first string
4828 // a3: length of second string
4829 // t2: sum of lengths.
4830 // Both strings have the same encoding.
4831 STATIC_ASSERT(kTwoByteStringTag == 0);
4832 __ And(t4, t1, Operand(kStringEncodingMask));
4833 __ Branch(&non_ascii_string_add_flat_result, eq, t4, Operand(zero_reg));
4834
4835 __ AllocateAsciiString(v0, t2, t0, t1, t5, &call_runtime);
4836 __ Addu(t2, v0, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag));
4837 // v0: result string.
4838 // t3: first character of first string.
4839 // a1: first character of second string
4840 // a2: length of first string.
4841 // a3: length of second string.
4842 // t2: first character of result.
4843
4844 StringHelper::GenerateCopyCharacters(masm, t2, t3, a2, t0, true);
4845 // t2: next character of result.
4846 StringHelper::GenerateCopyCharacters(masm, t2, a1, a3, t0, true);
4847 __ IncrementCounter(counters->string_add_native(), 1, a2, a3);
4848 __ DropAndRet(2);
4849
4850 __ bind(&non_ascii_string_add_flat_result);
4851 __ AllocateTwoByteString(v0, t2, t0, t1, t5, &call_runtime);
4852 __ Addu(t2, v0, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
4853 // v0: result string.
4854 // t3: first character of first string.
4855 // a1: first character of second string.
4856 // a2: length of first string.
4857 // a3: length of second string.
4858 // t2: first character of result.
4859 StringHelper::GenerateCopyCharacters(masm, t2, t3, a2, t0, false);
4860 // t2: next character of result.
4861 StringHelper::GenerateCopyCharacters(masm, t2, a1, a3, t0, false);
4862
4863 __ IncrementCounter(counters->string_add_native(), 1, a2, a3);
4864 __ DropAndRet(2);
4865
4866 // Just jump to runtime to add the two strings.
4867 __ bind(&call_runtime);
4868 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
4869
4870 if (call_builtin.is_linked()) {
4871 __ bind(&call_builtin);
4872 __ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
4873 }
4874 }
4875
4876
4877 void StringAddStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
4878 __ push(a0);
4879 __ push(a1);
4880 }
4881
4882
4883 void StringAddStub::GenerateRegisterArgsPop(MacroAssembler* masm) {
4884 __ pop(a1);
4885 __ pop(a0);
4886 }
4887
4888
4889 void StringAddStub::GenerateConvertArgument(MacroAssembler* masm,
4890 int stack_offset,
4891 Register arg,
4892 Register scratch1,
4893 Register scratch2,
4894 Register scratch3,
4895 Register scratch4,
4896 Label* slow) {
4897 // First check if the argument is already a string.
4898 Label not_string, done;
4899 __ JumpIfSmi(arg, &not_string);
4900 __ GetObjectType(arg, scratch1, scratch1);
4901 __ Branch(&done, lt, scratch1, Operand(FIRST_NONSTRING_TYPE));
4902
4903 // Check the number to string cache.
4904 __ bind(&not_string);
4905 // Puts the cached result into scratch1.
4906 __ LookupNumberStringCache(arg, scratch1, scratch2, scratch3, scratch4, slow);
4907 __ mov(arg, scratch1);
4908 __ sw(arg, MemOperand(sp, stack_offset));
4909 __ bind(&done);
4910 }
4911
4912
4913 void ICCompareStub::GenerateSmis(MacroAssembler* masm) { 4398 void ICCompareStub::GenerateSmis(MacroAssembler* masm) {
4914 ASSERT(state_ == CompareIC::SMI); 4399 ASSERT(state_ == CompareIC::SMI);
4915 Label miss; 4400 Label miss;
4916 __ Or(a2, a1, a0); 4401 __ Or(a2, a1, a0);
4917 __ JumpIfNotSmi(a2, &miss); 4402 __ JumpIfNotSmi(a2, &miss);
4918 4403
4919 if (GetCondition() == eq) { 4404 if (GetCondition() == eq) {
4920 // For equality we do not care about the sign of the result. 4405 // For equality we do not care about the sign of the result.
4921 __ Ret(USE_DELAY_SLOT); 4406 __ Ret(USE_DELAY_SLOT);
4922 __ Subu(v0, a0, a1); 4407 __ Subu(v0, a0, a1);
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
6218 __ bind(&fast_elements_case); 5703 __ bind(&fast_elements_case);
6219 GenerateCase(masm, FAST_ELEMENTS); 5704 GenerateCase(masm, FAST_ELEMENTS);
6220 } 5705 }
6221 5706
6222 5707
6223 #undef __ 5708 #undef __
6224 5709
6225 } } // namespace v8::internal 5710 } } // namespace v8::internal
6226 5711
6227 #endif // V8_TARGET_ARCH_MIPS 5712 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.h ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698