OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2011-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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_ | 28 #ifndef V8_SH4_REGEXP_MACRO_ASSEMBLER_SH4_H_ |
29 #define V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_ | 29 #define V8_SH4_REGEXP_MACRO_ASSEMBLER_SH4_H_ |
30 | 30 |
31 #include "arm/assembler-arm.h" | 31 #include "sh4/assembler-sh4.h" |
32 #include "arm/assembler-arm-inl.h" | 32 #include "sh4/assembler-sh4-inl.h" |
33 | 33 |
34 namespace v8 { | 34 namespace v8 { |
35 namespace internal { | 35 namespace internal { |
36 | 36 |
37 | 37 |
38 #ifndef V8_INTERPRETED_REGEXP | 38 #ifdef V8_INTERPRETED_REGEXP |
39 class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler { | 39 class RegExpMacroAssemblerSH4: public RegExpMacroAssembler { |
40 public: | 40 public: |
41 RegExpMacroAssemblerARM(Mode mode, int registers_to_save, Zone* zone); | 41 RegExpMacroAssemblerSH4(); |
42 virtual ~RegExpMacroAssemblerARM(); | 42 virtual ~RegExpMacroAssemblerSH4(); |
| 43 }; |
| 44 |
| 45 #else // V8_INTERPRETED_REGEXP |
| 46 class RegExpMacroAssemblerSH4: public NativeRegExpMacroAssembler { |
| 47 public: |
| 48 RegExpMacroAssemblerSH4(Mode mode, int registers_to_save, Zone* zone); |
| 49 virtual ~RegExpMacroAssemblerSH4(); |
43 virtual int stack_limit_slack(); | 50 virtual int stack_limit_slack(); |
44 virtual void AdvanceCurrentPosition(int by); | 51 virtual void AdvanceCurrentPosition(int by); |
45 virtual void AdvanceRegister(int reg, int by); | 52 virtual void AdvanceRegister(int reg, int by); |
46 virtual void Backtrack(); | 53 virtual void Backtrack(); |
47 virtual void Bind(Label* label); | 54 virtual void Bind(Label* label); |
48 virtual void CheckAtStart(Label* on_at_start); | 55 virtual void CheckAtStart(Label* on_at_start); |
49 virtual void CheckCharacter(unsigned c, Label* on_equal); | 56 virtual void CheckCharacter(unsigned c, Label* on_equal); |
50 virtual void CheckCharacterAfterAnd(unsigned c, | 57 virtual void CheckCharacterAfterAnd(unsigned c, |
51 unsigned mask, | 58 unsigned mask, |
52 Label* on_equal); | 59 Label* on_equal); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 virtual void PushRegister(int register_index, | 109 virtual void PushRegister(int register_index, |
103 StackCheckFlag check_stack_limit); | 110 StackCheckFlag check_stack_limit); |
104 virtual void ReadCurrentPositionFromRegister(int reg); | 111 virtual void ReadCurrentPositionFromRegister(int reg); |
105 virtual void ReadStackPointerFromRegister(int reg); | 112 virtual void ReadStackPointerFromRegister(int reg); |
106 virtual void SetCurrentPositionFromEnd(int by); | 113 virtual void SetCurrentPositionFromEnd(int by); |
107 virtual void SetRegister(int register_index, int to); | 114 virtual void SetRegister(int register_index, int to); |
108 virtual bool Succeed(); | 115 virtual bool Succeed(); |
109 virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); | 116 virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); |
110 virtual void ClearRegisters(int reg_from, int reg_to); | 117 virtual void ClearRegisters(int reg_from, int reg_to); |
111 virtual void WriteStackPointerToRegister(int reg); | 118 virtual void WriteStackPointerToRegister(int reg); |
112 virtual bool CanReadUnaligned(); | |
113 | 119 |
114 // Called from RegExp if the stack-guard is triggered. | 120 // Called from RegExp if the stack-guard is triggered. |
115 // If the code object is relocated, the return address is fixed before | 121 // If the code object is relocated, the return address is fixed before |
116 // returning. | 122 // returning. |
117 static int CheckStackGuardState(Address* return_address, | 123 static int CheckStackGuardState(Address* return_address, |
118 Code* re_code, | 124 Code* re_code, |
119 Address re_frame); | 125 Address re_frame); |
120 | 126 |
121 private: | 127 private: |
122 // Offsets from frame_pointer() of function parameters and stored registers. | 128 // Offsets from frame_pointer() of function parameters and stored registers. |
123 static const int kFramePointer = 0; | 129 static const int kFramePointer = 0; |
124 | 130 |
125 // Above the frame pointer - Stored registers and stack passed parameters. | 131 // Above the frame pointer - Stored registers and stack passed parameters. |
126 // Register 4..11. | 132 // Register 4..11. |
127 static const int kStoredRegisters = kFramePointer; | 133 static const int kStoredRegisters = kFramePointer; |
128 // Return address (stored from link register, read into pc on return). | 134 // Return address (stored from link register, read into pc on return). |
129 static const int kReturnAddress = kStoredRegisters + 8 * kPointerSize; | 135 static const int kReturnAddress = kStoredRegisters + 7 * kPointerSize; |
130 static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize; | 136 static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize; |
131 // Stack parameters placed by caller. | 137 // Stack parameters placed by caller. |
132 static const int kRegisterOutput = kSecondaryReturnAddress + kPointerSize; | 138 static const int kRegisterOutput = kSecondaryReturnAddress + kPointerSize; |
133 static const int kNumOutputRegisters = kRegisterOutput + kPointerSize; | 139 static const int kNumOutputRegisters = kRegisterOutput + kPointerSize; |
134 static const int kStackHighEnd = kNumOutputRegisters + kPointerSize; | 140 static const int kStackHighEnd = kNumOutputRegisters + kPointerSize; |
135 static const int kDirectCall = kStackHighEnd + kPointerSize; | 141 static const int kDirectCall = kStackHighEnd + kPointerSize; |
136 static const int kIsolate = kDirectCall + kPointerSize; | 142 static const int kIsolate = kDirectCall + kPointerSize; |
137 | 143 |
138 // Below the frame pointer. | 144 // Below the frame pointer. |
139 // Register parameters stored by setup code. | 145 // Register parameters stored by setup code. |
140 static const int kInputEnd = kFramePointer - kPointerSize; | 146 static const int kInputEnd = kFramePointer - kPointerSize; |
141 static const int kInputStart = kInputEnd - kPointerSize; | 147 static const int kInputStart = kInputEnd - kPointerSize; |
142 static const int kStartIndex = kInputStart - kPointerSize; | 148 static const int kStartIndex = kInputStart - kPointerSize; |
143 static const int kInputString = kStartIndex - kPointerSize; | 149 static const int kInputString = kStartIndex - kPointerSize; |
144 // When adding local variables remember to push space for them in | 150 // When adding local variables remember to push space for them in |
145 // the frame in GetCode. | 151 // the frame in GetCode. |
146 static const int kSuccessfulCaptures = kInputString - kPointerSize; | 152 static const int kSuccessfulCaptures = kInputString - kPointerSize; |
147 static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize; | 153 static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize; |
148 // First register address. Following registers are below it on the stack. | 154 // First register address. Following registers are below it on the stack. |
149 static const int kRegisterZero = kInputStartMinusOne - kPointerSize; | 155 static const int kRegisterZero = kInputStartMinusOne - kPointerSize; |
150 | 156 |
151 // Initial size of code buffer. | 157 // Initial size of code buffer. |
152 static const size_t kRegExpCodeSize = 1024; | 158 static const size_t kRegExpCodeSize = 1024; |
153 | 159 |
154 static const int kBacktrackConstantPoolSize = 4; | |
155 | |
156 // Load a number of characters at the given offset from the | 160 // Load a number of characters at the given offset from the |
157 // current position, into the current-character register. | 161 // current position, into the current-character register. |
158 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); | 162 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); |
159 | 163 |
160 // Check whether preemption has been requested. | 164 // Check whether preemption has been requested. |
161 void CheckPreemption(); | 165 void CheckPreemption(); |
162 | 166 |
163 // Check whether we are exceeding the stack limit on the backtrack stack. | 167 // Check whether we are exceeding the stack limit on the backtrack stack. |
164 void CheckStackLimit(); | 168 void CheckStackLimit(); |
165 | 169 |
166 void EmitBacktrackConstantPool(); | |
167 int GetBacktrackConstantPoolEntry(); | |
168 | |
169 | |
170 // Generate a call to CheckStackGuardState. | 170 // Generate a call to CheckStackGuardState. |
171 void CallCheckStackGuardState(Register scratch); | 171 void CallCheckStackGuardState(Register scratch); |
172 | 172 |
173 // The ebp-relative location of a regexp register. | 173 // The ebp-relative location of a regexp register. |
174 MemOperand register_location(int register_index); | 174 MemOperand register_location(int register_index); |
175 | 175 |
176 // Register holding the current input position as negative offset from | 176 // Register holding the current input position as negative offset from |
177 // the end of the string. | 177 // the end of the string. |
178 inline Register current_input_offset() { return r6; } | 178 inline Register current_input_offset() { return r6; } |
179 | 179 |
180 // The register containing the current character after LoadCurrentCharacter. | 180 // The register containing the current character after LoadCurrentCharacter. |
181 inline Register current_character() { return r7; } | 181 inline Register current_character() { return r7; } |
182 | 182 |
183 // Register holding address of the end of the input string. | 183 // Register holding address of the end of the input string. |
184 inline Register end_of_input_address() { return r10; } | 184 inline Register end_of_input_address() { return r9; } |
185 | 185 |
186 // Register holding the frame address. Local variables, parameters and | 186 // Register holding the frame address. Local variables, parameters and |
187 // regexp registers are addressed relative to this. | 187 // regexp registers are addressed relative to this. |
188 inline Register frame_pointer() { return fp; } | 188 inline Register frame_pointer() { return fp; } |
189 | 189 |
190 // The register containing the backtrack stack top. Provides a meaningful | 190 // The register containing the backtrack stack top. Provides a meaningful |
191 // name to the register. | 191 // name to the register. |
192 inline Register backtrack_stackpointer() { return r8; } | 192 inline Register backtrack_stackpointer() { return r8; } |
193 | 193 |
194 // Register holding pointer to the current code object. | 194 // Register holding pointer to the current code object. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // Which mode to generate code for (ASCII or UC16). | 229 // Which mode to generate code for (ASCII or UC16). |
230 Mode mode_; | 230 Mode mode_; |
231 | 231 |
232 // One greater than maximal register index actually used. | 232 // One greater than maximal register index actually used. |
233 int num_registers_; | 233 int num_registers_; |
234 | 234 |
235 // Number of registers to output at the end (the saved registers | 235 // Number of registers to output at the end (the saved registers |
236 // are always 0..num_saved_registers_-1) | 236 // are always 0..num_saved_registers_-1) |
237 int num_saved_registers_; | 237 int num_saved_registers_; |
238 | 238 |
239 // Manage a small pre-allocated pool for writing label targets | |
240 // to for pushing backtrack addresses. | |
241 int backtrack_constant_pool_offset_; | |
242 int backtrack_constant_pool_capacity_; | |
243 | |
244 // Labels used internally. | 239 // Labels used internally. |
245 Label entry_label_; | 240 Label entry_label_; |
246 Label start_label_; | 241 Label start_label_; |
247 Label success_label_; | 242 Label success_label_; |
248 Label backtrack_label_; | 243 Label backtrack_label_; |
249 Label exit_label_; | 244 Label exit_label_; |
250 Label check_preempt_label_; | 245 Label check_preempt_label_; |
251 Label stack_overflow_label_; | 246 Label stack_overflow_label_; |
252 }; | 247 }; |
253 | 248 |
254 #endif // V8_INTERPRETED_REGEXP | 249 #endif // V8_INTERPRETED_REGEXP |
255 | 250 |
256 | 251 |
257 }} // namespace v8::internal | 252 }} // namespace v8::internal |
258 | 253 |
259 #endif // V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_ | 254 #endif // V8_SH4_REGEXP_MACRO_ASSEMBLER_SH4_H_ |
OLD | NEW |