mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[vm] Fix handling regex compilation errors with non-intrinsified invocation.
RISC-V: Implement regex invocation intrinsic. TEST=regress_big_regexp_test Bug: https://github.com/dart-lang/sdk/issues/48333 Change-Id: Id3a30a692293a428c8310861eae6b9144bd169e6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233447 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
7822eb9107
commit
6cc25b013a
|
@ -2,6 +2,9 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// VMOptions=--intrinsify
|
||||
// VMOptions=--no_intrinsify
|
||||
|
||||
// Verifies that RegExp compilation doesn't crash on a huge source string.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// VMOptions=--intrinsify
|
||||
// VMOptions=--no_intrinsify
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Verifies that RegExp compilation doesn't crash on a huge source string.
|
||||
|
|
|
@ -670,8 +670,34 @@ void AsmIntrinsifier::IntrinsifyRegExpExecuteMatch(Assembler* assembler,
|
|||
bool sticky) {
|
||||
if (FLAG_interpret_irregexp) return;
|
||||
|
||||
// TODO(riscv)
|
||||
__ Bind(normal_ir_body);
|
||||
static const intptr_t kRegExpParamOffset = 2 * target::kWordSize;
|
||||
static const intptr_t kStringParamOffset = 1 * target::kWordSize;
|
||||
// start_index smi is located at offset 0.
|
||||
|
||||
// Incoming registers:
|
||||
// T0: Function. (Will be reloaded with the specialized matcher function.)
|
||||
// S4: Arguments descriptor. (Will be preserved.)
|
||||
// S5: Unknown. (Must be GC safe on tail call.)
|
||||
|
||||
// Load the specialized function pointer into R0. Leverage the fact the
|
||||
// string CIDs as well as stored function pointers are in sequence.
|
||||
__ lx(T2, Address(SP, kRegExpParamOffset));
|
||||
__ lx(T1, Address(SP, kStringParamOffset));
|
||||
__ LoadClassId(T1, T1);
|
||||
__ AddImmediate(T1, -kOneByteStringCid);
|
||||
__ slli(T1, T1, target::kWordSizeLog2);
|
||||
__ add(T1, T1, T2);
|
||||
__ lx(T0, FieldAddress(T1, target::RegExp::function_offset(kOneByteStringCid,
|
||||
sticky)));
|
||||
|
||||
// Registers are now set up for the lazy compile stub. It expects the function
|
||||
// in R0, the argument descriptor in R4, and IC-Data in R5.
|
||||
__ li(S5, 0);
|
||||
|
||||
// Tail-call the function.
|
||||
__ lx(CODE_REG, FieldAddress(T0, target::Function::code_offset()));
|
||||
__ lx(T1, FieldAddress(T0, target::Function::entry_point_offset()));
|
||||
__ jr(T1);
|
||||
}
|
||||
|
||||
void AsmIntrinsifier::UserTag_defaultTag(Assembler* assembler,
|
||||
|
|
|
@ -299,14 +299,12 @@ ArrayPtr IRRegExpMacroAssembler::Execute(const RegExp& regexp,
|
|||
|
||||
const Object& retval =
|
||||
Object::Handle(zone, DartEntry::InvokeFunction(fun, args));
|
||||
if (retval.IsUnwindError()) {
|
||||
Exceptions::PropagateError(Error::Cast(retval));
|
||||
if (retval.IsLanguageError()) {
|
||||
Exceptions::ThrowCompileTimeError(LanguageError::Cast(retval));
|
||||
UNREACHABLE();
|
||||
}
|
||||
if (retval.IsError()) {
|
||||
const Error& error = Error::Cast(retval);
|
||||
OS::PrintErr("%s\n", error.ToErrorCString());
|
||||
// Should never happen.
|
||||
UNREACHABLE();
|
||||
Exceptions::PropagateError(Error::Cast(retval));
|
||||
}
|
||||
|
||||
if (retval.IsNull()) {
|
||||
|
|
Loading…
Reference in a new issue