Bug 1638154: Refresh import r=tcampbell

This patch was auto-generated with `new-regexp/import-irregexp.py`.

Differential Revision: https://phabricator.services.mozilla.com/D76250
This commit is contained in:
Iain Ireland 2020-05-21 17:33:29 +00:00
Родитель dfbd6e7ef7
Коммит 7929770395
7 изменённых файлов: 155 добавлений и 120 удалений

Просмотреть файл

@ -1,2 +1,2 @@
Imported using import-irregexp.py from:
https://github.com/v8/v8/tree/a3fbabc726384ea1021955a640add8cfe6a431af/src/regexp
https://github.com/v8/v8/tree/ccd53957650b556cec412d1fd490cb9c50d2a6ff/src/regexp

Просмотреть файл

@ -180,7 +180,7 @@ void RegExpBytecodeGenerator::LoadCurrentCharacterImpl(int cp_offset,
int eats_at_least) {
DCHECK_GE(eats_at_least, characters);
if (eats_at_least > characters && check_bounds) {
DCHECK(is_uint24(cp_offset + eats_at_least));
DCHECK(is_int24(cp_offset + eats_at_least));
Emit(BC_CHECK_CURRENT_POSITION, cp_offset + eats_at_least);
EmitOrLink(on_failure);
check_bounds = false; // Load below doesn't need to check.

Просмотреть файл

@ -22,61 +22,60 @@ class V8_EXPORT_PRIVATE RegExpBytecodeGenerator : public RegExpMacroAssembler {
// determines the initial buffer size. The buffer is owned by the assembler
// and deallocated upon destruction of the assembler.
RegExpBytecodeGenerator(Isolate* isolate, Zone* zone);
virtual ~RegExpBytecodeGenerator();
~RegExpBytecodeGenerator() override;
// The byte-code interpreter checks on each push anyway.
virtual int stack_limit_slack() { return 1; }
virtual bool CanReadUnaligned() { return false; }
virtual void Bind(Label* label);
virtual void AdvanceCurrentPosition(int by); // Signed cp change.
virtual void PopCurrentPosition();
virtual void PushCurrentPosition();
virtual void Backtrack();
virtual void GoTo(Label* label);
virtual void PushBacktrack(Label* label);
virtual bool Succeed();
virtual void Fail();
virtual void PopRegister(int register_index);
virtual void PushRegister(int register_index,
StackCheckFlag check_stack_limit);
virtual void AdvanceRegister(int reg, int by); // r[reg] += by.
virtual void SetCurrentPositionFromEnd(int by);
virtual void SetRegister(int register_index, int to);
virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
virtual void ClearRegisters(int reg_from, int reg_to);
virtual void ReadCurrentPositionFromRegister(int reg);
virtual void WriteStackPointerToRegister(int reg);
virtual void ReadStackPointerFromRegister(int reg);
virtual void LoadCurrentCharacterImpl(int cp_offset, Label* on_end_of_input,
bool check_bounds, int characters,
int eats_at_least);
virtual void CheckCharacter(unsigned c, Label* on_equal);
virtual void CheckCharacterAfterAnd(unsigned c, unsigned mask,
Label* on_equal);
virtual void CheckCharacterGT(uc16 limit, Label* on_greater);
virtual void CheckCharacterLT(uc16 limit, Label* on_less);
virtual void CheckGreedyLoop(Label* on_tos_equals_current_position);
virtual void CheckAtStart(int cp_offset, Label* on_at_start);
virtual void CheckNotAtStart(int cp_offset, Label* on_not_at_start);
virtual void CheckNotCharacter(unsigned c, Label* on_not_equal);
virtual void CheckNotCharacterAfterAnd(unsigned c, unsigned mask,
Label* on_not_equal);
virtual void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 mask,
Label* on_not_equal);
virtual void CheckCharacterInRange(uc16 from, uc16 to, Label* on_in_range);
virtual void CheckCharacterNotInRange(uc16 from, uc16 to,
Label* on_not_in_range);
virtual void CheckBitInTable(Handle<ByteArray> table, Label* on_bit_set);
virtual void CheckNotBackReference(int start_reg, bool read_backward,
Label* on_no_match);
virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
bool read_backward,
Label* on_no_match);
virtual void IfRegisterLT(int register_index, int comparand, Label* if_lt);
virtual void IfRegisterGE(int register_index, int comparand, Label* if_ge);
virtual void IfRegisterEqPos(int register_index, Label* if_eq);
int stack_limit_slack() override { return 1; }
bool CanReadUnaligned() override { return false; }
void Bind(Label* label) override;
void AdvanceCurrentPosition(int by) override; // Signed cp change.
void PopCurrentPosition() override;
void PushCurrentPosition() override;
void Backtrack() override;
void GoTo(Label* label) override;
void PushBacktrack(Label* label) override;
bool Succeed() override;
void Fail() override;
void PopRegister(int register_index) override;
void PushRegister(int register_index,
StackCheckFlag check_stack_limit) override;
void AdvanceRegister(int reg, int by) override; // r[reg] += by.
void SetCurrentPositionFromEnd(int by) override;
void SetRegister(int register_index, int to) override;
void WriteCurrentPositionToRegister(int reg, int cp_offset) override;
void ClearRegisters(int reg_from, int reg_to) override;
void ReadCurrentPositionFromRegister(int reg) override;
void WriteStackPointerToRegister(int reg) override;
void ReadStackPointerFromRegister(int reg) override;
void LoadCurrentCharacterImpl(int cp_offset, Label* on_end_of_input,
bool check_bounds, int characters,
int eats_at_least) override;
void CheckCharacter(unsigned c, Label* on_equal) override;
void CheckCharacterAfterAnd(unsigned c, unsigned mask,
Label* on_equal) override;
void CheckCharacterGT(uc16 limit, Label* on_greater) override;
void CheckCharacterLT(uc16 limit, Label* on_less) override;
void CheckGreedyLoop(Label* on_tos_equals_current_position) override;
void CheckAtStart(int cp_offset, Label* on_at_start) override;
void CheckNotAtStart(int cp_offset, Label* on_not_at_start) override;
void CheckNotCharacter(unsigned c, Label* on_not_equal) override;
void CheckNotCharacterAfterAnd(unsigned c, unsigned mask,
Label* on_not_equal) override;
void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 mask,
Label* on_not_equal) override;
void CheckCharacterInRange(uc16 from, uc16 to, Label* on_in_range) override;
void CheckCharacterNotInRange(uc16 from, uc16 to,
Label* on_not_in_range) override;
void CheckBitInTable(Handle<ByteArray> table, Label* on_bit_set) override;
void CheckNotBackReference(int start_reg, bool read_backward,
Label* on_no_match) override;
void CheckNotBackReferenceIgnoreCase(int start_reg, bool read_backward,
Label* on_no_match) override;
void IfRegisterLT(int register_index, int comparand, Label* if_lt) override;
void IfRegisterGE(int register_index, int comparand, Label* if_ge) override;
void IfRegisterEqPos(int register_index, Label* if_eq) override;
virtual IrregexpImplementation Implementation();
virtual Handle<HeapObject> GetCode(Handle<String> source);
IrregexpImplementation Implementation() override;
Handle<HeapObject> GetCode(Handle<String> source) override;
private:
void Expand();

