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;
270 void StoreLocal(LocalVariable* local,
Value* value);
272 LoadStaticFieldInstr* LoadStaticField(
const Field& field,
273 bool calls_initializer =
false)
const;
275 Value* PushLocal(LocalVariable* local);
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) {
357 intptr_t current_id = next_id;
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;