OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 | 5 |
6 #ifndef V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ | 6 #ifndef V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ |
7 #define V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ | 7 #define V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ |
8 | 8 |
9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
10 #include "src/mips/assembler-mips-inl.h" | 10 #include "src/mips64/assembler-mips64-inl.h" |
11 #include "src/mips/assembler-mips.h" | 11 #include "src/mips64/assembler-mips64.h" |
12 #include "src/mips/macro-assembler-mips.h" | 12 #include "src/mips64/macro-assembler-mips64.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 #ifndef V8_INTERPRETED_REGEXP | 17 #ifndef V8_INTERPRETED_REGEXP |
18 class RegExpMacroAssemblerMIPS: public NativeRegExpMacroAssembler { | 18 class RegExpMacroAssemblerMIPS: public NativeRegExpMacroAssembler { |
19 public: | 19 public: |
20 RegExpMacroAssemblerMIPS(Mode mode, int registers_to_save, Zone* zone); | 20 RegExpMacroAssemblerMIPS(Mode mode, int registers_to_save, Zone* zone); |
21 virtual ~RegExpMacroAssemblerMIPS(); | 21 virtual ~RegExpMacroAssemblerMIPS(); |
22 virtual int stack_limit_slack(); | 22 virtual int stack_limit_slack(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 virtual void WriteStackPointerToRegister(int reg); | 86 virtual void WriteStackPointerToRegister(int reg); |
87 virtual bool CanReadUnaligned(); | 87 virtual bool CanReadUnaligned(); |
88 | 88 |
89 // Called from RegExp if the stack-guard is triggered. | 89 // Called from RegExp if the stack-guard is triggered. |
90 // If the code object is relocated, the return address is fixed before | 90 // If the code object is relocated, the return address is fixed before |
91 // returning. | 91 // returning. |
92 static int CheckStackGuardState(Address* return_address, | 92 static int CheckStackGuardState(Address* return_address, |
93 Code* re_code, | 93 Code* re_code, |
94 Address re_frame); | 94 Address re_frame); |
95 | 95 |
| 96 void print_regexp_frame_constants(); |
| 97 |
96 private: | 98 private: |
| 99 #if defined(MIPS_ABI_N64) |
97 // Offsets from frame_pointer() of function parameters and stored registers. | 100 // Offsets from frame_pointer() of function parameters and stored registers. |
98 static const int kFramePointer = 0; | 101 static const int kFramePointer = 0; |
99 | 102 |
| 103 // Above the frame pointer - Stored registers and stack passed parameters. |
| 104 // Registers s0 to s7, fp, and ra. |
| 105 static const int kStoredRegisters = kFramePointer; |
| 106 // Return address (stored from link register, read into pc on return). |
| 107 |
| 108 // TODO(plind): This 9 - is 8 s-regs (s0..s7) plus fp. |
| 109 |
| 110 static const int kReturnAddress = kStoredRegisters + 9 * kPointerSize; |
| 111 static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize; |
| 112 // Stack frame header. |
| 113 static const int kStackFrameHeader = kSecondaryReturnAddress; |
| 114 // Stack parameters placed by caller. |
| 115 static const int kIsolate = kStackFrameHeader + kPointerSize; |
| 116 |
| 117 // Below the frame pointer. |
| 118 // Register parameters stored by setup code. |
| 119 static const int kDirectCall = kFramePointer - kPointerSize; |
| 120 static const int kStackHighEnd = kDirectCall - kPointerSize; |
| 121 static const int kNumOutputRegisters = kStackHighEnd - kPointerSize; |
| 122 static const int kRegisterOutput = kNumOutputRegisters - kPointerSize; |
| 123 static const int kInputEnd = kRegisterOutput - kPointerSize; |
| 124 static const int kInputStart = kInputEnd - kPointerSize; |
| 125 static const int kStartIndex = kInputStart - kPointerSize; |
| 126 static const int kInputString = kStartIndex - kPointerSize; |
| 127 // When adding local variables remember to push space for them in |
| 128 // the frame in GetCode. |
| 129 static const int kSuccessfulCaptures = kInputString - kPointerSize; |
| 130 static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize; |
| 131 // First register address. Following registers are below it on the stack. |
| 132 static const int kRegisterZero = kInputStartMinusOne - kPointerSize; |
| 133 |
| 134 #elif defined(MIPS_ABI_O32) |
| 135 // Offsets from frame_pointer() of function parameters and stored registers. |
| 136 static const int kFramePointer = 0; |
| 137 |
100 // Above the frame pointer - Stored registers and stack passed parameters. | 138 // Above the frame pointer - Stored registers and stack passed parameters. |
101 // Registers s0 to s7, fp, and ra. | 139 // Registers s0 to s7, fp, and ra. |
102 static const int kStoredRegisters = kFramePointer; | 140 static const int kStoredRegisters = kFramePointer; |
103 // Return address (stored from link register, read into pc on return). | 141 // Return address (stored from link register, read into pc on return). |
104 static const int kReturnAddress = kStoredRegisters + 9 * kPointerSize; | 142 static const int kReturnAddress = kStoredRegisters + 9 * kPointerSize; |
105 static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize; | 143 static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize; |
106 // Stack frame header. | 144 // Stack frame header. |
107 static const int kStackFrameHeader = kReturnAddress + kPointerSize; | 145 static const int kStackFrameHeader = kReturnAddress + kPointerSize; |
108 // Stack parameters placed by caller. | 146 // Stack parameters placed by caller. |
109 static const int kRegisterOutput = kStackFrameHeader + 20; | 147 static const int kRegisterOutput = |
| 148 kStackFrameHeader + 4 * kPointerSize + kPointerSize; |
110 static const int kNumOutputRegisters = kRegisterOutput + kPointerSize; | 149 static const int kNumOutputRegisters = kRegisterOutput + kPointerSize; |
111 static const int kStackHighEnd = kNumOutputRegisters + kPointerSize; | 150 static const int kStackHighEnd = kNumOutputRegisters + kPointerSize; |
112 static const int kDirectCall = kStackHighEnd + kPointerSize; | 151 static const int kDirectCall = kStackHighEnd + kPointerSize; |
113 static const int kIsolate = kDirectCall + kPointerSize; | 152 static const int kIsolate = kDirectCall + kPointerSize; |
114 | 153 |
115 // Below the frame pointer. | 154 // Below the frame pointer. |
116 // Register parameters stored by setup code. | 155 // Register parameters stored by setup code. |
117 static const int kInputEnd = kFramePointer - kPointerSize; | 156 static const int kInputEnd = kFramePointer - kPointerSize; |
118 static const int kInputStart = kInputEnd - kPointerSize; | 157 static const int kInputStart = kInputEnd - kPointerSize; |
119 static const int kStartIndex = kInputStart - kPointerSize; | 158 static const int kStartIndex = kInputStart - kPointerSize; |
120 static const int kInputString = kStartIndex - kPointerSize; | 159 static const int kInputString = kStartIndex - kPointerSize; |
121 // When adding local variables remember to push space for them in | 160 // When adding local variables remember to push space for them in |
122 // the frame in GetCode. | 161 // the frame in GetCode. |
123 static const int kSuccessfulCaptures = kInputString - kPointerSize; | 162 static const int kSuccessfulCaptures = kInputString - kPointerSize; |
124 static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize; | 163 static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize; |
125 // First register address. Following registers are below it on the stack. | 164 // First register address. Following registers are below it on the stack. |
126 static const int kRegisterZero = kInputStartMinusOne - kPointerSize; | 165 static const int kRegisterZero = kInputStartMinusOne - kPointerSize; |
127 | 166 |
| 167 #else |
| 168 # error "undefined MIPS ABI" |
| 169 #endif |
| 170 |
128 // Initial size of code buffer. | 171 // Initial size of code buffer. |
129 static const size_t kRegExpCodeSize = 1024; | 172 static const size_t kRegExpCodeSize = 1024; |
130 | 173 |
131 // Load a number of characters at the given offset from the | 174 // Load a number of characters at the given offset from the |
132 // current position, into the current-character register. | 175 // current position, into the current-character register. |
133 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); | 176 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); |
134 | 177 |
135 // Check whether preemption has been requested. | 178 // Check whether preemption has been requested. |
136 void CheckPreemption(); | 179 void CheckPreemption(); |
137 | 180 |
138 // Check whether we are exceeding the stack limit on the backtrack stack. | 181 // Check whether we are exceeding the stack limit on the backtrack stack. |
139 void CheckStackLimit(); | 182 void CheckStackLimit(); |
140 | 183 |
141 | 184 |
142 // Generate a call to CheckStackGuardState. | 185 // Generate a call to CheckStackGuardState. |
143 void CallCheckStackGuardState(Register scratch); | 186 void CallCheckStackGuardState(Register scratch); |
144 | 187 |
145 // The ebp-relative location of a regexp register. | 188 // The ebp-relative location of a regexp register. |
146 MemOperand register_location(int register_index); | 189 MemOperand register_location(int register_index); |
147 | 190 |
148 // Register holding the current input position as negative offset from | 191 // Register holding the current input position as negative offset from |
149 // the end of the string. | 192 // the end of the string. |
150 inline Register current_input_offset() { return t2; } | 193 inline Register current_input_offset() { return a6; } |
151 | 194 |
152 // The register containing the current character after LoadCurrentCharacter. | 195 // The register containing the current character after LoadCurrentCharacter. |
153 inline Register current_character() { return t3; } | 196 inline Register current_character() { return a7; } |
154 | 197 |
155 // Register holding address of the end of the input string. | 198 // Register holding address of the end of the input string. |
156 inline Register end_of_input_address() { return t6; } | 199 inline Register end_of_input_address() { return t2; } |
157 | 200 |
158 // Register holding the frame address. Local variables, parameters and | 201 // Register holding the frame address. Local variables, parameters and |
159 // regexp registers are addressed relative to this. | 202 // regexp registers are addressed relative to this. |
160 inline Register frame_pointer() { return fp; } | 203 inline Register frame_pointer() { return fp; } |
161 | 204 |
162 // The register containing the backtrack stack top. Provides a meaningful | 205 // The register containing the backtrack stack top. Provides a meaningful |
163 // name to the register. | 206 // name to the register. |
164 inline Register backtrack_stackpointer() { return t4; } | 207 inline Register backtrack_stackpointer() { return t0; } |
165 | 208 |
166 // Register holding pointer to the current code object. | 209 // Register holding pointer to the current code object. |
167 inline Register code_pointer() { return t1; } | 210 inline Register code_pointer() { return a5; } |
168 | 211 |
169 // Byte size of chars in the string to match (decided by the Mode argument). | 212 // Byte size of chars in the string to match (decided by the Mode argument). |
170 inline int char_size() { return static_cast<int>(mode_); } | 213 inline int char_size() { return static_cast<int>(mode_); } |
171 | 214 |
172 // Equivalent to a conditional branch to the label, unless the label | 215 // Equivalent to a conditional branch to the label, unless the label |
173 // is NULL, in which case it is a conditional Backtrack. | 216 // is NULL, in which case it is a conditional Backtrack. |
174 void BranchOrBacktrack(Label* to, | 217 void BranchOrBacktrack(Label* to, |
175 Condition condition, | 218 Condition condition, |
176 Register rs, | 219 Register rs, |
177 const Operand& rt); | 220 const Operand& rt); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 Label stack_overflow_label_; | 260 Label stack_overflow_label_; |
218 Label internal_failure_label_; | 261 Label internal_failure_label_; |
219 }; | 262 }; |
220 | 263 |
221 #endif // V8_INTERPRETED_REGEXP | 264 #endif // V8_INTERPRETED_REGEXP |
222 | 265 |
223 | 266 |
224 }} // namespace v8::internal | 267 }} // namespace v8::internal |
225 | 268 |
226 #endif // V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ | 269 #endif // V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ |
OLD | NEW |