Просмотреть файл

@ -26,6 +26,7 @@ STATIC_ASSERT(1 << BYTECODE_SHIFT > BYTECODE_MASK);
// TODO(pthier): Argument offsets of bytecodes should be easily accessible by
// name or at least by position.
// TODO(jgruber): More precise types (e.g. int32/uint32 instead of value32).
#define BYTECODE_ITERATOR(V) \
V(BREAK, 0, 4) /* bc8 */ \
V(PUSH_CP, 1, 4) /* bc8 pad24 */ \

Просмотреть файл

@ -436,6 +436,8 @@ RegExpNode* RegExpCharacterClass::ToNode(RegExpCompiler* compiler,
AddNonBmpSurrogatePairs(compiler, result, on_success, &splitter);
AddLoneLeadSurrogates(compiler, result, on_success, &splitter);
AddLoneTrailSurrogates(compiler, result, on_success, &splitter);
static constexpr int kMaxRangesToInline = 32; // Arbitrary.
if (ranges->length() > kMaxRangesToInline) result->SetDoNotInline();
return result;
}
} else {

Просмотреть файл

@ -93,6 +93,18 @@ int32_t Load16AlignedSigned(const byte* pc) {
return *reinterpret_cast<const int16_t*>(pc);
}
// Helpers to access the packed argument. Takes the 32 bits containing the
// current bytecode, where the 8 LSB contain the bytecode and the rest contains
// a packed 24-bit argument.
// TODO(jgruber): Specify signed-ness in bytecode signature declarations, and
// police restrictions during bytecode generation.
int32_t LoadPacked24Signed(int32_t bytecode_and_packed_arg) {
return bytecode_and_packed_arg >> BYTECODE_SHIFT;
}
uint32_t LoadPacked24Unsigned(int32_t bytecode_and_packed_arg) {
return static_cast<uint32_t>(bytecode_and_packed_arg) >> BYTECODE_SHIFT;
}
// A simple abstraction over the backtracking stack used by the interpreter.
//
// Despite the name 'backtracking' stack, it's actually used as a generic stack
@ -289,6 +301,12 @@ bool CheckBitInTable(const uint32_t current_char, const byte* const table) {
return (b & (1 << bit)) != 0;
}
// Returns true iff 0 <= index < length.
bool IndexIsInBounds(int index, int length) {
DCHECK_GE(length, 0);
return static_cast<uintptr_t>(index) < static_cast<uintptr_t>(length);
}
// If computed gotos are supported by the compiler, we can get addresses to
// labels directly in C/C++. Every bytecode handler has its own label and we
// store the addresses in a dispatch table indexed by bytecode. To execute the
@ -330,6 +348,14 @@ bool CheckBitInTable(const uint32_t current_char, const byte* const table) {
next_pc = code_base + offset; \
DECODE()
// Current position mutations.
#define SET_CURRENT_POSITION(value) \
do { \
current = (value); \
DCHECK(base::IsInRange(current, 0, subject.length())); \
} while (false)
#define ADVANCE_CURRENT_POSITION(by) SET_CURRENT_POSITION(current + (by))
#ifdef DEBUG
#define BYTECODE(name) \
BC_LABEL(name) \
@ -440,44 +466,44 @@ IrregexpInterpreter::Result RawMatch(
}
BYTECODE(PUSH_REGISTER) {
ADVANCE(PUSH_REGISTER);
if (!backtrack_stack.push(registers[insn >> BYTECODE_SHIFT])) {
if (!backtrack_stack.push(registers[LoadPacked24Unsigned(insn)])) {
return MaybeThrowStackOverflow(isolate, call_origin);
}
DISPATCH();
}
BYTECODE(SET_REGISTER) {
ADVANCE(SET_REGISTER);
registers[insn >> BYTECODE_SHIFT] = Load32Aligned(pc + 4);
registers[LoadPacked24Unsigned(insn)] = Load32Aligned(pc + 4);
DISPATCH();
}
BYTECODE(ADVANCE_REGISTER) {
ADVANCE(ADVANCE_REGISTER);
registers[insn >> BYTECODE_SHIFT] += Load32Aligned(pc + 4);
registers[LoadPacked24Unsigned(insn)] += Load32Aligned(pc + 4);
DISPATCH();
}
BYTECODE(SET_REGISTER_TO_CP) {
ADVANCE(SET_REGISTER_TO_CP);
registers[insn >> BYTECODE_SHIFT] = current + Load32Aligned(pc + 4);
registers[LoadPacked24Unsigned(insn)] = current + Load32Aligned(pc + 4);
DISPATCH();
}
BYTECODE(SET_CP_TO_REGISTER) {
ADVANCE(SET_CP_TO_REGISTER);
current = registers[insn >> BYTECODE_SHIFT];
SET_CURRENT_POSITION(registers[LoadPacked24Unsigned(insn)]);
DISPATCH();
}
BYTECODE(SET_REGISTER_TO_SP) {
ADVANCE(SET_REGISTER_TO_SP);
registers[insn >> BYTECODE_SHIFT] = backtrack_stack.sp();
registers[LoadPacked24Unsigned(insn)] = backtrack_stack.sp();
DISPATCH();
}
BYTECODE(SET_SP_TO_REGISTER) {
ADVANCE(SET_SP_TO_REGISTER);
backtrack_stack.set_sp(registers[insn >> BYTECODE_SHIFT]);
backtrack_stack.set_sp(registers[LoadPacked24Unsigned(insn)]);
DISPATCH();
}
BYTECODE(POP_CP) {
ADVANCE(POP_CP);
current = backtrack_stack.pop();
SET_CURRENT_POSITION(backtrack_stack.pop());
DISPATCH();
}
BYTECODE(POP_BT) {
@ -497,7 +523,7 @@ IrregexpInterpreter::Result RawMatch(
}
BYTECODE(POP_REGISTER) {
ADVANCE(POP_REGISTER);
registers[insn >> BYTECODE_SHIFT] = backtrack_stack.pop();
registers[LoadPacked24Unsigned(insn)] = backtrack_stack.pop();
DISPATCH();
}
BYTECODE(FAIL) {
@ -513,7 +539,7 @@ IrregexpInterpreter::Result RawMatch(
}
BYTECODE(ADVANCE_CP) {
ADVANCE(ADVANCE_CP);
current += insn >> BYTECODE_SHIFT;
ADVANCE_CURRENT_POSITION(LoadPacked24Signed(insn));
DISPATCH();
}
BYTECODE(GOTO) {
@ -522,7 +548,7 @@ IrregexpInterpreter::Result RawMatch(
}
BYTECODE(ADVANCE_CP_AND_GOTO) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
current += insn >> BYTECODE_SHIFT;
ADVANCE_CURRENT_POSITION(LoadPacked24Signed(insn));
DISPATCH();
}
BYTECODE(CHECK_GREEDY) {
@ -535,7 +561,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(LOAD_CURRENT_CHAR) {
int pos = current + (insn >> BYTECODE_SHIFT);
int pos = current + LoadPacked24Signed(insn);
if (pos >= subject.length() || pos < 0) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
@ -546,12 +572,12 @@ IrregexpInterpreter::Result RawMatch(
}
BYTECODE(LOAD_CURRENT_CHAR_UNCHECKED) {
ADVANCE(LOAD_CURRENT_CHAR_UNCHECKED);
int pos = current + (insn >> BYTECODE_SHIFT);
int pos = current + LoadPacked24Signed(insn);
current_char = subject[pos];
DISPATCH();
}
BYTECODE(LOAD_2_CURRENT_CHARS) {
int pos = current + (insn >> BYTECODE_SHIFT);
int pos = current + LoadPacked24Signed(insn);
if (pos + 2 > subject.length() || pos < 0) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
@ -563,14 +589,14 @@ IrregexpInterpreter::Result RawMatch(
}
BYTECODE(LOAD_2_CURRENT_CHARS_UNCHECKED) {
ADVANCE(LOAD_2_CURRENT_CHARS_UNCHECKED);
int pos = current + (insn >> BYTECODE_SHIFT);
int pos = current + LoadPacked24Signed(insn);
Char next = subject[pos + 1];
current_char = (subject[pos] | (next << (kBitsPerByte * sizeof(Char))));
DISPATCH();
}
BYTECODE(LOAD_4_CURRENT_CHARS) {
DCHECK_EQ(1, sizeof(Char));
int pos = current + (insn >> BYTECODE_SHIFT);
int pos = current + LoadPacked24Signed(insn);
if (pos + 4 > subject.length() || pos < 0) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
@ -586,7 +612,7 @@ IrregexpInterpreter::Result RawMatch(
BYTECODE(LOAD_4_CURRENT_CHARS_UNCHECKED) {
ADVANCE(LOAD_4_CURRENT_CHARS_UNCHECKED);
DCHECK_EQ(1, sizeof(Char));
int pos = current + (insn >> BYTECODE_SHIFT);
int pos = current + LoadPacked24Signed(insn);
Char next1 = subject[pos + 1];
Char next2 = subject[pos + 2];
Char next3 = subject[pos + 3];
@ -604,7 +630,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_CHAR) {
uint32_t c = (insn >> BYTECODE_SHIFT);
uint32_t c = LoadPacked24Unsigned(insn);
if (c == current_char) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
@ -622,7 +648,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_NOT_CHAR) {
uint32_t c = (insn >> BYTECODE_SHIFT);
uint32_t c = LoadPacked24Unsigned(insn);
if (c != current_char) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
@ -640,7 +666,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(AND_CHECK_CHAR) {
uint32_t c = (insn >> BYTECODE_SHIFT);
uint32_t c = LoadPacked24Unsigned(insn);
if (c == (current_char & Load32Aligned(pc + 4))) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 8));
} else {
@ -658,7 +684,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(AND_CHECK_NOT_CHAR) {
uint32_t c = (insn >> BYTECODE_SHIFT);
uint32_t c = LoadPacked24Unsigned(insn);
if (c != (current_char & Load32Aligned(pc + 4))) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 8));
} else {
@ -667,7 +693,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(MINUS_AND_CHECK_NOT_CHAR) {
uint32_t c = (insn >> BYTECODE_SHIFT);
uint32_t c = LoadPacked24Unsigned(insn);
uint32_t minus = Load16Aligned(pc + 4);
uint32_t mask = Load16Aligned(pc + 6);
if (c != ((current_char - minus) & mask)) {
@ -706,7 +732,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_LT) {
uint32_t limit = (insn >> BYTECODE_SHIFT);
uint32_t limit = LoadPacked24Unsigned(insn);
if (current_char < limit) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
@ -715,7 +741,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_GT) {
uint32_t limit = (insn >> BYTECODE_SHIFT);
uint32_t limit = LoadPacked24Unsigned(insn);
if (current_char > limit) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
@ -724,7 +750,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_REGISTER_LT) {
if (registers[insn >> BYTECODE_SHIFT] < Load32Aligned(pc + 4)) {
if (registers[LoadPacked24Unsigned(insn)] < Load32Aligned(pc + 4)) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 8));
} else {
ADVANCE(CHECK_REGISTER_LT);
@ -732,7 +758,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_REGISTER_GE) {
if (registers[insn >> BYTECODE_SHIFT] >= Load32Aligned(pc + 4)) {
if (registers[LoadPacked24Unsigned(insn)] >= Load32Aligned(pc + 4)) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 8));
} else {
ADVANCE(CHECK_REGISTER_GE);
@ -740,7 +766,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_REGISTER_EQ_POS) {
if (registers[insn >> BYTECODE_SHIFT] == current) {
if (registers[LoadPacked24Unsigned(insn)] == current) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
ADVANCE(CHECK_REGISTER_EQ_POS);
@ -748,7 +774,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_NOT_REGS_EQUAL) {
if (registers[insn >> BYTECODE_SHIFT] ==
if (registers[LoadPacked24Unsigned(insn)] ==
registers[Load32Aligned(pc + 4)]) {
ADVANCE(CHECK_NOT_REGS_EQUAL);
} else {
@ -757,29 +783,29 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_NOT_BACK_REF) {
int from = registers[insn >> BYTECODE_SHIFT];
int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from;
int from = registers[LoadPacked24Unsigned(insn)];
int len = registers[LoadPacked24Unsigned(insn) + 1] - from;
if (from >= 0 && len > 0) {
if (current + len > subject.length() ||
CompareChars(&subject[from], &subject[current], len) != 0) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
DISPATCH();
}
current += len;
ADVANCE_CURRENT_POSITION(len);
}
ADVANCE(CHECK_NOT_BACK_REF);
DISPATCH();
}
BYTECODE(CHECK_NOT_BACK_REF_BACKWARD) {
int from = registers[insn >> BYTECODE_SHIFT];
int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from;
int from = registers[LoadPacked24Unsigned(insn)];
int len = registers[LoadPacked24Unsigned(insn) + 1] - from;
if (from >= 0 && len > 0) {
if (current - len < 0 ||
CompareChars(&subject[from], &subject[current - len], len) != 0) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
DISPATCH();
}
current -= len;
SET_CURRENT_POSITION(current - len);
}
ADVANCE(CHECK_NOT_BACK_REF_BACKWARD);
DISPATCH();
@ -788,15 +814,15 @@ IrregexpInterpreter::Result RawMatch(
UNREACHABLE(); // TODO(jgruber): Remove this unused bytecode.
}
BYTECODE(CHECK_NOT_BACK_REF_NO_CASE) {
int from = registers[insn >> BYTECODE_SHIFT];
int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from;
int from = registers[LoadPacked24Unsigned(insn)];
int len = registers[LoadPacked24Unsigned(insn) + 1] - from;
if (from >= 0 && len > 0) {
if (current + len > subject.length() ||
!BackRefMatchesNoCase(isolate, from, current, len, subject)) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
DISPATCH();
}
current += len;
ADVANCE_CURRENT_POSITION(len);
}
ADVANCE(CHECK_NOT_BACK_REF_NO_CASE);
DISPATCH();
@ -805,21 +831,21 @@ IrregexpInterpreter::Result RawMatch(
UNREACHABLE(); // TODO(jgruber): Remove this unused bytecode.
}
BYTECODE(CHECK_NOT_BACK_REF_NO_CASE_BACKWARD) {
int from = registers[insn >> BYTECODE_SHIFT];
int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from;
int from = registers[LoadPacked24Unsigned(insn)];
int len = registers[LoadPacked24Unsigned(insn) + 1] - from;
if (from >= 0 && len > 0) {
if (current - len < 0 ||
!BackRefMatchesNoCase(isolate, from, current - len, len, subject)) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
DISPATCH();
}
current -= len;
SET_CURRENT_POSITION(current - len);
}
ADVANCE(CHECK_NOT_BACK_REF_NO_CASE_BACKWARD);
DISPATCH();
}
BYTECODE(CHECK_AT_START) {
if (current + (insn >> BYTECODE_SHIFT) == 0) {
if (current + LoadPacked24Signed(insn) == 0) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
ADVANCE(CHECK_AT_START);
@ -827,7 +853,7 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(CHECK_NOT_AT_START) {
if (current + (insn >> BYTECODE_SHIFT) == 0) {
if (current + LoadPacked24Signed(insn) == 0) {
ADVANCE(CHECK_NOT_AT_START);
} else {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
@ -836,15 +862,15 @@ IrregexpInterpreter::Result RawMatch(
}
BYTECODE(SET_CURRENT_POSITION_FROM_END) {
ADVANCE(SET_CURRENT_POSITION_FROM_END);
int by = static_cast<uint32_t>(insn) >> BYTECODE_SHIFT;
int by = LoadPacked24Unsigned(insn);
if (subject.length() - current > by) {
current = subject.length() - by;
SET_CURRENT_POSITION(subject.length() - by);
current_char = subject[current - 1];
}
DISPATCH();
}
BYTECODE(CHECK_CURRENT_POSITION) {
int pos = current + (insn >> BYTECODE_SHIFT);
int pos = current + LoadPacked24Signed(insn);
if (pos > subject.length() || pos < 0) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 4));
} else {
@ -853,23 +879,22 @@ IrregexpInterpreter::Result RawMatch(
DISPATCH();
}
BYTECODE(SKIP_UNTIL_CHAR) {
int load_offset = (insn >> BYTECODE_SHIFT);
int32_t load_offset = LoadPacked24Signed(insn);
int32_t advance = Load16AlignedSigned(pc + 4);
uint32_t c = Load16Aligned(pc + 6);
while (static_cast<uintptr_t>(current + load_offset) <
static_cast<uintptr_t>(subject.length())) {
while (IndexIsInBounds(current + load_offset, subject.length())) {
current_char = subject[current + load_offset];
if (c == current_char) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 8));
DISPATCH();
}
current += advance;
ADVANCE_CURRENT_POSITION(advance);
}
SET_PC_FROM_OFFSET(Load32Aligned(pc + 12));
DISPATCH();
}
BYTECODE(SKIP_UNTIL_CHAR_AND) {
int load_offset = (insn >> BYTECODE_SHIFT);
int32_t load_offset = LoadPacked24Signed(insn);
int32_t advance = Load16AlignedSigned(pc + 4);
uint16_t c = Load16Aligned(pc + 6);
uint32_t mask = Load32Aligned(pc + 8);
@ -881,13 +906,13 @@ IrregexpInterpreter::Result RawMatch(
SET_PC_FROM_OFFSET(Load32Aligned(pc + 16));
DISPATCH();
}
current += advance;
ADVANCE_CURRENT_POSITION(advance);
}
SET_PC_FROM_OFFSET(Load32Aligned(pc + 20));
DISPATCH();
}
BYTECODE(SKIP_UNTIL_CHAR_POS_CHECKED) {
int load_offset = (insn >> BYTECODE_SHIFT);
int32_t load_offset = LoadPacked24Signed(insn);
int32_t advance = Load16AlignedSigned(pc + 4);
uint16_t c = Load16Aligned(pc + 6);
int32_t maximum_offset = Load32Aligned(pc + 8);
@ -898,34 +923,32 @@ IrregexpInterpreter::Result RawMatch(
SET_PC_FROM_OFFSET(Load32Aligned(pc + 12));
DISPATCH();
}
current += advance;
ADVANCE_CURRENT_POSITION(advance);
}
SET_PC_FROM_OFFSET(Load32Aligned(pc + 16));
DISPATCH();
}
BYTECODE(SKIP_UNTIL_BIT_IN_TABLE) {
int load_offset = (insn >> BYTECODE_SHIFT);
int32_t load_offset = LoadPacked24Signed(insn);
int32_t advance = Load16AlignedSigned(pc + 4);
const byte* table = pc + 8;
while (static_cast<uintptr_t>(current + load_offset) <
static_cast<uintptr_t>(subject.length())) {
while (IndexIsInBounds(current + load_offset, subject.length())) {
current_char = subject[current + load_offset];
if (CheckBitInTable(current_char, table)) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 24));
DISPATCH();
}
current += advance;
ADVANCE_CURRENT_POSITION(advance);
}
SET_PC_FROM_OFFSET(Load32Aligned(pc + 28));
DISPATCH();
}
BYTECODE(SKIP_UNTIL_GT_OR_NOT_BIT_IN_TABLE) {
int load_offset = (insn >> BYTECODE_SHIFT);
int32_t load_offset = LoadPacked24Signed(insn);
int32_t advance = Load16AlignedSigned(pc + 4);
uint16_t limit = Load16Aligned(pc + 6);
const byte* table = pc + 8;
while (static_cast<uintptr_t>(current + load_offset) <
static_cast<uintptr_t>(subject.length())) {
while (IndexIsInBounds(current + load_offset, subject.length())) {
current_char = subject[current + load_offset];
if (current_char > limit) {
SET_PC_FROM_OFFSET(Load32Aligned(pc + 24));
@ -935,18 +958,17 @@ IrregexpInterpreter::Result RawMatch(
SET_PC_FROM_OFFSET(Load32Aligned(pc + 24));
DISPATCH();
}
current += advance;
ADVANCE_CURRENT_POSITION(advance);
}
SET_PC_FROM_OFFSET(Load32Aligned(pc + 28));
DISPATCH();
}
BYTECODE(SKIP_UNTIL_CHAR_OR_CHAR) {
int load_offset = (insn >> BYTECODE_SHIFT);
int32_t load_offset = LoadPacked24Signed(insn);
int32_t advance = Load32Aligned(pc + 4);
uint16_t c = Load16Aligned(pc + 8);
uint16_t c2 = Load16Aligned(pc + 10);
while (static_cast<uintptr_t>(current + load_offset) <
static_cast<uintptr_t>(subject.length())) {
while (IndexIsInBounds(current + load_offset, subject.length())) {
current_char = subject[current + load_offset];
// The two if-statements below are split up intentionally, as combining
// them seems to result in register allocation behaving quite
@ -959,7 +981,7 @@ IrregexpInterpreter::Result RawMatch(
SET_PC_FROM_OFFSET(Load32Aligned(pc + 12));
DISPATCH();
}
current += advance;
ADVANCE_CURRENT_POSITION(advance);
}
SET_PC_FROM_OFFSET(Load32Aligned(pc + 16));
DISPATCH();
@ -979,6 +1001,8 @@ IrregexpInterpreter::Result RawMatch(
}
#undef BYTECODE
#undef ADVANCE_CURRENT_POSITION
#undef SET_CURRENT_POSITION
#undef DISPATCH
#undef DECODE
#undef SET_PC_FROM_OFFSET

Просмотреть файл

@ -236,6 +236,15 @@ class RegExpNode : public ZoneObject {
eats_at_least_ = eats_at_least;
}
// TODO(v8:10441): This is a hacky way to avoid exponential code size growth
// for very large choice nodes that can be generated by unicode property
// escapes. In order to avoid inlining (i.e. trace recursion), we pretend to
// have generated the maximum count of code copies already.
// We should instead fix this properly, e.g. by using the code size budget
// (flush_budget) or by generating property escape matches as calls to a C
// function.
void SetDoNotInline() { trace_count_ = kMaxCopiesCodeGenerated; }
BoyerMooreLookahead* bm_info(bool not_at_start) {
return bm_info_[not_at_start ? 1 : 0];
}