| Index: runtime/vm/regexp_assembler_bytecode.cc
|
| diff --git a/runtime/vm/regexp_assembler_bytecode.cc b/runtime/vm/regexp_assembler_bytecode.cc
|
| index 4f31fcfbbe42ce160ac56f3d6b926a985e8d2b87..01a52599e0fdb35d5a375f926b04e6120a75ed53 100644
|
| --- a/runtime/vm/regexp_assembler_bytecode.cc
|
| +++ b/runtime/vm/regexp_assembler_bytecode.cc
|
| @@ -4,14 +4,14 @@
|
|
|
| #include "vm/regexp_assembler_bytecode.h"
|
|
|
| -#include "vm/regexp_assembler_bytecode_inl.h"
|
| #include "vm/exceptions.h"
|
| #include "vm/object_store.h"
|
| -#include "vm/regexp_bytecodes.h"
|
| -#include "vm/regexp_assembler.h"
|
| #include "vm/regexp.h"
|
| -#include "vm/regexp_parser.h"
|
| +#include "vm/regexp_assembler.h"
|
| +#include "vm/regexp_assembler_bytecode_inl.h"
|
| +#include "vm/regexp_bytecodes.h"
|
| #include "vm/regexp_interpreter.h"
|
| +#include "vm/regexp_parser.h"
|
| #include "vm/timeline.h"
|
|
|
| namespace dart {
|
| @@ -24,18 +24,15 @@ BytecodeRegExpMacroAssembler::BytecodeRegExpMacroAssembler(
|
| pc_(0),
|
| advance_current_end_(kInvalidPC) {}
|
|
|
| -
|
| BytecodeRegExpMacroAssembler::~BytecodeRegExpMacroAssembler() {
|
| if (backtrack_.is_linked()) backtrack_.Unuse();
|
| }
|
|
|
| -
|
| BytecodeRegExpMacroAssembler::IrregexpImplementation
|
| BytecodeRegExpMacroAssembler::Implementation() {
|
| return kBytecodeImplementation;
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::BindBlock(BlockLabel* l) {
|
| advance_current_end_ = kInvalidPC;
|
| ASSERT(!l->is_bound());
|
| @@ -50,7 +47,6 @@ void BytecodeRegExpMacroAssembler::BindBlock(BlockLabel* l) {
|
| l->bind_to(pc_);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::EmitOrLink(BlockLabel* l) {
|
| if (l == NULL) l = &backtrack_;
|
| if (l->is_bound()) {
|
| @@ -65,21 +61,18 @@ void BytecodeRegExpMacroAssembler::EmitOrLink(BlockLabel* l) {
|
| }
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::PopRegister(intptr_t register_index) {
|
| ASSERT(register_index >= 0);
|
| ASSERT(register_index <= kMaxRegister);
|
| Emit(BC_POP_REGISTER, register_index);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::PushRegister(intptr_t register_index) {
|
| ASSERT(register_index >= 0);
|
| ASSERT(register_index <= kMaxRegister);
|
| Emit(BC_PUSH_REGISTER, register_index);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::WriteCurrentPositionToRegister(
|
| intptr_t register_index,
|
| intptr_t cp_offset) {
|
| @@ -89,7 +82,6 @@ void BytecodeRegExpMacroAssembler::WriteCurrentPositionToRegister(
|
| Emit32(cp_offset); // Current position offset.
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::ClearRegisters(intptr_t reg_from,
|
| intptr_t reg_to) {
|
| ASSERT(reg_from <= reg_to);
|
| @@ -98,7 +90,6 @@ void BytecodeRegExpMacroAssembler::ClearRegisters(intptr_t reg_from,
|
| }
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::ReadCurrentPositionFromRegister(
|
| intptr_t register_index) {
|
| ASSERT(register_index >= 0);
|
| @@ -106,7 +97,6 @@ void BytecodeRegExpMacroAssembler::ReadCurrentPositionFromRegister(
|
| Emit(BC_SET_CP_TO_REGISTER, register_index);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::WriteStackPointerToRegister(
|
| intptr_t register_index) {
|
| ASSERT(register_index >= 0);
|
| @@ -114,7 +104,6 @@ void BytecodeRegExpMacroAssembler::WriteStackPointerToRegister(
|
| Emit(BC_SET_REGISTER_TO_SP, register_index);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::ReadStackPointerFromRegister(
|
| intptr_t register_index) {
|
| ASSERT(register_index >= 0);
|
| @@ -122,13 +111,11 @@ void BytecodeRegExpMacroAssembler::ReadStackPointerFromRegister(
|
| Emit(BC_SET_SP_TO_REGISTER, register_index);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::SetCurrentPositionFromEnd(intptr_t by) {
|
| ASSERT(Utils::IsUint(24, by));
|
| Emit(BC_SET_CURRENT_POSITION_FROM_END, by);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::SetRegister(intptr_t register_index,
|
| intptr_t to) {
|
| ASSERT(register_index >= 0);
|
| @@ -137,7 +124,6 @@ void BytecodeRegExpMacroAssembler::SetRegister(intptr_t register_index,
|
| Emit32(to);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::AdvanceRegister(intptr_t register_index,
|
| intptr_t by) {
|
| ASSERT(register_index >= 0);
|
| @@ -146,22 +132,18 @@ void BytecodeRegExpMacroAssembler::AdvanceRegister(intptr_t register_index,
|
| Emit32(by);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::PopCurrentPosition() {
|
| Emit(BC_POP_CP, 0);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::PushCurrentPosition() {
|
| Emit(BC_PUSH_CP, 0);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::Backtrack() {
|
| Emit(BC_POP_BT, 0);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::GoTo(BlockLabel* l) {
|
| if (advance_current_end_ == pc_) {
|
| // Combine advance current and goto.
|
| @@ -176,24 +158,20 @@ void BytecodeRegExpMacroAssembler::GoTo(BlockLabel* l) {
|
| }
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::PushBacktrack(BlockLabel* l) {
|
| Emit(BC_PUSH_BT, 0);
|
| EmitOrLink(l);
|
| }
|
|
|
| -
|
| bool BytecodeRegExpMacroAssembler::Succeed() {
|
| Emit(BC_SUCCEED, 0);
|
| return false; // Restart matching for global regexp not supported.
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::Fail() {
|
| Emit(BC_FAIL, 0);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::AdvanceCurrentPosition(intptr_t by) {
|
| ASSERT(by >= kMinCPOffset);
|
| ASSERT(by <= kMaxCPOffset);
|
| @@ -203,14 +181,12 @@ void BytecodeRegExpMacroAssembler::AdvanceCurrentPosition(intptr_t by) {
|
| advance_current_end_ = pc_;
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckGreedyLoop(
|
| BlockLabel* on_tos_equals_current_position) {
|
| Emit(BC_CHECK_GREEDY, 0);
|
| EmitOrLink(on_tos_equals_current_position);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::LoadCurrentCharacter(intptr_t cp_offset,
|
| BlockLabel* on_failure,
|
| bool check_bounds,
|
| @@ -241,21 +217,18 @@ void BytecodeRegExpMacroAssembler::LoadCurrentCharacter(intptr_t cp_offset,
|
| if (check_bounds) EmitOrLink(on_failure);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckCharacterLT(uint16_t limit,
|
| BlockLabel* on_less) {
|
| Emit(BC_CHECK_LT, limit);
|
| EmitOrLink(on_less);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckCharacterGT(uint16_t limit,
|
| BlockLabel* on_greater) {
|
| Emit(BC_CHECK_GT, limit);
|
| EmitOrLink(on_greater);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckCharacter(uint32_t c,
|
| BlockLabel* on_equal) {
|
| if (c > MAX_FIRST_ARG) {
|
| @@ -267,20 +240,17 @@ void BytecodeRegExpMacroAssembler::CheckCharacter(uint32_t c,
|
| EmitOrLink(on_equal);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckAtStart(BlockLabel* on_at_start) {
|
| Emit(BC_CHECK_AT_START, 0);
|
| EmitOrLink(on_at_start);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckNotAtStart(
|
| BlockLabel* on_not_at_start) {
|
| Emit(BC_CHECK_NOT_AT_START, 0);
|
| EmitOrLink(on_not_at_start);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckNotCharacter(uint32_t c,
|
| BlockLabel* on_not_equal) {
|
| if (c > MAX_FIRST_ARG) {
|
| @@ -292,7 +262,6 @@ void BytecodeRegExpMacroAssembler::CheckNotCharacter(uint32_t c,
|
| EmitOrLink(on_not_equal);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckCharacterAfterAnd(
|
| uint32_t c,
|
| uint32_t mask,
|
| @@ -307,7 +276,6 @@ void BytecodeRegExpMacroAssembler::CheckCharacterAfterAnd(
|
| EmitOrLink(on_equal);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckNotCharacterAfterAnd(
|
| uint32_t c,
|
| uint32_t mask,
|
| @@ -322,7 +290,6 @@ void BytecodeRegExpMacroAssembler::CheckNotCharacterAfterAnd(
|
| EmitOrLink(on_not_equal);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckNotCharacterAfterMinusAnd(
|
| uint16_t c,
|
| uint16_t minus,
|
| @@ -334,7 +301,6 @@ void BytecodeRegExpMacroAssembler::CheckNotCharacterAfterMinusAnd(
|
| EmitOrLink(on_not_equal);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckCharacterInRange(
|
| uint16_t from,
|
| uint16_t to,
|
| @@ -345,7 +311,6 @@ void BytecodeRegExpMacroAssembler::CheckCharacterInRange(
|
| EmitOrLink(on_in_range);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckCharacterNotInRange(
|
| uint16_t from,
|
| uint16_t to,
|
| @@ -356,7 +321,6 @@ void BytecodeRegExpMacroAssembler::CheckCharacterNotInRange(
|
| EmitOrLink(on_not_in_range);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckBitInTable(const TypedData& table,
|
| BlockLabel* on_bit_set) {
|
| Emit(BC_CHECK_BIT_IN_TABLE, 0);
|
| @@ -370,7 +334,6 @@ void BytecodeRegExpMacroAssembler::CheckBitInTable(const TypedData& table,
|
| }
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckNotBackReference(
|
| intptr_t start_reg,
|
| BlockLabel* on_not_equal) {
|
| @@ -380,7 +343,6 @@ void BytecodeRegExpMacroAssembler::CheckNotBackReference(
|
| EmitOrLink(on_not_equal);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase(
|
| intptr_t start_reg,
|
| BlockLabel* on_not_equal) {
|
| @@ -390,7 +352,6 @@ void BytecodeRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase(
|
| EmitOrLink(on_not_equal);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::IfRegisterLT(intptr_t register_index,
|
| intptr_t comparand,
|
| BlockLabel* on_less_than) {
|
| @@ -401,7 +362,6 @@ void BytecodeRegExpMacroAssembler::IfRegisterLT(intptr_t register_index,
|
| EmitOrLink(on_less_than);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::IfRegisterGE(
|
| intptr_t register_index,
|
| intptr_t comparand,
|
| @@ -413,7 +373,6 @@ void BytecodeRegExpMacroAssembler::IfRegisterGE(
|
| EmitOrLink(on_greater_or_equal);
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::IfRegisterEqPos(intptr_t register_index,
|
| BlockLabel* on_eq) {
|
| ASSERT(register_index >= 0);
|
| @@ -422,7 +381,6 @@ void BytecodeRegExpMacroAssembler::IfRegisterEqPos(intptr_t register_index,
|
| EmitOrLink(on_eq);
|
| }
|
|
|
| -
|
| RawTypedData* BytecodeRegExpMacroAssembler::GetBytecode() {
|
| BindBlock(&backtrack_);
|
| Emit(BC_POP_BT, 0);
|
| @@ -437,12 +395,10 @@ RawTypedData* BytecodeRegExpMacroAssembler::GetBytecode() {
|
| return bytecode.raw();
|
| }
|
|
|
| -
|
| intptr_t BytecodeRegExpMacroAssembler::length() {
|
| return pc_;
|
| }
|
|
|
| -
|
| void BytecodeRegExpMacroAssembler::Expand() {
|
| // BOGUS
|
| buffer_->Add(0);
|
| @@ -454,7 +410,6 @@ void BytecodeRegExpMacroAssembler::Expand() {
|
| buffer_->Add(0);
|
| }
|
|
|
| -
|
| static intptr_t Prepare(const RegExp& regexp,
|
| const String& subject,
|
| bool sticky,
|
| @@ -502,7 +457,6 @@ static intptr_t Prepare(const RegExp& regexp,
|
| (Smi::Value(regexp.num_bracket_expressions()) + 1) * 2;
|
| }
|
|
|
| -
|
| static IrregexpInterpreter::IrregexpResult ExecRaw(const RegExp& regexp,
|
| const String& subject,
|
| intptr_t index,
|
| @@ -549,7 +503,6 @@ static IrregexpInterpreter::IrregexpResult ExecRaw(const RegExp& regexp,
|
| return result;
|
| }
|
|
|
| -
|
| RawInstance* BytecodeRegExpMacroAssembler::Interpret(const RegExp& regexp,
|
| const String& subject,
|
| const Smi& start_index,
|
| @@ -599,5 +552,4 @@ RawInstance* BytecodeRegExpMacroAssembler::Interpret(const RegExp& regexp,
|
| return Instance::null();
|
| }
|
|
|
| -
|
| } // namespace dart
|
|
|