| 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_MACRO_ASSEMBLER_H_ | 5 #ifndef V8_REGEXP_MACRO_ASSEMBLER_H_ |
| 6 #define V8_REGEXP_MACRO_ASSEMBLER_H_ | 6 #define V8_REGEXP_MACRO_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 kX64Implementation, | 36 kX64Implementation, |
| 37 kX87Implementation, | 37 kX87Implementation, |
| 38 kBytecodeImplementation | 38 kBytecodeImplementation |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 enum StackCheckFlag { | 41 enum StackCheckFlag { |
| 42 kNoStackLimitCheck = false, | 42 kNoStackLimitCheck = false, |
| 43 kCheckStackLimit = true | 43 kCheckStackLimit = true |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 explicit RegExpMacroAssembler(Zone* zone); | 46 RegExpMacroAssembler(Isolate* isolate, Zone* zone); |
| 47 virtual ~RegExpMacroAssembler(); | 47 virtual ~RegExpMacroAssembler(); |
| 48 // The maximal number of pushes between stack checks. Users must supply | 48 // The maximal number of pushes between stack checks. Users must supply |
| 49 // kCheckStackLimit flag to push operations (instead of kNoStackLimitCheck) | 49 // kCheckStackLimit flag to push operations (instead of kNoStackLimitCheck) |
| 50 // at least once for every stack_limit() pushes that are executed. | 50 // at least once for every stack_limit() pushes that are executed. |
| 51 virtual int stack_limit_slack() = 0; | 51 virtual int stack_limit_slack() = 0; |
| 52 virtual bool CanReadUnaligned() = 0; | 52 virtual bool CanReadUnaligned() = 0; |
| 53 virtual void AdvanceCurrentPosition(int by) = 0; // Signed cp change. | 53 virtual void AdvanceCurrentPosition(int by) = 0; // Signed cp change. |
| 54 virtual void AdvanceRegister(int reg, int by) = 0; // r[reg] += by. | 54 virtual void AdvanceRegister(int reg, int by) = 0; // r[reg] += by. |
| 55 // Continues execution from the position pushed on the top of the backtrack | 55 // Continues execution from the position pushed on the top of the backtrack |
| 56 // stack by an earlier PushBacktrack(Label*). | 56 // stack by an earlier PushBacktrack(Label*). |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 enum GlobalMode { NOT_GLOBAL, GLOBAL, GLOBAL_NO_ZERO_LENGTH_CHECK }; | 152 enum GlobalMode { NOT_GLOBAL, GLOBAL, GLOBAL_NO_ZERO_LENGTH_CHECK }; |
| 153 // Set whether the regular expression has the global flag. Exiting due to | 153 // Set whether the regular expression has the global flag. Exiting due to |
| 154 // a failure in a global regexp may still mean success overall. | 154 // a failure in a global regexp may still mean success overall. |
| 155 inline void set_global_mode(GlobalMode mode) { global_mode_ = mode; } | 155 inline void set_global_mode(GlobalMode mode) { global_mode_ = mode; } |
| 156 inline bool global() { return global_mode_ != NOT_GLOBAL; } | 156 inline bool global() { return global_mode_ != NOT_GLOBAL; } |
| 157 inline bool global_with_zero_length_check() { | 157 inline bool global_with_zero_length_check() { |
| 158 return global_mode_ == GLOBAL; | 158 return global_mode_ == GLOBAL; |
| 159 } | 159 } |
| 160 | 160 |
| 161 Isolate* isolate() const { return isolate_; } |
| 161 Zone* zone() const { return zone_; } | 162 Zone* zone() const { return zone_; } |
| 162 | 163 |
| 163 private: | 164 private: |
| 164 bool slow_safe_compiler_; | 165 bool slow_safe_compiler_; |
| 165 bool global_mode_; | 166 bool global_mode_; |
| 167 Isolate* isolate_; |
| 166 Zone* zone_; | 168 Zone* zone_; |
| 167 }; | 169 }; |
| 168 | 170 |
| 169 | 171 |
| 170 #ifndef V8_INTERPRETED_REGEXP // Avoid compiling unused code. | 172 #ifndef V8_INTERPRETED_REGEXP // Avoid compiling unused code. |
| 171 | 173 |
| 172 class NativeRegExpMacroAssembler: public RegExpMacroAssembler { | 174 class NativeRegExpMacroAssembler: public RegExpMacroAssembler { |
| 173 public: | 175 public: |
| 174 // Type of input string to generate code for. | 176 // Type of input string to generate code for. |
| 175 enum Mode { LATIN1 = 1, UC16 = 2 }; | 177 enum Mode { LATIN1 = 1, UC16 = 2 }; |
| 176 | 178 |
| 177 // Result of calling generated native RegExp code. | 179 // Result of calling generated native RegExp code. |
| 178 // RETRY: Something significant changed during execution, and the matching | 180 // RETRY: Something significant changed during execution, and the matching |
| 179 // should be retried from scratch. | 181 // should be retried from scratch. |
| 180 // EXCEPTION: Something failed during execution. If no exception has been | 182 // EXCEPTION: Something failed during execution. If no exception has been |
| 181 // thrown, it's an internal out-of-memory, and the caller should | 183 // thrown, it's an internal out-of-memory, and the caller should |
| 182 // throw the exception. | 184 // throw the exception. |
| 183 // FAILURE: Matching failed. | 185 // FAILURE: Matching failed. |
| 184 // SUCCESS: Matching succeeded, and the output array has been filled with | 186 // SUCCESS: Matching succeeded, and the output array has been filled with |
| 185 // capture positions. | 187 // capture positions. |
| 186 enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 }; | 188 enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 }; |
| 187 | 189 |
| 188 explicit NativeRegExpMacroAssembler(Zone* zone); | 190 NativeRegExpMacroAssembler(Isolate* isolate, Zone* zone); |
| 189 virtual ~NativeRegExpMacroAssembler(); | 191 virtual ~NativeRegExpMacroAssembler(); |
| 190 virtual bool CanReadUnaligned(); | 192 virtual bool CanReadUnaligned(); |
| 191 | 193 |
| 192 static Result Match(Handle<Code> regexp, | 194 static Result Match(Handle<Code> regexp, |
| 193 Handle<String> subject, | 195 Handle<String> subject, |
| 194 int* offsets_vector, | 196 int* offsets_vector, |
| 195 int offsets_vector_length, | 197 int offsets_vector_length, |
| 196 int previous_index, | 198 int previous_index, |
| 197 Isolate* isolate); | 199 Isolate* isolate); |
| 198 | 200 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 int* output, | 232 int* output, |
| 231 int output_size, | 233 int output_size, |
| 232 Isolate* isolate); | 234 Isolate* isolate); |
| 233 }; | 235 }; |
| 234 | 236 |
| 235 #endif // V8_INTERPRETED_REGEXP | 237 #endif // V8_INTERPRETED_REGEXP |
| 236 | 238 |
| 237 } } // namespace v8::internal | 239 } } // namespace v8::internal |
| 238 | 240 |
| 239 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ | 241 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ |
| OLD | NEW |