Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
dart::IRRegExpMacroAssembler Class Reference

#include <regexp_assembler_ir.h>

Inheritance diagram for dart::IRRegExpMacroAssembler:
dart::RegExpMacroAssembler dart::ZoneAllocated

Public Types

enum  Mode { ASCII = 1 , UC16 = 2 }
 
enum  Result { RETRY = -2 , EXCEPTION = -1 , FAILURE = 0 , SUCCESS = 1 }
 
- Public Types inherited from dart::RegExpMacroAssembler
enum  { kParamRegExpIndex = 0 , kParamStringIndex , kParamStartOffsetIndex , kParamCount }
 
enum  IrregexpImplementation { kBytecodeImplementation , kIRImplementation }
 
enum  GlobalMode { NOT_GLOBAL , GLOBAL , GLOBAL_NO_ZERO_LENGTH_CHECK , GLOBAL_UNICODE }
 

Public Member Functions

 IRRegExpMacroAssembler (intptr_t specialization_cid, intptr_t capture_count, const ParsedFunction *parsed_function, const ZoneGrowableArray< const ICData * > &ic_data_array, intptr_t osr_id, Zone *zone)
 
virtual ~IRRegExpMacroAssembler ()
 
virtual bool CanReadUnaligned ()
 
virtual bool IsClosed () const
 
virtual intptr_t stack_limit_slack ()
 
virtual void AdvanceCurrentPosition (intptr_t by)
 
virtual void AdvanceRegister (intptr_t reg, intptr_t by)
 
virtual void Backtrack ()
 
virtual void BindBlock (BlockLabel *label)
 
virtual void CheckAtStart (BlockLabel *on_at_start)
 
virtual void CheckCharacter (uint32_t c, BlockLabel *on_equal)
 
virtual void CheckCharacterAfterAnd (uint32_t c, uint32_t mask, BlockLabel *on_equal)
 
virtual void CheckCharacterGT (uint16_t limit, BlockLabel *on_greater)
 
virtual void CheckCharacterLT (uint16_t limit, BlockLabel *on_less)
 
virtual void CheckGreedyLoop (BlockLabel *on_tos_equals_current_position)
 
virtual void CheckNotAtStart (intptr_t cp_offset, BlockLabel *on_not_at_start)
 
virtual void CheckNotBackReference (intptr_t start_reg, bool read_backward, BlockLabel *on_no_match)
 
virtual void CheckNotBackReferenceIgnoreCase (intptr_t start_reg, bool read_backward, bool unicode, BlockLabel *on_no_match)
 
virtual void CheckNotCharacter (uint32_t c, BlockLabel *on_not_equal)
 
virtual void CheckNotCharacterAfterAnd (uint32_t c, uint32_t mask, BlockLabel *on_not_equal)
 
virtual void CheckNotCharacterAfterMinusAnd (uint16_t c, uint16_t minus, uint16_t mask, BlockLabel *on_not_equal)
 
virtual void CheckCharacterInRange (uint16_t from, uint16_t to, BlockLabel *on_in_range)
 
virtual void CheckCharacterNotInRange (uint16_t from, uint16_t to, BlockLabel *on_not_in_range)
 
virtual void CheckBitInTable (const TypedData &table, BlockLabel *on_bit_set)
 
virtual void CheckPosition (intptr_t cp_offset, BlockLabel *on_outside_input)
 
virtual bool CheckSpecialCharacterClass (uint16_t type, BlockLabel *on_no_match)
 
virtual void Fail ()
 
virtual void IfRegisterGE (intptr_t reg, intptr_t comparand, BlockLabel *if_ge)
 
virtual void IfRegisterLT (intptr_t reg, intptr_t comparand, BlockLabel *if_lt)
 
virtual void IfRegisterEqPos (intptr_t reg, BlockLabel *if_eq)
 
virtual IrregexpImplementation Implementation ()
 
virtual void GoTo (BlockLabel *to)
 
virtual void LoadCurrentCharacter (intptr_t cp_offset, BlockLabel *on_end_of_input, bool check_bounds=true, intptr_t characters=1)
 
virtual void PopCurrentPosition ()
 
virtual void PopRegister (intptr_t register_index)
 
virtual void Print (const char *str)
 
virtual void PushBacktrack (BlockLabel *label)
 
virtual void PushCurrentPosition ()
 
virtual void PushRegister (intptr_t register_index)
 
virtual void ReadCurrentPositionFromRegister (intptr_t reg)
 
virtual void ReadStackPointerFromRegister (intptr_t reg)
 
virtual void SetCurrentPositionFromEnd (intptr_t by)
 
virtual void SetRegister (intptr_t register_index, intptr_t to)
 
virtual bool Succeed ()
 
virtual void WriteCurrentPositionToRegister (intptr_t reg, intptr_t cp_offset)
 
virtual void ClearRegisters (intptr_t reg_from, intptr_t reg_to)
 
virtual void WriteStackPointerToRegister (intptr_t reg)
 
virtual void PrintBlocks ()
 
IndirectGotoInstrbacktrack_goto () const
 
GraphEntryInstrgraph_entry () const
 
intptr_t num_stack_locals () const
 
intptr_t num_blocks () const
 
void GenerateBacktrackBlock ()
 
void FinalizeRegistersArray ()
 
- Public Member Functions inherited from dart::RegExpMacroAssembler
 RegExpMacroAssembler (Zone *zone)
 
virtual ~RegExpMacroAssembler ()
 
virtual void CheckCharacter (unsigned c, BlockLabel *on_equal)=0
 
virtual void CheckCharacterAfterAnd (unsigned c, unsigned and_with, BlockLabel *on_equal)=0
 
virtual void CheckNotCharacter (unsigned c, BlockLabel *on_not_equal)=0
 
virtual void CheckNotCharacterAfterAnd (unsigned c, unsigned and_with, BlockLabel *on_not_equal)=0
 
void CheckNotInSurrogatePair (intptr_t cp_offset, BlockLabel *on_failure)
 
void set_slow_safe (bool ssc)
 
bool slow_safe ()
 
void set_global_mode (GlobalMode mode)
 
bool global ()
 
bool global_with_zero_length_check ()
 
bool global_unicode ()
 
Zonezone () const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static ArrayPtr Execute (const RegExp &regexp, const String &input, const Smi &start_offset, bool sticky, Zone *zone)
 

Additional Inherited Members

- Static Public Attributes inherited from dart::RegExpMacroAssembler
static constexpr intptr_t kMaxRegister = (1 << 16) - 1
 
static constexpr intptr_t kMaxCPOffset = (1 << 15) - 1
 
static constexpr intptr_t kMinCPOffset = -(1 << 15)
 
static constexpr intptr_t kTableSizeBits = 7
 
static constexpr intptr_t kTableSize = 1 << kTableSizeBits
 
static constexpr intptr_t kTableMask = kTableSize - 1
 

Detailed Description

Definition at line 15 of file regexp_assembler_ir.h.

Member Enumeration Documentation

◆ Mode

Enumerator
ASCII 
UC16 

Definition at line 18 of file regexp_assembler_ir.h.

