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

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

Issue 8680010: Add external strings support to regexp in generated code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixing small mistakes 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ia32/code-stubs-ia32.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 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 4542 matching lines...) Expand 10 before | Expand all | Expand 10 after
4553 4553
4554 // Reset offset for possibly sliced string. 4554 // Reset offset for possibly sliced string.
4555 __ mov(r9, Operand(0)); 4555 __ mov(r9, Operand(0));
4556 // subject: Subject string 4556 // subject: Subject string
4557 // regexp_data: RegExp data (FixedArray) 4557 // regexp_data: RegExp data (FixedArray)
4558 // Check the representation and encoding of the subject string. 4558 // Check the representation and encoding of the subject string.
4559 Label seq_string; 4559 Label seq_string;
4560 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); 4560 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset));
4561 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); 4561 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset));
4562 // First check for flat string. 4562 // First check for flat string.
4563 __ and_(r1, r0, Operand(kIsNotStringMask | kStringRepresentationMask), SetCC); 4563 __ and_(r1, r0, Operand(kIsNotStringMask | kStringRepresentationMask), SetCC);
Lasse Reichstein 2011/11/25 12:56:50 Could you add kShortStringMask here? That would ma
Yang 2011/11/25 14:19:25 Great idea!
4564 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); 4564 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0);
4565 __ b(eq, &seq_string); 4565 __ b(eq, &seq_string);
4566 4566
4567 // subject: Subject string 4567 // subject: Subject string
4568 // regexp_data: RegExp data (FixedArray) 4568 // regexp_data: RegExp data (FixedArray)
4569 // Check for flat cons string or sliced string. 4569 // Check for flat cons string or sliced string.
4570 // A flat cons string is a cons string where the second part is the empty 4570 // A flat cons string is a cons string where the second part is the empty
4571 // string. In that case the subject string is just the first part of the cons 4571 // string. In that case the subject string is just the first part of the cons
4572 // string. Also in this case the first part of the cons string is known to be 4572 // string. Also in this case the first part of the cons string is known to be
4573 // a sequential string or an external string. 4573 // a sequential string or an external string.
4574 // In the case of a sliced string its offset has to be taken into account. 4574 // In the case of a sliced string its offset has to be taken into account.
4575 Label cons_string, check_encoding; 4575 Label cons_string, external_string, check_encoding;
4576 STATIC_ASSERT(kConsStringTag < kExternalStringTag); 4576 STATIC_ASSERT(kConsStringTag < kExternalStringTag);
4577 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); 4577 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag);
4578 __ cmp(r1, Operand(kExternalStringTag)); 4578 __ cmp(r1, Operand(kExternalStringTag));
4579 __ b(lt, &cons_string); 4579 __ b(lt, &cons_string);
4580 __ b(eq, &runtime); 4580 __ b(eq, &external_string);
4581 4581
Lasse Reichstein 2011/11/25 12:56:50 This was where you added the is-not-string test, r
4582 // String is sliced. 4582 // String is sliced.
4583 __ ldr(r9, FieldMemOperand(subject, SlicedString::kOffsetOffset)); 4583 __ ldr(r9, FieldMemOperand(subject, SlicedString::kOffsetOffset));
4584 __ mov(r9, Operand(r9, ASR, kSmiTagSize)); 4584 __ mov(r9, Operand(r9, ASR, kSmiTagSize));
4585 __ ldr(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); 4585 __ ldr(subject, FieldMemOperand(subject, SlicedString::kParentOffset));
4586 // r9: offset of sliced string, smi-tagged. 4586 // r9: offset of sliced string, smi-tagged.
4587 __ jmp(&check_encoding); 4587 __ jmp(&check_encoding);
4588 // String is a cons string, check whether it is flat. 4588 // String is a cons string, check whether it is flat.
4589 __ bind(&cons_string); 4589 __ bind(&cons_string);
4590 __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset)); 4590 __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset));
4591 __ LoadRoot(r1, Heap::kEmptyStringRootIndex); 4591 __ CompareRoot(r0, Heap::kEmptyStringRootIndex);
4592 __ cmp(r0, r1);
4593 __ b(ne, &runtime); 4592 __ b(ne, &runtime);
4594 __ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); 4593 __ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset));
4595 // Is first part of cons or parent of slice a flat string? 4594 // Is first part of cons or parent of slice a flat string?
4596 __ bind(&check_encoding); 4595 __ bind(&check_encoding);
4597 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); 4596 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset));
4598 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); 4597 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset));
4599 STATIC_ASSERT(kSeqStringTag == 0); 4598 STATIC_ASSERT(kSeqStringTag == 0);
4600 __ tst(r0, Operand(kStringRepresentationMask)); 4599 __ tst(r0, Operand(kStringRepresentationMask));
4601 __ b(ne, &runtime); 4600 __ b(ne, &external_string);
4601
4602 __ bind(&seq_string); 4602 __ bind(&seq_string);
4603 // subject: Subject string 4603 // subject: Subject string
4604 // regexp_data: RegExp data (FixedArray) 4604 // regexp_data: RegExp data (FixedArray)
4605 // r0: Instance type of subject string 4605 // r0: Instance type of subject string
4606 STATIC_ASSERT(4 == kAsciiStringTag); 4606 STATIC_ASSERT(4 == kAsciiStringTag);
4607 STATIC_ASSERT(kTwoByteStringTag == 0); 4607 STATIC_ASSERT(kTwoByteStringTag == 0);
4608 // Find the code object based on the assumptions above. 4608 // Find the code object based on the assumptions above.
4609 __ and_(r0, r0, Operand(kStringEncodingMask)); 4609 __ and_(r0, r0, Operand(kStringEncodingMask));
4610 __ mov(r3, Operand(r0, ASR, 2), SetCC); 4610 __ mov(r3, Operand(r0, ASR, 2), SetCC);
4611 __ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne); 4611 __ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
4799 __ mov(r3, Operand(r3, LSL, kSmiTagSize)); 4799 __ mov(r3, Operand(r3, LSL, kSmiTagSize));
4800 __ str(r3, MemOperand(r0, kPointerSize, PostIndex)); 4800 __ str(r3, MemOperand(r0, kPointerSize, PostIndex));
4801 __ jmp(&next_capture); 4801 __ jmp(&next_capture);
4802 __ bind(&done); 4802 __ bind(&done);
4803 4803
4804 // Return last match info. 4804 // Return last match info.
4805 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); 4805 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset));
4806 __ add(sp, sp, Operand(4 * kPointerSize)); 4806 __ add(sp, sp, Operand(4 * kPointerSize));
4807 __ Ret(); 4807 __ Ret();
4808 4808
4809 // String is external.
4810 // r0: scratch
4811 __ bind(&external_string);
4812 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset));
4813 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset));
4814 if (FLAG_debug_code) {
4815 // Assert that we do not have a cons or slice (indirect strings) here.
4816 // Sequential strings have already been ruled out.
4817 __ tst(r0, Operand(kIsIndirectStringMask));
4818 __ Assert(eq, "external string expected, but not found");
4819 }
4820 // Rule out short external strings.
4821 STATIC_CHECK(kShortExternalStringTag != 0);
4822 __ tst(r0, Operand(kShortExternalStringMask));
4823 __ b(ne, &runtime);
4824 __ ldr(subject,
4825 FieldMemOperand(subject, ExternalString::kResourceDataOffset));
4826 // Move the pointer so that offset-wise, it looks like a sequential string.
4827 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize);
4828 __ sub(subject,
4829 subject,
4830 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
4831 __ jmp(&seq_string);
4832
4809 // Do the runtime call to execute the regexp. 4833 // Do the runtime call to execute the regexp.
4810 __ bind(&runtime); 4834 __ bind(&runtime);
4811 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); 4835 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
4812 #endif // V8_INTERPRETED_REGEXP 4836 #endif // V8_INTERPRETED_REGEXP
4813 } 4837 }
4814 4838
4815 4839
4816 void RegExpConstructResultStub::Generate(MacroAssembler* masm) { 4840 void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
4817 const int kMaxInlineLength = 100; 4841 const int kMaxInlineLength = 100;
4818 Label slowcase; 4842 Label slowcase;
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after
7179 __ StoreNumberToDoubleElements(r0, r3, r1, r5, r6, r7, r9, r10, 7203 __ StoreNumberToDoubleElements(r0, r3, r1, r5, r6, r7, r9, r10,
7180 &slow_elements); 7204 &slow_elements);
7181 __ Ret(); 7205 __ Ret();
7182 } 7206 }
7183 7207
7184 #undef __ 7208 #undef __
7185 7209
7186 } } // namespace v8::internal 7210 } } // namespace v8::internal
7187 7211
7188 #endif // V8_TARGET_ARCH_ARM 7212 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698