| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 kMIPSImplementation, | 56 kMIPSImplementation, |
| 57 kX64Implementation, | 57 kX64Implementation, |
| 58 kBytecodeImplementation | 58 kBytecodeImplementation |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 enum StackCheckFlag { | 61 enum StackCheckFlag { |
| 62 kNoStackLimitCheck = false, | 62 kNoStackLimitCheck = false, |
| 63 kCheckStackLimit = true | 63 kCheckStackLimit = true |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 RegExpMacroAssembler(); | 66 explicit RegExpMacroAssembler(Zone* zone); |
| 67 virtual ~RegExpMacroAssembler(); | 67 virtual ~RegExpMacroAssembler(); |
| 68 // The maximal number of pushes between stack checks. Users must supply | 68 // The maximal number of pushes between stack checks. Users must supply |
| 69 // kCheckStackLimit flag to push operations (instead of kNoStackLimitCheck) | 69 // kCheckStackLimit flag to push operations (instead of kNoStackLimitCheck) |
| 70 // at least once for every stack_limit() pushes that are executed. | 70 // at least once for every stack_limit() pushes that are executed. |
| 71 virtual int stack_limit_slack() = 0; | 71 virtual int stack_limit_slack() = 0; |
| 72 virtual bool CanReadUnaligned(); | 72 virtual bool CanReadUnaligned(); |
| 73 virtual void AdvanceCurrentPosition(int by) = 0; // Signed cp change. | 73 virtual void AdvanceCurrentPosition(int by) = 0; // Signed cp change. |
| 74 virtual void AdvanceRegister(int reg, int by) = 0; // r[reg] += by. | 74 virtual void AdvanceRegister(int reg, int by) = 0; // r[reg] += by. |
| 75 // Continues execution from the position pushed on the top of the backtrack | 75 // Continues execution from the position pushed on the top of the backtrack |
| 76 // stack by an earlier PushBacktrack(Label*). | 76 // stack by an earlier PushBacktrack(Label*). |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 enum GlobalMode { NOT_GLOBAL, GLOBAL, GLOBAL_NO_ZERO_LENGTH_CHECK }; | 187 enum GlobalMode { NOT_GLOBAL, GLOBAL, GLOBAL_NO_ZERO_LENGTH_CHECK }; |
| 188 // Set whether the regular expression has the global flag. Exiting due to | 188 // Set whether the regular expression has the global flag. Exiting due to |
| 189 // a failure in a global regexp may still mean success overall. | 189 // a failure in a global regexp may still mean success overall. |
| 190 inline void set_global_mode(GlobalMode mode) { global_mode_ = mode; } | 190 inline void set_global_mode(GlobalMode mode) { global_mode_ = mode; } |
| 191 inline bool global() { return global_mode_ != NOT_GLOBAL; } | 191 inline bool global() { return global_mode_ != NOT_GLOBAL; } |
| 192 inline bool global_with_zero_length_check() { | 192 inline bool global_with_zero_length_check() { |
| 193 return global_mode_ == GLOBAL; | 193 return global_mode_ == GLOBAL; |
| 194 } | 194 } |
| 195 | 195 |
| 196 Zone* zone() const { return zone_; } |
| 197 |
| 196 private: | 198 private: |
| 197 bool slow_safe_compiler_; | 199 bool slow_safe_compiler_; |
| 198 bool global_mode_; | 200 bool global_mode_; |
| 201 Zone* zone_; |
| 199 }; | 202 }; |
| 200 | 203 |
| 201 | 204 |
| 202 #ifndef V8_INTERPRETED_REGEXP // Avoid compiling unused code. | 205 #ifndef V8_INTERPRETED_REGEXP // Avoid compiling unused code. |
| 203 | 206 |
| 204 class NativeRegExpMacroAssembler: public RegExpMacroAssembler { | 207 class NativeRegExpMacroAssembler: public RegExpMacroAssembler { |
| 205 public: | 208 public: |
| 206 // Type of input string to generate code for. | 209 // Type of input string to generate code for. |
| 207 enum Mode { ASCII = 1, UC16 = 2 }; | 210 enum Mode { ASCII = 1, UC16 = 2 }; |
| 208 | 211 |
| 209 // Result of calling generated native RegExp code. | 212 // Result of calling generated native RegExp code. |
| 210 // RETRY: Something significant changed during execution, and the matching | 213 // RETRY: Something significant changed during execution, and the matching |
| 211 // should be retried from scratch. | 214 // should be retried from scratch. |
| 212 // EXCEPTION: Something failed during execution. If no exception has been | 215 // EXCEPTION: Something failed during execution. If no exception has been |
| 213 // thrown, it's an internal out-of-memory, and the caller should | 216 // thrown, it's an internal out-of-memory, and the caller should |
| 214 // throw the exception. | 217 // throw the exception. |
| 215 // FAILURE: Matching failed. | 218 // FAILURE: Matching failed. |
| 216 // SUCCESS: Matching succeeded, and the output array has been filled with | 219 // SUCCESS: Matching succeeded, and the output array has been filled with |
| 217 // capture positions. | 220 // capture positions. |
| 218 enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 }; | 221 enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 }; |
| 219 | 222 |
| 220 NativeRegExpMacroAssembler(); | 223 explicit NativeRegExpMacroAssembler(Zone* zone); |
| 221 virtual ~NativeRegExpMacroAssembler(); | 224 virtual ~NativeRegExpMacroAssembler(); |
| 222 virtual bool CanReadUnaligned(); | 225 virtual bool CanReadUnaligned(); |
| 223 | 226 |
| 224 static Result Match(Handle<Code> regexp, | 227 static Result Match(Handle<Code> regexp, |
| 225 Handle<String> subject, | 228 Handle<String> subject, |
| 226 int* offsets_vector, | 229 int* offsets_vector, |
| 227 int offsets_vector_length, | 230 int offsets_vector_length, |
| 228 int previous_index, | 231 int previous_index, |
| 229 Isolate* isolate); | 232 Isolate* isolate); |
| 230 | 233 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 int* output, | 265 int* output, |
| 263 int output_size, | 266 int output_size, |
| 264 Isolate* isolate); | 267 Isolate* isolate); |
| 265 }; | 268 }; |
| 266 | 269 |
| 267 #endif // V8_INTERPRETED_REGEXP | 270 #endif // V8_INTERPRETED_REGEXP |
| 268 | 271 |
| 269 } } // namespace v8::internal | 272 } } // namespace v8::internal |
| 270 | 273 |
| 271 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ | 274 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ |
| OLD | NEW |