| 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 }; | 675 }; |
| 676 | 676 |
| 677 | 677 |
| 678 class ActionNode: public SeqRegExpNode { | 678 class ActionNode: public SeqRegExpNode { |
| 679 public: | 679 public: |
| 680 enum Type { | 680 enum Type { |
| 681 SET_REGISTER, | 681 SET_REGISTER, |
| 682 INCREMENT_REGISTER, | 682 INCREMENT_REGISTER, |
| 683 STORE_POSITION, | 683 STORE_POSITION, |
| 684 BEGIN_SUBMATCH, | 684 BEGIN_SUBMATCH, |
| 685 POSITIVE_SUBMATCH_SUCCESS | 685 POSITIVE_SUBMATCH_SUCCESS, |
| 686 EMPTY_MATCH_CHECK |
| 686 }; | 687 }; |
| 687 static ActionNode* SetRegister(int reg, int val, RegExpNode* on_success); | 688 static ActionNode* SetRegister(int reg, int val, RegExpNode* on_success); |
| 688 static ActionNode* IncrementRegister(int reg, RegExpNode* on_success); | 689 static ActionNode* IncrementRegister(int reg, RegExpNode* on_success); |
| 689 static ActionNode* StorePosition(int reg, RegExpNode* on_success); | 690 static ActionNode* StorePosition(int reg, RegExpNode* on_success); |
| 690 static ActionNode* BeginSubmatch( | 691 static ActionNode* BeginSubmatch( |
| 691 int stack_pointer_reg, | 692 int stack_pointer_reg, |
| 692 int position_reg, | 693 int position_reg, |
| 693 RegExpNode* on_success); | 694 RegExpNode* on_success); |
| 694 static ActionNode* PositiveSubmatchSuccess( | 695 static ActionNode* PositiveSubmatchSuccess( |
| 695 int stack_pointer_reg, | 696 int stack_pointer_reg, |
| 696 int restore_reg, | 697 int restore_reg, |
| 697 RegExpNode* on_success); | 698 RegExpNode* on_success); |
| 699 static ActionNode* EmptyMatchCheck( |
| 700 int start_register, |
| 701 int repetition_register, |
| 702 int repetition_limit, |
| 703 RegExpNode* on_success); |
| 698 virtual void Accept(NodeVisitor* visitor); | 704 virtual void Accept(NodeVisitor* visitor); |
| 699 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); | 705 virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant); |
| 700 virtual int EatsAtLeast(int recursion_depth); | 706 virtual int EatsAtLeast(int recursion_depth); |
| 701 virtual void GetQuickCheckDetails(QuickCheckDetails* details, | 707 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
| 702 RegExpCompiler* compiler, | 708 RegExpCompiler* compiler, |
| 703 int filled_in) { | 709 int filled_in) { |
| 704 return on_success()->GetQuickCheckDetails(details, compiler, filled_in); | 710 return on_success()->GetQuickCheckDetails(details, compiler, filled_in); |
| 705 } | 711 } |
| 706 virtual RegExpNode* PropagateForward(NodeInfo* info); | 712 virtual RegExpNode* PropagateForward(NodeInfo* info); |
| 707 Type type() { return type_; } | 713 Type type() { return type_; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 718 struct { | 724 struct { |
| 719 int reg; | 725 int reg; |
| 720 } u_increment_register; | 726 } u_increment_register; |
| 721 struct { | 727 struct { |
| 722 int reg; | 728 int reg; |
| 723 } u_position_register; | 729 } u_position_register; |
| 724 struct { | 730 struct { |
| 725 int stack_pointer_register; | 731 int stack_pointer_register; |
| 726 int current_position_register; | 732 int current_position_register; |
| 727 } u_submatch; | 733 } u_submatch; |
| 734 struct { |
| 735 int start_register; |
| 736 int repetition_register; |
| 737 int repetition_limit; |
| 738 } u_empty_match_check; |
| 728 } data_; | 739 } data_; |
| 729 ActionNode(Type type, RegExpNode* on_success) | 740 ActionNode(Type type, RegExpNode* on_success) |
| 730 : SeqRegExpNode(on_success), | 741 : SeqRegExpNode(on_success), |
| 731 type_(type) { } | 742 type_(type) { } |
| 732 Type type_; | 743 Type type_; |
| 733 friend class DotPrinter; | 744 friend class DotPrinter; |
| 734 }; | 745 }; |
| 735 | 746 |
| 736 | 747 |
| 737 class TextNode: public SeqRegExpNode { | 748 class TextNode: public SeqRegExpNode { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 bound_checked_up_to_ == 0 && | 1035 bound_checked_up_to_ == 0 && |
| 1025 quick_check_performed_.characters() == 0; | 1036 quick_check_performed_.characters() == 0; |
| 1026 } | 1037 } |
| 1027 Label* backtrack() { return backtrack_; } | 1038 Label* backtrack() { return backtrack_; } |
| 1028 Label* loop_label() { return loop_label_; } | 1039 Label* loop_label() { return loop_label_; } |
| 1029 RegExpNode* stop_node() { return stop_node_; } | 1040 RegExpNode* stop_node() { return stop_node_; } |
| 1030 int characters_preloaded() { return characters_preloaded_; } | 1041 int characters_preloaded() { return characters_preloaded_; } |
| 1031 int bound_checked_up_to() { return bound_checked_up_to_; } | 1042 int bound_checked_up_to() { return bound_checked_up_to_; } |
| 1032 QuickCheckDetails* quick_check_performed() { return &quick_check_performed_; } | 1043 QuickCheckDetails* quick_check_performed() { return &quick_check_performed_; } |
| 1033 bool mentions_reg(int reg); | 1044 bool mentions_reg(int reg); |
| 1045 // Returns true if a deferred position store exists to the specified |
| 1046 // register and stores the offset in the out-parameter. Otherwise |
| 1047 // returns false. |
| 1048 bool GetStoredPosition(int reg, int* cp_offset); |
| 1034 // These set methods and AdvanceVariant should be used only on new | 1049 // These set methods and AdvanceVariant should be used only on new |
| 1035 // GenerationVariants - the intention is that GenerationVariants are | 1050 // GenerationVariants - the intention is that GenerationVariants are |
| 1036 // immutable after creation. | 1051 // immutable after creation. |
| 1037 void add_action(DeferredAction* new_action) { | 1052 void add_action(DeferredAction* new_action) { |
| 1038 ASSERT(new_action->next_ == NULL); | 1053 ASSERT(new_action->next_ == NULL); |
| 1039 new_action->next_ = actions_; | 1054 new_action->next_ = actions_; |
| 1040 actions_ = new_action; | 1055 actions_ = new_action; |
| 1041 } | 1056 } |
| 1042 void set_backtrack(Label* backtrack) { backtrack_ = backtrack; } | 1057 void set_backtrack(Label* backtrack) { backtrack_ = backtrack; } |
| 1043 void set_stop_node(RegExpNode* node) { stop_node_ = node; } | 1058 void set_stop_node(RegExpNode* node) { stop_node_ = node; } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 Handle<String> pattern, | 1183 Handle<String> pattern, |
| 1169 bool is_ascii); | 1184 bool is_ascii); |
| 1170 | 1185 |
| 1171 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); | 1186 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); |
| 1172 }; | 1187 }; |
| 1173 | 1188 |
| 1174 | 1189 |
| 1175 } } // namespace v8::internal | 1190 } } // namespace v8::internal |
| 1176 | 1191 |
| 1177 #endif // V8_JSREGEXP_H_ | 1192 #endif // V8_JSREGEXP_H_ |
| OLD | NEW |