OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_REGEXP_ASSEMBLER_H_ | 5 #ifndef VM_REGEXP_ASSEMBLER_H_ |
6 #define VM_REGEXP_ASSEMBLER_H_ | 6 #define VM_REGEXP_ASSEMBLER_H_ |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 virtual void ReadStackPointerFromRegister(intptr_t reg); | 321 virtual void ReadStackPointerFromRegister(intptr_t reg); |
322 virtual void SetCurrentPositionFromEnd(intptr_t by); | 322 virtual void SetCurrentPositionFromEnd(intptr_t by); |
323 virtual void SetRegister(intptr_t register_index, intptr_t to); | 323 virtual void SetRegister(intptr_t register_index, intptr_t to); |
324 virtual bool Succeed(); | 324 virtual bool Succeed(); |
325 virtual void WriteCurrentPositionToRegister(intptr_t reg, intptr_t cp_offset); | 325 virtual void WriteCurrentPositionToRegister(intptr_t reg, intptr_t cp_offset); |
326 virtual void ClearRegisters(intptr_t reg_from, intptr_t reg_to); | 326 virtual void ClearRegisters(intptr_t reg_from, intptr_t reg_to); |
327 virtual void WriteStackPointerToRegister(intptr_t reg); | 327 virtual void WriteStackPointerToRegister(intptr_t reg); |
328 | 328 |
329 virtual void PrintBlocks(); | 329 virtual void PrintBlocks(); |
330 | 330 |
| 331 IndirectGotoInstr* backtrack_goto() const { return backtrack_goto_; } |
331 GraphEntryInstr* graph_entry() const { return entry_block_; } | 332 GraphEntryInstr* graph_entry() const { return entry_block_; } |
332 | 333 |
333 intptr_t num_stack_locals() const { return local_id_.Count(); } | 334 intptr_t num_stack_locals() const { return local_id_.Count(); } |
334 intptr_t num_blocks() const { return block_id_.Count(); } | 335 intptr_t num_blocks() const { return block_id_.Count(); } |
335 | 336 |
336 // A table mapping block ids to block offsets, used to look up offsets | 337 // Generate a dispatch block implementing backtracking. Must be done after |
337 // for indirect goto instructions. | 338 // graph construction. |
338 void FinalizeBlockOffsetTable(); | 339 void GenerateBacktrackBlock(); |
339 | |
340 // Fill in indirect goto successors. | |
341 void FinalizeIndirectGotos(); | |
342 | 340 |
343 private: | 341 private: |
344 // Generate the contents of preset blocks. The entry block is the entry point | 342 // Generate the contents of preset blocks. The entry block is the entry point |
345 // of the generated code. | 343 // of the generated code. |
346 void GenerateEntryBlock(); | 344 void GenerateEntryBlock(); |
347 // Performs backtracking, i.e. popping an offset from the stack and doing | |
348 // an indirect goto. | |
349 void GenerateBacktrackBlock(); | |
350 // Copies capture indices into the result area and returns true. | 345 // Copies capture indices into the result area and returns true. |
351 void GenerateSuccessBlock(); | 346 void GenerateSuccessBlock(); |
352 // Returns false. | 347 // Returns false. |
353 void GenerateExitBlock(); | 348 void GenerateExitBlock(); |
354 | 349 |
355 enum ComparisonKind { | 350 enum ComparisonKind { |
356 kEQ, | 351 kEQ, |
357 kNE, | 352 kNE, |
358 kLT, | 353 kLT, |
359 kGT, | 354 kGT, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 // Which mode to generate code for (ASCII or UC16). | 555 // Which mode to generate code for (ASCII or UC16). |
561 Mode mode_; | 556 Mode mode_; |
562 | 557 |
563 // Which specific string class to generate code for. | 558 // Which specific string class to generate code for. |
564 intptr_t specialization_cid_; | 559 intptr_t specialization_cid_; |
565 | 560 |
566 // Block entries used internally. | 561 // Block entries used internally. |
567 GraphEntryInstr* entry_block_; | 562 GraphEntryInstr* entry_block_; |
568 JoinEntryInstr* start_block_; | 563 JoinEntryInstr* start_block_; |
569 JoinEntryInstr* success_block_; | 564 JoinEntryInstr* success_block_; |
| 565 JoinEntryInstr* exit_block_; |
| 566 |
| 567 // Shared backtracking block. |
570 JoinEntryInstr* backtrack_block_; | 568 JoinEntryInstr* backtrack_block_; |
571 JoinEntryInstr* exit_block_; | 569 // Single indirect goto instruction which performs all backtracking. |
| 570 IndirectGotoInstr* backtrack_goto_; |
572 | 571 |
573 const ParsedFunction* parsed_function_; | 572 const ParsedFunction* parsed_function_; |
574 const ZoneGrowableArray<const ICData*>& ic_data_array_; | 573 const ZoneGrowableArray<const ICData*>& ic_data_array_; |
575 | 574 |
576 // All created blocks are contained within this set. Used for printing | 575 // All created blocks are contained within this set. Used for printing |
577 // the generated code. | 576 // the generated code. |
578 GrowableArray<BlockEntryInstr*> blocks_; | 577 GrowableArray<BlockEntryInstr*> blocks_; |
579 | 578 |
580 // The current instruction to link to when new code is emitted. | 579 // The current instruction to link to when new code is emitted. |
581 Instruction* current_instruction_; | 580 Instruction* current_instruction_; |
(...skipping 28 matching lines...) Expand all Loading... |
610 | 609 |
611 LocalVariable* result_; | 610 LocalVariable* result_; |
612 | 611 |
613 // Stored positions containing group bounds. Generated as needed. | 612 // Stored positions containing group bounds. Generated as needed. |
614 const intptr_t position_registers_count_; | 613 const intptr_t position_registers_count_; |
615 GrowableArray<LocalVariable*> position_registers_; | 614 GrowableArray<LocalVariable*> position_registers_; |
616 | 615 |
617 // The actual array object used as the stack. | 616 // The actual array object used as the stack. |
618 GrowableObjectArray& stack_array_; | 617 GrowableObjectArray& stack_array_; |
619 | 618 |
620 GrowableArray<IndirectGotoInstr*> igotos_; | |
621 | |
622 IdAllocator block_id_; | 619 IdAllocator block_id_; |
623 IdAllocator temp_id_; | 620 IdAllocator temp_id_; |
624 IdAllocator arg_id_; | 621 IdAllocator arg_id_; |
625 IdAllocator local_id_; | 622 IdAllocator local_id_; |
626 IdAllocator indirect_id_; | 623 IdAllocator indirect_id_; |
627 }; | 624 }; |
628 | 625 |
629 | 626 |
630 } // namespace dart | 627 } // namespace dart |
631 | 628 |
632 #endif // VM_REGEXP_ASSEMBLER_H_ | 629 #endif // VM_REGEXP_ASSEMBLER_H_ |
OLD | NEW |