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/regexp/regexp-macro-assembler.h" | 5 #include "src/regexp/regexp-macro-assembler.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
9 #include "src/regexp/regexp-stack.h" | 9 #include "src/regexp/regexp-stack.h" |
10 #include "src/simulator.h" | 10 #include "src/simulator.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 | 127 |
128 const byte* NativeRegExpMacroAssembler::StringCharacterPosition( | 128 const byte* NativeRegExpMacroAssembler::StringCharacterPosition( |
129 String* subject, | 129 String* subject, |
130 int start_index) { | 130 int start_index) { |
131 if (subject->IsConsString()) { | 131 if (subject->IsConsString()) { |
132 subject = ConsString::cast(subject)->first(); | 132 subject = ConsString::cast(subject)->first(); |
133 } else if (subject->IsSlicedString()) { | 133 } else if (subject->IsSlicedString()) { |
134 start_index += SlicedString::cast(subject)->offset(); | 134 start_index += SlicedString::cast(subject)->offset(); |
135 subject = SlicedString::cast(subject)->parent(); | 135 subject = SlicedString::cast(subject)->parent(); |
| 136 } else if (subject->IsThinString()) { |
| 137 subject = ThinString::cast(subject)->actual(); |
136 } | 138 } |
137 DCHECK(start_index >= 0); | 139 DCHECK(start_index >= 0); |
138 DCHECK(start_index <= subject->length()); | 140 DCHECK(start_index <= subject->length()); |
139 if (subject->IsSeqOneByteString()) { | 141 if (subject->IsSeqOneByteString()) { |
140 return reinterpret_cast<const byte*>( | 142 return reinterpret_cast<const byte*>( |
141 SeqOneByteString::cast(subject)->GetChars() + start_index); | 143 SeqOneByteString::cast(subject)->GetChars() + start_index); |
142 } else if (subject->IsSeqTwoByteString()) { | 144 } else if (subject->IsSeqTwoByteString()) { |
143 return reinterpret_cast<const byte*>( | 145 return reinterpret_cast<const byte*>( |
144 SeqTwoByteString::cast(subject)->GetChars() + start_index); | 146 SeqTwoByteString::cast(subject)->GetChars() + start_index); |
145 } else if (subject->IsExternalOneByteString()) { | 147 } else if (subject->IsExternalOneByteString()) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // The string has been flattened, so if it is a cons string it contains the | 234 // The string has been flattened, so if it is a cons string it contains the |
233 // full string in the first part. | 235 // full string in the first part. |
234 if (StringShape(subject_ptr).IsCons()) { | 236 if (StringShape(subject_ptr).IsCons()) { |
235 DCHECK_EQ(0, ConsString::cast(subject_ptr)->second()->length()); | 237 DCHECK_EQ(0, ConsString::cast(subject_ptr)->second()->length()); |
236 subject_ptr = ConsString::cast(subject_ptr)->first(); | 238 subject_ptr = ConsString::cast(subject_ptr)->first(); |
237 } else if (StringShape(subject_ptr).IsSliced()) { | 239 } else if (StringShape(subject_ptr).IsSliced()) { |
238 SlicedString* slice = SlicedString::cast(subject_ptr); | 240 SlicedString* slice = SlicedString::cast(subject_ptr); |
239 subject_ptr = slice->parent(); | 241 subject_ptr = slice->parent(); |
240 slice_offset = slice->offset(); | 242 slice_offset = slice->offset(); |
241 } | 243 } |
| 244 if (StringShape(subject_ptr).IsThin()) { |
| 245 subject_ptr = ThinString::cast(subject_ptr)->actual(); |
| 246 } |
242 // Ensure that an underlying string has the same representation. | 247 // Ensure that an underlying string has the same representation. |
243 bool is_one_byte = subject_ptr->IsOneByteRepresentation(); | 248 bool is_one_byte = subject_ptr->IsOneByteRepresentation(); |
244 DCHECK(subject_ptr->IsExternalString() || subject_ptr->IsSeqString()); | 249 DCHECK(subject_ptr->IsExternalString() || subject_ptr->IsSeqString()); |
245 // String is now either Sequential or External | 250 // String is now either Sequential or External |
246 int char_size_shift = is_one_byte ? 0 : 1; | 251 int char_size_shift = is_one_byte ? 0 : 1; |
247 | 252 |
248 const byte* input_start = | 253 const byte* input_start = |
249 StringCharacterPosition(subject_ptr, start_offset + slice_offset); | 254 StringCharacterPosition(subject_ptr, start_offset + slice_offset); |
250 int byte_length = char_length << char_size_shift; | 255 int byte_length = char_length << char_size_shift; |
251 const byte* input_end = input_start + byte_length; | 256 const byte* input_end = input_start + byte_length; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 352 } |
348 *stack_base = new_stack_base; | 353 *stack_base = new_stack_base; |
349 intptr_t stack_content_size = old_stack_base - stack_pointer; | 354 intptr_t stack_content_size = old_stack_base - stack_pointer; |
350 return new_stack_base - stack_content_size; | 355 return new_stack_base - stack_content_size; |
351 } | 356 } |
352 | 357 |
353 #endif // V8_INTERPRETED_REGEXP | 358 #endif // V8_INTERPRETED_REGEXP |
354 | 359 |
355 } // namespace internal | 360 } // namespace internal |
356 } // namespace v8 | 361 } // namespace v8 |
OLD | NEW |