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_REGEXP_MACRO_ASSEMBLER_H_ | 5 #ifndef V8_REGEXP_REGEXP_MACRO_ASSEMBLER_H_ |
6 #define V8_REGEXP_REGEXP_MACRO_ASSEMBLER_H_ | 6 #define V8_REGEXP_REGEXP_MACRO_ASSEMBLER_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/regexp/regexp-ast.h" | 9 #include "src/regexp/regexp-ast.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
| 14 static const uc32 kLeadSurrogateStart = 0xd800; |
| 15 static const uc32 kLeadSurrogateEnd = 0xdbff; |
| 16 static const uc32 kTrailSurrogateStart = 0xdc00; |
| 17 static const uc32 kTrailSurrogateEnd = 0xdfff; |
| 18 static const uc32 kNonBmpStart = 0x10000; |
| 19 static const uc32 kNonBmpEnd = 0x10ffff; |
| 20 |
14 struct DisjunctDecisionRow { | 21 struct DisjunctDecisionRow { |
15 RegExpCharacterClass cc; | 22 RegExpCharacterClass cc; |
16 Label* on_match; | 23 Label* on_match; |
17 }; | 24 }; |
18 | 25 |
19 | 26 |
20 class RegExpMacroAssembler { | 27 class RegExpMacroAssembler { |
21 public: | 28 public: |
22 // The implementation must be able to handle at least: | 29 // The implementation must be able to handle at least: |
23 static const int kMaxRegister = (1 << 16) - 1; | 30 static const int kMaxRegister = (1 << 16) - 1; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 virtual void ReadCurrentPositionFromRegister(int reg) = 0; | 146 virtual void ReadCurrentPositionFromRegister(int reg) = 0; |
140 virtual void ReadStackPointerFromRegister(int reg) = 0; | 147 virtual void ReadStackPointerFromRegister(int reg) = 0; |
141 virtual void SetCurrentPositionFromEnd(int by) = 0; | 148 virtual void SetCurrentPositionFromEnd(int by) = 0; |
142 virtual void SetRegister(int register_index, int to) = 0; | 149 virtual void SetRegister(int register_index, int to) = 0; |
143 // Return whether the matching (with a global regexp) will be restarted. | 150 // Return whether the matching (with a global regexp) will be restarted. |
144 virtual bool Succeed() = 0; | 151 virtual bool Succeed() = 0; |
145 virtual void WriteCurrentPositionToRegister(int reg, int cp_offset) = 0; | 152 virtual void WriteCurrentPositionToRegister(int reg, int cp_offset) = 0; |
146 virtual void ClearRegisters(int reg_from, int reg_to) = 0; | 153 virtual void ClearRegisters(int reg_from, int reg_to) = 0; |
147 virtual void WriteStackPointerToRegister(int reg) = 0; | 154 virtual void WriteStackPointerToRegister(int reg) = 0; |
148 | 155 |
| 156 // Check that we are not in the middle of a surrogate pair. |
| 157 void CheckNotInSurrogatePair(int cp_offset, Label* on_failure); |
| 158 |
149 // Controls the generation of large inlined constants in the code. | 159 // Controls the generation of large inlined constants in the code. |
150 void set_slow_safe(bool ssc) { slow_safe_compiler_ = ssc; } | 160 void set_slow_safe(bool ssc) { slow_safe_compiler_ = ssc; } |
151 bool slow_safe() { return slow_safe_compiler_; } | 161 bool slow_safe() { return slow_safe_compiler_; } |
152 | 162 |
153 enum GlobalMode { NOT_GLOBAL, GLOBAL, GLOBAL_NO_ZERO_LENGTH_CHECK }; | 163 enum GlobalMode { NOT_GLOBAL, GLOBAL, GLOBAL_NO_ZERO_LENGTH_CHECK }; |
154 // Set whether the regular expression has the global flag. Exiting due to | 164 // Set whether the regular expression has the global flag. Exiting due to |
155 // a failure in a global regexp may still mean success overall. | 165 // a failure in a global regexp may still mean success overall. |
156 inline void set_global_mode(GlobalMode mode) { global_mode_ = mode; } | 166 inline void set_global_mode(GlobalMode mode) { global_mode_ = mode; } |
157 inline bool global() { return global_mode_ != NOT_GLOBAL; } | 167 inline bool global() { return global_mode_ != NOT_GLOBAL; } |
158 inline bool global_with_zero_length_check() { | 168 inline bool global_with_zero_length_check() { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 int output_size, | 250 int output_size, |
241 Isolate* isolate); | 251 Isolate* isolate); |
242 }; | 252 }; |
243 | 253 |
244 #endif // V8_INTERPRETED_REGEXP | 254 #endif // V8_INTERPRETED_REGEXP |
245 | 255 |
246 } // namespace internal | 256 } // namespace internal |
247 } // namespace v8 | 257 } // namespace v8 |
248 | 258 |
249 #endif // V8_REGEXP_REGEXP_MACRO_ASSEMBLER_H_ | 259 #endif // V8_REGEXP_REGEXP_MACRO_ASSEMBLER_H_ |
OLD | NEW |