[mips][regexp] Apply the backtrack limit in jitted code
Port 0089006fc5
Original Commit Message:
.. similar to how it is applied in the interpreter. We reserve a stack
slot for the backtrack count, increment it on each backtrack, and fail
if the limit is hit.
Change-Id: I51879e6cafb3c77d635fc6e84e7e2c5ce3a088e6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873445
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Mu Tao <pamilty@gmail.com>
Cr-Commit-Position: refs/heads/master@{#64490}
This commit is contained in:
parent
59c50264f1
commit
da0ef75fde
@ -156,6 +156,18 @@ void RegExpMacroAssemblerMIPS::AdvanceRegister(int reg, int by) {
|
||||
|
||||
void RegExpMacroAssemblerMIPS::Backtrack() {
|
||||
CheckPreemption();
|
||||
if (has_backtrack_limit()) {
|
||||
Label next;
|
||||
__ Lw(a0, MemOperand(frame_pointer(), kBacktrackCount));
|
||||
__ Addu(a0, a0, Operand(1));
|
||||
__ Sw(a0, MemOperand(frame_pointer(), kBacktrackCount));
|
||||
__ Branch(&next, ne, a0, Operand(backtrack_limit()));
|
||||
|
||||
// Exceeded limits are treated as a failed match.
|
||||
Fail();
|
||||
|
||||
__ bind(&next);
|
||||
}
|
||||
// Pop Code offset from backtrack stack, add Code and jump to location.
|
||||
Pop(a0);
|
||||
__ Addu(a0, a0, code_pointer());
|
||||
|
@ -121,8 +121,9 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerMIPS
|
||||
// the frame in GetCode.
|
||||
static const int kSuccessfulCaptures = kInputString - kPointerSize;
|
||||
static const int kStringStartMinusOne = kSuccessfulCaptures - kPointerSize;
|
||||
static const int kBacktrackCount = kStringStartMinusOne - kSystemPointerSize;
|
||||
// First register address. Following registers are below it on the stack.
|
||||
static const int kRegisterZero = kStringStartMinusOne - kPointerSize;
|
||||
static const int kRegisterZero = kBacktrackCount - kSystemPointerSize;
|
||||
|
||||
// Initial size of code buffer.
|
||||
static const int kRegExpCodeSize = 1024;
|
||||
|
@ -192,6 +192,18 @@ void RegExpMacroAssemblerMIPS::AdvanceRegister(int reg, int by) {
|
||||
|
||||
void RegExpMacroAssemblerMIPS::Backtrack() {
|
||||
CheckPreemption();
|
||||
if (has_backtrack_limit()) {
|
||||
Label next;
|
||||
__ Ld(a0, MemOperand(frame_pointer(), kBacktrackCount));
|
||||
__ Daddu(a0, a0, Operand(1));
|
||||
__ Sd(a0, MemOperand(frame_pointer(), kBacktrackCount));
|
||||
__ Branch(&next, ne, a0, Operand(backtrack_limit()));
|
||||
|
||||
// Exceeded limits are treated as a failed match.
|
||||
Fail();
|
||||
|
||||
__ bind(&next);
|
||||
}
|
||||
// Pop Code offset from backtrack stack, add Code and jump to location.
|
||||
Pop(a0);
|
||||
__ Daddu(a0, a0, code_pointer());
|
||||
|
@ -126,8 +126,9 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerMIPS
|
||||
// the frame in GetCode.
|
||||
static const int kSuccessfulCaptures = kInputString - kPointerSize;
|
||||
static const int kStringStartMinusOne = kSuccessfulCaptures - kPointerSize;
|
||||
static const int kBacktrackCount = kStringStartMinusOne - kSystemPointerSize;
|
||||
// First register address. Following registers are below it on the stack.
|
||||
static const int kRegisterZero = kStringStartMinusOne - kPointerSize;
|
||||
static const int kRegisterZero = kBacktrackCount - kSystemPointerSize;
|
||||
|
||||
// Initial size of code buffer.
|
||||
static const int kRegExpCodeSize = 1024;
|
||||
|
Loading…
Reference in New Issue
Block a user