OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 | 239 |
240 // Represents code units in the range from from_ to to_, both ends are | 240 // Represents code units in the range from from_ to to_, both ends are |
241 // inclusive. | 241 // inclusive. |
242 class CharacterRange { | 242 class CharacterRange { |
243 public: | 243 public: |
244 CharacterRange() : from_(0), to_(0) { } | 244 CharacterRange() : from_(0), to_(0) { } |
245 // For compatibility with the CHECK_OK macro | 245 // For compatibility with the CHECK_OK macro |
246 CharacterRange(void* null) { ASSERT_EQ(NULL, null); } //NOLINT | 246 CharacterRange(void* null) { ASSERT_EQ(NULL, null); } //NOLINT |
247 CharacterRange(uc16 from, uc16 to) : from_(from), to_(to) { } | 247 CharacterRange(uc16 from, uc16 to) : from_(from), to_(to) { } |
248 static void AddClassEscape(uc16 type, ZoneList<CharacterRange>* ranges); | 248 static void AddClassEscape(uc16 type, ZoneList<CharacterRange>* ranges, |
| 249 Zone* zone); |
249 static Vector<const int> GetWordBounds(); | 250 static Vector<const int> GetWordBounds(); |
250 static inline CharacterRange Singleton(uc16 value) { | 251 static inline CharacterRange Singleton(uc16 value) { |
251 return CharacterRange(value, value); | 252 return CharacterRange(value, value); |
252 } | 253 } |
253 static inline CharacterRange Range(uc16 from, uc16 to) { | 254 static inline CharacterRange Range(uc16 from, uc16 to) { |
254 ASSERT(from <= to); | 255 ASSERT(from <= to); |
255 return CharacterRange(from, to); | 256 return CharacterRange(from, to); |
256 } | 257 } |
257 static inline CharacterRange Everything() { | 258 static inline CharacterRange Everything() { |
258 return CharacterRange(0, 0xFFFF); | 259 return CharacterRange(0, 0xFFFF); |
259 } | 260 } |
260 bool Contains(uc16 i) { return from_ <= i && i <= to_; } | 261 bool Contains(uc16 i) { return from_ <= i && i <= to_; } |
261 uc16 from() const { return from_; } | 262 uc16 from() const { return from_; } |
262 void set_from(uc16 value) { from_ = value; } | 263 void set_from(uc16 value) { from_ = value; } |
263 uc16 to() const { return to_; } | 264 uc16 to() const { return to_; } |
264 void set_to(uc16 value) { to_ = value; } | 265 void set_to(uc16 value) { to_ = value; } |
265 bool is_valid() { return from_ <= to_; } | 266 bool is_valid() { return from_ <= to_; } |
266 bool IsEverything(uc16 max) { return from_ == 0 && to_ >= max; } | 267 bool IsEverything(uc16 max) { return from_ == 0 && to_ >= max; } |
267 bool IsSingleton() { return (from_ == to_); } | 268 bool IsSingleton() { return (from_ == to_); } |
268 void AddCaseEquivalents(ZoneList<CharacterRange>* ranges, bool is_ascii); | 269 void AddCaseEquivalents(ZoneList<CharacterRange>* ranges, bool is_ascii, |
| 270 Zone* zone); |
269 static void Split(ZoneList<CharacterRange>* base, | 271 static void Split(ZoneList<CharacterRange>* base, |
270 Vector<const int> overlay, | 272 Vector<const int> overlay, |
271 ZoneList<CharacterRange>** included, | 273 ZoneList<CharacterRange>** included, |
272 ZoneList<CharacterRange>** excluded); | 274 ZoneList<CharacterRange>** excluded, |
| 275 Zone* zone); |
273 // Whether a range list is in canonical form: Ranges ordered by from value, | 276 // Whether a range list is in canonical form: Ranges ordered by from value, |
274 // and ranges non-overlapping and non-adjacent. | 277 // and ranges non-overlapping and non-adjacent. |
275 static bool IsCanonical(ZoneList<CharacterRange>* ranges); | 278 static bool IsCanonical(ZoneList<CharacterRange>* ranges); |
276 // Convert range list to canonical form. The characters covered by the ranges | 279 // Convert range list to canonical form. The characters covered by the ranges |
277 // will still be the same, but no character is in more than one range, and | 280 // will still be the same, but no character is in more than one range, and |
278 // adjacent ranges are merged. The resulting list may be shorter than the | 281 // adjacent ranges are merged. The resulting list may be shorter than the |
279 // original, but cannot be longer. | 282 // original, but cannot be longer. |
280 static void Canonicalize(ZoneList<CharacterRange>* ranges); | 283 static void Canonicalize(ZoneList<CharacterRange>* ranges); |
281 // Negate the contents of a character range in canonical form. | 284 // Negate the contents of a character range in canonical form. |
282 static void Negate(ZoneList<CharacterRange>* src, | 285 static void Negate(ZoneList<CharacterRange>* src, |
283 ZoneList<CharacterRange>* dst); | 286 ZoneList<CharacterRange>* dst, |
| 287 Zone* zone); |
284 static const int kStartMarker = (1 << 24); | 288 static const int kStartMarker = (1 << 24); |
285 static const int kPayloadMask = (1 << 24) - 1; | 289 static const int kPayloadMask = (1 << 24) - 1; |
286 | 290 |
287 private: | 291 private: |
288 uc16 from_; | 292 uc16 from_; |
289 uc16 to_; | 293 uc16 to_; |
290 }; | 294 }; |
291 | 295 |
292 | 296 |
293 // A set of unsigned integers that behaves especially well on small | 297 // A set of unsigned integers that behaves especially well on small |
294 // integers (< 32). May do zone-allocation. | 298 // integers (< 32). May do zone-allocation. |
295 class OutSet: public ZoneObject { | 299 class OutSet: public ZoneObject { |
296 public: | 300 public: |
297 OutSet() : first_(0), remaining_(NULL), successors_(NULL) { } | 301 OutSet() : first_(0), remaining_(NULL), successors_(NULL) { } |
298 OutSet* Extend(unsigned value); | 302 OutSet* Extend(unsigned value, Zone* zone); |
299 bool Get(unsigned value); | 303 bool Get(unsigned value); |
300 static const unsigned kFirstLimit = 32; | 304 static const unsigned kFirstLimit = 32; |
301 | 305 |
302 private: | 306 private: |
303 // Destructively set a value in this set. In most cases you want | 307 // Destructively set a value in this set. In most cases you want |
304 // to use Extend instead to ensure that only one instance exists | 308 // to use Extend instead to ensure that only one instance exists |
305 // that contains the same values. | 309 // that contains the same values. |
306 void Set(unsigned value); | 310 void Set(unsigned value, Zone* zone); |
307 | 311 |
308 // The successors are a list of sets that contain the same values | 312 // The successors are a list of sets that contain the same values |
309 // as this set and the one more value that is not present in this | 313 // as this set and the one more value that is not present in this |
310 // set. | 314 // set. |
311 ZoneList<OutSet*>* successors() { return successors_; } | 315 ZoneList<OutSet*>* successors(Zone* zone) { return successors_; } |
312 | 316 |
313 OutSet(uint32_t first, ZoneList<unsigned>* remaining) | 317 OutSet(uint32_t first, ZoneList<unsigned>* remaining) |
314 : first_(first), remaining_(remaining), successors_(NULL) { } | 318 : first_(first), remaining_(remaining), successors_(NULL) { } |
315 uint32_t first_; | 319 uint32_t first_; |
316 ZoneList<unsigned>* remaining_; | 320 ZoneList<unsigned>* remaining_; |
317 ZoneList<OutSet*>* successors_; | 321 ZoneList<OutSet*>* successors_; |
318 friend class Trace; | 322 friend class Trace; |
319 }; | 323 }; |
320 | 324 |
321 | 325 |
322 // A mapping from integers, specified as ranges, to a set of integers. | 326 // A mapping from integers, specified as ranges, to a set of integers. |
323 // Used for mapping character ranges to choices. | 327 // Used for mapping character ranges to choices. |
324 class DispatchTable : public ZoneObject { | 328 class DispatchTable : public ZoneObject { |
325 public: | 329 public: |
| 330 explicit DispatchTable(Zone* zone) : tree_(zone) { } |
| 331 |
326 class Entry { | 332 class Entry { |
327 public: | 333 public: |
328 Entry() : from_(0), to_(0), out_set_(NULL) { } | 334 Entry() : from_(0), to_(0), out_set_(NULL) { } |
329 Entry(uc16 from, uc16 to, OutSet* out_set) | 335 Entry(uc16 from, uc16 to, OutSet* out_set) |
330 : from_(from), to_(to), out_set_(out_set) { } | 336 : from_(from), to_(to), out_set_(out_set) { } |
331 uc16 from() { return from_; } | 337 uc16 from() { return from_; } |
332 uc16 to() { return to_; } | 338 uc16 to() { return to_; } |
333 void set_to(uc16 value) { to_ = value; } | 339 void set_to(uc16 value) { to_ = value; } |
334 void AddValue(int value) { out_set_ = out_set_->Extend(value); } | 340 void AddValue(int value, Zone* zone) { |
| 341 out_set_ = out_set_->Extend(value, zone); |
| 342 } |
335 OutSet* out_set() { return out_set_; } | 343 OutSet* out_set() { return out_set_; } |
336 private: | 344 private: |
337 uc16 from_; | 345 uc16 from_; |
338 uc16 to_; | 346 uc16 to_; |
339 OutSet* out_set_; | 347 OutSet* out_set_; |
340 }; | 348 }; |
341 | 349 |
342 class Config { | 350 class Config { |
343 public: | 351 public: |
344 typedef uc16 Key; | 352 typedef uc16 Key; |
345 typedef Entry Value; | 353 typedef Entry Value; |
346 static const uc16 kNoKey; | 354 static const uc16 kNoKey; |
347 static const Entry NoValue() { return Value(); } | 355 static const Entry NoValue() { return Value(); } |
348 static inline int Compare(uc16 a, uc16 b) { | 356 static inline int Compare(uc16 a, uc16 b) { |
349 if (a == b) | 357 if (a == b) |
350 return 0; | 358 return 0; |
351 else if (a < b) | 359 else if (a < b) |
352 return -1; | 360 return -1; |
353 else | 361 else |
354 return 1; | 362 return 1; |
355 } | 363 } |
356 }; | 364 }; |
357 | 365 |
358 void AddRange(CharacterRange range, int value); | 366 void AddRange(CharacterRange range, int value, Zone* zone); |
359 OutSet* Get(uc16 value); | 367 OutSet* Get(uc16 value); |
360 void Dump(); | 368 void Dump(); |
361 | 369 |
362 template <typename Callback> | 370 template <typename Callback> |
363 void ForEach(Callback* callback) { return tree()->ForEach(callback); } | 371 void ForEach(Callback* callback) { |
| 372 return tree()->ForEach(callback); |
| 373 } |
364 | 374 |
365 private: | 375 private: |
366 // There can't be a static empty set since it allocates its | 376 // There can't be a static empty set since it allocates its |
367 // successors in a zone and caches them. | 377 // successors in a zone and caches them. |
368 OutSet* empty() { return &empty_; } | 378 OutSet* empty() { return &empty_; } |
369 OutSet empty_; | 379 OutSet empty_; |
370 ZoneSplayTree<Config>* tree() { return &tree_; } | 380 ZoneSplayTree<Config>* tree() { return &tree_; } |
371 ZoneSplayTree<Config> tree_; | 381 ZoneSplayTree<Config> tree_; |
372 }; | 382 }; |
373 | 383 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 // trace and generating generic code for a node that can be reused by flushing | 638 // trace and generating generic code for a node that can be reused by flushing |
629 // the deferred actions in the current trace and generating a goto. | 639 // the deferred actions in the current trace and generating a goto. |
630 static const int kMaxCopiesCodeGenerated = 10; | 640 static const int kMaxCopiesCodeGenerated = 10; |
631 | 641 |
632 NodeInfo* info() { return &info_; } | 642 NodeInfo* info() { return &info_; } |
633 | 643 |
634 BoyerMooreLookahead* bm_info(bool not_at_start) { | 644 BoyerMooreLookahead* bm_info(bool not_at_start) { |
635 return bm_info_[not_at_start ? 1 : 0]; | 645 return bm_info_[not_at_start ? 1 : 0]; |
636 } | 646 } |
637 | 647 |
638 Zone* zone() { return zone_; } | 648 Zone* zone() const { return zone_; } |
639 | 649 |
640 protected: | 650 protected: |
641 enum LimitResult { DONE, CONTINUE }; | 651 enum LimitResult { DONE, CONTINUE }; |
642 RegExpNode* replacement_; | 652 RegExpNode* replacement_; |
643 | 653 |
644 LimitResult LimitVersions(RegExpCompiler* compiler, Trace* trace); | 654 LimitResult LimitVersions(RegExpCompiler* compiler, Trace* trace); |
645 | 655 |
646 void set_bm_info(bool not_at_start, BoyerMooreLookahead* bm) { | 656 void set_bm_info(bool not_at_start, BoyerMooreLookahead* bm) { |
647 bm_info_[not_at_start ? 1 : 0] = bm; | 657 bm_info_[not_at_start ? 1 : 0] = bm; |
648 } | 658 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 814 |
805 class TextNode: public SeqRegExpNode { | 815 class TextNode: public SeqRegExpNode { |
806 public: | 816 public: |
807 TextNode(ZoneList<TextElement>* elms, | 817 TextNode(ZoneList<TextElement>* elms, |
808 RegExpNode* on_success) | 818 RegExpNode* on_success) |
809 : SeqRegExpNode(on_success), | 819 : SeqRegExpNode(on_success), |
810 elms_(elms) { } | 820 elms_(elms) { } |
811 TextNode(RegExpCharacterClass* that, | 821 TextNode(RegExpCharacterClass* that, |
812 RegExpNode* on_success) | 822 RegExpNode* on_success) |
813 : SeqRegExpNode(on_success), | 823 : SeqRegExpNode(on_success), |
814 elms_(new ZoneList<TextElement>(1, zone())) { | 824 elms_(new(zone()) ZoneList<TextElement>(1, zone())) { |
815 elms_->Add(TextElement::CharClass(that), zone()); | 825 elms_->Add(TextElement::CharClass(that), zone()); |
816 } | 826 } |
817 virtual void Accept(NodeVisitor* visitor); | 827 virtual void Accept(NodeVisitor* visitor); |
818 virtual void Emit(RegExpCompiler* compiler, Trace* trace); | 828 virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
819 virtual int EatsAtLeast(int still_to_find, | 829 virtual int EatsAtLeast(int still_to_find, |
820 int recursion_depth, | 830 int recursion_depth, |
821 bool not_at_start); | 831 bool not_at_start); |
822 virtual void GetQuickCheckDetails(QuickCheckDetails* details, | 832 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
823 RegExpCompiler* compiler, | 833 RegExpCompiler* compiler, |
824 int characters_filled_in, | 834 int characters_filled_in, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 class AssertionNode: public SeqRegExpNode { | 871 class AssertionNode: public SeqRegExpNode { |
862 public: | 872 public: |
863 enum AssertionNodeType { | 873 enum AssertionNodeType { |
864 AT_END, | 874 AT_END, |
865 AT_START, | 875 AT_START, |
866 AT_BOUNDARY, | 876 AT_BOUNDARY, |
867 AT_NON_BOUNDARY, | 877 AT_NON_BOUNDARY, |
868 AFTER_NEWLINE | 878 AFTER_NEWLINE |
869 }; | 879 }; |
870 static AssertionNode* AtEnd(RegExpNode* on_success) { | 880 static AssertionNode* AtEnd(RegExpNode* on_success) { |
871 return new AssertionNode(AT_END, on_success); | 881 return new(on_success->zone()) AssertionNode(AT_END, on_success); |
872 } | 882 } |
873 static AssertionNode* AtStart(RegExpNode* on_success) { | 883 static AssertionNode* AtStart(RegExpNode* on_success) { |
874 return new AssertionNode(AT_START, on_success); | 884 return new(on_success->zone()) AssertionNode(AT_START, on_success); |
875 } | 885 } |
876 static AssertionNode* AtBoundary(RegExpNode* on_success) { | 886 static AssertionNode* AtBoundary(RegExpNode* on_success) { |
877 return new AssertionNode(AT_BOUNDARY, on_success); | 887 return new(on_success->zone()) AssertionNode(AT_BOUNDARY, on_success); |
878 } | 888 } |
879 static AssertionNode* AtNonBoundary(RegExpNode* on_success) { | 889 static AssertionNode* AtNonBoundary(RegExpNode* on_success) { |
880 return new AssertionNode(AT_NON_BOUNDARY, on_success); | 890 return new(on_success->zone()) AssertionNode(AT_NON_BOUNDARY, on_success); |
881 } | 891 } |
882 static AssertionNode* AfterNewline(RegExpNode* on_success) { | 892 static AssertionNode* AfterNewline(RegExpNode* on_success) { |
883 return new AssertionNode(AFTER_NEWLINE, on_success); | 893 return new(on_success->zone()) AssertionNode(AFTER_NEWLINE, on_success); |
884 } | 894 } |
885 virtual void Accept(NodeVisitor* visitor); | 895 virtual void Accept(NodeVisitor* visitor); |
886 virtual void Emit(RegExpCompiler* compiler, Trace* trace); | 896 virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
887 virtual int EatsAtLeast(int still_to_find, | 897 virtual int EatsAtLeast(int still_to_find, |
888 int recursion_depth, | 898 int recursion_depth, |
889 bool not_at_start); | 899 bool not_at_start); |
890 virtual void GetQuickCheckDetails(QuickCheckDetails* details, | 900 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
891 RegExpCompiler* compiler, | 901 RegExpCompiler* compiler, |
892 int filled_in, | 902 int filled_in, |
893 bool not_at_start); | 903 bool not_at_start); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 private: | 1021 private: |
1012 int reg_; | 1022 int reg_; |
1013 Relation op_; | 1023 Relation op_; |
1014 int value_; | 1024 int value_; |
1015 }; | 1025 }; |
1016 | 1026 |
1017 | 1027 |
1018 class GuardedAlternative { | 1028 class GuardedAlternative { |
1019 public: | 1029 public: |
1020 explicit GuardedAlternative(RegExpNode* node) : node_(node), guards_(NULL) { } | 1030 explicit GuardedAlternative(RegExpNode* node) : node_(node), guards_(NULL) { } |
1021 void AddGuard(Guard* guard); | 1031 void AddGuard(Guard* guard, Zone* zone); |
1022 RegExpNode* node() { return node_; } | 1032 RegExpNode* node() { return node_; } |
1023 void set_node(RegExpNode* node) { node_ = node; } | 1033 void set_node(RegExpNode* node) { node_ = node; } |
1024 ZoneList<Guard*>* guards() { return guards_; } | 1034 ZoneList<Guard*>* guards() { return guards_; } |
1025 | 1035 |
1026 private: | 1036 private: |
1027 RegExpNode* node_; | 1037 RegExpNode* node_; |
1028 ZoneList<Guard*>* guards_; | 1038 ZoneList<Guard*>* guards_; |
1029 }; | 1039 }; |
1030 | 1040 |
1031 | 1041 |
1032 class AlternativeGeneration; | 1042 class AlternativeGeneration; |
1033 | 1043 |
1034 | 1044 |
1035 class ChoiceNode: public RegExpNode { | 1045 class ChoiceNode: public RegExpNode { |
1036 public: | 1046 public: |
1037 explicit ChoiceNode(int expected_size, Zone* zone) | 1047 explicit ChoiceNode(int expected_size, Zone* zone) |
1038 : RegExpNode(zone), | 1048 : RegExpNode(zone), |
1039 alternatives_(new ZoneList<GuardedAlternative>(expected_size, zone)), | 1049 alternatives_(new(zone) |
| 1050 ZoneList<GuardedAlternative>(expected_size, zone)), |
1040 table_(NULL), | 1051 table_(NULL), |
1041 not_at_start_(false), | 1052 not_at_start_(false), |
1042 being_calculated_(false) { } | 1053 being_calculated_(false) { } |
1043 virtual void Accept(NodeVisitor* visitor); | 1054 virtual void Accept(NodeVisitor* visitor); |
1044 void AddAlternative(GuardedAlternative node) { | 1055 void AddAlternative(GuardedAlternative node) { |
1045 alternatives()->Add(node, zone()); | 1056 alternatives()->Add(node, zone()); |
1046 } | 1057 } |
1047 ZoneList<GuardedAlternative>* alternatives() { return alternatives_; } | 1058 ZoneList<GuardedAlternative>* alternatives() { return alternatives_; } |
1048 DispatchTable* GetTable(bool ignore_case); | 1059 DispatchTable* GetTable(bool ignore_case); |
1049 virtual void Emit(RegExpCompiler* compiler, Trace* trace); | 1060 virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 | 1224 |
1214 ContainedInLattice AddRange(ContainedInLattice a, | 1225 ContainedInLattice AddRange(ContainedInLattice a, |
1215 const int* ranges, | 1226 const int* ranges, |
1216 int ranges_size, | 1227 int ranges_size, |
1217 Interval new_range); | 1228 Interval new_range); |
1218 | 1229 |
1219 | 1230 |
1220 class BoyerMoorePositionInfo : public ZoneObject { | 1231 class BoyerMoorePositionInfo : public ZoneObject { |
1221 public: | 1232 public: |
1222 explicit BoyerMoorePositionInfo(Zone* zone) | 1233 explicit BoyerMoorePositionInfo(Zone* zone) |
1223 : map_(new ZoneList<bool>(kMapSize, zone)), | 1234 : map_(new(zone) ZoneList<bool>(kMapSize, zone)), |
1224 map_count_(0), | 1235 map_count_(0), |
1225 w_(kNotYet), | 1236 w_(kNotYet), |
1226 s_(kNotYet), | 1237 s_(kNotYet), |
1227 d_(kNotYet), | 1238 d_(kNotYet), |
1228 surrogate_(kNotYet) { | 1239 surrogate_(kNotYet) { |
1229 for (int i = 0; i < kMapSize; i++) { | 1240 for (int i = 0; i < kMapSize; i++) { |
1230 map_->Add(false, zone); | 1241 map_->Add(false, zone); |
1231 } | 1242 } |
1232 } | 1243 } |
1233 | 1244 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 void set_characters_preloaded(int count) { characters_preloaded_ = count; } | 1462 void set_characters_preloaded(int count) { characters_preloaded_ = count; } |
1452 void set_bound_checked_up_to(int to) { bound_checked_up_to_ = to; } | 1463 void set_bound_checked_up_to(int to) { bound_checked_up_to_ = to; } |
1453 void set_flush_budget(int to) { flush_budget_ = to; } | 1464 void set_flush_budget(int to) { flush_budget_ = to; } |
1454 void set_quick_check_performed(QuickCheckDetails* d) { | 1465 void set_quick_check_performed(QuickCheckDetails* d) { |
1455 quick_check_performed_ = *d; | 1466 quick_check_performed_ = *d; |
1456 } | 1467 } |
1457 void InvalidateCurrentCharacter(); | 1468 void InvalidateCurrentCharacter(); |
1458 void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler); | 1469 void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler); |
1459 | 1470 |
1460 private: | 1471 private: |
1461 int FindAffectedRegisters(OutSet* affected_registers); | 1472 int FindAffectedRegisters(OutSet* affected_registers, Zone* zone); |
1462 void PerformDeferredActions(RegExpMacroAssembler* macro, | 1473 void PerformDeferredActions(RegExpMacroAssembler* macro, |
1463 int max_register, | 1474 int max_register, |
1464 OutSet& affected_registers, | 1475 OutSet& affected_registers, |
1465 OutSet* registers_to_pop, | 1476 OutSet* registers_to_pop, |
1466 OutSet* registers_to_clear); | 1477 OutSet* registers_to_clear, |
| 1478 Zone* zone); |
1467 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, | 1479 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, |
1468 int max_register, | 1480 int max_register, |
1469 OutSet& registers_to_pop, | 1481 OutSet& registers_to_pop, |
1470 OutSet& registers_to_clear); | 1482 OutSet& registers_to_clear); |
1471 int cp_offset_; | 1483 int cp_offset_; |
1472 DeferredAction* actions_; | 1484 DeferredAction* actions_; |
1473 Label* backtrack_; | 1485 Label* backtrack_; |
1474 RegExpNode* stop_node_; | 1486 RegExpNode* stop_node_; |
1475 Label* loop_label_; | 1487 Label* loop_label_; |
1476 int characters_preloaded_; | 1488 int characters_preloaded_; |
(...skipping 12 matching lines...) Expand all Loading... |
1489 FOR_EACH_NODE_TYPE(DECLARE_VISIT) | 1501 FOR_EACH_NODE_TYPE(DECLARE_VISIT) |
1490 #undef DECLARE_VISIT | 1502 #undef DECLARE_VISIT |
1491 virtual void VisitLoopChoice(LoopChoiceNode* that) { VisitChoice(that); } | 1503 virtual void VisitLoopChoice(LoopChoiceNode* that) { VisitChoice(that); } |
1492 }; | 1504 }; |
1493 | 1505 |
1494 | 1506 |
1495 // Node visitor used to add the start set of the alternatives to the | 1507 // Node visitor used to add the start set of the alternatives to the |
1496 // dispatch table of a choice node. | 1508 // dispatch table of a choice node. |
1497 class DispatchTableConstructor: public NodeVisitor { | 1509 class DispatchTableConstructor: public NodeVisitor { |
1498 public: | 1510 public: |
1499 DispatchTableConstructor(DispatchTable* table, bool ignore_case) | 1511 DispatchTableConstructor(DispatchTable* table, bool ignore_case, |
| 1512 Zone* zone) |
1500 : table_(table), | 1513 : table_(table), |
1501 choice_index_(-1), | 1514 choice_index_(-1), |
1502 ignore_case_(ignore_case) { } | 1515 ignore_case_(ignore_case), |
| 1516 zone_(zone) { } |
1503 | 1517 |
1504 void BuildTable(ChoiceNode* node); | 1518 void BuildTable(ChoiceNode* node); |
1505 | 1519 |
1506 void AddRange(CharacterRange range) { | 1520 void AddRange(CharacterRange range) { |
1507 table()->AddRange(range, choice_index_); | 1521 table()->AddRange(range, choice_index_, zone_); |
1508 } | 1522 } |
1509 | 1523 |
1510 void AddInverse(ZoneList<CharacterRange>* ranges); | 1524 void AddInverse(ZoneList<CharacterRange>* ranges); |
1511 | 1525 |
1512 #define DECLARE_VISIT(Type) \ | 1526 #define DECLARE_VISIT(Type) \ |
1513 virtual void Visit##Type(Type##Node* that); | 1527 virtual void Visit##Type(Type##Node* that); |
1514 FOR_EACH_NODE_TYPE(DECLARE_VISIT) | 1528 FOR_EACH_NODE_TYPE(DECLARE_VISIT) |
1515 #undef DECLARE_VISIT | 1529 #undef DECLARE_VISIT |
1516 | 1530 |
1517 DispatchTable* table() { return table_; } | 1531 DispatchTable* table() { return table_; } |
1518 void set_choice_index(int value) { choice_index_ = value; } | 1532 void set_choice_index(int value) { choice_index_ = value; } |
1519 | 1533 |
1520 protected: | 1534 protected: |
1521 DispatchTable* table_; | 1535 DispatchTable* table_; |
1522 int choice_index_; | 1536 int choice_index_; |
1523 bool ignore_case_; | 1537 bool ignore_case_; |
| 1538 Zone* zone_; |
1524 }; | 1539 }; |
1525 | 1540 |
1526 | 1541 |
1527 // Assertion propagation moves information about assertions such as | 1542 // Assertion propagation moves information about assertions such as |
1528 // \b to the affected nodes. For instance, in /.\b./ information must | 1543 // \b to the affected nodes. For instance, in /.\b./ information must |
1529 // be propagated to the first '.' that whatever follows needs to know | 1544 // be propagated to the first '.' that whatever follows needs to know |
1530 // if it matched a word or a non-word, and to the second '.' that it | 1545 // if it matched a word or a non-word, and to the second '.' that it |
1531 // has to check if it succeeds a word or non-word. In this case the | 1546 // has to check if it succeeds a word or non-word. In this case the |
1532 // result will be something like: | 1547 // result will be something like: |
1533 // | 1548 // |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 int* vector_; | 1657 int* vector_; |
1643 int offsets_vector_length_; | 1658 int offsets_vector_length_; |
1644 | 1659 |
1645 friend class ExternalReference; | 1660 friend class ExternalReference; |
1646 }; | 1661 }; |
1647 | 1662 |
1648 | 1663 |
1649 } } // namespace v8::internal | 1664 } } // namespace v8::internal |
1650 | 1665 |
1651 #endif // V8_JSREGEXP_H_ | 1666 #endif // V8_JSREGEXP_H_ |
OLD | NEW |