◆ Result

Enumerator
RETRY 
EXCEPTION 
FAILURE 
SUCCESS 

Definition at line 29 of file regexp_assembler_ir.h.

Constructor & Destructor Documentation

◆ IRRegExpMacroAssembler()

dart::IRRegExpMacroAssembler::IRRegExpMacroAssembler ( intptr_t  specialization_cid,
intptr_t  capture_count,
const ParsedFunction parsed_function,
const ZoneGrowableArray< const ICData * > &  ic_data_array,
intptr_t  osr_id,
Zone zone 
)

Definition at line 66 of file regexp_assembler_ir.cc.

74 thread_(Thread::Current()),
75 specialization_cid_(specialization_cid),
76 parsed_function_(parsed_function),
77 ic_data_array_(ic_data_array),
78 current_instruction_(nullptr),
79 stack_(nullptr),
80 stack_pointer_(nullptr),
81 current_character_(nullptr),
82 current_position_(nullptr),
83 string_param_(nullptr),
84 string_param_length_(nullptr),
85 start_index_param_(nullptr),
86 registers_count_(0),
87 saved_registers_count_((capture_count + 1) * 2),
88 // B0 is taken by GraphEntry thus block ids must start at 1.
89 block_id_(1) {
90 switch (specialization_cid) {
91 case kOneByteStringCid:
92 mode_ = ASCII;
93 break;
94 case kTwoByteStringCid:
95 mode_ = UC16;
96 break;
97 default:
99 }
100
101 InitializeLocals();
102
103 // Create and generate all preset blocks.
104 entry_block_ = new (zone) GraphEntryInstr(*parsed_function_, osr_id);
105
106 auto function_entry = new (zone) FunctionEntryInstr(
107 entry_block_, block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId());
108 entry_block_->set_normal_entry(function_entry);
109
110 start_block_ = new (zone)
111 JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId());
112 success_block_ = new (zone)
113 JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId());
114 backtrack_block_ = new (zone)
115 JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId());
116 exit_block_ = new (zone)
117 JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId());
118
119 GenerateEntryBlock();
120 GenerateSuccessBlock();
121 GenerateExitBlock();
122
123 blocks_.Add(entry_block_);
124 blocks_.Add(entry_block_->normal_entry());
125 blocks_.Add(start_block_);
126 blocks_.Add(success_block_);
127 blocks_.Add(backtrack_block_);
128 blocks_.Add(exit_block_);
129
130 // Begin emission at the start_block_.
131 set_current_instruction(start_block_);
132}
#define UNREACHABLE()
Definition assert.h:248
FunctionEntryInstr * normal_entry() const
Definition il.h:1986
void set_normal_entry(FunctionEntryInstr *entry)
Definition il.h:1988
static Thread * Current()
Definition thread.h:361
static constexpr intptr_t kInvalidTryIndex

◆ ~IRRegExpMacroAssembler()

dart::IRRegExpMacroAssembler::~IRRegExpMacroAssembler ( )
virtual

Definition at line 134 of file regexp_assembler_ir.cc.

134{}

Member Function Documentation

◆ AdvanceCurrentPosition()

void dart::IRRegExpMacroAssembler::AdvanceCurrentPosition ( intptr_t  by)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 631 of file regexp_assembler_ir.cc.

631 {
632 TAG();
633 if (by != 0) {
634 Value* cur_pos_push = PushLocal(current_position_);
635 Value* by_push = Bind(Int64Constant(by));
636
637 Value* new_pos_value = Bind(Add(cur_pos_push, by_push));
638 StoreLocal(current_position_, new_pos_value);
639 }
640}
#define TAG()

◆ AdvanceRegister()

