Chromium Code Reviews| 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 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1169 }; | 1169 }; |
| 1170 | 1170 |
| 1171 Trace() | 1171 Trace() |
| 1172 : cp_offset_(0), | 1172 : cp_offset_(0), |
| 1173 actions_(NULL), | 1173 actions_(NULL), |
| 1174 backtrack_(NULL), | 1174 backtrack_(NULL), |
| 1175 stop_node_(NULL), | 1175 stop_node_(NULL), |
| 1176 loop_label_(NULL), | 1176 loop_label_(NULL), |
| 1177 characters_preloaded_(0), | 1177 characters_preloaded_(0), |
| 1178 bound_checked_up_to_(0), | 1178 bound_checked_up_to_(0), |
| 1179 flush_budget_(100), | |
|
Lasse Reichstein
2009/02/18 15:29:05
Have other initial values of flush_budget been tri
| |
| 1179 at_start_(UNKNOWN) { } | 1180 at_start_(UNKNOWN) { } |
| 1180 | 1181 |
| 1181 // End the trace. This involves flushing the deferred actions in the trace | 1182 // End the trace. This involves flushing the deferred actions in the trace |
| 1182 // and pushing a backtrack location onto the backtrack stack. Once this is | 1183 // and pushing a backtrack location onto the backtrack stack. Once this is |
| 1183 // done we can start a new trace or go to one that has already been | 1184 // done we can start a new trace or go to one that has already been |
| 1184 // generated. | 1185 // generated. |
| 1185 void Flush(RegExpCompiler* compiler, RegExpNode* successor); | 1186 void Flush(RegExpCompiler* compiler, RegExpNode* successor); |
| 1186 int cp_offset() { return cp_offset_; } | 1187 int cp_offset() { return cp_offset_; } |
| 1187 DeferredAction* actions() { return actions_; } | 1188 DeferredAction* actions() { return actions_; } |
| 1188 // A trivial trace is one that has no deferred actions or other state that | 1189 // A trivial trace is one that has no deferred actions or other state that |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1204 quick_check_performed_.characters() == 0 && | 1205 quick_check_performed_.characters() == 0 && |
| 1205 at_start_ == UNKNOWN; | 1206 at_start_ == UNKNOWN; |
| 1206 } | 1207 } |
| 1207 TriBool at_start() { return at_start_; } | 1208 TriBool at_start() { return at_start_; } |
| 1208 void set_at_start(bool at_start) { at_start_ = at_start ? TRUE : FALSE; } | 1209 void set_at_start(bool at_start) { at_start_ = at_start ? TRUE : FALSE; } |
| 1209 Label* backtrack() { return backtrack_; } | 1210 Label* backtrack() { return backtrack_; } |
| 1210 Label* loop_label() { return loop_label_; } | 1211 Label* loop_label() { return loop_label_; } |
| 1211 RegExpNode* stop_node() { return stop_node_; } | 1212 RegExpNode* stop_node() { return stop_node_; } |
| 1212 int characters_preloaded() { return characters_preloaded_; } | 1213 int characters_preloaded() { return characters_preloaded_; } |
| 1213 int bound_checked_up_to() { return bound_checked_up_to_; } | 1214 int bound_checked_up_to() { return bound_checked_up_to_; } |
| 1215 int flush_budget() { return flush_budget_; } | |
| 1214 QuickCheckDetails* quick_check_performed() { return &quick_check_performed_; } | 1216 QuickCheckDetails* quick_check_performed() { return &quick_check_performed_; } |
| 1215 bool mentions_reg(int reg); | 1217 bool mentions_reg(int reg); |
| 1216 // Returns true if a deferred position store exists to the specified | 1218 // Returns true if a deferred position store exists to the specified |
| 1217 // register and stores the offset in the out-parameter. Otherwise | 1219 // register and stores the offset in the out-parameter. Otherwise |
| 1218 // returns false. | 1220 // returns false. |
| 1219 bool GetStoredPosition(int reg, int* cp_offset); | 1221 bool GetStoredPosition(int reg, int* cp_offset); |
| 1220 // These set methods and AdvanceCurrentPositionInTrace should be used only on | 1222 // These set methods and AdvanceCurrentPositionInTrace should be used only on |
| 1221 // new traces - the intention is that traces are immutable after creation. | 1223 // new traces - the intention is that traces are immutable after creation. |
| 1222 void add_action(DeferredAction* new_action) { | 1224 void add_action(DeferredAction* new_action) { |
| 1223 ASSERT(new_action->next_ == NULL); | 1225 ASSERT(new_action->next_ == NULL); |
| 1224 new_action->next_ = actions_; | 1226 new_action->next_ = actions_; |
| 1225 actions_ = new_action; | 1227 actions_ = new_action; |
| 1226 } | 1228 } |
| 1227 void set_backtrack(Label* backtrack) { backtrack_ = backtrack; } | 1229 void set_backtrack(Label* backtrack) { backtrack_ = backtrack; } |
| 1228 void set_stop_node(RegExpNode* node) { stop_node_ = node; } | 1230 void set_stop_node(RegExpNode* node) { stop_node_ = node; } |
| 1229 void set_loop_label(Label* label) { loop_label_ = label; } | 1231 void set_loop_label(Label* label) { loop_label_ = label; } |
| 1230 void set_characters_preloaded(int cpre) { characters_preloaded_ = cpre; } | 1232 void set_characters_preloaded(int cpre) { characters_preloaded_ = cpre; } |
| 1231 void set_bound_checked_up_to(int to) { bound_checked_up_to_ = to; } | 1233 void set_bound_checked_up_to(int to) { bound_checked_up_to_ = to; } |
| 1234 void set_flush_budget(int to) { flush_budget_ = to; } | |
| 1232 void set_quick_check_performed(QuickCheckDetails* d) { | 1235 void set_quick_check_performed(QuickCheckDetails* d) { |
| 1233 quick_check_performed_ = *d; | 1236 quick_check_performed_ = *d; |
| 1234 } | 1237 } |
| 1235 void InvalidateCurrentCharacter(); | 1238 void InvalidateCurrentCharacter(); |
| 1236 void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler); | 1239 void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler); |
| 1237 private: | 1240 private: |
| 1238 int FindAffectedRegisters(OutSet* affected_registers); | 1241 int FindAffectedRegisters(OutSet* affected_registers); |
| 1239 void PerformDeferredActions(RegExpMacroAssembler* macro, | 1242 void PerformDeferredActions(RegExpMacroAssembler* macro, |
| 1240 int max_register, | 1243 int max_register, |
| 1241 OutSet& affected_registers, | 1244 OutSet& affected_registers, |
| 1242 OutSet* registers_to_pop, | 1245 OutSet* registers_to_pop, |
| 1243 OutSet* registers_to_clear); | 1246 OutSet* registers_to_clear); |
| 1244 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, | 1247 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, |
| 1245 int max_register, | 1248 int max_register, |
| 1246 OutSet& registers_to_pop, | 1249 OutSet& registers_to_pop, |
| 1247 OutSet& registers_to_clear); | 1250 OutSet& registers_to_clear); |
| 1248 int cp_offset_; | 1251 int cp_offset_; |
| 1249 DeferredAction* actions_; | 1252 DeferredAction* actions_; |
| 1250 Label* backtrack_; | 1253 Label* backtrack_; |
| 1251 RegExpNode* stop_node_; | 1254 RegExpNode* stop_node_; |
| 1252 Label* loop_label_; | 1255 Label* loop_label_; |
| 1253 int characters_preloaded_; | 1256 int characters_preloaded_; |
| 1254 int bound_checked_up_to_; | 1257 int bound_checked_up_to_; |
| 1255 QuickCheckDetails quick_check_performed_; | 1258 QuickCheckDetails quick_check_performed_; |
| 1259 int flush_budget_; | |
| 1256 TriBool at_start_; | 1260 TriBool at_start_; |
| 1257 }; | 1261 }; |
| 1258 | 1262 |
| 1259 | 1263 |
| 1260 class NodeVisitor { | 1264 class NodeVisitor { |
| 1261 public: | 1265 public: |
| 1262 virtual ~NodeVisitor() { } | 1266 virtual ~NodeVisitor() { } |
| 1263 #define DECLARE_VISIT(Type) \ | 1267 #define DECLARE_VISIT(Type) \ |
| 1264 virtual void Visit##Type(Type##Node* that) = 0; | 1268 virtual void Visit##Type(Type##Node* that) = 0; |
| 1265 FOR_EACH_NODE_TYPE(DECLARE_VISIT) | 1269 FOR_EACH_NODE_TYPE(DECLARE_VISIT) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1355 Handle<String> pattern, | 1359 Handle<String> pattern, |
| 1356 bool is_ascii); | 1360 bool is_ascii); |
| 1357 | 1361 |
| 1358 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); | 1362 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); |
| 1359 }; | 1363 }; |
| 1360 | 1364 |
| 1361 | 1365 |
| 1362 } } // namespace v8::internal | 1366 } } // namespace v8::internal |
| 1363 | 1367 |
| 1364 #endif // V8_JSREGEXP_H_ | 1368 #endif // V8_JSREGEXP_H_ |
| OLD | NEW |