[cleanup] Rename RegExpMacroAssemblerIrregexp to RegExpBytecodeGenerator
This makes it clearer what this class does, and is more consistent with the terminology used by ignition (BytecodeGenerator). Change-Id: I9085f29f437cf15605a5ae971b1fc72d6c79feaa Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1692923 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#62612}
This commit is contained in:
parent
909ab89956
commit
6b2b60cb02
6
BUILD.gn
6
BUILD.gn
@ -2688,6 +2688,9 @@ v8_source_set("v8_base_without_compiler") {
|
||||
"src/regexp/property-sequences.h",
|
||||
"src/regexp/regexp-ast.cc",
|
||||
"src/regexp/regexp-ast.h",
|
||||
"src/regexp/regexp-bytecode-generator-inl.h",
|
||||
"src/regexp/regexp-bytecode-generator.cc",
|
||||
"src/regexp/regexp-bytecode-generator.h",
|
||||
"src/regexp/regexp-bytecodes.h",
|
||||
"src/regexp/regexp-compiler-tonode.cc",
|
||||
"src/regexp/regexp-compiler.cc",
|
||||
@ -2697,9 +2700,6 @@ v8_source_set("v8_base_without_compiler") {
|
||||
"src/regexp/regexp-interpreter.cc",
|
||||
"src/regexp/regexp-interpreter.h",
|
||||
"src/regexp/regexp-macro-assembler-arch.h",
|
||||
"src/regexp/regexp-macro-assembler-irregexp-inl.h",
|
||||
"src/regexp/regexp-macro-assembler-irregexp.cc",
|
||||
"src/regexp/regexp-macro-assembler-irregexp.h",
|
||||
"src/regexp/regexp-macro-assembler-tracer.cc",
|
||||
"src/regexp/regexp-macro-assembler-tracer.h",
|
||||
"src/regexp/regexp-macro-assembler.cc",
|
||||
|
@ -99,7 +99,7 @@ class Label {
|
||||
|
||||
friend class Assembler;
|
||||
friend class Displacement;
|
||||
friend class RegExpMacroAssemblerIrregexp;
|
||||
friend class RegExpBytecodeGenerator;
|
||||
|
||||
// Disallow copy construction and assignment, but allow move construction and
|
||||
// move assignment on selected platforms (see above).
|
||||
|
@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
|
||||
#define V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
|
||||
#ifndef V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_
|
||||
#define V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_
|
||||
|
||||
#include "src/regexp/regexp-macro-assembler-irregexp.h"
|
||||
#include "src/regexp/regexp-bytecode-generator.h"
|
||||
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/regexp/regexp-bytecodes.h"
|
||||
@ -13,19 +13,17 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte,
|
||||
uint32_t twenty_four_bits) {
|
||||
void RegExpBytecodeGenerator::Emit(uint32_t byte, uint32_t twenty_four_bits) {
|
||||
uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte);
|
||||
DCHECK(pc_ <= buffer_.length());
|
||||
if (pc_ + 3 >= buffer_.length()) {
|
||||
if (pc_ + 3 >= buffer_.length()) {
|
||||
Expand();
|
||||
}
|
||||
*reinterpret_cast<uint32_t*>(buffer_.begin() + pc_) = word;
|
||||
pc_ += 4;
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) {
|
||||
void RegExpBytecodeGenerator::Emit16(uint32_t word) {
|
||||
DCHECK(pc_ <= buffer_.length());
|
||||
if (pc_ + 1 >= buffer_.length()) {
|
||||
Expand();
|
||||
@ -34,8 +32,7 @@ void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) {
|
||||
pc_ += 2;
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Emit8(uint32_t word) {
|
||||
void RegExpBytecodeGenerator::Emit8(uint32_t word) {
|
||||
DCHECK(pc_ <= buffer_.length());
|
||||
if (pc_ == buffer_.length()) {
|
||||
Expand();
|
||||
@ -44,8 +41,7 @@ void RegExpMacroAssemblerIrregexp::Emit8(uint32_t word) {
|
||||
pc_ += 1;
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) {
|
||||
void RegExpBytecodeGenerator::Emit32(uint32_t word) {
|
||||
DCHECK(pc_ <= buffer_.length());
|
||||
if (pc_ + 3 >= buffer_.length()) {
|
||||
Expand();
|
||||
@ -57,4 +53,4 @@ void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) {
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
|
||||
#endif // V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_
|
@ -2,19 +2,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/regexp/regexp-macro-assembler-irregexp.h"
|
||||
#include "src/regexp/regexp-bytecode-generator.h"
|
||||
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "src/regexp/regexp-bytecode-generator-inl.h"
|
||||
#include "src/regexp/regexp-bytecodes.h"
|
||||
#include "src/regexp/regexp-macro-assembler-irregexp-inl.h"
|
||||
#include "src/regexp/regexp-macro-assembler.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Isolate* isolate,
|
||||
Zone* zone)
|
||||
RegExpBytecodeGenerator::RegExpBytecodeGenerator(Isolate* isolate, Zone* zone)
|
||||
: RegExpMacroAssembler(isolate, zone),
|
||||
buffer_(Vector<byte>::New(1024)),
|
||||
pc_(0),
|
||||
@ -22,19 +21,17 @@ RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Isolate* isolate,
|
||||
advance_current_end_(kInvalidPC),
|
||||
isolate_(isolate) {}
|
||||
|
||||
RegExpMacroAssemblerIrregexp::~RegExpMacroAssemblerIrregexp() {
|
||||
RegExpBytecodeGenerator::~RegExpBytecodeGenerator() {
|
||||
if (backtrack_.is_linked()) backtrack_.Unuse();
|
||||
if (own_buffer_) buffer_.Dispose();
|
||||
}
|
||||
|
||||
|
||||
RegExpMacroAssemblerIrregexp::IrregexpImplementation
|
||||
RegExpMacroAssemblerIrregexp::Implementation() {
|
||||
RegExpBytecodeGenerator::IrregexpImplementation
|
||||
RegExpBytecodeGenerator::Implementation() {
|
||||
return kBytecodeImplementation;
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Bind(Label* l) {
|
||||
void RegExpBytecodeGenerator::Bind(Label* l) {
|
||||
advance_current_end_ = kInvalidPC;
|
||||
DCHECK(!l->is_bound());
|
||||
if (l->is_linked()) {
|
||||
@ -48,8 +45,7 @@ void RegExpMacroAssemblerIrregexp::Bind(Label* l) {
|
||||
l->bind_to(pc_);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::EmitOrLink(Label* l) {
|
||||
void RegExpBytecodeGenerator::EmitOrLink(Label* l) {
|
||||
if (l == nullptr) l = &backtrack_;
|
||||
if (l->is_bound()) {
|
||||
Emit32(l->pos());
|
||||
@ -63,102 +59,79 @@ void RegExpMacroAssemblerIrregexp::EmitOrLink(Label* l) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) {
|
||||
void RegExpBytecodeGenerator::PopRegister(int register_index) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_POP_REGISTER, register_index);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::PushRegister(
|
||||
int register_index,
|
||||
StackCheckFlag check_stack_limit) {
|
||||
void RegExpBytecodeGenerator::PushRegister(int register_index,
|
||||
StackCheckFlag check_stack_limit) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_PUSH_REGISTER, register_index);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister(
|
||||
int register_index, int cp_offset) {
|
||||
void RegExpBytecodeGenerator::WriteCurrentPositionToRegister(int register_index,
|
||||
int cp_offset) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_SET_REGISTER_TO_CP, register_index);
|
||||
Emit32(cp_offset); // Current position offset.
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::ClearRegisters(int reg_from, int reg_to) {
|
||||
void RegExpBytecodeGenerator::ClearRegisters(int reg_from, int reg_to) {
|
||||
DCHECK(reg_from <= reg_to);
|
||||
for (int reg = reg_from; reg <= reg_to; reg++) {
|
||||
SetRegister(reg, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister(
|
||||
void RegExpBytecodeGenerator::ReadCurrentPositionFromRegister(
|
||||
int register_index) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_SET_CP_TO_REGISTER, register_index);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister(
|
||||
int register_index) {
|
||||
void RegExpBytecodeGenerator::WriteStackPointerToRegister(int register_index) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_SET_REGISTER_TO_SP, register_index);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister(
|
||||
int register_index) {
|
||||
void RegExpBytecodeGenerator::ReadStackPointerFromRegister(int register_index) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_SET_SP_TO_REGISTER, register_index);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::SetCurrentPositionFromEnd(int by) {
|
||||
void RegExpBytecodeGenerator::SetCurrentPositionFromEnd(int by) {
|
||||
DCHECK(is_uint24(by));
|
||||
Emit(BC_SET_CURRENT_POSITION_FROM_END, by);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::SetRegister(int register_index, int to) {
|
||||
void RegExpBytecodeGenerator::SetRegister(int register_index, int to) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_SET_REGISTER, register_index);
|
||||
Emit32(to);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::AdvanceRegister(int register_index, int by) {
|
||||
void RegExpBytecodeGenerator::AdvanceRegister(int register_index, int by) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_ADVANCE_REGISTER, register_index);
|
||||
Emit32(by);
|
||||
}
|
||||
|
||||
void RegExpBytecodeGenerator::PopCurrentPosition() { Emit(BC_POP_CP, 0); }
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::PopCurrentPosition() {
|
||||
Emit(BC_POP_CP, 0);
|
||||
}
|
||||
void RegExpBytecodeGenerator::PushCurrentPosition() { Emit(BC_PUSH_CP, 0); }
|
||||
|
||||
void RegExpBytecodeGenerator::Backtrack() { Emit(BC_POP_BT, 0); }
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::PushCurrentPosition() {
|
||||
Emit(BC_PUSH_CP, 0);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Backtrack() {
|
||||
Emit(BC_POP_BT, 0);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::GoTo(Label* l) {
|
||||
void RegExpBytecodeGenerator::GoTo(Label* l) {
|
||||
if (advance_current_end_ == pc_) {
|
||||
// Combine advance current and goto.
|
||||
pc_ = advance_current_start_;
|
||||
@ -172,25 +145,19 @@ void RegExpMacroAssemblerIrregexp::GoTo(Label* l) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::PushBacktrack(Label* l) {
|
||||
void RegExpBytecodeGenerator::PushBacktrack(Label* l) {
|
||||
Emit(BC_PUSH_BT, 0);
|
||||
EmitOrLink(l);
|
||||
}
|
||||
|
||||
|
||||
bool RegExpMacroAssemblerIrregexp::Succeed() {
|
||||
bool RegExpBytecodeGenerator::Succeed() {
|
||||
Emit(BC_SUCCEED, 0);
|
||||
return false; // Restart matching for global regexp not supported.
|
||||
}
|
||||
|
||||
void RegExpBytecodeGenerator::Fail() { Emit(BC_FAIL, 0); }
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Fail() {
|
||||
Emit(BC_FAIL, 0);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) {
|
||||
void RegExpBytecodeGenerator::AdvanceCurrentPosition(int by) {
|
||||
DCHECK_LE(kMinCPOffset, by);
|
||||
DCHECK_GE(kMaxCPOffset, by);
|
||||
advance_current_start_ = pc_;
|
||||
@ -199,18 +166,16 @@ void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) {
|
||||
advance_current_end_ = pc_;
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckGreedyLoop(
|
||||
Label* on_tos_equals_current_position) {
|
||||
void RegExpBytecodeGenerator::CheckGreedyLoop(
|
||||
Label* on_tos_equals_current_position) {
|
||||
Emit(BC_CHECK_GREEDY, 0);
|
||||
EmitOrLink(on_tos_equals_current_position);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset,
|
||||
Label* on_failure,
|
||||
bool check_bounds,
|
||||
int characters) {
|
||||
void RegExpBytecodeGenerator::LoadCurrentCharacter(int cp_offset,
|
||||
Label* on_failure,
|
||||
bool check_bounds,
|
||||
int characters) {
|
||||
DCHECK_LE(kMinCPOffset, cp_offset);
|
||||
DCHECK_GE(kMaxCPOffset, cp_offset);
|
||||
int bytecode;
|
||||
@ -237,22 +202,17 @@ void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset,
|
||||
if (check_bounds) EmitOrLink(on_failure);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckCharacterLT(uc16 limit,
|
||||
Label* on_less) {
|
||||
void RegExpBytecodeGenerator::CheckCharacterLT(uc16 limit, Label* on_less) {
|
||||
Emit(BC_CHECK_LT, limit);
|
||||
EmitOrLink(on_less);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckCharacterGT(uc16 limit,
|
||||
Label* on_greater) {
|
||||
void RegExpBytecodeGenerator::CheckCharacterGT(uc16 limit, Label* on_greater) {
|
||||
Emit(BC_CHECK_GT, limit);
|
||||
EmitOrLink(on_greater);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckCharacter(uint32_t c, Label* on_equal) {
|
||||
void RegExpBytecodeGenerator::CheckCharacter(uint32_t c, Label* on_equal) {
|
||||
if (c > MAX_FIRST_ARG) {
|
||||
Emit(BC_CHECK_4_CHARS, 0);
|
||||
Emit32(c);
|
||||
@ -262,22 +222,19 @@ void RegExpMacroAssemblerIrregexp::CheckCharacter(uint32_t c, Label* on_equal) {
|
||||
EmitOrLink(on_equal);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckAtStart(Label* on_at_start) {
|
||||
void RegExpBytecodeGenerator::CheckAtStart(Label* on_at_start) {
|
||||
Emit(BC_CHECK_AT_START, 0);
|
||||
EmitOrLink(on_at_start);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckNotAtStart(int cp_offset,
|
||||
Label* on_not_at_start) {
|
||||
void RegExpBytecodeGenerator::CheckNotAtStart(int cp_offset,
|
||||
Label* on_not_at_start) {
|
||||
Emit(BC_CHECK_NOT_AT_START, cp_offset);
|
||||
EmitOrLink(on_not_at_start);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uint32_t c,
|
||||
Label* on_not_equal) {
|
||||
void RegExpBytecodeGenerator::CheckNotCharacter(uint32_t c,
|
||||
Label* on_not_equal) {
|
||||
if (c > MAX_FIRST_ARG) {
|
||||
Emit(BC_CHECK_NOT_4_CHARS, 0);
|
||||
Emit32(c);
|
||||
@ -287,11 +244,8 @@ void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uint32_t c,
|
||||
EmitOrLink(on_not_equal);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckCharacterAfterAnd(
|
||||
uint32_t c,
|
||||
uint32_t mask,
|
||||
Label* on_equal) {
|
||||
void RegExpBytecodeGenerator::CheckCharacterAfterAnd(uint32_t c, uint32_t mask,
|
||||
Label* on_equal) {
|
||||
if (c > MAX_FIRST_ARG) {
|
||||
Emit(BC_AND_CHECK_4_CHARS, 0);
|
||||
Emit32(c);
|
||||
@ -302,11 +256,9 @@ void RegExpMacroAssemblerIrregexp::CheckCharacterAfterAnd(
|
||||
EmitOrLink(on_equal);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterAnd(
|
||||
uint32_t c,
|
||||
uint32_t mask,
|
||||
Label* on_not_equal) {
|
||||
void RegExpBytecodeGenerator::CheckNotCharacterAfterAnd(uint32_t c,
|
||||
uint32_t mask,
|
||||
Label* on_not_equal) {
|
||||
if (c > MAX_FIRST_ARG) {
|
||||
Emit(BC_AND_CHECK_NOT_4_CHARS, 0);
|
||||
Emit32(c);
|
||||
@ -317,43 +269,32 @@ void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterAnd(
|
||||
EmitOrLink(on_not_equal);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterMinusAnd(
|
||||
uc16 c,
|
||||
uc16 minus,
|
||||
uc16 mask,
|
||||
Label* on_not_equal) {
|
||||
void RegExpBytecodeGenerator::CheckNotCharacterAfterMinusAnd(
|
||||
uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) {
|
||||
Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c);
|
||||
Emit16(minus);
|
||||
Emit16(mask);
|
||||
EmitOrLink(on_not_equal);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckCharacterInRange(
|
||||
uc16 from,
|
||||
uc16 to,
|
||||
Label* on_in_range) {
|
||||
void RegExpBytecodeGenerator::CheckCharacterInRange(uc16 from, uc16 to,
|
||||
Label* on_in_range) {
|
||||
Emit(BC_CHECK_CHAR_IN_RANGE, 0);
|
||||
Emit16(from);
|
||||
Emit16(to);
|
||||
EmitOrLink(on_in_range);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckCharacterNotInRange(
|
||||
uc16 from,
|
||||
uc16 to,
|
||||
Label* on_not_in_range) {
|
||||
void RegExpBytecodeGenerator::CheckCharacterNotInRange(uc16 from, uc16 to,
|
||||
Label* on_not_in_range) {
|
||||
Emit(BC_CHECK_CHAR_NOT_IN_RANGE, 0);
|
||||
Emit16(from);
|
||||
Emit16(to);
|
||||
EmitOrLink(on_not_in_range);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckBitInTable(
|
||||
Handle<ByteArray> table, Label* on_bit_set) {
|
||||
void RegExpBytecodeGenerator::CheckBitInTable(Handle<ByteArray> table,
|
||||
Label* on_bit_set) {
|
||||
Emit(BC_CHECK_BIT_IN_TABLE, 0);
|
||||
EmitOrLink(on_bit_set);
|
||||
for (int i = 0; i < kTableSize; i += kBitsPerByte) {
|
||||
@ -365,10 +306,9 @@ void RegExpMacroAssemblerIrregexp::CheckBitInTable(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg,
|
||||
bool read_backward,
|
||||
Label* on_not_equal) {
|
||||
void RegExpBytecodeGenerator::CheckNotBackReference(int start_reg,
|
||||
bool read_backward,
|
||||
Label* on_not_equal) {
|
||||
DCHECK_LE(0, start_reg);
|
||||
DCHECK_GE(kMaxRegister, start_reg);
|
||||
Emit(read_backward ? BC_CHECK_NOT_BACK_REF_BACKWARD : BC_CHECK_NOT_BACK_REF,
|
||||
@ -376,8 +316,7 @@ void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg,
|
||||
EmitOrLink(on_not_equal);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase(
|
||||
void RegExpBytecodeGenerator::CheckNotBackReferenceIgnoreCase(
|
||||
int start_reg, bool read_backward, bool unicode, Label* on_not_equal) {
|
||||
DCHECK_LE(0, start_reg);
|
||||
DCHECK_GE(kMaxRegister, start_reg);
|
||||
@ -389,10 +328,8 @@ void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase(
|
||||
EmitOrLink(on_not_equal);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index,
|
||||
int comparand,
|
||||
Label* on_less_than) {
|
||||
void RegExpBytecodeGenerator::IfRegisterLT(int register_index, int comparand,
|
||||
Label* on_less_than) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_CHECK_REGISTER_LT, register_index);
|
||||
@ -400,10 +337,8 @@ void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index,
|
||||
EmitOrLink(on_less_than);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index,
|
||||
int comparand,
|
||||
Label* on_greater_or_equal) {
|
||||
void RegExpBytecodeGenerator::IfRegisterGE(int register_index, int comparand,
|
||||
Label* on_greater_or_equal) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_CHECK_REGISTER_GE, register_index);
|
||||
@ -411,18 +346,15 @@ void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index,
|
||||
EmitOrLink(on_greater_or_equal);
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(int register_index,
|
||||
Label* on_eq) {
|
||||
void RegExpBytecodeGenerator::IfRegisterEqPos(int register_index,
|
||||
Label* on_eq) {
|
||||
DCHECK_LE(0, register_index);
|
||||
DCHECK_GE(kMaxRegister, register_index);
|
||||
Emit(BC_CHECK_REGISTER_EQ_POS, register_index);
|
||||
EmitOrLink(on_eq);
|
||||
}
|
||||
|
||||
|
||||
Handle<HeapObject> RegExpMacroAssemblerIrregexp::GetCode(
|
||||
Handle<String> source) {
|
||||
Handle<HeapObject> RegExpBytecodeGenerator::GetCode(Handle<String> source) {
|
||||
Bind(&backtrack_);
|
||||
Emit(BC_POP_BT, 0);
|
||||
Handle<ByteArray> array = isolate_->factory()->NewByteArray(length());
|
||||
@ -430,17 +362,13 @@ Handle<HeapObject> RegExpMacroAssemblerIrregexp::GetCode(
|
||||
return array;
|
||||
}
|
||||
|
||||
int RegExpBytecodeGenerator::length() { return pc_; }
|
||||
|
||||
int RegExpMacroAssemblerIrregexp::length() {
|
||||
return pc_;
|
||||
}
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Copy(byte* a) {
|
||||
void RegExpBytecodeGenerator::Copy(byte* a) {
|
||||
MemCopy(a, buffer_.begin(), length());
|
||||
}
|
||||
|
||||
|
||||
void RegExpMacroAssemblerIrregexp::Expand() {
|
||||
void RegExpBytecodeGenerator::Expand() {
|
||||
bool old_buffer_was_our_own = own_buffer_;
|
||||
Vector<byte> old_buffer = buffer_;
|
||||
buffer_ = Vector<byte>::New(old_buffer.length() * 2);
|
@ -2,17 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_
|
||||
#define V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_
|
||||
#ifndef V8_REGEXP_REGEXP_BYTECODE_GENERATOR_H_
|
||||
#define V8_REGEXP_REGEXP_BYTECODE_GENERATOR_H_
|
||||
|
||||
#include "src/regexp/regexp-macro-assembler.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
// A light-weight assembler for the Irregexp byte code.
|
||||
class V8_EXPORT_PRIVATE RegExpMacroAssemblerIrregexp
|
||||
: public RegExpMacroAssembler {
|
||||
// An assembler/generator for the Irregexp byte code.
|
||||
class V8_EXPORT_PRIVATE RegExpBytecodeGenerator : public RegExpMacroAssembler {
|
||||
public:
|
||||
// Create an assembler. Instructions and relocation information are emitted
|
||||
// into a buffer, with the instructions starting from the beginning and the
|
||||
@ -22,8 +21,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerIrregexp
|
||||
// The assembler allocates and grows its own buffer, and buffer_size
|
||||
// determines the initial buffer size. The buffer is owned by the assembler
|
||||
// and deallocated upon destruction of the assembler.
|
||||
RegExpMacroAssemblerIrregexp(Isolate* isolate, Zone* zone);
|
||||
virtual ~RegExpMacroAssemblerIrregexp();
|
||||
RegExpBytecodeGenerator(Isolate* isolate, Zone* zone);
|
||||
virtual ~RegExpBytecodeGenerator();
|
||||
// The byte-code interpreter checks on each push anyway.
|
||||
virtual int stack_limit_slack() { return 1; }
|
||||
virtual bool CanReadUnaligned() { return false; }
|
||||
@ -47,13 +46,11 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerIrregexp
|
||||
virtual void ReadCurrentPositionFromRegister(int reg);
|
||||
virtual void WriteStackPointerToRegister(int reg);
|
||||
virtual void ReadStackPointerFromRegister(int reg);
|
||||
virtual void LoadCurrentCharacter(int cp_offset,
|
||||
Label* on_end_of_input,
|
||||
virtual void LoadCurrentCharacter(int cp_offset, Label* on_end_of_input,
|
||||
bool check_bounds = true,
|
||||
int characters = 1);
|
||||
virtual void CheckCharacter(unsigned c, Label* on_equal);
|
||||
virtual void CheckCharacterAfterAnd(unsigned c,
|
||||
unsigned mask,
|
||||
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);
|
||||
@ -61,18 +58,12 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerIrregexp
|
||||
virtual void CheckAtStart(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,
|
||||
virtual void CheckNotCharacterAfterAnd(unsigned c, unsigned mask,
|
||||
Label* on_not_equal);
|
||||
virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
|
||||
uc16 minus,
|
||||
uc16 mask,
|
||||
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,
|
||||
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,
|
||||
@ -115,10 +106,10 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerIrregexp
|
||||
|
||||
static const int kInvalidPC = -1;
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(RegExpMacroAssemblerIrregexp);
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(RegExpBytecodeGenerator);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_
|
||||
#endif // V8_REGEXP_REGEXP_BYTECODE_GENERATOR_H_
|
@ -7,11 +7,11 @@
|
||||
#include "src/codegen/compilation-cache.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/objects/js-regexp-inl.h"
|
||||
#include "src/regexp/regexp-bytecode-generator.h"
|
||||
#include "src/regexp/regexp-compiler.h"
|
||||
#include "src/regexp/regexp-dotprinter.h"
|
||||
#include "src/regexp/regexp-interpreter.h"
|
||||
#include "src/regexp/regexp-macro-assembler-arch.h"
|
||||
#include "src/regexp/regexp-macro-assembler-irregexp.h"
|
||||
#include "src/regexp/regexp-parser.h"
|
||||
#include "src/strings/string-search.h"
|
||||
|
||||
@ -755,7 +755,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data,
|
||||
DCHECK(FLAG_regexp_interpret_all);
|
||||
|
||||
// Interpreted regexp implementation.
|
||||
macro_assembler.reset(new RegExpMacroAssemblerIrregexp(isolate, zone));
|
||||
macro_assembler.reset(new RegExpBytecodeGenerator(isolate, zone));
|
||||
}
|
||||
|
||||
macro_assembler->set_slow_safe(TooMuchRegExpCode(isolate, pattern));
|
||||
|
@ -36,10 +36,10 @@
|
||||
#include "src/codegen/macro-assembler.h"
|
||||
#include "src/init/v8.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "src/regexp/regexp-bytecode-generator.h"
|
||||
#include "src/regexp/regexp-compiler.h"
|
||||
#include "src/regexp/regexp-interpreter.h"
|
||||
#include "src/regexp/regexp-macro-assembler-arch.h"
|
||||
#include "src/regexp/regexp-macro-assembler-irregexp.h"
|
||||
#include "src/regexp/regexp-parser.h"
|
||||
#include "src/regexp/regexp.h"
|
||||
#include "src/strings/char-predicates-inl.h"
|
||||
@ -1254,7 +1254,7 @@ TEST(MacroAssemblerNativeLotsOfRegisters) {
|
||||
|
||||
TEST(MacroAssembler) {
|
||||
Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
|
||||
RegExpMacroAssemblerIrregexp m(CcTest::i_isolate(), &zone);
|
||||
RegExpBytecodeGenerator m(CcTest::i_isolate(), &zone);
|
||||
// ^f(o)o.
|
||||
Label start, fail, backtrack;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user