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