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: |
326 class Entry { | 330 class Entry { |
327 public: | 331 public: |
328 Entry() : from_(0), to_(0), out_set_(NULL) { } | 332 Entry() : from_(0), to_(0), out_set_(NULL) { } |
329 Entry(uc16 from, uc16 to, OutSet* out_set) | 333 Entry(uc16 from, uc16 to, OutSet* out_set) |
330 : from_(from), to_(to), out_set_(out_set) { } | 334 : from_(from), to_(to), out_set_(out_set) { } |
331 uc16 from() { return from_; } | 335 uc16 from() { return from_; } |
332 uc16 to() { return to_; } | 336 uc16 to() { return to_; } |
333 void set_to(uc16 value) { to_ = value; } | 337 void set_to(uc16 value) { to_ = value; } |
334 void AddValue(int value) { out_set_ = out_set_->Extend(value); } | 338 void AddValue(int value, Zone* zone) { |
| 339 out_set_ = out_set_->Extend(value, zone); |
| 340 } |
335 OutSet* out_set() { return out_set_; } | 341 OutSet* out_set() { return out_set_; } |
336 private: | 342 private: |
337 uc16 from_; | 343 uc16 from_; |
338 uc16 to_; | 344 uc16 to_; |
339 OutSet* out_set_; | 345 OutSet* out_set_; |
340 }; | 346 }; |
341 | 347 |
342 class Config { | 348 class Config { |
343 public: | 349 public: |
344 typedef uc16 Key; | 350 typedef uc16 Key; |
345 typedef Entry Value; | 351 typedef Entry Value; |
346 static const uc16 kNoKey; | 352 static const uc16 kNoKey; |
347 static const Entry NoValue() { return Value(); } | 353 static const Entry NoValue() { return Value(); } |
348 static inline int Compare(uc16 a, uc16 b) { | 354 static inline int Compare(uc16 a, uc16 b) { |
349 if (a == b) | 355 if (a == b) |
350 return 0; | 356 return 0; |
351 else if (a < b) | 357 else if (a < b) |
352 return -1; | 358 return -1; |
353 else | 359 else |
354 return 1; | 360 return 1; |
355 } | 361 } |
356 }; | 362 }; |
357 | 363 |
358 void AddRange(CharacterRange range, int value); | 364 void AddRange(CharacterRange range, int value, Zone* zone); |
359 OutSet* Get(uc16 value); | 365 OutSet* Get(uc16 value); |
360 void Dump(); | 366 void Dump(); |
361 | 367 |
362 template <typename Callback> | 368 template <typename Callback> |
363 void ForEach(Callback* callback) { return tree()->ForEach(callback); } | 369 void ForEach(Callback* callback, Zone* zone) { |
| 370 return tree()->ForEach(callback, ZoneAllocationPolicy(zone)); |
| 371 } |
364 | 372 |
365 private: | 373 private: |
366 // There can't be a static empty set since it allocates its | 374 // There can't be a static empty set since it allocates its |
367 // successors in a zone and caches them. | 375 // successors in a zone and caches them. |
368 OutSet* empty() { return &empty_; } | 376 OutSet* empty() { return &empty_; } |
369 OutSet empty_; | 377 OutSet empty_; |
370 ZoneSplayTree<Config>* tree() { return &tree_; } | 378 ZoneSplayTree<Config>* tree() { return &tree_; } |
371 ZoneSplayTree<Config> tree_; | 379 ZoneSplayTree<Config> tree_; |
372 }; | 380 }; |
373 | 381 |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 812 |
805 class TextNode: public SeqRegExpNode { | 813 class TextNode: public SeqRegExpNode { |
806 public: | 814 public: |
807 TextNode(ZoneList<TextElement>* elms, | 815 TextNode(ZoneList<TextElement>* elms, |
808 RegExpNode* on_success) | 816 RegExpNode* on_success) |
809 : SeqRegExpNode(on_success), | 817 : SeqRegExpNode(on_success), |
810 elms_(elms) { } | 818 elms_(elms) { } |
811 TextNode(RegExpCharacterClass* that, | 819 TextNode(RegExpCharacterClass* that, |
812 RegExpNode* on_success) | 820 RegExpNode* on_success) |
813 : SeqRegExpNode(on_success), | 821 : SeqRegExpNode(on_success), |
814 elms_(new ZoneList<TextElement>(1, zone())) { | 822 elms_(new(zone()) ZoneList<TextElement>(1, zone())) { |
815 elms_->Add(TextElement::CharClass(that), zone()); | 823 elms_->Add(TextElement::CharClass(that), zone()); |
816 } | 824 } |
817 virtual void Accept(NodeVisitor* visitor); | 825 virtual void Accept(NodeVisitor* visitor); |
818 virtual void Emit(RegExpCompiler* compiler, Trace* trace); | 826 virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
819 virtual int EatsAtLeast(int still_to_find, | 827 virtual int EatsAtLeast(int still_to_find, |
820 int recursion_depth, | 828 int recursion_depth, |
821 bool not_at_start); | 829 bool not_at_start); |
822 virtual void GetQuickCheckDetails(QuickCheckDetails* details, | 830 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
823 RegExpCompiler* compiler, | 831 RegExpCompiler* compiler, |
824 int characters_filled_in, | 832 int characters_filled_in, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 class AssertionNode: public SeqRegExpNode { | 869 class AssertionNode: public SeqRegExpNode { |
862 public: | 870 public: |
863 enum AssertionNodeType { | 871 enum AssertionNodeType { |
864 AT_END, | 872 AT_END, |
865 AT_START, | 873 AT_START, |
866 AT_BOUNDARY, | 874 AT_BOUNDARY, |
867 AT_NON_BOUNDARY, | 875 AT_NON_BOUNDARY, |
868 AFTER_NEWLINE | 876 AFTER_NEWLINE |
869 }; | 877 }; |
870 static AssertionNode* AtEnd(RegExpNode* on_success) { | 878 static AssertionNode* AtEnd(RegExpNode* on_success) { |
871 return new AssertionNode(AT_END, on_success); | 879 return new(on_success->zone()) AssertionNode(AT_END, on_success); |
872 } | 880 } |
873 static AssertionNode* AtStart(RegExpNode* on_success) { | 881 static AssertionNode* AtStart(RegExpNode* on_success) { |
874 return new AssertionNode(AT_START, on_success); | 882 return new(on_success->zone()) AssertionNode(AT_START, on_success); |
875 } | 883 } |
876 static AssertionNode* AtBoundary(RegExpNode* on_success) { | 884 static AssertionNode* AtBoundary(RegExpNode* on_success) { |
877 return new AssertionNode(AT_BOUNDARY, on_success); | 885 return new(on_success->zone()) AssertionNode(AT_BOUNDARY, on_success); |
878 } | 886 } |
879 static AssertionNode* AtNonBoundary(RegExpNode* on_success) { | 887 static AssertionNode* AtNonBoundary(RegExpNode* on_success) { |
880 return new AssertionNode(AT_NON_BOUNDARY, on_success); | 888 return new(on_success->zone()) AssertionNode(AT_NON_BOUNDARY, on_success); |
881 } | 889 } |
882 static AssertionNode* AfterNewline(RegExpNode* on_success) { | 890 static AssertionNode* AfterNewline(RegExpNode* on_success) { |
883 return new AssertionNode(AFTER_NEWLINE, on_success); | 891 return new(on_success->zone()) AssertionNode(AFTER_NEWLINE, on_success); |
884 } | 892 } |
885 virtual void Accept(NodeVisitor* visitor); | 893 virtual void Accept(NodeVisitor* visitor); |
886 virtual void Emit(RegExpCompiler* compiler, Trace* trace); | 894 virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
887 virtual int EatsAtLeast(int still_to_find, | 895 virtual int EatsAtLeast(int still_to_find, |
888 int recursion_depth, | 896 int recursion_depth, |
889 bool not_at_start); | 897 bool not_at_start); |
890 virtual void GetQuickCheckDetails(QuickCheckDetails* details, | 898 virtual void GetQuickCheckDetails(QuickCheckDetails* details, |
891 RegExpCompiler* compiler, | 899 RegExpCompiler* compiler, |
892 int filled_in, | 900 int filled_in, |
893 bool not_at_start); | 901 bool not_at_start); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 private: | 1019 private: |
1012 int reg_; | 1020 int reg_; |
1013 Relation op_; | 1021 Relation op_; |
1014 int value_; | 1022 int value_; |
1015 }; | 1023 }; |
1016 | 1024 |
1017 | 1025 |
1018 class GuardedAlternative { | 1026 class GuardedAlternative { |
1019 public: | 1027 public: |
1020 explicit GuardedAlternative(RegExpNode* node) : node_(node), guards_(NULL) { } | 1028 explicit GuardedAlternative(RegExpNode* node) : node_(node), guards_(NULL) { } |
1021 void AddGuard(Guard* guard); | 1029 void AddGuard(Guard* guard, Zone* zone); |
1022 RegExpNode* node() { return node_; } | 1030 RegExpNode* node() { return node_; } |
1023 void set_node(RegExpNode* node) { node_ = node; } | 1031 void set_node(RegExpNode* node) { node_ = node; } |
1024 ZoneList<Guard*>* guards() { return guards_; } | 1032 ZoneList<Guard*>* guards() { return guards_; } |
1025 | 1033 |
1026 private: | 1034 private: |
1027 RegExpNode* node_; | 1035 RegExpNode* node_; |
1028 ZoneList<Guard*>* guards_; | 1036 ZoneList<Guard*>* guards_; |
1029 }; | 1037 }; |
1030 | 1038 |
1031 | 1039 |
1032 class AlternativeGeneration; | 1040 class AlternativeGeneration; |
1033 | 1041 |
1034 | 1042 |
1035 class ChoiceNode: public RegExpNode { | 1043 class ChoiceNode: public RegExpNode { |
1036 public: | 1044 public: |
1037 explicit ChoiceNode(int expected_size, Zone* zone) | 1045 explicit ChoiceNode(int expected_size, Zone* zone) |
1038 : RegExpNode(zone), | 1046 : RegExpNode(zone), |
1039 alternatives_(new ZoneList<GuardedAlternative>(expected_size, zone)), | 1047 alternatives_(new(zone) |
| 1048 ZoneList<GuardedAlternative>(expected_size, zone)), |
1040 table_(NULL), | 1049 table_(NULL), |
1041 not_at_start_(false), | 1050 not_at_start_(false), |
1042 being_calculated_(false) { } | 1051 being_calculated_(false) { } |
1043 virtual void Accept(NodeVisitor* visitor); | 1052 virtual void Accept(NodeVisitor* visitor); |
1044 void AddAlternative(GuardedAlternative node) { | 1053 void AddAlternative(GuardedAlternative node) { |
1045 alternatives()->Add(node, zone()); | 1054 alternatives()->Add(node, zone()); |
1046 } | 1055 } |
1047 ZoneList<GuardedAlternative>* alternatives() { return alternatives_; } | 1056 ZoneList<GuardedAlternative>* alternatives() { return alternatives_; } |
1048 DispatchTable* GetTable(bool ignore_case); | 1057 DispatchTable* GetTable(bool ignore_case); |
1049 virtual void Emit(RegExpCompiler* compiler, Trace* trace); | 1058 virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 | 1222 |
1214 ContainedInLattice AddRange(ContainedInLattice a, | 1223 ContainedInLattice AddRange(ContainedInLattice a, |
1215 const int* ranges, | 1224 const int* ranges, |
1216 int ranges_size, | 1225 int ranges_size, |
1217 Interval new_range); | 1226 Interval new_range); |
1218 | 1227 |
1219 | 1228 |
1220 class BoyerMoorePositionInfo : public ZoneObject { | 1229 class BoyerMoorePositionInfo : public ZoneObject { |
1221 public: | 1230 public: |
1222 explicit BoyerMoorePositionInfo(Zone* zone) | 1231 explicit BoyerMoorePositionInfo(Zone* zone) |
1223 : map_(new ZoneList<bool>(kMapSize, zone)), | 1232 : map_(new(zone) ZoneList<bool>(kMapSize, zone)), |
1224 map_count_(0), | 1233 map_count_(0), |
1225 w_(kNotYet), | 1234 w_(kNotYet), |
1226 s_(kNotYet), | 1235 s_(kNotYet), |
1227 d_(kNotYet), | 1236 d_(kNotYet), |
1228 surrogate_(kNotYet) { | 1237 surrogate_(kNotYet) { |
1229 for (int i = 0; i < kMapSize; i++) { | 1238 for (int i = 0; i < kMapSize; i++) { |
1230 map_->Add(false, zone); | 1239 map_->Add(false, zone); |
1231 } | 1240 } |
1232 } | 1241 } |
1233 | 1242 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 void set_characters_preloaded(int count) { characters_preloaded_ = count; } | 1460 void set_characters_preloaded(int count) { characters_preloaded_ = count; } |
1452 void set_bound_checked_up_to(int to) { bound_checked_up_to_ = to; } | 1461 void set_bound_checked_up_to(int to) { bound_checked_up_to_ = to; } |
1453 void set_flush_budget(int to) { flush_budget_ = to; } | 1462 void set_flush_budget(int to) { flush_budget_ = to; } |
1454 void set_quick_check_performed(QuickCheckDetails* d) { | 1463 void set_quick_check_performed(QuickCheckDetails* d) { |
1455 quick_check_performed_ = *d; | 1464 quick_check_performed_ = *d; |
1456 } | 1465 } |
1457 void InvalidateCurrentCharacter(); | 1466 void InvalidateCurrentCharacter(); |
1458 void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler); | 1467 void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler); |
1459 | 1468 |
1460 private: | 1469 private: |
1461 int FindAffectedRegisters(OutSet* affected_registers); | 1470 int FindAffectedRegisters(OutSet* affected_registers, Zone* zone); |
1462 void PerformDeferredActions(RegExpMacroAssembler* macro, | 1471 void PerformDeferredActions(RegExpMacroAssembler* macro, |
1463 int max_register, | 1472 int max_register, |
1464 OutSet& affected_registers, | 1473 OutSet& affected_registers, |
1465 OutSet* registers_to_pop, | 1474 OutSet* registers_to_pop, |
1466 OutSet* registers_to_clear); | 1475 OutSet* registers_to_clear, |
| 1476 Zone* zone); |
1467 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, | 1477 void RestoreAffectedRegisters(RegExpMacroAssembler* macro, |
1468 int max_register, | 1478 int max_register, |
1469 OutSet& registers_to_pop, | 1479 OutSet& registers_to_pop, |
1470 OutSet& registers_to_clear); | 1480 OutSet& registers_to_clear); |
1471 int cp_offset_; | 1481 int cp_offset_; |
1472 DeferredAction* actions_; | 1482 DeferredAction* actions_; |
1473 Label* backtrack_; | 1483 Label* backtrack_; |
1474 RegExpNode* stop_node_; | 1484 RegExpNode* stop_node_; |
1475 Label* loop_label_; | 1485 Label* loop_label_; |
1476 int characters_preloaded_; | 1486 int characters_preloaded_; |
(...skipping 12 matching lines...) Expand all Loading... |
1489 FOR_EACH_NODE_TYPE(DECLARE_VISIT) | 1499 FOR_EACH_NODE_TYPE(DECLARE_VISIT) |
1490 #undef DECLARE_VISIT | 1500 #undef DECLARE_VISIT |
1491 virtual void VisitLoopChoice(LoopChoiceNode* that) { VisitChoice(that); } | 1501 virtual void VisitLoopChoice(LoopChoiceNode* that) { VisitChoice(that); } |
1492 }; | 1502 }; |
1493 | 1503 |
1494 | 1504 |
1495 // Node visitor used to add the start set of the alternatives to the | 1505 // Node visitor used to add the start set of the alternatives to the |
1496 // dispatch table of a choice node. | 1506 // dispatch table of a choice node. |
1497 class DispatchTableConstructor: public NodeVisitor { | 1507 class DispatchTableConstructor: public NodeVisitor { |
1498 public: | 1508 public: |
1499 DispatchTableConstructor(DispatchTable* table, bool ignore_case) | 1509 DispatchTableConstructor(DispatchTable* table, bool ignore_case, |
| 1510 Zone* zone) |
1500 : table_(table), | 1511 : table_(table), |
1501 choice_index_(-1), | 1512 choice_index_(-1), |
1502 ignore_case_(ignore_case) { } | 1513 ignore_case_(ignore_case), |
| 1514 zone_(zone) { } |
1503 | 1515 |
1504 void BuildTable(ChoiceNode* node); | 1516 void BuildTable(ChoiceNode* node); |
1505 | 1517 |
1506 void AddRange(CharacterRange range) { | 1518 void AddRange(CharacterRange range) { |
1507 table()->AddRange(range, choice_index_); | 1519 table()->AddRange(range, choice_index_, zone_); |
1508 } | 1520 } |
1509 | 1521 |
1510 void AddInverse(ZoneList<CharacterRange>* ranges); | 1522 void AddInverse(ZoneList<CharacterRange>* ranges); |
1511 | 1523 |
1512 #define DECLARE_VISIT(Type) \ | 1524 #define DECLARE_VISIT(Type) \ |
1513 virtual void Visit##Type(Type##Node* that); | 1525 virtual void Visit##Type(Type##Node* that); |
1514 FOR_EACH_NODE_TYPE(DECLARE_VISIT) | 1526 FOR_EACH_NODE_TYPE(DECLARE_VISIT) |
1515 #undef DECLARE_VISIT | 1527 #undef DECLARE_VISIT |
1516 | 1528 |
1517 DispatchTable* table() { return table_; } | 1529 DispatchTable* table() { return table_; } |
1518 void set_choice_index(int value) { choice_index_ = value; } | 1530 void set_choice_index(int value) { choice_index_ = value; } |
1519 | 1531 |
1520 protected: | 1532 protected: |
1521 DispatchTable* table_; | 1533 DispatchTable* table_; |
1522 int choice_index_; | 1534 int choice_index_; |
1523 bool ignore_case_; | 1535 bool ignore_case_; |
| 1536 Zone* zone_; |
1524 }; | 1537 }; |
1525 | 1538 |
1526 | 1539 |
1527 // Assertion propagation moves information about assertions such as | 1540 // Assertion propagation moves information about assertions such as |
1528 // \b to the affected nodes. For instance, in /.\b./ information must | 1541 // \b to the affected nodes. For instance, in /.\b./ information must |
1529 // be propagated to the first '.' that whatever follows needs to know | 1542 // 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 | 1543 // 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 | 1544 // has to check if it succeeds a word or non-word. In this case the |
1532 // result will be something like: | 1545 // result will be something like: |
1533 // | 1546 // |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 int* vector_; | 1655 int* vector_; |
1643 int offsets_vector_length_; | 1656 int offsets_vector_length_; |
1644 | 1657 |
1645 friend class ExternalReference; | 1658 friend class ExternalReference; |
1646 }; | 1659 }; |
1647 | 1660 |
1648 | 1661 |
1649 } } // namespace v8::internal | 1662 } } // namespace v8::internal |
1650 | 1663 |
1651 #endif // V8_JSREGEXP_H_ | 1664 #endif // V8_JSREGEXP_H_ |
OLD | NEW |