Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: src/regexp/regexp-macro-assembler.cc

Issue 2654433003: [regexp] Fix StringCharacterPosition for ThinStrings (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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()) { 136 }
137 if (subject->IsThinString()) {
137 subject = ThinString::cast(subject)->actual(); 138 subject = ThinString::cast(subject)->actual();
138 } 139 }
139 DCHECK(start_index >= 0); 140 DCHECK(start_index >= 0);
140 DCHECK(start_index <= subject->length()); 141 DCHECK(start_index <= subject->length());
141 if (subject->IsSeqOneByteString()) { 142 if (subject->IsSeqOneByteString()) {
142 return reinterpret_cast<const byte*>( 143 return reinterpret_cast<const byte*>(
143 SeqOneByteString::cast(subject)->GetChars() + start_index); 144 SeqOneByteString::cast(subject)->GetChars() + start_index);
144 } else if (subject->IsSeqTwoByteString()) { 145 } else if (subject->IsSeqTwoByteString()) {
145 return reinterpret_cast<const byte*>( 146 return reinterpret_cast<const byte*>(
146 SeqTwoByteString::cast(subject)->GetChars() + start_index); 147 SeqTwoByteString::cast(subject)->GetChars() + start_index);
147 } else if (subject->IsExternalOneByteString()) { 148 } else if (subject->IsExternalOneByteString()) {
148 return reinterpret_cast<const byte*>( 149 return reinterpret_cast<const byte*>(
149 ExternalOneByteString::cast(subject)->GetChars() + start_index); 150 ExternalOneByteString::cast(subject)->GetChars() + start_index);
150 } else { 151 } else {
152 DCHECK(subject->IsExternalTwoByteString());
151 return reinterpret_cast<const byte*>( 153 return reinterpret_cast<const byte*>(
152 ExternalTwoByteString::cast(subject)->GetChars() + start_index); 154 ExternalTwoByteString::cast(subject)->GetChars() + start_index);
153 } 155 }
154 } 156 }
155 157
156 158
157 int NativeRegExpMacroAssembler::CheckStackGuardState( 159 int NativeRegExpMacroAssembler::CheckStackGuardState(
158 Isolate* isolate, int start_index, bool is_direct_call, 160 Isolate* isolate, int start_index, bool is_direct_call,
159 Address* return_address, Code* re_code, String** subject, 161 Address* return_address, Code* re_code, String** subject,
160 const byte** input_start, const byte** input_end) { 162 const byte** input_start, const byte** input_end) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 354 }
353 *stack_base = new_stack_base; 355 *stack_base = new_stack_base;
354 intptr_t stack_content_size = old_stack_base - stack_pointer; 356 intptr_t stack_content_size = old_stack_base - stack_pointer;
355 return new_stack_base - stack_content_size; 357 return new_stack_base - stack_content_size;
356 } 358 }
357 359
358 #endif // V8_INTERPRETED_REGEXP 360 #endif // V8_INTERPRETED_REGEXP
359 361
360 } // namespace internal 362 } // namespace internal
361 } // namespace v8 363 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698