| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return FLAG_enable_unaligned_accesses && !slow_safe(); | 70 return FLAG_enable_unaligned_accesses && !slow_safe(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 const byte* NativeRegExpMacroAssembler::StringCharacterPosition( | 73 const byte* NativeRegExpMacroAssembler::StringCharacterPosition( |
| 74 String* subject, | 74 String* subject, |
| 75 int start_index) { | 75 int start_index) { |
| 76 // Not just flat, but ultra flat. | 76 // Not just flat, but ultra flat. |
| 77 ASSERT(subject->IsExternalString() || subject->IsSeqString()); | 77 ASSERT(subject->IsExternalString() || subject->IsSeqString()); |
| 78 ASSERT(start_index >= 0); | 78 ASSERT(start_index >= 0); |
| 79 ASSERT(start_index <= subject->length()); | 79 ASSERT(start_index <= subject->length()); |
| 80 if (subject->IsAsciiRepresentation()) { | 80 if (subject->IsOneByteRepresentation()) { |
| 81 const byte* address; | 81 const byte* address; |
| 82 if (StringShape(subject).IsExternal()) { | 82 if (StringShape(subject).IsExternal()) { |
| 83 const char* data = ExternalAsciiString::cast(subject)->GetChars(); | 83 const char* data = ExternalAsciiString::cast(subject)->GetChars(); |
| 84 address = reinterpret_cast<const byte*>(data); | 84 address = reinterpret_cast<const byte*>(data); |
| 85 } else { | 85 } else { |
| 86 ASSERT(subject->IsSeqOneByteString()); | 86 ASSERT(subject->IsSeqOneByteString()); |
| 87 char* data = SeqOneByteString::cast(subject)->GetChars(); | 87 char* data = SeqOneByteString::cast(subject)->GetChars(); |
| 88 address = reinterpret_cast<const byte*>(data); | 88 address = reinterpret_cast<const byte*>(data); |
| 89 } | 89 } |
| 90 return address + start_index; | 90 return address + start_index; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // full string in the first part. | 126 // full string in the first part. |
| 127 if (StringShape(subject_ptr).IsCons()) { | 127 if (StringShape(subject_ptr).IsCons()) { |
| 128 ASSERT_EQ(0, ConsString::cast(subject_ptr)->second()->length()); | 128 ASSERT_EQ(0, ConsString::cast(subject_ptr)->second()->length()); |
| 129 subject_ptr = ConsString::cast(subject_ptr)->first(); | 129 subject_ptr = ConsString::cast(subject_ptr)->first(); |
| 130 } else if (StringShape(subject_ptr).IsSliced()) { | 130 } else if (StringShape(subject_ptr).IsSliced()) { |
| 131 SlicedString* slice = SlicedString::cast(subject_ptr); | 131 SlicedString* slice = SlicedString::cast(subject_ptr); |
| 132 subject_ptr = slice->parent(); | 132 subject_ptr = slice->parent(); |
| 133 slice_offset = slice->offset(); | 133 slice_offset = slice->offset(); |
| 134 } | 134 } |
| 135 // Ensure that an underlying string has the same ASCII-ness. | 135 // Ensure that an underlying string has the same ASCII-ness. |
| 136 bool is_ascii = subject_ptr->IsAsciiRepresentation(); | 136 bool is_ascii = subject_ptr->IsOneByteRepresentation(); |
| 137 ASSERT(subject_ptr->IsExternalString() || subject_ptr->IsSeqString()); | 137 ASSERT(subject_ptr->IsExternalString() || subject_ptr->IsSeqString()); |
| 138 // String is now either Sequential or External | 138 // String is now either Sequential or External |
| 139 int char_size_shift = is_ascii ? 0 : 1; | 139 int char_size_shift = is_ascii ? 0 : 1; |
| 140 | 140 |
| 141 const byte* input_start = | 141 const byte* input_start = |
| 142 StringCharacterPosition(subject_ptr, start_offset + slice_offset); | 142 StringCharacterPosition(subject_ptr, start_offset + slice_offset); |
| 143 int byte_length = char_length << char_size_shift; | 143 int byte_length = char_length << char_size_shift; |
| 144 const byte* input_end = input_start + byte_length; | 144 const byte* input_end = input_start + byte_length; |
| 145 Result res = Execute(*regexp_code, | 145 Result res = Execute(*regexp_code, |
| 146 *subject, | 146 *subject, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 return NULL; | 263 return NULL; |
| 264 } | 264 } |
| 265 *stack_base = new_stack_base; | 265 *stack_base = new_stack_base; |
| 266 intptr_t stack_content_size = old_stack_base - stack_pointer; | 266 intptr_t stack_content_size = old_stack_base - stack_pointer; |
| 267 return new_stack_base - stack_content_size; | 267 return new_stack_base - stack_content_size; |
| 268 } | 268 } |
| 269 | 269 |
| 270 #endif // V8_INTERPRETED_REGEXP | 270 #endif // V8_INTERPRETED_REGEXP |
| 271 | 271 |
| 272 } } // namespace v8::internal | 272 } } // namespace v8::internal |
| OLD | NEW |