diff --git a/src/regexp/jsregexp.cc b/src/regexp/jsregexp.cc index 6ecc611814..1b02b23d59 100644 --- a/src/regexp/jsregexp.cc +++ b/src/regexp/jsregexp.cc @@ -444,9 +444,8 @@ int RegExpImpl::IrregexpExecRaw(Isolate* isolate, Handle regexp, // This means that in case of failure, the output registers array is left // untouched and contains the capture results from the previous successful // match. We can use that to set the last match info lazily. - NativeRegExpMacroAssembler::Result res = - NativeRegExpMacroAssembler::Match(code, subject, output, output_size, - index, isolate); + int res = NativeRegExpMacroAssembler::Match(code, subject, output, + output_size, index, isolate); if (res != NativeRegExpMacroAssembler::RETRY) { DCHECK(res != NativeRegExpMacroAssembler::EXCEPTION || isolate->has_pending_exception()); @@ -456,7 +455,7 @@ int RegExpImpl::IrregexpExecRaw(Isolate* isolate, Handle regexp, RE_FAILURE); STATIC_ASSERT(static_cast(NativeRegExpMacroAssembler::EXCEPTION) == RE_EXCEPTION); - return static_cast(res); + return res; } // If result is RETRY, the string has changed representation, and we // must restart from scratch. diff --git a/src/regexp/regexp-macro-assembler.cc b/src/regexp/regexp-macro-assembler.cc index 25c0ae3636..fa56dd13c2 100644 --- a/src/regexp/regexp-macro-assembler.cc +++ b/src/regexp/regexp-macro-assembler.cc @@ -207,14 +207,12 @@ int NativeRegExpMacroAssembler::CheckStackGuardState( return return_value; } -NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Match( - Handle regexp_code, - Handle subject, - int* offsets_vector, - int offsets_vector_length, - int previous_index, - Isolate* isolate) { - +// Returns a {Result} sentinel, or the number of successful matches. +int NativeRegExpMacroAssembler::Match(Handle regexp_code, + Handle subject, + int* offsets_vector, + int offsets_vector_length, + int previous_index, Isolate* isolate) { DCHECK(subject->IsFlat()); DCHECK_LE(0, previous_index); DCHECK_LE(previous_index, subject->length()); @@ -253,18 +251,12 @@ NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Match( StringCharacterPosition(subject_ptr, start_offset + slice_offset, no_gc); int byte_length = char_length << char_size_shift; const byte* input_end = input_start + byte_length; - Result res = Execute(*regexp_code, - *subject, - start_offset, - input_start, - input_end, - offsets_vector, - offsets_vector_length, - isolate); - return res; + return Execute(*regexp_code, *subject, start_offset, input_start, input_end, + offsets_vector, offsets_vector_length, isolate); } -NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute( +// Returns a {Result} sentinel, or the number of successful matches. +int NativeRegExpMacroAssembler::Execute( Code code, String input, // This needs to be the unpacked (sliced, cons) string. int start_offset, const byte* input_start, const byte* input_end, @@ -293,7 +285,7 @@ NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute( AllowHeapAllocation allow_allocation; isolate->StackOverflow(); } - return static_cast(result); + return result; } // clang-format off diff --git a/src/regexp/regexp-macro-assembler.h b/src/regexp/regexp-macro-assembler.h index 5124908537..228f4a701b 100644 --- a/src/regexp/regexp-macro-assembler.h +++ b/src/regexp/regexp-macro-assembler.h @@ -212,12 +212,10 @@ class NativeRegExpMacroAssembler: public RegExpMacroAssembler { ~NativeRegExpMacroAssembler() override; bool CanReadUnaligned() override; - static Result Match(Handle regexp, - Handle subject, - int* offsets_vector, - int offsets_vector_length, - int previous_index, - Isolate* isolate); + // Returns a {Result} sentinel, or the number of successful matches. + static int Match(Handle regexp, Handle subject, + int* offsets_vector, int offsets_vector_length, + int previous_index, Isolate* isolate); // Called from RegExp if the backtrack stack limit is hit. // Tries to expand the stack. Returns the new stack-pointer if @@ -245,9 +243,10 @@ class NativeRegExpMacroAssembler: public RegExpMacroAssembler { return reinterpret_cast
(&word_character_map[0]); } - static Result Execute(Code code, String input, int start_offset, - const byte* input_start, const byte* input_end, - int* output, int output_size, Isolate* isolate); + // Returns a {Result} sentinel, or the number of successful matches. + static int Execute(Code code, String input, int start_offset, + const byte* input_start, const byte* input_end, + int* output, int output_size, Isolate* isolate); }; } // namespace internal diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc index c9bb85b598..fd06f08477 100644 --- a/test/cctest/test-regexp.cc +++ b/test/cctest/test-regexp.cc @@ -771,9 +771,11 @@ static ArchRegExpMacroAssembler::Result Execute(Code code, String input, Address input_start, Address input_end, int* captures) { - return NativeRegExpMacroAssembler::Execute( - code, input, start_offset, reinterpret_cast(input_start), - reinterpret_cast(input_end), captures, 0, CcTest::i_isolate()); + return static_cast( + NativeRegExpMacroAssembler::Execute(code, input, start_offset, + reinterpret_cast(input_start), + reinterpret_cast(input_end), + captures, 0, CcTest::i_isolate())); } TEST(MacroAssemblerNativeSuccess) {