| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_REGEXP_JSREGEXP_H_ | 5 #ifndef V8_REGEXP_JSREGEXP_H_ |
| 6 #define V8_REGEXP_JSREGEXP_H_ | 6 #define V8_REGEXP_JSREGEXP_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
| 10 #include "src/regexp/regexp-ast.h" | 10 #include "src/regexp/regexp-ast.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 enum ElementInSetsRelation { | 175 enum ElementInSetsRelation { |
| 176 kInsideNone = 0, | 176 kInsideNone = 0, |
| 177 kInsideFirst = 1, | 177 kInsideFirst = 1, |
| 178 kInsideSecond = 2, | 178 kInsideSecond = 2, |
| 179 kInsideBoth = 3 | 179 kInsideBoth = 3 |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 | 182 |
| 183 // A set of unsigned integers that behaves especially well on small | 183 // A set of unsigned integers that behaves especially well on small |
| 184 // integers (< 32). May do zone-allocation. | 184 // integers (< 32). May do zone-allocation. |
| 185 class OutSet: public ZoneObject { | 185 class OutSet : public ZoneObject { |
| 186 public: | 186 public: |
| 187 OutSet() : first_(0), remaining_(NULL), successors_(NULL) { } | 187 OutSet() : first_(0), remaining_(NULL), successors_(NULL) { } |
| 188 OutSet* Extend(unsigned value, Zone* zone); | 188 OutSet* Extend(unsigned value, Zone* zone); |
| 189 bool Get(unsigned value) const; | 189 bool Get(unsigned value) const; |
| 190 static const unsigned kFirstLimit = 32; | 190 static const unsigned kFirstLimit = 32; |
| 191 | 191 |
| 192 private: | 192 private: |
| 193 // Destructively set a value in this set. In most cases you want | 193 // Destructively set a value in this set. In most cases you want |
| 194 // to use Extend instead to ensure that only one instance exists | 194 // to use Extend instead to ensure that only one instance exists |
| 195 // that contains the same values. | 195 // that contains the same values. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 uint32_t mask_; | 422 uint32_t mask_; |
| 423 uint32_t value_; | 423 uint32_t value_; |
| 424 // If set to true, there is no way this quick check can match at all. | 424 // If set to true, there is no way this quick check can match at all. |
| 425 // E.g., if it requires to be at the start of the input, and isn't. | 425 // E.g., if it requires to be at the start of the input, and isn't. |
| 426 bool cannot_match_; | 426 bool cannot_match_; |
| 427 }; | 427 }; |
| 428 | 428 |
| 429 | 429 |
| 430 extern int kUninitializedRegExpNodePlaceHolder; | 430 extern int kUninitializedRegExpNodePlaceHolder; |
| 431 | 431 |
| 432 | 432 class RegExpNode : public ZoneObject { |
| 433 class RegExpNode: public ZoneObject { | |
| 434 public: | 433 public: |
| 435 explicit RegExpNode(Zone* zone) | 434 explicit RegExpNode(Zone* zone) |
| 436 : replacement_(NULL), on_work_list_(false), trace_count_(0), zone_(zone) { | 435 : replacement_(NULL), on_work_list_(false), trace_count_(0), zone_(zone) { |
| 437 bm_info_[0] = bm_info_[1] = NULL; | 436 bm_info_[0] = bm_info_[1] = NULL; |
| 438 } | 437 } |
| 439 virtual ~RegExpNode(); | 438 virtual ~RegExpNode(); |
| 440 virtual void Accept(NodeVisitor* visitor) = 0; | 439 virtual void Accept(NodeVisitor* visitor) = 0; |
| 441 // Generates a goto to this node or actually generates the code at this point. | 440 // Generates a goto to this node or actually generates the code at this point. |
| 442 virtual void Emit(RegExpCompiler* compiler, Trace* trace) = 0; | 441 virtual void Emit(RegExpCompiler* compiler, Trace* trace) = 0; |
| 443 // How many characters must this node consume at a minimum in order to | 442 // How many characters must this node consume at a minimum in order to |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 clear_capture_start_(clear_capture_start) { } | 844 clear_capture_start_(clear_capture_start) { } |
| 846 virtual void Emit(RegExpCompiler* compiler, Trace* trace); | 845 virtual void Emit(RegExpCompiler* compiler, Trace* trace); |
| 847 | 846 |
| 848 private: | 847 private: |
| 849 int stack_pointer_register_; | 848 int stack_pointer_register_; |
| 850 int current_position_register_; | 849 int current_position_register_; |
| 851 int clear_capture_count_; | 850 int clear_capture_count_; |
| 852 int clear_capture_start_; | 851 int clear_capture_start_; |
| 853 }; | 852 }; |
| 854 | 853 |
| 855 | 854 class Guard : public ZoneObject { |
| 856 class Guard: public ZoneObject { | |
| 857 public: | 855 public: |
| 858 enum Relation { LT, GEQ }; | 856 enum Relation { LT, GEQ }; |
| 859 Guard(int reg, Relation op, int value) | 857 Guard(int reg, Relation op, int value) |
| 860 : reg_(reg), | 858 : reg_(reg), |
| 861 op_(op), | 859 op_(op), |
| 862 value_(value) { } | 860 value_(value) { } |
| 863 int reg() { return reg_; } | 861 int reg() { return reg_; } |
| 864 Relation op() { return op_; } | 862 Relation op() { return op_; } |
| 865 int value() { return value_; } | 863 int value() { return value_; } |
| 866 | 864 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 inline ContainedInLattice Combine(ContainedInLattice a, ContainedInLattice b) { | 1073 inline ContainedInLattice Combine(ContainedInLattice a, ContainedInLattice b) { |
| 1076 return static_cast<ContainedInLattice>(a | b); | 1074 return static_cast<ContainedInLattice>(a | b); |
| 1077 } | 1075 } |
| 1078 | 1076 |
| 1079 | 1077 |
| 1080 ContainedInLattice AddRange(ContainedInLattice a, | 1078 ContainedInLattice AddRange(ContainedInLattice a, |
| 1081 const int* ranges, | 1079 const int* ranges, |
| 1082 int ranges_size, | 1080 int ranges_size, |
| 1083 Interval new_range); | 1081 Interval new_range); |
| 1084 | 1082 |
| 1085 | |
| 1086 class BoyerMoorePositionInfo : public ZoneObject { | 1083 class BoyerMoorePositionInfo : public ZoneObject { |
| 1087 public: | 1084 public: |
| 1088 explicit BoyerMoorePositionInfo(Zone* zone) | 1085 explicit BoyerMoorePositionInfo(Zone* zone) |
| 1089 : map_(new(zone) ZoneList<bool>(kMapSize, zone)), | 1086 : map_(new(zone) ZoneList<bool>(kMapSize, zone)), |
| 1090 map_count_(0), | 1087 map_count_(0), |
| 1091 w_(kNotYet), | 1088 w_(kNotYet), |
| 1092 s_(kNotYet), | 1089 s_(kNotYet), |
| 1093 d_(kNotYet), | 1090 d_(kNotYet), |
| 1094 surrogate_(kNotYet) { | 1091 surrogate_(kNotYet) { |
| 1095 for (int i = 0; i < kMapSize; i++) { | 1092 for (int i = 0; i < kMapSize; i++) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1112 | 1109 |
| 1113 private: | 1110 private: |
| 1114 ZoneList<bool>* map_; | 1111 ZoneList<bool>* map_; |
| 1115 int map_count_; // Number of set bits in the map. | 1112 int map_count_; // Number of set bits in the map. |
| 1116 ContainedInLattice w_; // The \w character class. | 1113 ContainedInLattice w_; // The \w character class. |
| 1117 ContainedInLattice s_; // The \s character class. | 1114 ContainedInLattice s_; // The \s character class. |
| 1118 ContainedInLattice d_; // The \d character class. | 1115 ContainedInLattice d_; // The \d character class. |
| 1119 ContainedInLattice surrogate_; // Surrogate UTF-16 code units. | 1116 ContainedInLattice surrogate_; // Surrogate UTF-16 code units. |
| 1120 }; | 1117 }; |
| 1121 | 1118 |
| 1122 | |
| 1123 class BoyerMooreLookahead : public ZoneObject { | 1119 class BoyerMooreLookahead : public ZoneObject { |
| 1124 public: | 1120 public: |
| 1125 BoyerMooreLookahead(int length, RegExpCompiler* compiler, Zone* zone); | 1121 BoyerMooreLookahead(int length, RegExpCompiler* compiler, Zone* zone); |
| 1126 | 1122 |
| 1127 int length() { return length_; } | 1123 int length() { return length_; } |
| 1128 int max_char() { return max_char_; } | 1124 int max_char() { return max_char_; } |
| 1129 RegExpCompiler* compiler() { return compiler_; } | 1125 RegExpCompiler* compiler() { return compiler_; } |
| 1130 | 1126 |
| 1131 int Count(int map_number) { | 1127 int Count(int map_number) { |
| 1132 return bitmaps_->at(map_number)->map_count(); | 1128 return bitmaps_->at(map_number)->map_count(); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 static const int kStringOffset = 0; | 1531 static const int kStringOffset = 0; |
| 1536 static const int kPatternOffset = 1; | 1532 static const int kPatternOffset = 1; |
| 1537 static const int kArrayOffset = 2; | 1533 static const int kArrayOffset = 2; |
| 1538 static const int kLastMatchOffset = 3; | 1534 static const int kLastMatchOffset = 3; |
| 1539 }; | 1535 }; |
| 1540 | 1536 |
| 1541 } // namespace internal | 1537 } // namespace internal |
| 1542 } // namespace v8 | 1538 } // namespace v8 |
| 1543 | 1539 |
| 1544 #endif // V8_REGEXP_JSREGEXP_H_ | 1540 #endif // V8_REGEXP_JSREGEXP_H_ |
| OLD | NEW |