OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 list_->Add(parent); | 529 list_->Add(parent); |
530 } | 530 } |
531 } | 531 } |
532 void Add(RegExpNode* node) { list_->Add(node); } | 532 void Add(RegExpNode* node) { list_->Add(node); } |
533 RegExpNode* Get(int index) { return list_->at(index); } | 533 RegExpNode* Get(int index) { return list_->at(index); } |
534 private: | 534 private: |
535 ZoneList<RegExpNode*>* list_; | 535 ZoneList<RegExpNode*>* list_; |
536 }; | 536 }; |
537 | 537 |
538 | 538 |
| 539 // Details of a quick mask-compare check that can look ahead in the |
| 540 // input stream. |
| 541 class QuickCheckDetails { |
| 542 public: |
| 543 QuickCheckDetails() |
| 544 : characters_(0), |
| 545 mask_(0), |
| 546 value_(0) { } |
| 547 explicit QuickCheckDetails(int characters) |
| 548 : characters_(characters), |
| 549 mask_(0), |
| 550 value_(0) { } |
| 551 bool Rationalize(bool ascii); |
| 552 // Merge in the information from another branch of an alternation. |
| 553 void Merge(QuickCheckDetails* other, int from_index); |
| 554 // Advance the current position by some amount. |
| 555 void Advance(int by, bool ascii); |
| 556 void Clear(); |
| 557 struct Position { |
| 558 Position() : mask(0), value(0), determines_perfectly(false) { } |
| 559 uc16 mask; |
| 560 uc16 value; |
| 561 bool determines_perfectly; |
| 562 }; |
| 563 int characters() { return characters_; } |
| 564 void set_characters(int characters) { characters_ = characters; } |
| 565 Position* positions(int index) { |
| 566 ASSERT(index >= 0); |
| 567 ASSERT(index < characters_); |
| 568 return positions_ + index; |
| 569 } |
| 570 uint32_t mask() { return mask_; } |
| 571 uint32_t value() { return value_; } |
| 572 |
| 573 private: |
| 574 // How many characters do we have quick check information from. This is |
| 575 // the same for all branches of a choice node. |
| 576 int characters_; |
| 577 Position positions_[4]; |
| 578 // These values are the condensate of the above array after Rationalize(). |
| 579 uint32_t mask_; |
| 580 uint32_t value_; |
| 581 }; |
| 582 |
| 583 |
539 class RegExpNode: public ZoneObject { | 584 class RegExpNode: public ZoneObject { |
540 public: | 585 public: |
541 RegExpNode() : variants_generated_(0) { } | 586 RegExpNode() : variants_generated_(0) { } |
542 virtual ~RegExpNode() { } | 587 virtual ~RegExpNode(); |
543 virtual void Accept(NodeVisitor* visitor) = 0; | 588 virtual void Accept(NodeVisitor* visitor) = 0; |
544 // Generates a goto to this node or actually generates the code at this point. | 589 // Generates a goto to this node or actually generates the code at this point. |
545 // Until the implementation is complete we will return true for success and | 590 // Until the implementation is complete we will return true for success and |
546 // false for failure. | 591 // false for failure. |
547 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant) = 0; | 592 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant) = 0; |
| 593 // How many characters must this node consume at a minimum in order to |
| 594 // succeed. |
| 595 virtual int EatsAtLeast(int recursion_depth) = 0; |
| 596 // Emits some quick code that checks whether the preloaded characters match. |
| 597 // Falls through on certain failure, jumps to the label on possible success. |
| 598 // If the node cannot make a quick check it does nothing and returns false. |
| 599 bool EmitQuickCheck(RegExpCompiler* compiler, |
| 600 GenerationVariant* variant, |
| 601 bool preload_has_checked_bounds, |
| 602 Label* on_possible_success, |
| 603 QuickCheckDetails* details_return, |
| 604 bool fall_through_on_failure); |
| 605 // For a given number of characters this returns a mask and a value. The |
| 606 // next n characters are anded with the mask and compared with the value. |
| 607 // A comparison failure indicates the node cannot match the next n characters. |
| 608 // A comparison success indicates the node may match. |
| 609 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 610 RegExpCompiler* compiler, |
| 611 int characters_filled_in) = 0; |
548 static const int kNodeIsTooComplexForGreedyLoops = -1; | 612 static const int kNodeIsTooComplexForGreedyLoops = -1; |
549 virtual int GreedyLoopTextLength() { return kNodeIsTooComplexForGreedyLoops; } | 613 virtual int GreedyLoopTextLength() { return kNodeIsTooComplexForGreedyLoops; } |
550 Label* label() { return &label_; } | 614 Label* label() { return &label_; } |
551 static const int kMaxVariantsGenerated = 10; | 615 static const int kMaxVariantsGenerated = 10; |
552 | 616 |
553 // Propagates the given interest information forward. When seeing | 617 // Propagates the given interest information forward. When seeing |
554 // \bfoo for instance, the \b is implemented by propagating forward | 618 // \bfoo for instance, the \b is implemented by propagating forward |
555 // to the 'foo' string that it should only succeed if its first | 619 // to the 'foo' string that it should only succeed if its first |
556 // character is a letter xor the previous character was a letter. | 620 // character is a letter xor the previous character was a letter. |
557 virtual RegExpNode* PropagateForward(NodeInfo* info) = 0; | 621 virtual RegExpNode* PropagateForward(NodeInfo* info) = 0; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 static ActionNode* BeginSubmatch( | 690 static ActionNode* BeginSubmatch( |
627 int stack_pointer_reg, | 691 int stack_pointer_reg, |
628 int position_reg, | 692 int position_reg, |
629 RegExpNode* on_success); | 693 RegExpNode* on_success); |
630 static ActionNode* PositiveSubmatchSuccess( | 694 static ActionNode* PositiveSubmatchSuccess( |
631 int stack_pointer_reg, | 695 int stack_pointer_reg, |
632 int restore_reg, | 696 int restore_reg, |
633 RegExpNode* on_success); | 697 RegExpNode* on_success); |
634 virtual void Accept(NodeVisitor* visitor); | 698 virtual void Accept(NodeVisitor* visitor); |
635 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); | 699 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); |
| 700 virtual int EatsAtLeast(int recursion_depth); |
| 701 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 702 RegExpCompiler* compiler, |
| 703 int filled_in) { |
| 704 return on_success()->GetQuickCheckDetails(details, compiler, filled_in); |
| 705 } |
636 virtual RegExpNode* PropagateForward(NodeInfo* info); | 706 virtual RegExpNode* PropagateForward(NodeInfo* info); |
637 Type type() { return type_; } | 707 Type type() { return type_; } |
638 // TODO(erikcorry): We should allow some action nodes in greedy loops. | 708 // TODO(erikcorry): We should allow some action nodes in greedy loops. |
639 virtual int GreedyLoopTextLength() { return kNodeIsTooComplexForGreedyLoops; } | 709 virtual int GreedyLoopTextLength() { return kNodeIsTooComplexForGreedyLoops; } |
640 virtual ActionNode* Clone() { return new ActionNode(*this); } | 710 virtual ActionNode* Clone() { return new ActionNode(*this); } |
641 | 711 |
642 private: | 712 private: |
643 union { | 713 union { |
644 struct { | 714 struct { |
645 int reg; | 715 int reg; |
(...skipping 26 matching lines...) Expand all Loading... |
672 elms_(elms) { } | 742 elms_(elms) { } |
673 TextNode(RegExpCharacterClass* that, | 743 TextNode(RegExpCharacterClass* that, |
674 RegExpNode* on_success) | 744 RegExpNode* on_success) |
675 : SeqRegExpNode(on_success), | 745 : SeqRegExpNode(on_success), |
676 elms_(new ZoneList<TextElement>(1)) { | 746 elms_(new ZoneList<TextElement>(1)) { |
677 elms_->Add(TextElement::CharClass(that)); | 747 elms_->Add(TextElement::CharClass(that)); |
678 } | 748 } |
679 virtual void Accept(NodeVisitor* visitor); | 749 virtual void Accept(NodeVisitor* visitor); |
680 virtual RegExpNode* PropagateForward(NodeInfo* info); | 750 virtual RegExpNode* PropagateForward(NodeInfo* info); |
681 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); | 751 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); |
| 752 virtual int EatsAtLeast(int recursion_depth); |
| 753 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 754 RegExpCompiler* compiler, |
| 755 int characters_filled_in); |
682 ZoneList<TextElement>* elements() { return elms_; } | 756 ZoneList<TextElement>* elements() { return elms_; } |
683 void MakeCaseIndependent(); | 757 void MakeCaseIndependent(); |
684 virtual int GreedyLoopTextLength(); | 758 virtual int GreedyLoopTextLength(); |
685 virtual TextNode* Clone() { | 759 virtual TextNode* Clone() { |
686 TextNode* result = new TextNode(*this); | 760 TextNode* result = new TextNode(*this); |
687 result->CalculateOffsets(); | 761 result->CalculateOffsets(); |
688 return result; | 762 return result; |
689 } | 763 } |
690 void CalculateOffsets(); | 764 void CalculateOffsets(); |
691 | 765 |
692 private: | 766 private: |
| 767 enum TextEmitPassType { |
| 768 NON_ASCII_MATCH, |
| 769 CHARACTER_MATCH, |
| 770 CASE_CHARACTER_MATCH, |
| 771 CHARACTER_CLASS_MATCH |
| 772 }; |
| 773 void TextEmitPass(RegExpCompiler* compiler, |
| 774 TextEmitPassType pass, |
| 775 bool preloaded, |
| 776 GenerationVariant* variant, |
| 777 bool first_element_checked, |
| 778 int* checked_up_to); |
| 779 int Length(); |
693 ZoneList<TextElement>* elms_; | 780 ZoneList<TextElement>* elms_; |
694 }; | 781 }; |
695 | 782 |
696 | 783 |
697 class BackReferenceNode: public SeqRegExpNode { | 784 class BackReferenceNode: public SeqRegExpNode { |
698 public: | 785 public: |
699 BackReferenceNode(int start_reg, | 786 BackReferenceNode(int start_reg, |
700 int end_reg, | 787 int end_reg, |
701 RegExpNode* on_success) | 788 RegExpNode* on_success) |
702 : SeqRegExpNode(on_success), | 789 : SeqRegExpNode(on_success), |
703 start_reg_(start_reg), | 790 start_reg_(start_reg), |
704 end_reg_(end_reg) { } | 791 end_reg_(end_reg) { } |
705 virtual void Accept(NodeVisitor* visitor); | 792 virtual void Accept(NodeVisitor* visitor); |
706 int start_register() { return start_reg_; } | 793 int start_register() { return start_reg_; } |
707 int end_register() { return end_reg_; } | 794 int end_register() { return end_reg_; } |
708 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); | 795 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); |
| 796 virtual int EatsAtLeast(int recursion_depth) { return 0; } |
| 797 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 798 RegExpCompiler* compiler, |
| 799 int characters_filled_in) { |
| 800 return; |
| 801 } |
709 virtual RegExpNode* PropagateForward(NodeInfo* info); | 802 virtual RegExpNode* PropagateForward(NodeInfo* info); |
710 virtual BackReferenceNode* Clone() { return new BackReferenceNode(*this); } | 803 virtual BackReferenceNode* Clone() { return new BackReferenceNode(*this); } |
711 | 804 |
712 private: | 805 private: |
713 int start_reg_; | 806 int start_reg_; |
714 int end_reg_; | 807 int end_reg_; |
715 }; | 808 }; |
716 | 809 |
717 | 810 |
718 class EndNode: public RegExpNode { | 811 class EndNode: public RegExpNode { |
719 public: | 812 public: |
720 enum Action { ACCEPT, BACKTRACK, NEGATIVE_SUBMATCH_SUCCESS }; | 813 enum Action { ACCEPT, BACKTRACK, NEGATIVE_SUBMATCH_SUCCESS }; |
721 explicit EndNode(Action action) : action_(action) { } | 814 explicit EndNode(Action action) : action_(action) { } |
722 virtual void Accept(NodeVisitor* visitor); | 815 virtual void Accept(NodeVisitor* visitor); |
723 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); | 816 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); |
| 817 virtual int EatsAtLeast(int recursion_depth) { return 0; } |
| 818 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 819 RegExpCompiler* compiler, |
| 820 int characters_filled_in) { |
| 821 // Returning 0 from EatsAtLeast should ensure we never get here. |
| 822 UNREACHABLE(); |
| 823 } |
724 virtual RegExpNode* PropagateForward(NodeInfo* info); | 824 virtual RegExpNode* PropagateForward(NodeInfo* info); |
725 virtual EndNode* Clone() { return new EndNode(*this); } | 825 virtual EndNode* Clone() { return new EndNode(*this); } |
726 | 826 |
727 protected: | 827 protected: |
728 void EmitInfoChecks(RegExpMacroAssembler* macro, GenerationVariant* variant); | 828 void EmitInfoChecks(RegExpMacroAssembler* macro, GenerationVariant* variant); |
729 | 829 |
730 private: | 830 private: |
731 Action action_; | 831 Action action_; |
732 }; | 832 }; |
733 | 833 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 RegExpNode* node() { return node_; } | 871 RegExpNode* node() { return node_; } |
772 void set_node(RegExpNode* node) { node_ = node; } | 872 void set_node(RegExpNode* node) { node_ = node; } |
773 ZoneList<Guard*>* guards() { return guards_; } | 873 ZoneList<Guard*>* guards() { return guards_; } |
774 | 874 |
775 private: | 875 private: |
776 RegExpNode* node_; | 876 RegExpNode* node_; |
777 ZoneList<Guard*>* guards_; | 877 ZoneList<Guard*>* guards_; |
778 }; | 878 }; |
779 | 879 |
780 | 880 |
| 881 class AlternativeGeneration; |
| 882 |
| 883 |
781 class ChoiceNode: public RegExpNode { | 884 class ChoiceNode: public RegExpNode { |
782 public: | 885 public: |
783 explicit ChoiceNode(int expected_size) | 886 explicit ChoiceNode(int expected_size) |
784 : alternatives_(new ZoneList<GuardedAlternative>(expected_size)), | 887 : alternatives_(new ZoneList<GuardedAlternative>(expected_size)), |
785 table_(NULL), | 888 table_(NULL), |
786 being_calculated_(false) { } | 889 being_calculated_(false) { } |
787 virtual void Accept(NodeVisitor* visitor); | 890 virtual void Accept(NodeVisitor* visitor); |
788 void AddAlternative(GuardedAlternative node) { alternatives()->Add(node); } | 891 void AddAlternative(GuardedAlternative node) { alternatives()->Add(node); } |
789 ZoneList<GuardedAlternative>* alternatives() { return alternatives_; } | 892 ZoneList<GuardedAlternative>* alternatives() { return alternatives_; } |
790 DispatchTable* GetTable(bool ignore_case); | 893 DispatchTable* GetTable(bool ignore_case); |
791 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); | 894 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); |
| 895 virtual int EatsAtLeast(int recursion_depth); |
| 896 int EatsAtLeastHelper(int recursion_depth, int start_from_node); |
| 897 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 898 RegExpCompiler* compiler, |
| 899 int characters_filled_in); |
792 virtual RegExpNode* PropagateForward(NodeInfo* info); | 900 virtual RegExpNode* PropagateForward(NodeInfo* info); |
793 virtual ChoiceNode* Clone() { return new ChoiceNode(*this); } | 901 virtual ChoiceNode* Clone() { return new ChoiceNode(*this); } |
794 | 902 |
795 bool being_calculated() { return being_calculated_; } | 903 bool being_calculated() { return being_calculated_; } |
796 void set_being_calculated(bool b) { being_calculated_ = b; } | 904 void set_being_calculated(bool b) { being_calculated_ = b; } |
797 | 905 |
798 protected: | 906 protected: |
799 int GreedyLoopTextLength(GuardedAlternative *alternative); | 907 int GreedyLoopTextLength(GuardedAlternative *alternative); |
800 ZoneList<GuardedAlternative>* alternatives_; | 908 ZoneList<GuardedAlternative>* alternatives_; |
801 | 909 |
802 private: | 910 private: |
803 friend class DispatchTableConstructor; | 911 friend class DispatchTableConstructor; |
804 friend class Analysis; | 912 friend class Analysis; |
805 void GenerateGuard(RegExpMacroAssembler* macro_assembler, | 913 void GenerateGuard(RegExpMacroAssembler* macro_assembler, |
806 Guard *guard, | 914 Guard *guard, |
807 GenerationVariant* variant); | 915 GenerationVariant* variant); |
| 916 int CalculatePreloadCharacters(RegExpCompiler* compiler, int start_from_node); |
| 917 bool EmitOutOfLineContinuation(RegExpCompiler* compiler, |
| 918 GenerationVariant* variant, |
| 919 GuardedAlternative alternative, |
| 920 AlternativeGeneration* alt_gen, |
| 921 int preload_characters, |
| 922 bool next_expects_preload); |
808 DispatchTable* table_; | 923 DispatchTable* table_; |
809 bool being_calculated_; | 924 bool being_calculated_; |
810 }; | 925 }; |
811 | 926 |
812 | 927 |
813 class LoopChoiceNode: public ChoiceNode { | 928 class LoopChoiceNode: public ChoiceNode { |
814 public: | 929 public: |
815 explicit LoopChoiceNode() | 930 explicit LoopChoiceNode() |
816 : ChoiceNode(2), | 931 : ChoiceNode(2), |
817 loop_node_(NULL), | 932 loop_node_(NULL), |
818 continue_node_(NULL) { } | 933 continue_node_(NULL) { } |
819 void AddLoopAlternative(GuardedAlternative alt); | 934 void AddLoopAlternative(GuardedAlternative alt); |
820 void AddContinueAlternative(GuardedAlternative alt); | 935 void AddContinueAlternative(GuardedAlternative alt); |
821 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); | 936 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); |
| 937 virtual int EatsAtLeast(int recursion_depth); // Returns 0. |
| 938 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 939 RegExpCompiler* compiler, |
| 940 int characters_filled_in) { |
| 941 // Returning 0 from EatsAtLeast should ensure we never get here. |
| 942 UNREACHABLE(); |
| 943 } |
822 virtual LoopChoiceNode* Clone() { return new LoopChoiceNode(*this); } | 944 virtual LoopChoiceNode* Clone() { return new LoopChoiceNode(*this); } |
823 RegExpNode* loop_node() { return loop_node_; } | 945 RegExpNode* loop_node() { return loop_node_; } |
824 RegExpNode* continue_node() { return continue_node_; } | 946 RegExpNode* continue_node() { return continue_node_; } |
825 virtual void Accept(NodeVisitor* visitor); | 947 virtual void Accept(NodeVisitor* visitor); |
826 | 948 |
827 private: | 949 private: |
828 // AddAlternative is made private for loop nodes because alternatives | 950 // AddAlternative is made private for loop nodes because alternatives |
829 // should not be added freely, we need to keep track of which node | 951 // should not be added freely, we need to keep track of which node |
830 // goes back to the node itself. | 952 // goes back to the node itself. |
831 void AddAlternative(GuardedAlternative node) { | 953 void AddAlternative(GuardedAlternative node) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 private: | 998 private: |
877 int value_; | 999 int value_; |
878 }; | 1000 }; |
879 | 1001 |
880 class DeferredIncrementRegister: public DeferredAction { | 1002 class DeferredIncrementRegister: public DeferredAction { |
881 public: | 1003 public: |
882 explicit DeferredIncrementRegister(int reg) | 1004 explicit DeferredIncrementRegister(int reg) |
883 : DeferredAction(ActionNode::INCREMENT_REGISTER, reg) { } | 1005 : DeferredAction(ActionNode::INCREMENT_REGISTER, reg) { } |
884 }; | 1006 }; |
885 | 1007 |
886 explicit GenerationVariant(Label* backtrack) | |
887 : cp_offset_(0), | |
888 actions_(NULL), | |
889 backtrack_(backtrack), | |
890 stop_node_(NULL), | |
891 loop_label_(NULL) { } | |
892 GenerationVariant() | 1008 GenerationVariant() |
893 : cp_offset_(0), | 1009 : cp_offset_(0), |
894 actions_(NULL), | 1010 actions_(NULL), |
895 backtrack_(NULL), | 1011 backtrack_(NULL), |
896 stop_node_(NULL), | 1012 stop_node_(NULL), |
897 loop_label_(NULL) { } | 1013 loop_label_(NULL), |
| 1014 characters_preloaded_(0) { } |
898 bool Flush(RegExpCompiler* compiler, RegExpNode* successor); | 1015 bool Flush(RegExpCompiler* compiler, RegExpNode* successor); |
899 int cp_offset() { return cp_offset_; } | 1016 int cp_offset() { return cp_offset_; } |
900 DeferredAction* actions() { return actions_; } | 1017 DeferredAction* actions() { return actions_; } |
901 bool is_trivial() { | 1018 bool is_trivial() { |
902 return backtrack_ == NULL && actions_ == NULL && cp_offset_ == 0; | 1019 return backtrack_ == NULL && |
| 1020 actions_ == NULL && |
| 1021 cp_offset_ == 0 && |
| 1022 characters_preloaded_ == 0 && |
| 1023 quick_check_performed_.characters() == 0; |
903 } | 1024 } |
904 Label* backtrack() { return backtrack_; } | 1025 Label* backtrack() { return backtrack_; } |
905 Label* loop_label() { return loop_label_; } | 1026 Label* loop_label() { return loop_label_; } |
906 RegExpNode* stop_node() { return stop_node_; } | 1027 RegExpNode* stop_node() { return stop_node_; } |
907 // These set methods should be used only on new GenerationVariants - the | 1028 int characters_preloaded() { return characters_preloaded_; } |
908 // intention is that GenerationVariants are immutable after creation. | 1029 QuickCheckDetails* quick_check_performed() { return &quick_check_performed_; } |
| 1030 bool mentions_reg(int reg); |
| 1031 // These set methods and AdvanceVariant should be used only on new |
| 1032 // GenerationVariants - the intention is that GenerationVariants are |
| 1033 // immutable after creation. |
909 void add_action(DeferredAction* new_action) { | 1034 void add_action(DeferredAction* new_action) { |
910 ASSERT(new_action->next_ == NULL); | 1035 ASSERT(new_action->next_ == NULL); |
911 new_action->next_ = actions_; | 1036 new_action->next_ = actions_; |
912 actions_ = new_action; | 1037 actions_ = new_action; |
913 } | 1038 } |
914 void set_cp_offset(int new_cp_offset) { | |
915 ASSERT(new_cp_offset >= cp_offset_); | |
916 cp_offset_ = new_cp_offset; | |
917 } | |
918 void set_backtrack(Label* backtrack) { backtrack_ = backtrack; } | 1039 void set_backtrack(Label* backtrack) { backtrack_ = backtrack; } |
919 void set_stop_node(RegExpNode* node) { stop_node_ = node; } | 1040 void set_stop_node(RegExpNode* node) { stop_node_ = node; } |
920 void set_loop_label(Label* label) { loop_label_ = label; } | 1041 void set_loop_label(Label* label) { loop_label_ = label; } |
921 bool mentions_reg(int reg); | 1042 void set_characters_preloaded(int cpre) { characters_preloaded_ = cpre; } |
| 1043 void set_quick_check_performed(QuickCheckDetails* d) { |
| 1044 quick_check_performed_ = *d; |
| 1045 } |
| 1046 void clear_quick_check_performed() { |
| 1047 } |
| 1048 void AdvanceVariant(int by, bool ascii); |
922 private: | 1049 private: |
923 int FindAffectedRegisters(OutSet* affected_registers); | 1050 int FindAffectedRegisters(OutSet* affected_registers); |
924 void PerformDeferredActions(RegExpMacroAssembler* macro, | 1051 void PerformDeferredActions(RegExpMacroAssembler* macro, |
925 int max_register, | 1052 int max_register, |
926 OutSet& affected_registers); | 1053 OutSet& affected_registers); |
927 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, | 1054 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, |
928 int max_register, | 1055 int max_register, |
929 OutSet& affected_registers); | 1056 OutSet& affected_registers); |
930 void PushAffectedRegisters(RegExpMacroAssembler* macro, | 1057 void PushAffectedRegisters(RegExpMacroAssembler* macro, |
931 int max_register, | 1058 int max_register, |
932 OutSet& affected_registers); | 1059 OutSet& affected_registers); |
933 int cp_offset_; | 1060 int cp_offset_; |
934 DeferredAction* actions_; | 1061 DeferredAction* actions_; |
935 Label* backtrack_; | 1062 Label* backtrack_; |
936 RegExpNode* stop_node_; | 1063 RegExpNode* stop_node_; |
937 Label* loop_label_; | 1064 Label* loop_label_; |
| 1065 int characters_preloaded_; |
| 1066 QuickCheckDetails quick_check_performed_; |
938 }; | 1067 }; |
| 1068 |
| 1069 |
939 class NodeVisitor { | 1070 class NodeVisitor { |
940 public: | 1071 public: |
941 virtual ~NodeVisitor() { } | 1072 virtual ~NodeVisitor() { } |
942 #define DECLARE_VISIT(Type) \ | 1073 #define DECLARE_VISIT(Type) \ |
943 virtual void Visit##Type(Type##Node* that) = 0; | 1074 virtual void Visit##Type(Type##Node* that) = 0; |
944 FOR_EACH_NODE_TYPE(DECLARE_VISIT) | 1075 FOR_EACH_NODE_TYPE(DECLARE_VISIT) |
945 #undef DECLARE_VISIT | 1076 #undef DECLARE_VISIT |
946 virtual void VisitLoopChoice(LoopChoiceNode* that) { VisitChoice(that); } | 1077 virtual void VisitLoopChoice(LoopChoiceNode* that) { VisitChoice(that); } |
947 }; | 1078 }; |
948 | 1079 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 Handle<String> pattern, | 1163 Handle<String> pattern, |
1033 bool is_ascii); | 1164 bool is_ascii); |
1034 | 1165 |
1035 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); | 1166 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); |
1036 }; | 1167 }; |
1037 | 1168 |
1038 | 1169 |
1039 } } // namespace v8::internal | 1170 } } // namespace v8::internal |
1040 | 1171 |
1041 #endif // V8_JSREGEXP_H_ | 1172 #endif // V8_JSREGEXP_H_ |
OLD | NEW |