| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 enum GlobalMode { NOT_GLOBAL, GLOBAL, GLOBAL_NO_ZERO_LENGTH_CHECK }; | 183 enum GlobalMode { NOT_GLOBAL, GLOBAL, GLOBAL_NO_ZERO_LENGTH_CHECK }; |
| 184 // Set whether the regular expression has the global flag. Exiting due to | 184 // Set whether the regular expression has the global flag. Exiting due to |
| 185 // a failure in a global regexp may still mean success overall. | 185 // a failure in a global regexp may still mean success overall. |
| 186 inline void set_global_mode(GlobalMode mode) { global_mode_ = mode; } | 186 inline void set_global_mode(GlobalMode mode) { global_mode_ = mode; } |
| 187 inline bool global() { return global_mode_ != NOT_GLOBAL; } | 187 inline bool global() { return global_mode_ != NOT_GLOBAL; } |
| 188 inline bool global_with_zero_length_check() { | 188 inline bool global_with_zero_length_check() { |
| 189 return global_mode_ == GLOBAL; | 189 return global_mode_ == GLOBAL; |
| 190 } | 190 } |
| 191 | 191 |
| 192 Zone* zone() const { return zone_; } |
| 193 |
| 192 private: | 194 private: |
| 193 bool slow_safe_compiler_; | 195 bool slow_safe_compiler_; |
| 194 bool global_mode_; | 196 bool global_mode_; |
| 197 Zone* zone_; |
| 195 }; | 198 }; |
| 196 | 199 |
| 197 | 200 |
| 198 #ifndef V8_INTERPRETED_REGEXP // Avoid compiling unused code. | 201 #ifndef V8_INTERPRETED_REGEXP // Avoid compiling unused code. |
| 199 | 202 |
| 200 class NativeRegExpMacroAssembler: public RegExpMacroAssembler { | 203 class NativeRegExpMacroAssembler: public RegExpMacroAssembler { |
| 201 public: | 204 public: |
| 202 // Type of input string to generate code for. | 205 // Type of input string to generate code for. |
| 203 enum Mode { ASCII = 1, UC16 = 2 }; | 206 enum Mode { ASCII = 1, UC16 = 2 }; |
| 204 | 207 |
| 205 // Result of calling generated native RegExp code. | 208 // Result of calling generated native RegExp code. |
| 206 // RETRY: Something significant changed during execution, and the matching | 209 // RETRY: Something significant changed during execution, and the matching |
| 207 // should be retried from scratch. | 210 // should be retried from scratch. |
| 208 // EXCEPTION: Something failed during execution. If no exception has been | 211 // EXCEPTION: Something failed during execution. If no exception has been |
| 209 // thrown, it's an internal out-of-memory, and the caller should | 212 // thrown, it's an internal out-of-memory, and the caller should |
| 210 // throw the exception. | 213 // throw the exception. |
| 211 // FAILURE: Matching failed. | 214 // FAILURE: Matching failed. |
| 212 // SUCCESS: Matching succeeded, and the output array has been filled with | 215 // SUCCESS: Matching succeeded, and the output array has been filled with |
| 213 // capture positions. | 216 // capture positions. |
| 214 enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 }; | 217 enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 }; |
| 215 | 218 |
| 216 NativeRegExpMacroAssembler(); | 219 explicit NativeRegExpMacroAssembler(Zone* zone); |
| 217 virtual ~NativeRegExpMacroAssembler(); | 220 virtual ~NativeRegExpMacroAssembler(); |
| 218 virtual bool CanReadUnaligned(); | 221 virtual bool CanReadUnaligned(); |
| 219 | 222 |
| 220 static Result Match(Handle<Code> regexp, | 223 static Result Match(Handle<Code> regexp, |
| 221 Handle<String> subject, | 224 Handle<String> subject, |
| 222 int* offsets_vector, | 225 int* offsets_vector, |
| 223 int offsets_vector_length, | 226 int offsets_vector_length, |
| 224 int previous_index, | 227 int previous_index, |
| 225 Isolate* isolate); | 228 Isolate* isolate); |
| 226 | 229 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 int* output, | 261 int* output, |
| 259 int output_size, | 262 int output_size, |
| 260 Isolate* isolate); | 263 Isolate* isolate); |
| 261 }; | 264 }; |
| 262 | 265 |
| 263 #endif // V8_INTERPRETED_REGEXP | 266 #endif // V8_INTERPRETED_REGEXP |
| 264 | 267 |
| 265 } } // namespace v8::internal | 268 } } // namespace v8::internal |
| 266 | 269 |
| 267 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ | 270 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ |
| OLD | NEW |