#include "src/regexp/regexp-interpreter.h"
#include "src/base/small-vector.h"
#include "src/base/strings.h"
#include "src/execution/isolate.h"
#include "src/logging/counters.h"
#include "src/objects/js-regexp-inl.h"
#include "src/objects/string-inl.h"
#include "src/regexp/regexp-bytecodes.h"
#include "src/regexp/regexp-macro-assembler.h"
#include "src/regexp/regexp-stack.h"
#include "src/regexp/regexp.h"
#include "src/strings/unicode.h"
#include "src/utils/memcopy.h"
#include "src/utils/utils.h"
#ifdef V8_INTL_SUPPORT
#include "unicode/uchar.h"
#endif
#if V8_HAS_COMPUTED_GOTO && \
defined(V8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH)
#define V8_USE_COMPUTED_GOTO …
#endif
namespace v8 {
namespace internal {
namespace {
bool BackRefMatchesNoCase(Isolate* isolate, int from, int current, int len,
base::Vector<const base::uc16> subject,
bool unicode) { … }
bool BackRefMatchesNoCase(Isolate* isolate, int from, int current, int len,
base::Vector<const uint8_t> subject, bool unicode) { … }
#ifdef DEBUG
void MaybeTraceInterpreter(const uint8_t* code_base, const uint8_t* pc,
int stack_depth, int current_position,
uint32_t current_char, int bytecode_length,
const char* bytecode_name) { … }
#endif
int32_t Load32Aligned(const uint8_t* pc) { … }
uint32_t Load16AlignedUnsigned(const uint8_t* pc) { … }
int32_t Load16AlignedSigned(const uint8_t* pc) { … }
int32_t LoadPacked24Signed(int32_t bytecode_and_packed_arg) { … }
uint32_t LoadPacked24Unsigned(int32_t bytecode_and_packed_arg) { … }
class BacktrackStack { … };
class InterpreterRegisters { … };
IrregexpInterpreter::Result ThrowStackOverflow(Isolate* isolate,
RegExp::CallOrigin call_origin) { … }
IrregexpInterpreter::Result MaybeThrowStackOverflow(
Isolate* isolate, RegExp::CallOrigin call_origin) { … }
template <typename Char>
void UpdateCodeAndSubjectReferences(
Isolate* isolate, DirectHandle<TrustedByteArray> code_array,
DirectHandle<String> subject_string,
Tagged<TrustedByteArray>* code_array_out, const uint8_t** code_base_out,
const uint8_t** pc_out, Tagged<String>* subject_string_out,
base::Vector<const Char>* subject_string_vector_out) { … }
template <typename Char>
IrregexpInterpreter::Result HandleInterrupts(
Isolate* isolate, RegExp::CallOrigin call_origin,
Tagged<TrustedByteArray>* code_array_out,
Tagged<String>* subject_string_out, const uint8_t** code_base_out,
base::Vector<const Char>* subject_string_vector_out,
const uint8_t** pc_out) { … }
bool CheckBitInTable(const uint32_t current_char, const uint8_t* const table) { … }
bool IndexIsInBounds(int index, int length) { … }
#if V8_USE_COMPUTED_GOTO
#define BC_LABEL …
#define DECODE …
#define DISPATCH …
#else
#define BC_LABEL …
#define DECODE …
#define DISPATCH …
#endif
#define ADVANCE …
#define SET_PC_FROM_OFFSET …
#define SET_CURRENT_POSITION …
#define ADVANCE_CURRENT_POSITION …
#ifdef DEBUG
#define BYTECODE …
#else
#define BYTECODE …
#endif
template <typename Char>
IrregexpInterpreter::Result RawMatch(
Isolate* isolate, Tagged<TrustedByteArray> code_array,
Tagged<String> subject_string, base::Vector<const Char> subject,
int* output_registers, int output_register_count, int total_register_count,
int current, uint32_t current_char, RegExp::CallOrigin call_origin,
const uint32_t backtrack_limit) { … }
#undef BYTECODE
#undef ADVANCE_CURRENT_POSITION
#undef SET_CURRENT_POSITION
#undef DISPATCH
#undef DECODE
#undef SET_PC_FROM_OFFSET
#undef ADVANCE
#undef BC_LABEL
#undef V8_USE_COMPUTED_GOTO
}
IrregexpInterpreter::Result IrregexpInterpreter::Match(
Isolate* isolate, Tagged<IrRegExpData> regexp_data,
Tagged<String> subject_string, int* output_registers,
int output_register_count, int start_position,
RegExp::CallOrigin call_origin) { … }
IrregexpInterpreter::Result IrregexpInterpreter::MatchInternal(
Isolate* isolate, Tagged<TrustedByteArray> code_array,
Tagged<String> subject_string, int* output_registers,
int output_register_count, int total_register_count, int start_position,
RegExp::CallOrigin call_origin, uint32_t backtrack_limit) { … }
#ifndef COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER
IrregexpInterpreter::Result IrregexpInterpreter::MatchForCallFromJs(
Address subject, int32_t start_position, Address, Address,
int* output_registers, int32_t output_register_count,
RegExp::CallOrigin call_origin, Isolate* isolate, Address regexp_data) { … }
#endif
IrregexpInterpreter::Result IrregexpInterpreter::MatchForCallFromRuntime(
Isolate* isolate, DirectHandle<IrRegExpData> regexp_data,
DirectHandle<String> subject_string, int* output_registers,
int output_register_count, int start_position) { … }
}
}