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

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

Issue 1640823003: X87: [regexp] correctly advance zero length matches for global/unicode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/regexp/x87/regexp-macro-assembler-x87.h" 7 #include "src/regexp/x87/regexp-macro-assembler-x87.h"
8 8
9 #include "src/log.h" 9 #include "src/log.h"
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 void RegExpMacroAssemblerX87::CheckGreedyLoop(Label* on_equal) { 181 void RegExpMacroAssemblerX87::CheckGreedyLoop(Label* on_equal) {
182 Label fallthrough; 182 Label fallthrough;
183 __ cmp(edi, Operand(backtrack_stackpointer(), 0)); 183 __ cmp(edi, Operand(backtrack_stackpointer(), 0));
184 __ j(not_equal, &fallthrough); 184 __ j(not_equal, &fallthrough);
185 __ add(backtrack_stackpointer(), Immediate(kPointerSize)); // Pop. 185 __ add(backtrack_stackpointer(), Immediate(kPointerSize)); // Pop.
186 BranchOrBacktrack(no_condition, on_equal); 186 BranchOrBacktrack(no_condition, on_equal);
187 __ bind(&fallthrough); 187 __ bind(&fallthrough);
188 } 188 }
189 189
190
191 void RegExpMacroAssemblerX87::CheckNotBackReferenceIgnoreCase( 190 void RegExpMacroAssemblerX87::CheckNotBackReferenceIgnoreCase(
192 int start_reg, bool read_backward, Label* on_no_match) { 191 int start_reg, bool read_backward, Label* on_no_match) {
193 Label fallthrough; 192 Label fallthrough;
194 __ mov(edx, register_location(start_reg)); // Index of start of capture 193 __ mov(edx, register_location(start_reg)); // Index of start of capture
195 __ mov(ebx, register_location(start_reg + 1)); // Index of end of capture 194 __ mov(ebx, register_location(start_reg + 1)); // Index of end of capture
196 __ sub(ebx, edx); // Length of capture. 195 __ sub(ebx, edx); // Length of capture.
197 196
198 // At this point, the capture registers are either both set or both cleared. 197 // At this point, the capture registers are either both set or both cleared.
199 // If the capture length is zero, then the capture is either empty or cleared. 198 // If the capture length is zero, then the capture is either empty or cleared.
200 // Fall through in both cases. 199 // Fall through in both cases.
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 if (global_with_zero_length_check()) { 814 if (global_with_zero_length_check()) {
816 // Special case for zero-length matches. 815 // Special case for zero-length matches.
817 // edx: capture start index 816 // edx: capture start index
818 __ cmp(edi, edx); 817 __ cmp(edi, edx);
819 // Not a zero-length match, restart. 818 // Not a zero-length match, restart.
820 __ j(not_equal, &load_char_start_regexp); 819 __ j(not_equal, &load_char_start_regexp);
821 // edi (offset from the end) is zero if we already reached the end. 820 // edi (offset from the end) is zero if we already reached the end.
822 __ test(edi, edi); 821 __ test(edi, edi);
823 __ j(zero, &exit_label_, Label::kNear); 822 __ j(zero, &exit_label_, Label::kNear);
824 // Advance current position after a zero-length match. 823 // Advance current position after a zero-length match.
824 Label advance;
825 __ bind(&advance);
825 if (mode_ == UC16) { 826 if (mode_ == UC16) {
826 __ add(edi, Immediate(2)); 827 __ add(edi, Immediate(2));
827 } else { 828 } else {
828 __ inc(edi); 829 __ inc(edi);
829 } 830 }
831 if (global_unicode()) CheckNotInSurrogatePair(0, &advance);
830 } 832 }
831
832 __ jmp(&load_char_start_regexp); 833 __ jmp(&load_char_start_regexp);
833 } else { 834 } else {
834 __ mov(eax, Immediate(SUCCESS)); 835 __ mov(eax, Immediate(SUCCESS));
835 } 836 }
836 } 837 }
837 838
838 __ bind(&exit_label_); 839 __ bind(&exit_label_);
839 if (global()) { 840 if (global()) {
840 // Return the number of successful captures. 841 // Return the number of successful captures.
841 __ mov(eax, Operand(ebp, kSuccessfulCaptures)); 842 __ mov(eax, Operand(ebp, kSuccessfulCaptures));
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 1255
1255 1256
1256 #undef __ 1257 #undef __
1257 1258
1258 #endif // V8_INTERPRETED_REGEXP 1259 #endif // V8_INTERPRETED_REGEXP
1259 1260
1260 } // namespace internal 1261 } // namespace internal
1261 } // namespace v8 1262 } // namespace v8
1262 1263
1263 #endif // V8_TARGET_ARCH_X87 1264 #endif // V8_TARGET_ARCH_X87
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