| Index: src/x64/regexp-macro-assembler-x64.cc
|
| diff --git a/src/x64/regexp-macro-assembler-x64.cc b/src/x64/regexp-macro-assembler-x64.cc
|
| index 13a4caa3fbca8862aa3efc18fca1fde18d1727a6..2db5e7ac45ad2d81b553bc93ae13942acc59e578 100644
|
| --- a/src/x64/regexp-macro-assembler-x64.cc
|
| +++ b/src/x64/regexp-macro-assembler-x64.cc
|
| @@ -926,7 +926,7 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
|
| }
|
| for (int i = 0; i < num_saved_registers_; i++) {
|
| __ movq(rax, register_location(i));
|
| - if (i == 0 && global()) {
|
| + if (i == 0 && global_with_zero_length_match()) {
|
| // Keep capture start in rdx for the zero-length check later.
|
| __ movq(rdx, rax);
|
| }
|
| @@ -958,20 +958,23 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
|
| // Prepare rax to initialize registers with its value in the next run.
|
| __ movq(rax, Operand(rbp, kInputStartMinusOne));
|
|
|
| - // Special case for zero-length matches.
|
| - // rdx: capture start index
|
| - __ cmpq(rdi, rdx);
|
| - // Not a zero-length match, restart.
|
| - __ j(not_equal, &load_char_start_regexp);
|
| - // rdi (offset from the end) is zero if we already reached the end.
|
| - __ testq(rdi, rdi);
|
| - __ j(zero, &exit_label_, Label::kNear);
|
| - // Advance current position after a zero-length match.
|
| - if (mode_ == UC16) {
|
| - __ addq(rdi, Immediate(2));
|
| - } else {
|
| - __ incq(rdi);
|
| + if (global_with_zero_length_match()) {
|
| + // Special case for zero-length matches.
|
| + // rdx: capture start index
|
| + __ cmpq(rdi, rdx);
|
| + // Not a zero-length match, restart.
|
| + __ j(not_equal, &load_char_start_regexp);
|
| + // rdi (offset from the end) is zero if we already reached the end.
|
| + __ testq(rdi, rdi);
|
| + __ j(zero, &exit_label_, Label::kNear);
|
| + // Advance current position after a zero-length match.
|
| + if (mode_ == UC16) {
|
| + __ addq(rdi, Immediate(2));
|
| + } else {
|
| + __ incq(rdi);
|
| + }
|
| }
|
| +
|
| __ jmp(&load_char_start_regexp);
|
| } else {
|
| __ movq(rax, Immediate(SUCCESS));
|
|
|