5#ifndef RUNTIME_VM_REGEXP_ASSEMBLER_IR_H_
6#define RUNTIME_VM_REGEXP_ASSEMBLER_IR_H_
32 intptr_t capture_count,
43 const Smi& start_offset,
47 virtual bool IsClosed()
const {
return (current_instruction_ ==
nullptr); }
106 intptr_t characters = 1);
109 virtual void Print(
const char* str);
116 virtual void SetRegister(intptr_t register_index, intptr_t to);
139 intptr_t GetNextDeoptId()
const {
145 void GenerateEntryBlock();
147 void GenerateSuccessBlock();
149 void GenerateExitBlock();
151 enum ComparisonKind {
160 struct InstanceCallDescriptor {
162 explicit InstanceCallDescriptor(
const String&
name)
163 :
name(
name), token_kind(Token::kILLEGAL), checked_argument_count(1) {}
165 InstanceCallDescriptor(
const String&
name,
167 intptr_t checked_argument_count)
169 token_kind(token_kind),
170 checked_argument_count(checked_argument_count) {}
173 static InstanceCallDescriptor FromToken(
Token::Kind token_kind) {
174 switch (token_kind) {
176 return InstanceCallDescriptor(Symbols::EqualOperator(), token_kind,
179 return InstanceCallDescriptor(
Symbols::Plus(), token_kind, 2);
184 case Token::kBIT_AND:
190 return InstanceCallDescriptor(Symbols::LessEqualOperator(),
196 return InstanceCallDescriptor(Symbols::GreaterEqualOperator(),
199 return InstanceCallDescriptor(Symbols::UnaryMinus(), token_kind, 1);
201 return InstanceCallDescriptor(Symbols::IndexToken(), token_kind, 2);
202 case Token::kASSIGN_INDEX:
203 return InstanceCallDescriptor(Symbols::AssignIndexToken(), token_kind,
214 intptr_t checked_argument_count;
217 LocalVariable* Local(
const String&
name);
218 LocalVariable* Parameter(
const String&
name, intptr_t index)
const;
220 ConstantInstr* Int64Constant(int64_t
value)
const;
221 ConstantInstr* Uint64Constant(uint64_t
value)
const;
222 ConstantInstr* BoolConstant(
bool value)
const;
223 ConstantInstr* StringConstant(
const char*
value)
const;
229 ConstantInstr* WordCharacterMapConstant()
const;
231 ComparisonInstr* Comparison(ComparisonKind kind,
Value* lhs,
Value* rhs);
232 ComparisonInstr* Comparison(ComparisonKind kind,
236 InstanceCallInstr* InstanceCall(
const InstanceCallDescriptor&
desc,
238 InstanceCallInstr* InstanceCall(
const InstanceCallDescriptor&
desc,
241 InstanceCallInstr* InstanceCall(
const InstanceCallDescriptor&
desc,
245 InstanceCallInstr* InstanceCall(
const InstanceCallDescriptor&
desc,
248 StaticCallInstr* StaticCall(
const Function&
function,
250 StaticCallInstr* StaticCall(
const Function&
function,
253 StaticCallInstr* StaticCall(
const Function&
function,
257 StaticCallInstr* StaticCall(
const Function&
function,
262 TargetEntryInstr* TargetWithJoinGoto(JoinEntryInstr*
dst);
263 IndirectEntryInstr* IndirectWithJoinGoto(JoinEntryInstr*
dst);
269 LoadLocalInstr* LoadLocal(LocalVariable*
local)
const;
272 LoadStaticFieldInstr* LoadStaticField(
const Field& field,
273 bool calls_initializer =
false)
const;
277 Value* PushRegisterIndex(intptr_t reg);
278 Value* LoadRegister(intptr_t reg);
279 void StoreRegister(intptr_t reg, intptr_t
value);
284 void LoadCurrentCharacterUnchecked(intptr_t cp_offset,
285 intptr_t character_count);
288 Value* CharacterAt(LocalVariable* index);
291 Value* LoadCodeUnitsAt(LocalVariable* index, intptr_t character_count);
294 void CheckPreemption(
bool is_backtrack);
297 inline intptr_t char_size() {
return static_cast<int>(mode_); }
301 void BranchOrBacktrack(ComparisonInstr* comparison,
302 BlockLabel* true_successor);
305 void InitializeLocals();
309 intptr_t GetNextLocalIndex();
312 intptr_t num_copied_params()
const {
return 0; }
317 LocalVariable* position_register(intptr_t index);
319 void set_current_instruction(Instruction* instruction);
325 void AppendInstruction(Instruction* instruction);
328 void CloseBlockWith(Instruction* instruction);
330 Value* Bind(Definition* definition);
332 Value* BindLoadLocal(
const LocalVariable&
local);
335 void Do(Definition* definition);
337 void GoTo(JoinEntryInstr* to);
340 void PushStack(Definition* definition);
341 Definition* PopStack();
342 Definition* PeekStack();
343 void CheckStackLimit();
350 class IdAllocator :
public ValueObject {
352 explicit IdAllocator(intptr_t first_id = 0) :
next_id(first_id) {}
354 intptr_t Count()
const {
return next_id; }
355 intptr_t Alloc(intptr_t
count = 1) {
361 void Dealloc(intptr_t
count = 1) {
376 intptr_t specialization_cid_;
379 GraphEntryInstr* entry_block_;
380 JoinEntryInstr* start_block_;
381 JoinEntryInstr* success_block_;
382 JoinEntryInstr* exit_block_;
385 JoinEntryInstr* backtrack_block_;
387 IndirectGotoInstr* backtrack_goto_;
389 const ParsedFunction* parsed_function_;
390 const ZoneGrowableArray<const ICData*>& ic_data_array_;
394 GrowableArray<BlockEntryInstr*> blocks_;
397 Instruction* current_instruction_;
401 LocalVariable* stack_;
402 LocalVariable* stack_pointer_;
405 LocalVariable* current_character_;
409 LocalVariable* current_position_;
412 LocalVariable* string_param_;
415 LocalVariable* string_param_length_;
418 LocalVariable* start_index_param_;
421 LocalVariable* capture_length_;
422 LocalVariable* match_start_index_;
423 LocalVariable* capture_start_index_;
424 LocalVariable* match_end_index_;
425 LocalVariable* char_in_capture_;
426 LocalVariable* char_in_match_;
427 LocalVariable* index_temp_;
429 LocalVariable* result_;
432 LocalVariable* registers_;
433 intptr_t registers_count_;
434 const intptr_t saved_registers_count_;
436 IdAllocator block_id_;
437 IdAllocator temp_id_;
438 IdAllocator local_id_;
439 IdAllocator indirect_id_;
443 ConstantInstr* num_registers_constant_instr =
nullptr;
void check_bounds(skiatest::Reporter *reporter, const SkPath &path)
static uint32_t next_id()
Convenience wrapper around a BlockEntryInstr pointer.
intptr_t GetNextDeoptId()
virtual void CheckNotCharacter(uint32_t c, BlockLabel *on_not_equal)
virtual void CheckCharacterNotInRange(uint16_t from, uint16_t to, BlockLabel *on_not_in_range)
virtual void PopCurrentPosition()
void FinalizeRegistersArray()
virtual void CheckCharacterInRange(uint16_t from, uint16_t to, BlockLabel *on_in_range)
virtual void BindBlock(BlockLabel *label)
virtual void CheckCharacterGT(uint16_t limit, BlockLabel *on_greater)
intptr_t num_stack_locals() const
virtual void IfRegisterLT(intptr_t reg, intptr_t comparand, BlockLabel *if_lt)
void GenerateBacktrackBlock()
GraphEntryInstr * graph_entry() const
virtual void IfRegisterGE(intptr_t reg, intptr_t comparand, BlockLabel *if_ge)
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 void SetRegister(intptr_t register_index, intptr_t to)
virtual void CheckAtStart(BlockLabel *on_at_start)
virtual void CheckCharacterLT(uint16_t limit, BlockLabel *on_less)
virtual void GoTo(BlockLabel *to)
virtual IrregexpImplementation Implementation()
virtual void CheckNotAtStart(intptr_t cp_offset, BlockLabel *on_not_at_start)
virtual void Print(const char *str)
virtual void CheckGreedyLoop(BlockLabel *on_tos_equals_current_position)
static ArrayPtr Execute(const RegExp ®exp, const String &input, const Smi &start_offset, bool sticky, Zone *zone)
virtual bool IsClosed() const
virtual void ClearRegisters(intptr_t reg_from, intptr_t reg_to)
virtual void AdvanceCurrentPosition(intptr_t by)
virtual void CheckCharacterAfterAnd(uint32_t c, uint32_t mask, BlockLabel *on_equal)
virtual void PrintBlocks()
virtual void IfRegisterEqPos(intptr_t reg, BlockLabel *if_eq)
virtual bool CanReadUnaligned()
virtual void AdvanceRegister(intptr_t reg, intptr_t by)
virtual void PushRegister(intptr_t register_index)
virtual void CheckNotCharacterAfterAnd(uint32_t c, uint32_t mask, BlockLabel *on_not_equal)
virtual void CheckCharacter(uint32_t c, BlockLabel *on_equal)
virtual void ReadCurrentPositionFromRegister(intptr_t reg)
virtual void CheckNotCharacterAfterMinusAnd(uint16_t c, uint16_t minus, uint16_t mask, BlockLabel *on_not_equal)
IndirectGotoInstr * backtrack_goto() const
virtual void CheckPosition(intptr_t cp_offset, BlockLabel *on_outside_input)
virtual ~IRRegExpMacroAssembler()
virtual void SetCurrentPositionFromEnd(intptr_t by)
virtual void CheckNotBackReference(intptr_t start_reg, bool read_backward, BlockLabel *on_no_match)
virtual void ReadStackPointerFromRegister(intptr_t reg)
virtual bool CheckSpecialCharacterClass(uint16_t type, BlockLabel *on_no_match)
virtual void CheckBitInTable(const TypedData &table, BlockLabel *on_bit_set)
virtual void PushCurrentPosition()
virtual void LoadCurrentCharacter(intptr_t cp_offset, BlockLabel *on_end_of_input, bool check_bounds=true, intptr_t characters=1)
virtual void WriteStackPointerToRegister(intptr_t reg)
intptr_t num_blocks() const
virtual intptr_t stack_limit_slack()
virtual void PushBacktrack(BlockLabel *label)
virtual void CheckNotBackReferenceIgnoreCase(intptr_t start_reg, bool read_backward, bool unicode, BlockLabel *on_no_match)
virtual void WriteCurrentPositionToRegister(intptr_t reg, intptr_t cp_offset)
virtual void PopRegister(intptr_t register_index)
static const String & Plus()
static const String & LAngleBracket()
static const String & BitOr()
static const String & RAngleBracket()
static const String & Empty()
static const String & BitAnd()
static const String & Minus()
CompilerState & compiler_state()
Dart_NativeFunction function
GrowableArray< Value * > InputsArray