void dart::IRRegExpMacroAssembler::AdvanceRegister ( intptr_t  reg,
intptr_t  by 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 642 of file regexp_assembler_ir.cc.

642 {
643 TAG();
644 ASSERT(reg >= 0);
645 ASSERT(reg < registers_count_);
646
647 if (by != 0) {
648 Value* registers_push = PushLocal(registers_);
649 Value* index_push = PushRegisterIndex(reg);
650 Value* reg_push = LoadRegister(reg);
651 Value* by_push = Bind(Int64Constant(by));
652 Value* value_push = Bind(Add(reg_push, by_push));
653 StoreRegister(registers_push, index_push, value_push);
654 }
655}
#define ASSERT(E)

◆ Backtrack()

void dart::IRRegExpMacroAssembler::Backtrack ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 657 of file regexp_assembler_ir.cc.

657 {
658 TAG();
659 GoTo(backtrack_block_);
660}
virtual void GoTo(BlockLabel *to)

◆ backtrack_goto()

IndirectGotoInstr * dart::IRRegExpMacroAssembler::backtrack_goto ( ) const
inline

Definition at line 124 of file regexp_assembler_ir.h.

124{ return backtrack_goto_; }

◆ BindBlock()

void dart::IRRegExpMacroAssembler::BindBlock ( BlockLabel label)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 665 of file regexp_assembler_ir.cc.

665 {
666 ASSERT(!label->is_bound());
667 ASSERT(label->block()->next() == nullptr);
668
669 label->BindTo(block_id_.Alloc());
670 blocks_.Add(label->block());
671
672 if (current_instruction_ != nullptr) {
673 GoTo(label);
674 }
675 set_current_instruction(label->block());
676
677 // Print the id of the current block if tracing.
678 PRINT(Bind(Uint64Constant(label->block()->block_id())));
679}
#define PRINT(arg)

◆ CanReadUnaligned()

bool dart::IRRegExpMacroAssembler::CanReadUnaligned ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 281 of file regexp_assembler_ir.cc.

281 {
282 return !slow_safe();
283}

◆ CheckAtStart()

void dart::IRRegExpMacroAssembler::CheckAtStart ( BlockLabel on_at_start)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 731 of file regexp_assembler_ir.cc.

731 {
732 TAG();
733
734 // Are we at the start of the input, i.e. is (offset == string_length * -1)?
735 Definition* neg_len_def =
736 InstanceCall(InstanceCallDescriptor::FromToken(Token::kNEGATE),
737 PushLocal(string_param_length_));
738 Definition* offset_def = LoadLocal(current_position_);
739 BranchOrBacktrack(Comparison(kEQ, neg_len_def, offset_def), on_at_start);
740}

◆ CheckBitInTable()

void dart::IRRegExpMacroAssembler::CheckBitInTable ( const TypedData table,
BlockLabel on_bit_set 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1166 of file regexp_assembler_ir.cc.

1167 {
1168 TAG();
1169
1170 Value* table_push = Bind(new (Z) ConstantInstr(table));
1171 Value* index_push = PushLocal(current_character_);
1172
1173 if (mode_ != ASCII || kTableMask != Symbols::kMaxOneCharCodeSymbol) {
1174 Value* mask_push = Bind(Uint64Constant(kTableSize - 1));
1175 index_push =
1176 Bind(InstanceCall(InstanceCallDescriptor::FromToken(Token::kBIT_AND),
1177 index_push, mask_push));
1178 }
1179
1180 Definition* byte_def = InstanceCall(
1181 InstanceCallDescriptor::FromToken(Token::kINDEX), table_push, index_push);
1182 Definition* zero_def = Int64Constant(0);
1183
1184 BranchOrBacktrack(Comparison(kNE, byte_def, zero_def), on_bit_set);
1185}
SI F table(const skcms_Curve *curve, F v)
#define Z
static constexpr intptr_t kTableMask
static constexpr intptr_t kTableSize
@ kMaxOneCharCodeSymbol
Definition symbols.h:576

◆ CheckCharacter()

void dart::IRRegExpMacroAssembler::CheckCharacter ( uint32_t  c,
BlockLabel on_equal 
)
virtual

Definition at line 715 of file regexp_assembler_ir.cc.

715 {
716 TAG();
717 Definition* cur_char_def = LoadLocal(current_character_);
718 Definition* char_def = Uint64Constant(c);
719
720 BranchOrBacktrack(Comparison(kEQ, cur_char_def, char_def), on_equal);
721}

◆ CheckCharacterAfterAnd()

void dart::IRRegExpMacroAssembler::CheckCharacterAfterAnd ( uint32_t  c,
uint32_t  mask,
BlockLabel on_equal 
)
virtual

Definition at line 1074 of file regexp_assembler_ir.cc.

1076 {
1077 TAG();
1078
1079 Definition* actual_def = LoadLocal(current_character_);
1080
1081 Value* actual_push = Bind(actual_def);
1082 Value* mask_push = Bind(Uint64Constant(mask));
1083 actual_def = InstanceCall(InstanceCallDescriptor::FromToken(Token::kBIT_AND),
1084 actual_push, mask_push);
1085 Definition* expected_def = Uint64Constant(c);
1086
1087 BranchOrBacktrack(Comparison(kEQ, actual_def, expected_def), on_equal);
1088}

◆ CheckCharacterGT()

void dart::IRRegExpMacroAssembler::CheckCharacterGT ( uint16_t  limit,
BlockLabel on_greater 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 723 of file regexp_assembler_ir.cc.

724 {
725 TAG();
726 BranchOrBacktrack(
727 Comparison(kGT, LoadLocal(current_character_), Uint64Constant(limit)),
728 on_greater);
729}

◆ CheckCharacterInRange()

void dart::IRRegExpMacroAssembler::CheckCharacterInRange ( uint16_t  from,
uint16_t  to,
BlockLabel on_in_range 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1129 of file regexp_assembler_ir.cc.

1131 {
1132 TAG();
1133 ASSERT(from <= to);
1134
1135 // TODO(zerny): All range comparisons could be done cheaper with unsigned
1136 // compares. This pattern repeats in various places.
1137
1138 BlockLabel on_not_in_range;
1139 BranchOrBacktrack(
1140 Comparison(kLT, LoadLocal(current_character_), Uint64Constant(from)),
1141 &on_not_in_range);
1142 BranchOrBacktrack(
1143 Comparison(kGT, LoadLocal(current_character_), Uint64Constant(to)),
1144 &on_not_in_range);
1145 BranchOrBacktrack(nullptr, on_in_range);
1146
1147 BindBlock(&on_not_in_range);
1148}
virtual void BindBlock(BlockLabel *label)

◆ CheckCharacterLT()

void dart::IRRegExpMacroAssembler::CheckCharacterLT ( uint16_t  limit,
BlockLabel on_less 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 758 of file regexp_assembler_ir.cc.

759 {
760 TAG();
761 BranchOrBacktrack(
762 Comparison(kLT, LoadLocal(current_character_), Uint64Constant(limit)),
763 on_less);
764}

◆ CheckCharacterNotInRange()

void dart::IRRegExpMacroAssembler::CheckCharacterNotInRange ( uint16_t  from,
uint16_t  to,
BlockLabel on_not_in_range 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1150 of file regexp_assembler_ir.cc.

1153 {
1154 TAG();
1155 ASSERT(from <= to);
1156
1157 BranchOrBacktrack(
1158 Comparison(kLT, LoadLocal(current_character_), Uint64Constant(from)),
1159 on_not_in_range);
1160
1161 BranchOrBacktrack(
1162 Comparison(kGT, LoadLocal(current_character_), Uint64Constant(to)),
1163 on_not_in_range);
1164}

◆ CheckGreedyLoop()

void dart::IRRegExpMacroAssembler::CheckGreedyLoop ( BlockLabel on_tos_equals_current_position)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 766 of file regexp_assembler_ir.cc.

766 {
767 TAG();
768
769 BlockLabel fallthrough;
770
771 Definition* head = PeekStack();
772 Definition* cur_pos_def = LoadLocal(current_position_);
773 BranchOrBacktrack(Comparison(kNE, head, cur_pos_def), &fallthrough);
774
775 // Pop, throwing away the value.
776 Do(PopStack());
777
778 BranchOrBacktrack(nullptr, on_equal);
779
780 BindBlock(&fallthrough);
781}

◆ CheckNotAtStart()

void dart::IRRegExpMacroAssembler::CheckNotAtStart ( intptr_t  cp_offset,
BlockLabel on_not_at_start 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 744 of file regexp_assembler_ir.cc.

745 {
746 TAG();
747
748 // Are we at the start of the input, i.e. is (offset == string_length * -1)?
749 auto neg_len_def =
750 Bind(InstanceCall(InstanceCallDescriptor::FromToken(Token::kNEGATE),
751 PushLocal(string_param_length_)));
752 auto current_pos_def = PushLocal(current_position_);
753 auto cp_offset_def = Bind(Int64Constant(cp_offset));
754 auto offset_def = Bind(Add(current_pos_def, cp_offset_def));
755 BranchOrBacktrack(Comparison(kNE, neg_len_def, offset_def), on_not_at_start);
756}

◆ CheckNotBackReference()

void dart::IRRegExpMacroAssembler::CheckNotBackReference ( intptr_t  start_reg,
bool  read_backward,
BlockLabel on_no_match 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 960 of file regexp_assembler_ir.cc.

962 {
963 TAG();
964 ASSERT(start_reg + 1 <= registers_count_);
965
966 BlockLabel fallthrough;
967 BlockLabel success;
968
969 // Find length of back-referenced capture.
970 Value* end_push = LoadRegister(start_reg + 1);
971 Value* start_push = LoadRegister(start_reg);
972 StoreLocal(capture_length_, Bind(Sub(end_push, start_push)));
973
974 // Fail on partial or illegal capture (start of capture after end of capture).
975 BranchOrBacktrack(
976 Comparison(kLT, LoadLocal(capture_length_), Uint64Constant(0)),
977 on_no_match);
978
979 // Succeed on empty capture (including no capture)
980 BranchOrBacktrack(
981 Comparison(kEQ, LoadLocal(capture_length_), Uint64Constant(0)),
982 &fallthrough);
983
984 Value* pos_push = nullptr;
985 Value* len_push = nullptr;
986
987 if (!read_backward) {
988 // Check that there are sufficient characters left in the input.
989 pos_push = PushLocal(current_position_);
990 len_push = PushLocal(capture_length_);
991 BranchOrBacktrack(
992 Comparison(kGT,
993 InstanceCall(InstanceCallDescriptor::FromToken(Token::kADD),
994 pos_push, len_push),
995 Uint64Constant(0)),
996 on_no_match);
997 }
998
999 // Compute pointers to match string and capture string.
1000 pos_push = PushLocal(current_position_);
1001 len_push = PushLocal(string_param_length_);
1002 StoreLocal(match_start_index_, Bind(Add(pos_push, len_push)));
1003
1004 if (read_backward) {
1005 // First check that there are enough characters before this point in
1006 // the string that we can match the backreference.
1007 BranchOrBacktrack(Comparison(kLT, LoadLocal(match_start_index_),
1008 LoadLocal(capture_length_)),
1009 on_no_match);
1010
1011 // The string to check is before the current position, not at it.
1012 pos_push = PushLocal(match_start_index_);
1013 len_push = PushLocal(capture_length_);
1014 StoreLocal(match_start_index_, Bind(Sub(pos_push, len_push)));
1015 }
1016
1017 pos_push = LoadRegister(start_reg);
1018 len_push = PushLocal(string_param_length_);
1019 StoreLocal(capture_start_index_, Bind(Add(pos_push, len_push)));
1020
1021 pos_push = PushLocal(match_start_index_);
1022 len_push = PushLocal(capture_length_);
1023 StoreLocal(match_end_index_, Bind(Add(pos_push, len_push)));
1024
1025 BlockLabel loop;
1026 BindBlock(&loop);
1027
1028 StoreLocal(char_in_capture_, CharacterAt(capture_start_index_));
1029 StoreLocal(char_in_match_, CharacterAt(match_start_index_));
1030
1031 BranchOrBacktrack(
1032 Comparison(kNE, LoadLocal(char_in_capture_), LoadLocal(char_in_match_)),
1033 on_no_match);
1034
1035 // Increment indexes into capture and match strings.
1036 Value* index_push = PushLocal(capture_start_index_);
1037 Value* inc_push = Bind(Uint64Constant(1));
1038 StoreLocal(capture_start_index_, Bind(Add(index_push, inc_push)));
1039
1040 index_push = PushLocal(match_start_index_);
1041 inc_push = Bind(Uint64Constant(1));
1042 StoreLocal(match_start_index_, Bind(Add(index_push, inc_push)));
1043
1044 // Check if we have reached end of match area.
1045 BranchOrBacktrack(Comparison(kLT, LoadLocal(match_start_index_),
1046 LoadLocal(match_end_index_)),
1047 &loop);
1048
1049 BindBlock(&success);
1050
1051 if (read_backward) {
1052 // Move current character position to start of match.
1053 pos_push = PushLocal(current_position_);
1054 len_push = PushLocal(capture_length_);
1055 StoreLocal(current_position_, Bind(Sub(pos_push, len_push)));
1056 } else {
1057 // Move current character position to position after match.
1058 Value* match_end_push = PushLocal(match_end_index_);
1059 len_push = PushLocal(string_param_length_);
1060 StoreLocal(current_position_, Bind(Sub(match_end_push, len_push)));
1061 }
1062
1063 BindBlock(&fallthrough);
1064}

◆ CheckNotBackReferenceIgnoreCase()

void dart::IRRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase ( intptr_t  start_reg,
bool  read_backward,
bool  unicode,
BlockLabel on_no_match 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 783 of file regexp_assembler_ir.cc.

787 {
788 TAG();
789 ASSERT(start_reg + 1 <= registers_count_);
790
791 BlockLabel fallthrough;
792
793 Value* end_push = LoadRegister(start_reg + 1);
794 Value* start_push = LoadRegister(start_reg);
795 StoreLocal(capture_length_, Bind(Sub(end_push, start_push)));
796
797 // The length of a capture should not be negative. This can only happen
798 // if the end of the capture is unrecorded, or at a point earlier than
799 // the start of the capture.
800 // BranchOrBacktrack(less, on_no_match);
801
802 BranchOrBacktrack(
803 Comparison(kLT, LoadLocal(capture_length_), Uint64Constant(0)),
804 on_no_match);
805
806 // If length is zero, either the capture is empty or it is completely
807 // uncaptured. In either case succeed immediately.
808 BranchOrBacktrack(
809 Comparison(kEQ, LoadLocal(capture_length_), Uint64Constant(0)),
810 &fallthrough);
811
812 Value* pos_push = nullptr;
813 Value* len_push = nullptr;
814
815 if (!read_backward) {
816 // Check that there are sufficient characters left in the input.
817 pos_push = PushLocal(current_position_);
818 len_push = PushLocal(capture_length_);
819 BranchOrBacktrack(
820 Comparison(kGT,
821 InstanceCall(InstanceCallDescriptor::FromToken(Token::kADD),
822 pos_push, len_push),
823 Uint64Constant(0)),
824 on_no_match);
825 }
826
827 pos_push = PushLocal(current_position_);
828 len_push = PushLocal(string_param_length_);
829 StoreLocal(match_start_index_, Bind(Add(pos_push, len_push)));
830
831 if (read_backward) {
832 // First check that there are enough characters before this point in
833 // the string that we can match the backreference.
834 BranchOrBacktrack(Comparison(kLT, LoadLocal(match_start_index_),
835 LoadLocal(capture_length_)),
836 on_no_match);
837
838 // The string to check is before the current position, not at it.
839 pos_push = PushLocal(match_start_index_);
840 len_push = PushLocal(capture_length_);
841 StoreLocal(match_start_index_, Bind(Sub(pos_push, len_push)));
842 }
843
844 pos_push = LoadRegister(start_reg);
845 len_push = PushLocal(string_param_length_);
846 StoreLocal(capture_start_index_, Bind(Add(pos_push, len_push)));
847
848 pos_push = PushLocal(match_start_index_);
849 len_push = PushLocal(capture_length_);
850 StoreLocal(match_end_index_, Bind(Add(pos_push, len_push)));
851
852 BlockLabel success;
853 if (mode_ == ASCII) {
854 BlockLabel loop_increment;
855 BlockLabel loop;
856 BindBlock(&loop);
857
858 StoreLocal(char_in_capture_, CharacterAt(capture_start_index_));
859 StoreLocal(char_in_match_, CharacterAt(match_start_index_));
860
861 BranchOrBacktrack(
862 Comparison(kEQ, LoadLocal(char_in_capture_), LoadLocal(char_in_match_)),
863 &loop_increment);
864
865 // Mismatch, try case-insensitive match (converting letters to lower-case).
866 Value* match_char_push = PushLocal(char_in_match_);
867 Value* mask_push = Bind(Uint64Constant(0x20));
868 StoreLocal(
869 char_in_match_,
870 Bind(InstanceCall(InstanceCallDescriptor::FromToken(Token::kBIT_OR),
871 match_char_push, mask_push)));
872
873 BlockLabel convert_capture;
874 BlockLabel on_not_in_range;
875 BranchOrBacktrack(
876 Comparison(kLT, LoadLocal(char_in_match_), Uint64Constant('a')),
877 &on_not_in_range);
878 BranchOrBacktrack(
879 Comparison(kGT, LoadLocal(char_in_match_), Uint64Constant('z')),
880 &on_not_in_range);
881 GoTo(&convert_capture);
882 BindBlock(&on_not_in_range);
883
884 // Latin-1: Check for values in range [224,254] but not 247.
885 BranchOrBacktrack(
886 Comparison(kLT, LoadLocal(char_in_match_), Uint64Constant(224)),
887 on_no_match);
888 BranchOrBacktrack(
889 Comparison(kGT, LoadLocal(char_in_match_), Uint64Constant(254)),
890 on_no_match);
891
892 BranchOrBacktrack(
893 Comparison(kEQ, LoadLocal(char_in_match_), Uint64Constant(247)),
894 on_no_match);
895
896 // Also convert capture character.
897 BindBlock(&convert_capture);
898
899 Value* capture_char_push = PushLocal(char_in_capture_);
900 mask_push = Bind(Uint64Constant(0x20));
901 StoreLocal(
902 char_in_capture_,
903 Bind(InstanceCall(InstanceCallDescriptor::FromToken(Token::kBIT_OR),
904 capture_char_push, mask_push)));
905
906 BranchOrBacktrack(
907 Comparison(kNE, LoadLocal(char_in_match_), LoadLocal(char_in_capture_)),
908 on_no_match);
909
910 BindBlock(&loop_increment);
911
912 // Increment indexes into capture and match strings.
913 Value* index_push = PushLocal(capture_start_index_);
914 Value* inc_push = Bind(Uint64Constant(1));
915 StoreLocal(capture_start_index_, Bind(Add(index_push, inc_push)));
916
917 index_push = PushLocal(match_start_index_);
918 inc_push = Bind(Uint64Constant(1));
919 StoreLocal(match_start_index_, Bind(Add(index_push, inc_push)));
920
921 // Compare to end of match, and loop if not done.
922 BranchOrBacktrack(Comparison(kLT, LoadLocal(match_start_index_),
923 LoadLocal(match_end_index_)),
924 &loop);
925 } else {
926 ASSERT(mode_ == UC16);
927
928 Value* string_value = Bind(LoadLocal(string_param_));
929 Value* lhs_index_value = Bind(LoadLocal(match_start_index_));
930 Value* rhs_index_value = Bind(LoadLocal(capture_start_index_));
931 Value* length_value = Bind(LoadLocal(capture_length_));
932
933 Definition* is_match_def;
934
935 is_match_def = new (Z) CaseInsensitiveCompareInstr(
936 string_value, lhs_index_value, rhs_index_value, length_value,
937 /*handle_surrogates=*/unicode, specialization_cid_);
938
939 BranchOrBacktrack(Comparison(kNE, is_match_def, BoolConstant(true)),
940 on_no_match);
941 }
942
943 BindBlock(&success);
944
945 if (read_backward) {
946 // Move current character position to start of match.
947 pos_push = PushLocal(current_position_);
948 len_push = PushLocal(capture_length_);
949 StoreLocal(current_position_, Bind(Sub(pos_push, len_push)));
950 } else {
951 // Move current character position to position after match.
952 Value* match_end_push = PushLocal(match_end_index_);
953 len_push = PushLocal(string_param_length_);
954 StoreLocal(current_position_, Bind(Sub(match_end_push, len_push)));
955 }
956
957 BindBlock(&fallthrough);
958}

◆ CheckNotCharacter()

void dart::IRRegExpMacroAssembler::CheckNotCharacter ( uint32_t  c,
BlockLabel on_not_equal 
)
virtual

Definition at line 1066 of file regexp_assembler_ir.cc.

1067 {
1068 TAG();
1069 BranchOrBacktrack(
1070 Comparison(kNE, LoadLocal(current_character_), Uint64Constant(c)),
1071 on_not_equal);
1072}

◆ CheckNotCharacterAfterAnd()

void dart::IRRegExpMacroAssembler::CheckNotCharacterAfterAnd ( uint32_t  c,
uint32_t  mask,
BlockLabel on_not_equal 
)
virtual

Definition at line 1090 of file regexp_assembler_ir.cc.

1093 {
1094 TAG();
1095
1096 Definition* actual_def = LoadLocal(current_character_);
1097
1098 Value* actual_push = Bind(actual_def);
1099 Value* mask_push = Bind(Uint64Constant(mask));
1100 actual_def = InstanceCall(InstanceCallDescriptor::FromToken(Token::kBIT_AND),
1101 actual_push, mask_push);
1102 Definition* expected_def = Uint64Constant(c);
1103
1104 BranchOrBacktrack(Comparison(kNE, actual_def, expected_def), on_not_equal);
1105}

◆ CheckNotCharacterAfterMinusAnd()

void dart::IRRegExpMacroAssembler::CheckNotCharacterAfterMinusAnd ( uint16_t  c,
uint16_t  minus,
uint16_t  mask,
BlockLabel on_not_equal 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1107 of file regexp_assembler_ir.cc.

1111 {
1112 TAG();
1113 ASSERT(minus < Utf16::kMaxCodeUnit); // NOLINT
1114
1115 Definition* actual_def = LoadLocal(current_character_);
1116
1117 Value* actual_push = Bind(actual_def);
1118 Value* minus_push = Bind(Uint64Constant(minus));
1119
1120 actual_push = Bind(Sub(actual_push, minus_push));
1121 Value* mask_push = Bind(Uint64Constant(mask));
1122 actual_def = InstanceCall(InstanceCallDescriptor::FromToken(Token::kBIT_AND),
1123 actual_push, mask_push);
1124 Definition* expected_def = Uint64Constant(c);
1125
1126 BranchOrBacktrack(Comparison(kNE, actual_def, expected_def), on_not_equal);
1127}
static constexpr int32_t kMaxCodeUnit
Definition unicode.h:158

◆ CheckPosition()

void dart::IRRegExpMacroAssembler::CheckPosition ( intptr_t  cp_offset,
BlockLabel on_outside_input 
)
virtual

Reimplemented from dart::RegExpMacroAssembler.

Definition at line 1589 of file regexp_assembler_ir.cc.

1590 {
1591 TAG();
1592 if (cp_offset >= 0) {
1593 Definition* curpos_def = LoadLocal(current_position_);
1594 Definition* cp_off_def = Int64Constant(-cp_offset);
1595 // If (current_position_ < -cp_offset), we are in bounds.
1596 // Remember, current_position_ is a negative offset from the string end.
1597
1598 BranchOrBacktrack(Comparison(kGTE, curpos_def, cp_off_def),
1599 on_outside_input);
1600 } else {
1601 // We need to see if there's enough characters left in the string to go
1602 // back cp_offset characters, so get the normalized position and then
1603 // make sure that (normalized_position >= -cp_offset).
1604 Value* pos_push = PushLocal(current_position_);
1605 Value* len_push = PushLocal(string_param_length_);
1606 BranchOrBacktrack(
1607 Comparison(kLT, Add(pos_push, len_push), Uint64Constant(-cp_offset)),
1608 on_outside_input);
1609 }
1610}

◆ CheckSpecialCharacterClass()

bool dart::IRRegExpMacroAssembler::CheckSpecialCharacterClass ( uint16_t  type,
BlockLabel on_no_match 
)
virtual

Reimplemented from dart::RegExpMacroAssembler.

Definition at line 1187 of file regexp_assembler_ir.cc.

1189 {
1190 TAG();
1191
1192 // Range checks (c in min..max) are generally implemented by an unsigned
1193 // (c - min) <= (max - min) check
1194 switch (type) {
1195 case 's':
1196 // Match space-characters
1197 if (mode_ == ASCII) {
1198 // One byte space characters are '\t'..'\r', ' ' and \u00a0.
1199 BlockLabel success;
1200 // Space (' ').
1201 BranchOrBacktrack(
1202 Comparison(kEQ, LoadLocal(current_character_), Uint64Constant(' ')),
1203 &success);
1204 // Check range 0x09..0x0d.
1205 CheckCharacterInRange('\t', '\r', &success);
1206 // \u00a0 (NBSP).
1207 BranchOrBacktrack(Comparison(kNE, LoadLocal(current_character_),
1208 Uint64Constant(0x00a0)),
1209 on_no_match);
1210 BindBlock(&success);
1211 return true;
1212 }
1213 return false;
1214 case 'S':
1215 // The emitted code for generic character classes is good enough.
1216 return false;
1217 case 'd':
1218 // Match ASCII digits ('0'..'9')
1219 CheckCharacterNotInRange('0', '9', on_no_match);
1220 return true;
1221 case 'D':
1222 // Match non ASCII-digits
1223 CheckCharacterInRange('0', '9', on_no_match);
1224 return true;
1225 case '.': {
1226 // Match non-newlines (not 0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029)
1227 BranchOrBacktrack(
1228 Comparison(kEQ, LoadLocal(current_character_), Uint64Constant('\n')),
1229 on_no_match);
1230 BranchOrBacktrack(
1231 Comparison(kEQ, LoadLocal(current_character_), Uint64Constant('\r')),
1232 on_no_match);
1233 if (mode_ == UC16) {
1234 BranchOrBacktrack(Comparison(kEQ, LoadLocal(current_character_),
1235 Uint64Constant(0x2028)),
1236 on_no_match);
1237 BranchOrBacktrack(Comparison(kEQ, LoadLocal(current_character_),
1238 Uint64Constant(0x2029)),
1239 on_no_match);
1240 }
1241 return true;
1242 }
1243 case 'w': {
1244 if (mode_ != ASCII) {
1245 // Table is 128 entries, so all ASCII characters can be tested.
1246 BranchOrBacktrack(
1247 Comparison(kGT, LoadLocal(current_character_), Uint64Constant('z')),
1248 on_no_match);
1249 }
1250
1251 Value* table_push = Bind(WordCharacterMapConstant());
1252 Value* index_push = PushLocal(current_character_);
1253
1254 Definition* byte_def =
1255 InstanceCall(InstanceCallDescriptor::FromToken(Token::kINDEX),
1256 table_push, index_push);
1257 Definition* zero_def = Int64Constant(0);
1258
1259 BranchOrBacktrack(Comparison(kEQ, byte_def, zero_def), on_no_match);
1260
1261 return true;
1262 }
1263 case 'W': {
1264 BlockLabel done;
1265 if (mode_ != ASCII) {
1266 // Table is 128 entries, so all ASCII characters can be tested.
1267 BranchOrBacktrack(
1268 Comparison(kGT, LoadLocal(current_character_), Uint64Constant('z')),
1269 &done);
1270 }
1271
1272 // TODO(zerny): Refactor to use CheckBitInTable if possible.
1273
1274 Value* table_push = Bind(WordCharacterMapConstant());
1275 Value* index_push = PushLocal(current_character_);
1276
1277 Definition* byte_def =
1278 InstanceCall(InstanceCallDescriptor::FromToken(Token::kINDEX),
1279 table_push, index_push);
1280 Definition* zero_def = Int64Constant(0);
1281
1282 BranchOrBacktrack(Comparison(kNE, byte_def, zero_def), on_no_match);
1283
1284 if (mode_ != ASCII) {
1285 BindBlock(&done);
1286 }
1287 return true;
1288 }
1289 // Non-standard classes (with no syntactic shorthand) used internally.
1290 case '*':
1291 // Match any character.
1292 return true;
1293 case 'n': {
1294 // Match newlines (0x0a('\n'), 0x0d('\r'), 0x2028 or 0x2029).
1295 // The opposite of '.'.
1296 BlockLabel success;
1297 BranchOrBacktrack(
1298 Comparison(kEQ, LoadLocal(current_character_), Uint64Constant('\n')),
1299 &success);
1300 BranchOrBacktrack(
1301 Comparison(kEQ, LoadLocal(current_character_), Uint64Constant('\r')),
1302 &success);
1303 if (mode_ == UC16) {
1304 BranchOrBacktrack(Comparison(kEQ, LoadLocal(current_character_),
1305 Uint64Constant(0x2028)),
1306 &success);
1307 BranchOrBacktrack(Comparison(kEQ, LoadLocal(current_character_),
1308 Uint64Constant(0x2029)),
1309 &success);
1310 }
1311 BranchOrBacktrack(nullptr, on_no_match);
1312 BindBlock(&success);
1313 return true;
1314 }
1315 // No custom implementation (yet): s(uint16_t), S(uint16_t).
1316 default:
1317 return false;
1318 }
1319}
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
Definition DM.cpp:263
virtual void CheckCharacterNotInRange(uint16_t from, uint16_t to, BlockLabel *on_not_in_range)
virtual void CheckCharacterInRange(uint16_t from, uint16_t to, BlockLabel *on_in_range)

◆ ClearRegisters()

void dart::IRRegExpMacroAssembler::ClearRegisters ( intptr_t  reg_from,
intptr_t  reg_to 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1559 of file regexp_assembler_ir.cc.

1560 {
1561 TAG();
1562
1563 ASSERT(reg_from <= reg_to);
1564
1565 // In order to clear registers to a final result value of -1, set them to
1566 // (-1 - string length), the offset of -1 from the end of the string.
1567
1568 for (intptr_t reg = reg_from; reg <= reg_to; reg++) {
1569 Value* registers_push = PushLocal(registers_);
1570 Value* index_push = PushRegisterIndex(reg);
1571 Value* minus_one_push = Bind(Int64Constant(-1));
1572 Value* length_push = PushLocal(string_param_length_);
1573 Value* value_push = Bind(Sub(minus_one_push, length_push));
1574 StoreRegister(registers_push, index_push, value_push);
1575 }
1576}

◆ Execute()

ArrayPtr dart::IRRegExpMacroAssembler::Execute ( const RegExp regexp,
const String input,
const Smi start_offset,
bool  sticky,
Zone zone 
)
static

Definition at line 285 of file regexp_assembler_ir.cc.

289 {
290 const intptr_t cid = input.GetClassId();
291 const Function& fun = Function::Handle(regexp.function(cid, sticky));
292 ASSERT(!fun.IsNull());
293 // Create the argument list.
294 const Array& args =
299
300 // And finally call the generated code.
301
302 const Object& retval =
304 if (retval.IsLanguageError()) {
305 Exceptions::ThrowCompileTimeError(LanguageError::Cast(retval));
306 UNREACHABLE();
307 }
308 if (retval.IsError()) {
309 Exceptions::PropagateError(Error::Cast(retval));
310 }
311
312 if (retval.IsNull()) {
313 return Array::null();
314 }
315
316 ASSERT(retval.IsArray());
317 return Array::Cast(retval).ptr();
318}
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition object.h:10933
static ObjectPtr InvokeFunction(const Function &function, const Array &arguments)
Definition dart_entry.cc:31
static DART_NORETURN void ThrowCompileTimeError(const LanguageError &error)
static DART_NORETURN void PropagateError(const Error &error)
static ObjectPtr null()
Definition object.h:433
static Object & Handle()
Definition object.h:407
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const intptr_t cid

◆ Fail()

void dart::IRRegExpMacroAssembler::Fail ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1321 of file regexp_assembler_ir.cc.

1321 {
1322 TAG();
1323 ASSERT(FAILURE == 0); // Return value for failure is zero.
1324 if (!global()) {
1325 UNREACHABLE(); // Dart regexps are always global.
1326 }
1327 GoTo(exit_block_);
1328}

◆ FinalizeRegistersArray()

void dart::IRRegExpMacroAssembler::FinalizeRegistersArray ( )

Definition at line 273 of file regexp_assembler_ir.cc.

273 {
274 ASSERT(registers_count_ >= saved_registers_count_);
275
276 ConstantInstr* new_constant = Int64Constant(registers_count_);
277 new_constant->set_temp_index(num_registers_constant_instr->temp_index());
278 num_registers_constant_instr->ReplaceWith(new_constant, /*iterator=*/nullptr);
279}

◆ GenerateBacktrackBlock()

void dart::IRRegExpMacroAssembler::GenerateBacktrackBlock ( )

Definition at line 212 of file regexp_assembler_ir.cc.

212 {
213 set_current_instruction(backtrack_block_);
214 TAG();
215 CheckPreemption(/*is_backtrack=*/true);
216
217 const intptr_t entries_count = entry_block_->indirect_entries().length();
218
219 Value* block_id_push = Bind(PopStack());
220 backtrack_goto_ = new (Z) IndirectGotoInstr(entries_count, block_id_push);
221 CloseBlockWith(backtrack_goto_);
222
223 // Add an edge from the "indirect" goto to each of the targets.
224 for (intptr_t j = 0; j < entries_count; j++) {
225 backtrack_goto_->AddSuccessor(
226 TargetWithJoinGoto(entry_block_->indirect_entries().At(j)));
227 }
228}
const GrowableArray< IndirectEntryInstr * > & indirect_entries() const
Definition il.h:2001
void AddSuccessor(TargetEntryInstr *successor)
Definition il.h:3794

◆ GoTo()

void dart::IRRegExpMacroAssembler::GoTo ( BlockLabel to)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 585 of file regexp_assembler_ir.cc.

585 {
586 if (to == nullptr) {
587 Backtrack();
588 } else {
589 to->SetLinked();
590 GoTo(to->block());
591 }
592}

◆ graph_entry()

GraphEntryInstr * dart::IRRegExpMacroAssembler::graph_entry ( ) const
inline

Definition at line 125 of file regexp_assembler_ir.h.

125{ return entry_block_; }

◆ IfRegisterEqPos()

void dart::IRRegExpMacroAssembler::IfRegisterEqPos ( intptr_t  reg,
BlockLabel if_eq 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1348 of file regexp_assembler_ir.cc.

1348 {
1349 TAG();
1350 Value* reg_push = LoadRegister(reg);
1351 Value* pos = Bind(LoadLocal(current_position_));
1352 BranchOrBacktrack(Comparison(kEQ, reg_push, pos), if_eq);
1353}
SkPoint pos

◆ IfRegisterGE()

void dart::IRRegExpMacroAssembler::IfRegisterGE ( intptr_t  reg,
intptr_t  comparand,
BlockLabel if_ge 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1330 of file regexp_assembler_ir.cc.

1332 {
1333 TAG();
1334 Value* reg_push = LoadRegister(reg);
1335 Value* pos = Bind(Int64Constant(comparand));
1336 BranchOrBacktrack(Comparison(kGTE, reg_push, pos), if_ge);
1337}

◆ IfRegisterLT()

void dart::IRRegExpMacroAssembler::IfRegisterLT ( intptr_t  reg,
intptr_t  comparand,
BlockLabel if_lt 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1339 of file regexp_assembler_ir.cc.

1341 {
1342 TAG();
1343 Value* reg_push = LoadRegister(reg);
1344 Value* pos = Bind(Int64Constant(comparand));
1345 BranchOrBacktrack(Comparison(kLT, reg_push, pos), if_lt);
1346}

◆ Implementation()

RegExpMacroAssembler::IrregexpImplementation dart::IRRegExpMacroAssembler::Implementation ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1356 of file regexp_assembler_ir.cc.

1356 {
1357 return kIRImplementation;
1358}

◆ IsClosed()

virtual bool dart::IRRegExpMacroAssembler::IsClosed ( ) const
inlinevirtual

Implements dart::RegExpMacroAssembler.

Definition at line 47 of file regexp_assembler_ir.h.

47{ return (current_instruction_ == nullptr); }

◆ LoadCurrentCharacter()

void dart::IRRegExpMacroAssembler::LoadCurrentCharacter ( intptr_t  cp_offset,
BlockLabel on_end_of_input,
bool  check_bounds = true,
intptr_t  characters = 1 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1360 of file regexp_assembler_ir.cc.

1363 {
1364 TAG();
1365 ASSERT(cp_offset < (1 << 30)); // Be sane! (And ensure negation works)
1366 if (check_bounds) {
1367 if (cp_offset >= 0) {
1368 CheckPosition(cp_offset + characters - 1, on_end_of_input);
1369 } else {
1370 CheckPosition(cp_offset, on_end_of_input);
1371 }
1372 }
1373 LoadCurrentCharacterUnchecked(cp_offset, characters);
1374}
void check_bounds(skiatest::Reporter *reporter, const SkPath &path)
virtual void CheckPosition(intptr_t cp_offset, BlockLabel *on_outside_input)

◆ num_blocks()

intptr_t dart::IRRegExpMacroAssembler::num_blocks ( ) const
inline

Definition at line 128 of file regexp_assembler_ir.h.

128{ return block_id_.Count(); }

◆ num_stack_locals()

intptr_t dart::IRRegExpMacroAssembler::num_stack_locals ( ) const
inline

Definition at line 127 of file regexp_assembler_ir.h.

127{ return local_id_.Count(); }

◆ PopCurrentPosition()

void dart::IRRegExpMacroAssembler::PopCurrentPosition ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1376 of file regexp_assembler_ir.cc.

1376 {
1377 TAG();
1378 StoreLocal(current_position_, Bind(PopStack()));
1379}

◆ PopRegister()

void dart::IRRegExpMacroAssembler::PopRegister ( intptr_t  register_index)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1381 of file regexp_assembler_ir.cc.

1381 {
1382 TAG();
1383 ASSERT(reg < registers_count_);
1384 Value* registers_push = PushLocal(registers_);
1385 Value* index_push = PushRegisterIndex(reg);
1386 Value* pop_push = Bind(PopStack());
1387 StoreRegister(registers_push, index_push, pop_push);
1388}

◆ Print()

void dart::IRRegExpMacroAssembler::Print ( const char *  str)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 609 of file regexp_assembler_ir.cc.

609 {
610 Print(Bind(new (Z) ConstantInstr(
612}
@ kOld
Definition heap.h:39
virtual void Print(const char *str)
static Object & ZoneHandle()
Definition object.h:419
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition object.cc:23777

◆ PrintBlocks()

void dart::IRRegExpMacroAssembler::PrintBlocks ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 621 of file regexp_assembler_ir.cc.

621 {
622 for (intptr_t i = 0; i < blocks_.length(); i++) {
623 FlowGraphPrinter::PrintBlock(blocks_[i], false);
624 }
625}
static void PrintBlock(BlockEntryInstr *block, bool print_locations)

◆ PushBacktrack()

void dart::IRRegExpMacroAssembler::PushBacktrack ( BlockLabel label)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1420 of file regexp_assembler_ir.cc.

1420 {
1421 TAG();
1422
1423 // Ensure that targets of indirect jumps are never accessed through a
1424 // normal control flow instructions by creating a new block for each backtrack
1425 // target.
1426 IndirectEntryInstr* indirect_target = IndirectWithJoinGoto(label->block());
1427
1428 // Add a fake edge from the graph entry for data flow analysis.
1429 entry_block_->AddIndirectEntry(indirect_target);
1430
1431 ConstantInstr* offset = Uint64Constant(indirect_target->indirect_id());
1432 PushStack(offset);
1433 CheckStackLimit();
1434}
void AddIndirectEntry(IndirectEntryInstr *entry)
Definition il.h:1955
Point offset

◆ PushCurrentPosition()

void dart::IRRegExpMacroAssembler::PushCurrentPosition ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1436 of file regexp_assembler_ir.cc.

1436 {
1437 TAG();
1438 PushStack(LoadLocal(current_position_));
1439}

◆ PushRegister()

void dart::IRRegExpMacroAssembler::PushRegister ( intptr_t  register_index)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1441 of file regexp_assembler_ir.cc.

1441 {
1442 TAG();
1443 // TODO(zerny): Refactor PushStack so it can be reused here.
1444 Value* stack_push = PushLocal(stack_);
1445 Value* stack_pointer_push = PushLocal(stack_pointer_);
1446 StoreLocal(stack_pointer_,
1447 Bind(Add(stack_pointer_push, Bind(Uint64Constant(1)))));
1448 stack_pointer_push = PushLocal(stack_pointer_);
1449 // TODO(zerny): bind value and push could break stack discipline.
1450 Value* value_push = LoadRegister(reg);
1451 Do(InstanceCall(InstanceCallDescriptor::FromToken(Token::kASSIGN_INDEX),
1452 stack_push, stack_pointer_push, value_push));
1453 CheckStackLimit();
1454}

◆ ReadCurrentPositionFromRegister()

void dart::IRRegExpMacroAssembler::ReadCurrentPositionFromRegister ( intptr_t  reg)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1498 of file regexp_assembler_ir.cc.

1498 {
1499 TAG();
1500 StoreLocal(current_position_, LoadRegister(reg));
1501}

◆ ReadStackPointerFromRegister()

void dart::IRRegExpMacroAssembler::ReadStackPointerFromRegister ( intptr_t  reg)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1504 of file regexp_assembler_ir.cc.

1504 {
1505 TAG();
1506 ASSERT(reg < registers_count_);
1507 StoreLocal(stack_pointer_, LoadRegister(reg));
1508}

◆ SetCurrentPositionFromEnd()

void dart::IRRegExpMacroAssembler::SetCurrentPositionFromEnd ( intptr_t  by)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1510 of file regexp_assembler_ir.cc.

1510 {
1511 TAG();
1512
1513 BlockLabel after_position;
1514
1515 Definition* cur_pos_def = LoadLocal(current_position_);
1516 Definition* by_value_def = Int64Constant(-by);
1517
1518 BranchOrBacktrack(Comparison(kGTE, cur_pos_def, by_value_def),
1519 &after_position);
1520
1521 StoreLocal(current_position_, Bind(Int64Constant(-by)));
1522
1523 // On RegExp code entry (where this operation is used), the character before
1524 // the current position is expected to be already loaded.
1525 // We have advanced the position, so it's safe to read backwards.
1526 LoadCurrentCharacterUnchecked(-1, 1);
1527
1528 BindBlock(&after_position);
1529}

◆ SetRegister()

void dart::IRRegExpMacroAssembler::SetRegister ( intptr_t  register_index,
intptr_t  to 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1531 of file regexp_assembler_ir.cc.

1531 {
1532 TAG();
1533 // Reserved for positions!
1534 ASSERT(reg >= saved_registers_count_);
1535 StoreRegister(reg, to);
1536}

◆ stack_limit_slack()

intptr_t dart::IRRegExpMacroAssembler::stack_limit_slack ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 627 of file regexp_assembler_ir.cc.

627 {
628 return 32;
629}

◆ Succeed()

bool dart::IRRegExpMacroAssembler::Succeed ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1538 of file regexp_assembler_ir.cc.

1538 {
1539 TAG();
1540 GoTo(success_block_);
1541 return global();
1542}

◆ WriteCurrentPositionToRegister()

void dart::IRRegExpMacroAssembler::WriteCurrentPositionToRegister ( intptr_t  reg,
intptr_t  cp_offset 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1544 of file regexp_assembler_ir.cc.

1546 {
1547 TAG();
1548
1549 Value* registers_push = PushLocal(registers_);
1550 Value* index_push = PushRegisterIndex(reg);
1551 Value* pos_push = PushLocal(current_position_);
1552 Value* off_push = Bind(Int64Constant(cp_offset));
1553 Value* neg_off_push = Bind(Add(pos_push, off_push));
1554 // Push the negative offset; these are converted to positive string positions
1555 // within the success block.
1556 StoreRegister(registers_push, index_push, neg_off_push);
1557}

◆ WriteStackPointerToRegister()

void dart::IRRegExpMacroAssembler::WriteStackPointerToRegister ( intptr_t  reg)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 1578 of file regexp_assembler_ir.cc.

1578 {
1579 TAG();
1580
1581 Value* registers_push = PushLocal(registers_);
1582 Value* index_push = PushRegisterIndex(reg);
1583 Value* tip_push = PushLocal(stack_pointer_);
1584 StoreRegister(registers_push, index_push, tip_push);
1585}

The documentation for this class was generated from the following files: