| Index: src/regexp/mips64/regexp-macro-assembler-mips64.cc
|
| diff --git a/src/regexp/mips64/regexp-macro-assembler-mips64.cc b/src/regexp/mips64/regexp-macro-assembler-mips64.cc
|
| index d774b14016b7fcf35eccfd1cb0864446235f982a..869cbc4f2e20398595bb421ad65d6e8c1517685b 100644
|
| --- a/src/regexp/mips64/regexp-macro-assembler-mips64.cc
|
| +++ b/src/regexp/mips64/regexp-macro-assembler-mips64.cc
|
| @@ -61,7 +61,7 @@
|
| * - fp[-16] void* input_string (location of a handle containing the string).
|
| * - fp[-20] success counter (only for global regexps to count matches).
|
| * - fp[-24] Offset of location before start of input (effectively character
|
| - * string start - 1). Used to initialize capture registers to a
|
| + * position -1). Used to initialize capture registers to a
|
| * non-position.
|
| * - fp[-28] At start (if 1, we are starting at the start of the
|
| * string, otherwise 0)
|
| @@ -91,7 +91,7 @@
|
| * - fp[-56] start index (character index of start). kStartIndex
|
| * - fp[-64] void* input_string (location of a handle containing the string). kInputString
|
| * - fp[-72] success counter (only for global regexps to count matches). kSuccessfulCaptures
|
| - * - fp[-80] Offset of location before start of input (effectively character kStringStartMinusOne
|
| + * - fp[-80] Offset of location before start of input (effectively character kInputStartMinusOne
|
| * position -1). Used to initialize capture registers to a
|
| * non-position.
|
| * --------- The following output registers are 32-bit values. ---------
|
| @@ -217,17 +217,26 @@
|
|
|
|
|
| void RegExpMacroAssemblerMIPS::CheckAtStart(Label* on_at_start) {
|
| - __ ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne));
|
| - __ Daddu(a0, current_input_offset(), Operand(-char_size()));
|
| + Label not_at_start;
|
| + // Did we start the match at the start of the string at all?
|
| + __ ld(a0, MemOperand(frame_pointer(), kStartIndex));
|
| + BranchOrBacktrack(¬_at_start, ne, a0, Operand(zero_reg));
|
| +
|
| + // If we did, are we still at the start of the input?
|
| + __ ld(a1, MemOperand(frame_pointer(), kInputStart));
|
| + __ Daddu(a0, end_of_input_address(), Operand(current_input_offset()));
|
| BranchOrBacktrack(on_at_start, eq, a0, Operand(a1));
|
| -}
|
| -
|
| -
|
| -void RegExpMacroAssemblerMIPS::CheckNotAtStart(int cp_offset,
|
| - Label* on_not_at_start) {
|
| - __ ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne));
|
| - __ Daddu(a0, current_input_offset(),
|
| - Operand(-char_size() + cp_offset * char_size()));
|
| + __ bind(¬_at_start);
|
| +}
|
| +
|
| +
|
| +void RegExpMacroAssemblerMIPS::CheckNotAtStart(Label* on_not_at_start) {
|
| + // Did we start the match at the start of the string at all?
|
| + __ ld(a0, MemOperand(frame_pointer(), kStartIndex));
|
| + BranchOrBacktrack(on_not_at_start, ne, a0, Operand(zero_reg));
|
| + // If we did, are we still at the start of the input?
|
| + __ ld(a1, MemOperand(frame_pointer(), kInputStart));
|
| + __ Daddu(a0, end_of_input_address(), Operand(current_input_offset()));
|
| BranchOrBacktrack(on_not_at_start, ne, a0, Operand(a1));
|
| }
|
|
|
| @@ -250,26 +259,20 @@
|
|
|
|
|
| void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase(
|
| - int start_reg, bool read_backward, Label* on_no_match) {
|
| + int start_reg,
|
| + Label* on_no_match) {
|
| Label fallthrough;
|
| __ ld(a0, register_location(start_reg)); // Index of start of capture.
|
| __ ld(a1, register_location(start_reg + 1)); // Index of end of capture.
|
| __ Dsubu(a1, a1, a0); // Length of capture.
|
|
|
| - // At this point, the capture registers are either both set or both cleared.
|
| - // If the capture length is zero, then the capture is either empty or cleared.
|
| - // Fall through in both cases.
|
| + // If length is zero, either the capture is empty or it is not participating.
|
| + // In either case succeed immediately.
|
| __ Branch(&fallthrough, eq, a1, Operand(zero_reg));
|
|
|
| - if (read_backward) {
|
| - __ ld(t1, MemOperand(frame_pointer(), kStringStartMinusOne));
|
| - __ Daddu(t1, t1, a1);
|
| - BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1));
|
| - } else {
|
| - __ Daddu(t1, a1, current_input_offset());
|
| - // Check that there are enough characters left in the input.
|
| - BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg));
|
| - }
|
| + __ Daddu(t1, a1, current_input_offset());
|
| + // Check that there are enough characters left in the input.
|
| + BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg));
|
|
|
| if (mode_ == LATIN1) {
|
| Label success;
|
| @@ -280,9 +283,6 @@
|
| // a1 - length of capture.
|
| __ Daddu(a0, a0, Operand(end_of_input_address()));
|
| __ Daddu(a2, end_of_input_address(), Operand(current_input_offset()));
|
| - if (read_backward) {
|
| - __ Dsubu(a2, a2, Operand(a1));
|
| - }
|
| __ Daddu(a1, a0, Operand(a1));
|
|
|
| // a0 - Address of start of capture.
|
| @@ -321,12 +321,6 @@
|
| __ bind(&success);
|
| // Compute new value of character position after the matched part.
|
| __ Dsubu(current_input_offset(), a2, end_of_input_address());
|
| - if (read_backward) {
|
| - __ ld(t1, register_location(start_reg)); // Index of start of capture.
|
| - __ ld(a2, register_location(start_reg + 1)); // Index of end of capture.
|
| - __ Daddu(current_input_offset(), current_input_offset(), Operand(t1));
|
| - __ Dsubu(current_input_offset(), current_input_offset(), Operand(a2));
|
| - }
|
| } else {
|
| DCHECK(mode_ == UC16);
|
| // Put regexp engine registers on stack.
|
| @@ -355,9 +349,6 @@
|
| __ mov(s3, a1);
|
| // Address of current input position.
|
| __ Daddu(a1, current_input_offset(), Operand(end_of_input_address()));
|
| - if (read_backward) {
|
| - __ Dsubu(a1, a1, Operand(s3));
|
| - }
|
| // Isolate.
|
| __ li(a3, Operand(ExternalReference::isolate_address(masm_->isolate())));
|
|
|
| @@ -376,20 +367,16 @@
|
| // Check if function returned non-zero for success or zero for failure.
|
| BranchOrBacktrack(on_no_match, eq, v0, Operand(zero_reg));
|
| // On success, increment position by length of capture.
|
| - if (read_backward) {
|
| - __ Dsubu(current_input_offset(), current_input_offset(), Operand(s3));
|
| - } else {
|
| - __ Daddu(current_input_offset(), current_input_offset(), Operand(s3));
|
| - }
|
| + __ Daddu(current_input_offset(), current_input_offset(), Operand(s3));
|
| }
|
|
|
| __ bind(&fallthrough);
|
| }
|
|
|
|
|
| -void RegExpMacroAssemblerMIPS::CheckNotBackReference(int start_reg,
|
| - bool read_backward,
|
| - Label* on_no_match) {
|
| +void RegExpMacroAssemblerMIPS::CheckNotBackReference(
|
| + int start_reg,
|
| + Label* on_no_match) {
|
| Label fallthrough;
|
| Label success;
|
|
|
| @@ -397,28 +384,16 @@
|
| __ ld(a0, register_location(start_reg));
|
| __ ld(a1, register_location(start_reg + 1));
|
| __ Dsubu(a1, a1, a0); // Length to check.
|
| -
|
| - // At this point, the capture registers are either both set or both cleared.
|
| - // If the capture length is zero, then the capture is either empty or cleared.
|
| - // Fall through in both cases.
|
| + // Succeed on empty capture (including no capture).
|
| __ Branch(&fallthrough, eq, a1, Operand(zero_reg));
|
|
|
| - if (read_backward) {
|
| - __ ld(t1, MemOperand(frame_pointer(), kStringStartMinusOne));
|
| - __ Daddu(t1, t1, a1);
|
| - BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1));
|
| - } else {
|
| - __ Daddu(t1, a1, current_input_offset());
|
| - // Check that there are enough characters left in the input.
|
| - BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg));
|
| - }
|
| + __ Daddu(t1, a1, current_input_offset());
|
| + // Check that there are enough characters left in the input.
|
| + BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg));
|
|
|
| // Compute pointers to match string and capture string.
|
| __ Daddu(a0, a0, Operand(end_of_input_address()));
|
| __ Daddu(a2, end_of_input_address(), Operand(current_input_offset()));
|
| - if (read_backward) {
|
| - __ Dsubu(a2, a2, Operand(a1));
|
| - }
|
| __ Daddu(a1, a1, Operand(a0));
|
|
|
| Label loop;
|
| @@ -440,12 +415,6 @@
|
|
|
| // Move current character position to position after match.
|
| __ Dsubu(current_input_offset(), a2, end_of_input_address());
|
| - if (read_backward) {
|
| - __ ld(t1, register_location(start_reg)); // Index of start of capture.
|
| - __ ld(a2, register_location(start_reg + 1)); // Index of end of capture.
|
| - __ Daddu(current_input_offset(), current_input_offset(), Operand(t1));
|
| - __ Dsubu(current_input_offset(), current_input_offset(), Operand(a2));
|
| - }
|
| __ bind(&fallthrough);
|
| }
|
|
|
| @@ -675,7 +644,7 @@
|
| __ Daddu(frame_pointer(), sp, Operand(8 * kPointerSize));
|
| __ mov(a0, zero_reg);
|
| __ push(a0); // Make room for success counter and initialize it to 0.
|
| - __ push(a0); // Make room for "string start - 1" constant.
|
| + __ push(a0); // Make room for "position - 1" constant (value irrelevant).
|
|
|
| // Check if we have space on the stack for registers.
|
| Label stack_limit_hit;
|
| @@ -718,7 +687,7 @@
|
| __ Dsubu(a0, a0, t1);
|
| // Store this value in a local variable, for use when clearing
|
| // position registers.
|
| - __ sd(a0, MemOperand(frame_pointer(), kStringStartMinusOne));
|
| + __ sd(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
|
|
|
| // Initialize code pointer register
|
| __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE);
|
| @@ -828,7 +797,7 @@
|
| __ sd(a2, MemOperand(frame_pointer(), kRegisterOutput));
|
|
|
| // Prepare a0 to initialize registers with its value in the next run.
|
| - __ ld(a0, MemOperand(frame_pointer(), kStringStartMinusOne));
|
| + __ ld(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
|
|
|
| if (global_with_zero_length_check()) {
|
| // Special case for zero-length matches.
|
| @@ -982,13 +951,10 @@
|
| Label* on_end_of_input,
|
| bool check_bounds,
|
| int characters) {
|
| + DCHECK(cp_offset >= -1); // ^ and \b can look behind one character.
|
| DCHECK(cp_offset < (1<<30)); // Be sane! (And ensure negation works).
|
| if (check_bounds) {
|
| - if (cp_offset >= 0) {
|
| - CheckPosition(cp_offset + characters - 1, on_end_of_input);
|
| - } else {
|
| - CheckPosition(cp_offset, on_end_of_input);
|
| - }
|
| + CheckPosition(cp_offset + characters - 1, on_end_of_input);
|
| }
|
| LoadCurrentCharacterUnchecked(cp_offset, characters);
|
| }
|
| @@ -1096,7 +1062,7 @@
|
|
|
| void RegExpMacroAssemblerMIPS::ClearRegisters(int reg_from, int reg_to) {
|
| DCHECK(reg_from <= reg_to);
|
| - __ ld(a0, MemOperand(frame_pointer(), kStringStartMinusOne));
|
| + __ ld(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
|
| for (int reg = reg_from; reg <= reg_to; reg++) {
|
| __ sd(a0, register_location(reg));
|
| }
|
| @@ -1209,14 +1175,10 @@
|
|
|
| void RegExpMacroAssemblerMIPS::CheckPosition(int cp_offset,
|
| Label* on_outside_input) {
|
| - if (cp_offset >= 0) {
|
| - BranchOrBacktrack(on_outside_input, ge, current_input_offset(),
|
| - Operand(-cp_offset * char_size()));
|
| - } else {
|
| - __ ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne));
|
| - __ Daddu(a0, current_input_offset(), Operand(cp_offset * char_size()));
|
| - BranchOrBacktrack(on_outside_input, le, a0, Operand(a1));
|
| - }
|
| + BranchOrBacktrack(on_outside_input,
|
| + ge,
|
| + current_input_offset(),
|
| + Operand(-cp_offset * char_size()));
|
| }
|
|
|
|
|
|
|