| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_X64_REGEXP_MACRO_ASSEMBLER_X64_H_ | 28 #ifndef V8_X64_REGEXP_MACRO_ASSEMBLER_X64_H_ |
| 29 #define V8_X64_REGEXP_MACRO_ASSEMBLER_X64_H_ | 29 #define V8_X64_REGEXP_MACRO_ASSEMBLER_X64_H_ |
| 30 | 30 |
| 31 namespace v8 { | 31 namespace v8 { |
| 32 namespace internal { | 32 namespace internal { |
| 33 | 33 |
| 34 #ifdef V8_NATIVE_REGEXP |
| 35 |
| 34 class RegExpMacroAssemblerX64: public NativeRegExpMacroAssembler { | 36 class RegExpMacroAssemblerX64: public NativeRegExpMacroAssembler { |
| 35 public: | 37 public: |
| 36 RegExpMacroAssemblerX64(Mode mode, int registers_to_save); | 38 RegExpMacroAssemblerX64(Mode mode, int registers_to_save); |
| 37 virtual ~RegExpMacroAssemblerX64(); | 39 virtual ~RegExpMacroAssemblerX64(); |
| 38 virtual int stack_limit_slack(); | 40 virtual int stack_limit_slack(); |
| 39 virtual void AdvanceCurrentPosition(int by); | 41 virtual void AdvanceCurrentPosition(int by); |
| 40 virtual void AdvanceRegister(int reg, int by); | 42 virtual void AdvanceRegister(int reg, int by); |
| 41 virtual void Backtrack(); | 43 virtual void Backtrack(); |
| 42 virtual void Bind(Label* label); | 44 virtual void Bind(Label* label); |
| 43 virtual void CheckAtStart(Label* on_at_start); | 45 virtual void CheckAtStart(Label* on_at_start); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 int previous_index); | 108 int previous_index); |
| 107 | 109 |
| 108 static Result Execute(Code* code, | 110 static Result Execute(Code* code, |
| 109 String* input, | 111 String* input, |
| 110 int start_offset, | 112 int start_offset, |
| 111 const byte* input_start, | 113 const byte* input_start, |
| 112 const byte* input_end, | 114 const byte* input_end, |
| 113 int* output, | 115 int* output, |
| 114 bool at_start); | 116 bool at_start); |
| 115 | 117 |
| 118 // Called from RegExp if the stack-guard is triggered. |
| 119 // If the code object is relocated, the return address is fixed before |
| 120 // returning. |
| 121 static int CheckStackGuardState(Address* return_address, |
| 122 Code* re_code, |
| 123 Address re_frame); |
| 124 |
| 116 private: | 125 private: |
| 117 // Offsets from rbp of function parameters and stored registers. | 126 // Offsets from rbp of function parameters and stored registers. |
| 118 static const int kFramePointer = 0; | 127 static const int kFramePointer = 0; |
| 119 // Above the frame pointer - function parameters and return address. | 128 // Above the frame pointer - function parameters and return address. |
| 120 static const int kReturn_eip = kFramePointer + kPointerSize; | 129 static const int kReturn_eip = kFramePointer + kPointerSize; |
| 121 static const int kFrameAlign = kReturn_eip + kPointerSize; | 130 static const int kFrameAlign = kReturn_eip + kPointerSize; |
| 122 | 131 |
| 123 #ifdef __MSVC__ | 132 #ifdef __MSVC__ |
| 124 // Parameters (first four passed as registers, but with room on stack). | 133 // Parameters (first four passed as registers, but with room on stack). |
| 125 // In Microsoft 64-bit Calling Convention, there is room on the callers | 134 // In Microsoft 64-bit Calling Convention, there is room on the callers |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Load a number of characters at the given offset from the | 183 // Load a number of characters at the given offset from the |
| 175 // current position, into the current-character register. | 184 // current position, into the current-character register. |
| 176 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); | 185 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); |
| 177 | 186 |
| 178 // Check whether preemption has been requested. | 187 // Check whether preemption has been requested. |
| 179 void CheckPreemption(); | 188 void CheckPreemption(); |
| 180 | 189 |
| 181 // Check whether we are exceeding the stack limit on the backtrack stack. | 190 // Check whether we are exceeding the stack limit on the backtrack stack. |
| 182 void CheckStackLimit(); | 191 void CheckStackLimit(); |
| 183 | 192 |
| 184 // Called from RegExp if the stack-guard is triggered. | |
| 185 // If the code object is relocated, the return address is fixed before | |
| 186 // returning. | |
| 187 static int CheckStackGuardState(Address* return_address, | |
| 188 Code* re_code, | |
| 189 Address re_frame); | |
| 190 | |
| 191 // Generate a call to CheckStackGuardState. | 193 // Generate a call to CheckStackGuardState. |
| 192 void CallCheckStackGuardState(); | 194 void CallCheckStackGuardState(); |
| 193 | 195 |
| 194 // Called from RegExp if the backtrack stack limit is hit. | |
| 195 // Tries to expand the stack. Returns the new stack-pointer if | |
| 196 // successful, and updates the stack_top address, or returns 0 if unable | |
| 197 // to grow the stack. | |
| 198 // This function must not trigger a garbage collection. | |
| 199 static Address GrowStack(Address stack_pointer, Address* stack_top); | |
| 200 | |
| 201 // The rbp-relative location of a regexp register. | 196 // The rbp-relative location of a regexp register. |
| 202 Operand register_location(int register_index); | 197 Operand register_location(int register_index); |
| 203 | 198 |
| 204 // The register containing the current character after LoadCurrentCharacter. | 199 // The register containing the current character after LoadCurrentCharacter. |
| 205 inline Register current_character() { return rdx; } | 200 inline Register current_character() { return rdx; } |
| 206 | 201 |
| 207 // The register containing the backtrack stack top. Provides a meaningful | 202 // The register containing the backtrack stack top. Provides a meaningful |
| 208 // name to the register. | 203 // name to the register. |
| 209 inline Register backtrack_stackpointer() { return rcx; } | 204 inline Register backtrack_stackpointer() { return rcx; } |
| 210 | 205 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // Some compilers/platforms require the stack to be aligned when calling | 252 // Some compilers/platforms require the stack to be aligned when calling |
| 258 // C++ code. | 253 // C++ code. |
| 259 // Needs a scratch register to do some arithmetic. This register will be | 254 // Needs a scratch register to do some arithmetic. This register will be |
| 260 // trashed. | 255 // trashed. |
| 261 inline void FrameAlign(int num_arguments); | 256 inline void FrameAlign(int num_arguments); |
| 262 | 257 |
| 263 // Calls a C function and cleans up the space for arguments allocated | 258 // Calls a C function and cleans up the space for arguments allocated |
| 264 // by FrameAlign. The called function is not allowed to trigger a garbage | 259 // by FrameAlign. The called function is not allowed to trigger a garbage |
| 265 // collection, since that might move the code and invalidate the return | 260 // collection, since that might move the code and invalidate the return |
| 266 // address (unless this is somehow accounted for by the called function). | 261 // address (unless this is somehow accounted for by the called function). |
| 267 inline void CallCFunction(Address function_address, int num_arguments); | 262 inline void CallCFunction(ExternalReference function, int num_arguments); |
| 268 | 263 |
| 269 MacroAssembler* masm_; | 264 MacroAssembler* masm_; |
| 270 | 265 |
| 271 ZoneList<int> code_relative_fixup_positions_; | 266 ZoneList<int> code_relative_fixup_positions_; |
| 272 | 267 |
| 273 // Which mode to generate code for (ASCII or UC16). | 268 // Which mode to generate code for (ASCII or UC16). |
| 274 Mode mode_; | 269 Mode mode_; |
| 275 | 270 |
| 276 // One greater than maximal register index actually used. | 271 // One greater than maximal register index actually used. |
| 277 int num_registers_; | 272 int num_registers_; |
| 278 | 273 |
| 279 // Number of registers to output at the end (the saved registers | 274 // Number of registers to output at the end (the saved registers |
| 280 // are always 0..num_saved_registers_-1) | 275 // are always 0..num_saved_registers_-1) |
| 281 int num_saved_registers_; | 276 int num_saved_registers_; |
| 282 | 277 |
| 283 // Labels used internally. | 278 // Labels used internally. |
| 284 Label entry_label_; | 279 Label entry_label_; |
| 285 Label start_label_; | 280 Label start_label_; |
| 286 Label success_label_; | 281 Label success_label_; |
| 287 Label backtrack_label_; | 282 Label backtrack_label_; |
| 288 Label exit_label_; | 283 Label exit_label_; |
| 289 Label check_preempt_label_; | 284 Label check_preempt_label_; |
| 290 Label stack_overflow_label_; | 285 Label stack_overflow_label_; |
| 291 }; | 286 }; |
| 292 | 287 |
| 288 #endif // V8_NATIVE_REGEXP |
| 289 |
| 293 }} // namespace v8::internal | 290 }} // namespace v8::internal |
| 294 | 291 |
| 295 #endif // V8_X64_REGEXP_MACRO_ASSEMBLER_X64_H_ | 292 #endif // V8_X64_REGEXP_MACRO_ASSEMBLER_X64_H_ |
| OLD | NEW |