Commit 0f82719b authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[regexp] Throw exceptions from within the interpreter

It will soon be possible to throw arbitrary exceptions from within
interpreter execution (namely, in interrupts). We can thus no longer
assume that an EXCEPTION return code means we need to throw a stack
overflow exception.

Bug: v8:8724
Change-Id: I10e24aba4305dc7b39248ced9a52735c59ab662c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511474
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60161}
parent 1d327898
......@@ -173,6 +173,7 @@ static IrregexpInterpreter::Result RawMatch(Isolate* isolate,
UNREACHABLE();
BYTECODE(PUSH_CP)
if (--backtrack_stack_space < 0) {
isolate->StackOverflow();
return IrregexpInterpreter::EXCEPTION;
}
*backtrack_sp++ = current;
......@@ -180,6 +181,7 @@ static IrregexpInterpreter::Result RawMatch(Isolate* isolate,
break;
BYTECODE(PUSH_BT)
if (--backtrack_stack_space < 0) {
isolate->StackOverflow();
return IrregexpInterpreter::EXCEPTION;
}
*backtrack_sp++ = Load32Aligned(pc + 4);
......@@ -187,6 +189,7 @@ static IrregexpInterpreter::Result RawMatch(Isolate* isolate,
break;
BYTECODE(PUSH_REGISTER)
if (--backtrack_stack_space < 0) {
isolate->StackOverflow();
return IrregexpInterpreter::EXCEPTION;
}
*backtrack_sp++ = registers[insn >> BYTECODE_SHIFT];
......
......@@ -488,15 +488,14 @@ int RegExpImpl::IrregexpExecRaw(Isolate* isolate, Handle<JSRegExp> regexp,
IrregexpInterpreter::Result result = IrregexpInterpreter::Match(
isolate, byte_codes, subject, raw_output, index);
DCHECK_IMPLIES(result == IrregexpInterpreter::EXCEPTION,
isolate->has_pending_exception());
if (result == IrregexpInterpreter::SUCCESS) {
// Copy capture results to the start of the registers array.
MemCopy(output, raw_output,
number_of_capture_registers * sizeof(int32_t));
}
if (result == IrregexpInterpreter::EXCEPTION) {
DCHECK(!isolate->has_pending_exception());
isolate->StackOverflow();
}
return result;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment