Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Side by Side Diff: src/jsregexp.h

Issue 16410: Some irregexp optimizations around keeping track of when the current characte... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/jsregexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 explicit DeferredIncrementRegister(int reg) 1004 explicit DeferredIncrementRegister(int reg)
1005 : DeferredAction(ActionNode::INCREMENT_REGISTER, reg) { } 1005 : DeferredAction(ActionNode::INCREMENT_REGISTER, reg) { }
1006 }; 1006 };
1007 1007
1008 GenerationVariant() 1008 GenerationVariant()
1009 : cp_offset_(0), 1009 : cp_offset_(0),
1010 actions_(NULL), 1010 actions_(NULL),
1011 backtrack_(NULL), 1011 backtrack_(NULL),
1012 stop_node_(NULL), 1012 stop_node_(NULL),
1013 loop_label_(NULL), 1013 loop_label_(NULL),
1014 characters_preloaded_(0) { } 1014 characters_preloaded_(0),
1015 bound_checked_up_to_(0) { }
1015 bool Flush(RegExpCompiler* compiler, RegExpNode* successor); 1016 bool Flush(RegExpCompiler* compiler, RegExpNode* successor);
1016 int cp_offset() { return cp_offset_; } 1017 int cp_offset() { return cp_offset_; }
1017 DeferredAction* actions() { return actions_; } 1018 DeferredAction* actions() { return actions_; }
1018 bool is_trivial() { 1019 bool is_trivial() {
1019 return backtrack_ == NULL && 1020 return backtrack_ == NULL &&
1020 actions_ == NULL && 1021 actions_ == NULL &&
1021 cp_offset_ == 0 && 1022 cp_offset_ == 0 &&
1022 characters_preloaded_ == 0 && 1023 characters_preloaded_ == 0 &&
1024 bound_checked_up_to_ == 0 &&
1023 quick_check_performed_.characters() == 0; 1025 quick_check_performed_.characters() == 0;
1024 } 1026 }
1025 Label* backtrack() { return backtrack_; } 1027 Label* backtrack() { return backtrack_; }
1026 Label* loop_label() { return loop_label_; } 1028 Label* loop_label() { return loop_label_; }
1027 RegExpNode* stop_node() { return stop_node_; } 1029 RegExpNode* stop_node() { return stop_node_; }
1028 int characters_preloaded() { return characters_preloaded_; } 1030 int characters_preloaded() { return characters_preloaded_; }
1031 int bound_checked_up_to() { return bound_checked_up_to_; }
1029 QuickCheckDetails* quick_check_performed() { return &quick_check_performed_; } 1032 QuickCheckDetails* quick_check_performed() { return &quick_check_performed_; }
1030 bool mentions_reg(int reg); 1033 bool mentions_reg(int reg);
1031 // These set methods and AdvanceVariant should be used only on new 1034 // These set methods and AdvanceVariant should be used only on new
1032 // GenerationVariants - the intention is that GenerationVariants are 1035 // GenerationVariants - the intention is that GenerationVariants are
1033 // immutable after creation. 1036 // immutable after creation.
1034 void add_action(DeferredAction* new_action) { 1037 void add_action(DeferredAction* new_action) {
1035 ASSERT(new_action->next_ == NULL); 1038 ASSERT(new_action->next_ == NULL);
1036 new_action->next_ = actions_; 1039 new_action->next_ = actions_;
1037 actions_ = new_action; 1040 actions_ = new_action;
1038 } 1041 }
1039 void set_backtrack(Label* backtrack) { backtrack_ = backtrack; } 1042 void set_backtrack(Label* backtrack) { backtrack_ = backtrack; }
1040 void set_stop_node(RegExpNode* node) { stop_node_ = node; } 1043 void set_stop_node(RegExpNode* node) { stop_node_ = node; }
1041 void set_loop_label(Label* label) { loop_label_ = label; } 1044 void set_loop_label(Label* label) { loop_label_ = label; }
1042 void set_characters_preloaded(int cpre) { characters_preloaded_ = cpre; } 1045 void set_characters_preloaded(int cpre) { characters_preloaded_ = cpre; }
1046 void set_bound_checked_up_to(int to) { bound_checked_up_to_ = to; }
1043 void set_quick_check_performed(QuickCheckDetails* d) { 1047 void set_quick_check_performed(QuickCheckDetails* d) {
1044 quick_check_performed_ = *d; 1048 quick_check_performed_ = *d;
1045 } 1049 }
1046 void clear_quick_check_performed() { 1050 void clear_quick_check_performed() {
1047 } 1051 }
1048 void AdvanceVariant(int by, bool ascii); 1052 void AdvanceVariant(int by, bool ascii);
1049 private: 1053 private:
1050 int FindAffectedRegisters(OutSet* affected_registers); 1054 int FindAffectedRegisters(OutSet* affected_registers);
1051 void PerformDeferredActions(RegExpMacroAssembler* macro, 1055 void PerformDeferredActions(RegExpMacroAssembler* macro,
1052 int max_register, 1056 int max_register,
1053 OutSet& affected_registers); 1057 OutSet& affected_registers);
1054 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, 1058 void RestoreAffectedRegisters(RegExpMacroAssembler* macro,
1055 int max_register, 1059 int max_register,
1056 OutSet& affected_registers); 1060 OutSet& affected_registers);
1057 void PushAffectedRegisters(RegExpMacroAssembler* macro, 1061 void PushAffectedRegisters(RegExpMacroAssembler* macro,
1058 int max_register, 1062 int max_register,
1059 OutSet& affected_registers); 1063 OutSet& affected_registers);
1060 int cp_offset_; 1064 int cp_offset_;
1061 DeferredAction* actions_; 1065 DeferredAction* actions_;
1062 Label* backtrack_; 1066 Label* backtrack_;
1063 RegExpNode* stop_node_; 1067 RegExpNode* stop_node_;
1064 Label* loop_label_; 1068 Label* loop_label_;
1065 int characters_preloaded_; 1069 int characters_preloaded_;
1070 int bound_checked_up_to_;
1066 QuickCheckDetails quick_check_performed_; 1071 QuickCheckDetails quick_check_performed_;
1067 }; 1072 };
1068 1073
1069 1074
1070 class NodeVisitor { 1075 class NodeVisitor {
1071 public: 1076 public:
1072 virtual ~NodeVisitor() { } 1077 virtual ~NodeVisitor() { }
1073 #define DECLARE_VISIT(Type) \ 1078 #define DECLARE_VISIT(Type) \
1074 virtual void Visit##Type(Type##Node* that) = 0; 1079 virtual void Visit##Type(Type##Node* that) = 0;
1075 FOR_EACH_NODE_TYPE(DECLARE_VISIT) 1080 FOR_EACH_NODE_TYPE(DECLARE_VISIT)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 Handle<String> pattern, 1168 Handle<String> pattern,
1164 bool is_ascii); 1169 bool is_ascii);
1165 1170
1166 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); 1171 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
1167 }; 1172 };
1168 1173
1169 1174
1170 } } // namespace v8::internal 1175 } } // namespace v8::internal
1171 1176
1172 #endif // V8_JSREGEXP_H_ 1177 #endif // V8_JSREGEXP_H_
OLDNEW
« no previous file with comments | « no previous file | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698