OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #ifdef V8_TARGET_CAN_READ_UNALIGNED | 67 #ifdef V8_TARGET_CAN_READ_UNALIGNED |
68 return !slow_safe(); | 68 return !slow_safe(); |
69 #else | 69 #else |
70 return false; | 70 return false; |
71 #endif | 71 #endif |
72 } | 72 } |
73 | 73 |
74 const byte* NativeRegExpMacroAssembler::StringCharacterPosition( | 74 const byte* NativeRegExpMacroAssembler::StringCharacterPosition( |
75 String* subject, | 75 String* subject, |
76 int start_index) { | 76 int start_index) { |
| 77 // Unpack sliced string. |
| 78 if (subject->IsSlicedString()) { |
| 79 SlicedString* slice = SlicedString::cast(subject); |
| 80 subject = slice->parent(); |
| 81 start_index += slice->offset(); |
| 82 } |
77 // Not just flat, but ultra flat. | 83 // Not just flat, but ultra flat. |
78 ASSERT(subject->IsExternalString() || subject->IsSeqString()); | 84 ASSERT(subject->IsExternalString() || subject->IsSeqString()); |
79 ASSERT(start_index >= 0); | 85 ASSERT(start_index >= 0); |
80 ASSERT(start_index <= subject->length()); | 86 ASSERT(start_index <= subject->length()); |
81 if (subject->IsAsciiRepresentation()) { | 87 if (subject->IsAsciiRepresentation()) { |
82 const byte* address; | 88 const byte* address; |
83 if (StringShape(subject).IsExternal()) { | 89 if (StringShape(subject).IsExternal()) { |
84 const char* data = ExternalAsciiString::cast(subject)->resource()->data(); | 90 const char* data = ExternalAsciiString::cast(subject)->resource()->data(); |
85 address = reinterpret_cast<const byte*>(data); | 91 address = reinterpret_cast<const byte*>(data); |
86 } else { | 92 } else { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 int end_offset = subject_ptr->length(); | 129 int end_offset = subject_ptr->length(); |
124 | 130 |
125 // The string has been flattened, so it it is a cons string it contains the | 131 // The string has been flattened, so it it is a cons string it contains the |
126 // full string in the first part. | 132 // full string in the first part. |
127 if (StringShape(subject_ptr).IsCons()) { | 133 if (StringShape(subject_ptr).IsCons()) { |
128 ASSERT_EQ(0, ConsString::cast(subject_ptr)->second()->length()); | 134 ASSERT_EQ(0, ConsString::cast(subject_ptr)->second()->length()); |
129 subject_ptr = ConsString::cast(subject_ptr)->first(); | 135 subject_ptr = ConsString::cast(subject_ptr)->first(); |
130 } | 136 } |
131 // Ensure that an underlying string has the same ascii-ness. | 137 // Ensure that an underlying string has the same ascii-ness. |
132 bool is_ascii = subject_ptr->IsAsciiRepresentation(); | 138 bool is_ascii = subject_ptr->IsAsciiRepresentation(); |
133 ASSERT(subject_ptr->IsExternalString() || subject_ptr->IsSeqString()); | 139 ASSERT(subject_ptr->IsExternalString() || |
| 140 subject_ptr->IsSeqString() || |
| 141 subject_ptr->IsSlicedString()); |
134 // String is now either Sequential or External | 142 // String is now either Sequential or External |
135 int char_size_shift = is_ascii ? 0 : 1; | 143 int char_size_shift = is_ascii ? 0 : 1; |
136 int char_length = end_offset - start_offset; | 144 int char_length = end_offset - start_offset; |
137 | 145 |
138 const byte* input_start = | 146 const byte* input_start = |
139 StringCharacterPosition(subject_ptr, start_offset); | 147 StringCharacterPosition(subject_ptr, start_offset); |
140 int byte_length = char_length << char_size_shift; | 148 int byte_length = char_length << char_size_shift; |
141 const byte* input_end = input_start + byte_length; | 149 const byte* input_end = input_start + byte_length; |
142 Result res = Execute(*regexp_code, | 150 Result res = Execute(*regexp_code, |
143 subject_ptr, | 151 subject_ptr, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return NULL; | 266 return NULL; |
259 } | 267 } |
260 *stack_base = new_stack_base; | 268 *stack_base = new_stack_base; |
261 intptr_t stack_content_size = old_stack_base - stack_pointer; | 269 intptr_t stack_content_size = old_stack_base - stack_pointer; |
262 return new_stack_base - stack_content_size; | 270 return new_stack_base - stack_content_size; |
263 } | 271 } |
264 | 272 |
265 #endif // V8_INTERPRETED_REGEXP | 273 #endif // V8_INTERPRETED_REGEXP |
266 | 274 |
267 } } // namespace v8::internal | 275 } } // namespace v8::internal |
OLD | NEW |