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

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

Issue 8744012: MIPS: Add external strings support to regexp in generated code. (Closed)
Patch Set: Created 9 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 4729 matching lines...) Expand 10 before | Expand all | Expand 10 after
4740 4740
4741 // Reset offset for possibly sliced string. 4741 // Reset offset for possibly sliced string.
4742 __ mov(t0, zero_reg); 4742 __ mov(t0, zero_reg);
4743 // subject: Subject string 4743 // subject: Subject string
4744 // regexp_data: RegExp data (FixedArray) 4744 // regexp_data: RegExp data (FixedArray)
4745 // Check the representation and encoding of the subject string. 4745 // Check the representation and encoding of the subject string.
4746 Label seq_string; 4746 Label seq_string;
4747 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); 4747 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset));
4748 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); 4748 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset));
4749 // First check for flat string. None of the following string type tests will 4749 // First check for flat string. None of the following string type tests will
4750 // succeed if kIsNotStringTag is set. 4750 // succeed if subject is not a string or a short external string.
4751 __ And(a1, a0, Operand(kIsNotStringMask | kStringRepresentationMask)); 4751 __ And(a1,
4752 a0,
4753 Operand(kIsNotStringMask |
4754 kStringRepresentationMask |
4755 kShortExternalStringMask));
4752 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); 4756 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0);
4753 __ Branch(&seq_string, eq, a1, Operand(zero_reg)); 4757 __ Branch(&seq_string, eq, a1, Operand(zero_reg));
4754 4758
4755 // subject: Subject string 4759 // subject: Subject string
4756 // a0: instance type if Subject string 4760 // a0: instance type if Subject string
4757 // regexp_data: RegExp data (FixedArray) 4761 // regexp_data: RegExp data (FixedArray)
4758 // a1: whether subject is a string and if yes, its string representation 4762 // a1: whether subject is a string and if yes, its string representation
4759 // Check for flat cons string or sliced string. 4763 // Check for flat cons string or sliced string.
4760 // A flat cons string is a cons string where the second part is the empty 4764 // A flat cons string is a cons string where the second part is the empty
4761 // string. In that case the subject string is just the first part of the cons 4765 // string. In that case the subject string is just the first part of the cons
4762 // string. Also in this case the first part of the cons string is known to be 4766 // string. Also in this case the first part of the cons string is known to be
4763 // a sequential string or an external string. 4767 // a sequential string or an external string.
4764 // In the case of a sliced string its offset has to be taken into account. 4768 // In the case of a sliced string its offset has to be taken into account.
4765 Label cons_string, check_encoding; 4769 Label cons_string, external_string, check_encoding;
4766 STATIC_ASSERT(kConsStringTag < kExternalStringTag); 4770 STATIC_ASSERT(kConsStringTag < kExternalStringTag);
4767 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); 4771 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag);
4768 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); 4772 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag);
4773 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag);
4769 __ Branch(&cons_string, lt, a1, Operand(kExternalStringTag)); 4774 __ Branch(&cons_string, lt, a1, Operand(kExternalStringTag));
4770 __ Branch(&runtime, eq, a1, Operand(kExternalStringTag)); 4775 __ Branch(&external_string, eq, a1, Operand(kExternalStringTag));
4771 4776
4772 // Catch non-string subject (should already have been guarded against). 4777 // Catch non-string subject or short external string.
4773 STATIC_ASSERT(kNotStringTag != 0); 4778 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0);
4774 __ And(at, a1, Operand(kIsNotStringMask)); 4779 __ And(at, a1, Operand(kIsNotStringMask | kShortExternalStringMask));
4775 __ Branch(&runtime, ne, at, Operand(zero_reg)); 4780 __ Branch(&runtime, ne, at, Operand(zero_reg));
4776 4781
4777 // String is sliced. 4782 // String is sliced.
4778 __ lw(t0, FieldMemOperand(subject, SlicedString::kOffsetOffset)); 4783 __ lw(t0, FieldMemOperand(subject, SlicedString::kOffsetOffset));
4779 __ sra(t0, t0, kSmiTagSize); 4784 __ sra(t0, t0, kSmiTagSize);
4780 __ lw(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); 4785 __ lw(subject, FieldMemOperand(subject, SlicedString::kParentOffset));
4781 // t5: offset of sliced string, smi-tagged. 4786 // t5: offset of sliced string, smi-tagged.
4782 __ jmp(&check_encoding); 4787 __ jmp(&check_encoding);
4783 // String is a cons string, check whether it is flat. 4788 // String is a cons string, check whether it is flat.
4784 __ bind(&cons_string); 4789 __ bind(&cons_string);
4785 __ lw(a0, FieldMemOperand(subject, ConsString::kSecondOffset)); 4790 __ lw(a0, FieldMemOperand(subject, ConsString::kSecondOffset));
4786 __ LoadRoot(a1, Heap::kEmptyStringRootIndex); 4791 __ LoadRoot(a1, Heap::kEmptyStringRootIndex);
4787 __ Branch(&runtime, ne, a0, Operand(a1)); 4792 __ Branch(&runtime, ne, a0, Operand(a1));
4788 __ lw(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); 4793 __ lw(subject, FieldMemOperand(subject, ConsString::kFirstOffset));
4789 // Is first part of cons or parent of slice a flat string? 4794 // Is first part of cons or parent of slice a flat string?
4790 __ bind(&check_encoding); 4795 __ bind(&check_encoding);
4791 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); 4796 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset));
4792 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); 4797 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset));
4793 STATIC_ASSERT(kSeqStringTag == 0); 4798 STATIC_ASSERT(kSeqStringTag == 0);
4794 __ And(at, a0, Operand(kStringRepresentationMask)); 4799 __ And(at, a0, Operand(kStringRepresentationMask));
4795 __ Branch(&runtime, ne, at, Operand(zero_reg)); 4800 __ Branch(&external_string, ne, at, Operand(zero_reg));
4796 4801
4797 __ bind(&seq_string); 4802 __ bind(&seq_string);
4798 // subject: Subject string 4803 // subject: Subject string
4799 // regexp_data: RegExp data (FixedArray) 4804 // regexp_data: RegExp data (FixedArray)
4800 // a0: Instance type of subject string 4805 // a0: Instance type of subject string
4801 STATIC_ASSERT(kStringEncodingMask == 4); 4806 STATIC_ASSERT(kStringEncodingMask == 4);
4802 STATIC_ASSERT(kAsciiStringTag == 4); 4807 STATIC_ASSERT(kAsciiStringTag == 4);
4803 STATIC_ASSERT(kTwoByteStringTag == 0); 4808 STATIC_ASSERT(kTwoByteStringTag == 0);
4804 // Find the code object based on the assumptions above. 4809 // Find the code object based on the assumptions above.
4805 __ And(a0, a0, Operand(kStringEncodingMask)); // Non-zero for ascii. 4810 __ And(a0, a0, Operand(kStringEncodingMask)); // Non-zero for ascii.
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
5011 __ Branch(&next_capture, USE_DELAY_SLOT); 5016 __ Branch(&next_capture, USE_DELAY_SLOT);
5012 __ addiu(a0, a0, kPointerSize); // In branch delay slot. 5017 __ addiu(a0, a0, kPointerSize); // In branch delay slot.
5013 5018
5014 __ bind(&done); 5019 __ bind(&done);
5015 5020
5016 // Return last match info. 5021 // Return last match info.
5017 __ lw(v0, MemOperand(sp, kLastMatchInfoOffset)); 5022 __ lw(v0, MemOperand(sp, kLastMatchInfoOffset));
5018 __ Addu(sp, sp, Operand(4 * kPointerSize)); 5023 __ Addu(sp, sp, Operand(4 * kPointerSize));
5019 __ Ret(); 5024 __ Ret();
5020 5025
5026 // External string. Short external strings have already been ruled out.
5027 // a0: scratch
5028 __ bind(&external_string);
5029 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset));
5030 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset));
5031 if (FLAG_debug_code) {
5032 // Assert that we do not have a cons or slice (indirect strings) here.
5033 // Sequential strings have already been ruled out.
5034 __ And(at, a0, Operand(kIsIndirectStringMask));
5035 __ Assert(eq, "external string expected, but not found",
5036 at, Operand(zero_reg));
5037 }
5038 __ lw(subject,
5039 FieldMemOperand(subject, ExternalString::kResourceDataOffset));
5040 // Move the pointer so that offset-wise, it looks like a sequential string.
5041 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize);
5042 __ Subu(subject,
5043 subject,
5044 SeqTwoByteString::kHeaderSize - kHeapObjectTag);
5045 __ jmp(&seq_string);
5046
5021 // Do the runtime call to execute the regexp. 5047 // Do the runtime call to execute the regexp.
5022 __ bind(&runtime); 5048 __ bind(&runtime);
5023 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); 5049 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
5024 #endif // V8_INTERPRETED_REGEXP 5050 #endif // V8_INTERPRETED_REGEXP
5025 } 5051 }
5026 5052
5027 5053
5028 void RegExpConstructResultStub::Generate(MacroAssembler* masm) { 5054 void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
5029 const int kMaxInlineLength = 100; 5055 const int kMaxInlineLength = 100;
5030 Label slowcase; 5056 Label slowcase;
(...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after
7469 &slow_elements); 7495 &slow_elements);
7470 __ Ret(); 7496 __ Ret();
7471 } 7497 }
7472 7498
7473 7499
7474 #undef __ 7500 #undef __
7475 7501
7476 } } // namespace v8::internal 7502 } } // namespace v8::internal
7477 7503
7478 #endif // V8_TARGET_ARCH_MIPS 7504 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698