Chromium Code Reviews| Index: src/ia32/regexp-macro-assembler-ia32.cc |
| diff --git a/src/ia32/regexp-macro-assembler-ia32.cc b/src/ia32/regexp-macro-assembler-ia32.cc |
| index 8db2e9b160f41f7bd8ec2bc20b4f71f77fc5e59a..14f1e518ebb22e908d45eda76e0914e7146bf955 100644 |
| --- a/src/ia32/regexp-macro-assembler-ia32.cc |
| +++ b/src/ia32/regexp-macro-assembler-ia32.cc |
| @@ -1069,8 +1069,21 @@ int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address, |
| Handle<Code> code_handle(re_code); |
| Handle<String> subject(frame_entry<String*>(re_frame, kInputString)); |
| + |
| + String* subject_ptr = *subject; |
|
Vitaly Repeshko
2011/08/12 19:01:00
Should be put in a handle.
|
| + int slice_offset = 0; |
| + |
| + // Extract the underlying string and the slice offset. |
| + if (StringShape(subject_ptr).IsCons()) { |
| + subject_ptr = ConsString::cast(subject_ptr)->first(); |
| + } else if (StringShape(subject_ptr).IsSliced()) { |
| + SlicedString* slice = SlicedString::cast(subject_ptr); |
| + subject_ptr = slice->parent(); |
| + slice_offset = slice->offset(); |
| + } |
| + |
| // Current string. |
| - bool is_ascii = subject->IsAsciiRepresentation(); |
| + bool is_ascii = subject_ptr->IsAsciiRepresentation(); |
| ASSERT(re_code->instruction_start() <= *return_address); |
| ASSERT(*return_address <= |
| @@ -1089,7 +1102,7 @@ int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address, |
| } |
| // String might have changed. |
| - if (subject->IsAsciiRepresentation() != is_ascii) { |
| + if (subject_ptr->IsAsciiRepresentation() != is_ascii) { |
| // If we changed between an ASCII and an UC16 string, the specialized |
| // code cannot be used, and we need to restart regexp matching from |
| // scratch (including, potentially, compiling a new version of the code). |
| @@ -1100,8 +1113,8 @@ int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address, |
| // be a sequential or external string with the same content. |
| // Update the start and end pointers in the stack frame to the current |
| // location (whether it has actually moved or not). |
| - ASSERT(StringShape(*subject).IsSequential() || |
| - StringShape(*subject).IsExternal()); |
| + ASSERT(StringShape(subject_ptr).IsSequential() || |
| + StringShape(subject_ptr).IsExternal()); |
| // The original start address of the characters to match. |
| const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart); |
| @@ -1109,13 +1122,14 @@ int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address, |
| // Find the current start address of the same character at the current string |
| // position. |
| int start_index = frame_entry<int>(re_frame, kStartIndex); |
| - const byte* new_address = StringCharacterPosition(*subject, start_index); |
| + const byte* new_address = StringCharacterPosition(subject_ptr, |
| + start_index + slice_offset); |
| if (start_address != new_address) { |
| // If there is a difference, update the object pointer and start and end |
| // addresses in the RegExp stack frame to match the new value. |
| const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd); |
| - int byte_length = end_address - start_address; |
| + int byte_length = static_cast<int>(end_address - start_address); |
| frame_entry<const String*>(re_frame, kInputString) = *subject; |
| frame_entry<const byte*>(re_frame, kInputStart) = new_address; |
| frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; |