OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // |
| 3 // Copyright IBM Corp. 2012, 2013. All rights reserved. |
| 4 // |
2 // Use of this source code is governed by a BSD-style license that can be | 5 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 6 // found in the LICENSE file. |
4 | 7 |
5 #ifndef V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_ | 8 #ifndef V8_PPC_REGEXP_MACRO_ASSEMBLER_PPC_H_ |
6 #define V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_ | 9 #define V8_PPC_REGEXP_MACRO_ASSEMBLER_PPC_H_ |
7 | 10 |
8 #include "src/arm/assembler-arm.h" | |
9 #include "src/arm/assembler-arm-inl.h" | |
10 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
| 12 #include "src/ppc/assembler-ppc.h" |
| 13 #include "src/ppc/assembler-ppc-inl.h" |
11 | 14 |
12 namespace v8 { | 15 namespace v8 { |
13 namespace internal { | 16 namespace internal { |
14 | 17 |
15 | 18 |
16 #ifndef V8_INTERPRETED_REGEXP | 19 #ifndef V8_INTERPRETED_REGEXP |
17 class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler { | 20 class RegExpMacroAssemblerPPC: public NativeRegExpMacroAssembler { |
18 public: | 21 public: |
19 RegExpMacroAssemblerARM(Mode mode, int registers_to_save, Zone* zone); | 22 RegExpMacroAssemblerPPC(Mode mode, int registers_to_save, Zone* zone); |
20 virtual ~RegExpMacroAssemblerARM(); | 23 virtual ~RegExpMacroAssemblerPPC(); |
21 virtual int stack_limit_slack(); | 24 virtual int stack_limit_slack(); |
22 virtual void AdvanceCurrentPosition(int by); | 25 virtual void AdvanceCurrentPosition(int by); |
23 virtual void AdvanceRegister(int reg, int by); | 26 virtual void AdvanceRegister(int reg, int by); |
24 virtual void Backtrack(); | 27 virtual void Backtrack(); |
25 virtual void Bind(Label* label); | 28 virtual void Bind(Label* label); |
26 virtual void CheckAtStart(Label* on_at_start); | 29 virtual void CheckAtStart(Label* on_at_start); |
27 virtual void CheckCharacter(unsigned c, Label* on_equal); | 30 virtual void CheckCharacter(unsigned c, Label* on_equal); |
28 virtual void CheckCharacterAfterAnd(unsigned c, | 31 virtual void CheckCharacterAfterAnd(unsigned c, |
29 unsigned mask, | 32 unsigned mask, |
30 Label* on_equal); | 33 Label* on_equal); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // returning. | 93 // returning. |
91 static int CheckStackGuardState(Address* return_address, | 94 static int CheckStackGuardState(Address* return_address, |
92 Code* re_code, | 95 Code* re_code, |
93 Address re_frame); | 96 Address re_frame); |
94 | 97 |
95 private: | 98 private: |
96 // Offsets from frame_pointer() of function parameters and stored registers. | 99 // Offsets from frame_pointer() of function parameters and stored registers. |
97 static const int kFramePointer = 0; | 100 static const int kFramePointer = 0; |
98 | 101 |
99 // Above the frame pointer - Stored registers and stack passed parameters. | 102 // Above the frame pointer - Stored registers and stack passed parameters. |
100 // Register 4..11. | 103 // Register 25..31. |
101 static const int kStoredRegisters = kFramePointer; | 104 static const int kStoredRegisters = kFramePointer; |
102 // Return address (stored from link register, read into pc on return). | 105 // Return address (stored from link register, read into pc on return). |
103 static const int kReturnAddress = kStoredRegisters + 8 * kPointerSize; | 106 static const int kReturnAddress = kStoredRegisters + 7 * kPointerSize; |
104 static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize; | 107 static const int kCallerFrame = kReturnAddress + kPointerSize; |
105 // Stack parameters placed by caller. | 108 // Stack parameters placed by caller. |
106 static const int kRegisterOutput = kSecondaryReturnAddress + kPointerSize; | 109 static const int kSecondaryReturnAddress = kCallerFrame + |
107 static const int kNumOutputRegisters = kRegisterOutput + kPointerSize; | 110 kStackFrameExtraParamSlot * kPointerSize; |
108 static const int kStackHighEnd = kNumOutputRegisters + kPointerSize; | 111 static const int kIsolate = kSecondaryReturnAddress + kPointerSize; |
109 static const int kDirectCall = kStackHighEnd + kPointerSize; | |
110 static const int kIsolate = kDirectCall + kPointerSize; | |
111 | 112 |
112 // Below the frame pointer. | 113 // Below the frame pointer. |
113 // Register parameters stored by setup code. | 114 // Register parameters stored by setup code. |
114 static const int kInputEnd = kFramePointer - kPointerSize; | 115 static const int kDirectCall = kFramePointer - kPointerSize; |
| 116 static const int kStackHighEnd = kDirectCall - kPointerSize; |
| 117 static const int kNumOutputRegisters = kStackHighEnd - kPointerSize; |
| 118 static const int kRegisterOutput = kNumOutputRegisters - kPointerSize; |
| 119 static const int kInputEnd = kRegisterOutput - kPointerSize; |
115 static const int kInputStart = kInputEnd - kPointerSize; | 120 static const int kInputStart = kInputEnd - kPointerSize; |
116 static const int kStartIndex = kInputStart - kPointerSize; | 121 static const int kStartIndex = kInputStart - kPointerSize; |
117 static const int kInputString = kStartIndex - kPointerSize; | 122 static const int kInputString = kStartIndex - kPointerSize; |
118 // When adding local variables remember to push space for them in | 123 // When adding local variables remember to push space for them in |
119 // the frame in GetCode. | 124 // the frame in GetCode. |
120 static const int kSuccessfulCaptures = kInputString - kPointerSize; | 125 static const int kSuccessfulCaptures = kInputString - kPointerSize; |
121 static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize; | 126 static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize; |
122 // First register address. Following registers are below it on the stack. | 127 // First register address. Following registers are below it on the stack. |
123 static const int kRegisterZero = kInputStartMinusOne - kPointerSize; | 128 static const int kRegisterZero = kInputStartMinusOne - kPointerSize; |
124 | 129 |
125 // Initial size of code buffer. | 130 // Initial size of code buffer. |
126 static const size_t kRegExpCodeSize = 1024; | 131 static const size_t kRegExpCodeSize = 1024; |
127 | 132 |
128 static const int kBacktrackConstantPoolSize = 4; | |
129 | |
130 // Load a number of characters at the given offset from the | 133 // Load a number of characters at the given offset from the |
131 // current position, into the current-character register. | 134 // current position, into the current-character register. |
132 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); | 135 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); |
133 | 136 |
134 // Check whether preemption has been requested. | 137 // Check whether preemption has been requested. |
135 void CheckPreemption(); | 138 void CheckPreemption(); |
136 | 139 |
137 // Check whether we are exceeding the stack limit on the backtrack stack. | 140 // Check whether we are exceeding the stack limit on the backtrack stack. |
138 void CheckStackLimit(); | 141 void CheckStackLimit(); |
139 | 142 |
140 | 143 |
141 // Generate a call to CheckStackGuardState. | 144 // Generate a call to CheckStackGuardState. |
142 void CallCheckStackGuardState(Register scratch); | 145 void CallCheckStackGuardState(Register scratch); |
143 | 146 |
144 // The ebp-relative location of a regexp register. | 147 // The ebp-relative location of a regexp register. |
145 MemOperand register_location(int register_index); | 148 MemOperand register_location(int register_index); |
146 | 149 |
147 // Register holding the current input position as negative offset from | 150 // Register holding the current input position as negative offset from |
148 // the end of the string. | 151 // the end of the string. |
149 inline Register current_input_offset() { return r6; } | 152 inline Register current_input_offset() { return r27; } |
150 | 153 |
151 // The register containing the current character after LoadCurrentCharacter. | 154 // The register containing the current character after LoadCurrentCharacter. |
152 inline Register current_character() { return r7; } | 155 inline Register current_character() { return r28; } |
153 | 156 |
154 // Register holding address of the end of the input string. | 157 // Register holding address of the end of the input string. |
155 inline Register end_of_input_address() { return r10; } | 158 inline Register end_of_input_address() { return r30; } |
156 | 159 |
157 // Register holding the frame address. Local variables, parameters and | 160 // Register holding the frame address. Local variables, parameters and |
158 // regexp registers are addressed relative to this. | 161 // regexp registers are addressed relative to this. |
159 inline Register frame_pointer() { return fp; } | 162 inline Register frame_pointer() { return fp; } |
160 | 163 |
161 // The register containing the backtrack stack top. Provides a meaningful | 164 // The register containing the backtrack stack top. Provides a meaningful |
162 // name to the register. | 165 // name to the register. |
163 inline Register backtrack_stackpointer() { return r8; } | 166 inline Register backtrack_stackpointer() { return r29; } |
164 | 167 |
165 // Register holding pointer to the current code object. | 168 // Register holding pointer to the current code object. |
166 inline Register code_pointer() { return r5; } | 169 inline Register code_pointer() { return r26; } |
167 | 170 |
168 // Byte size of chars in the string to match (decided by the Mode argument) | 171 // Byte size of chars in the string to match (decided by the Mode argument) |
169 inline int char_size() { return static_cast<int>(mode_); } | 172 inline int char_size() { return static_cast<int>(mode_); } |
170 | 173 |
171 // Equivalent to a conditional branch to the label, unless the label | 174 // Equivalent to a conditional branch to the label, unless the label |
172 // is NULL, in which case it is a conditional Backtrack. | 175 // is NULL, in which case it is a conditional Backtrack. |
173 void BranchOrBacktrack(Condition condition, Label* to); | 176 void BranchOrBacktrack(Condition condition, Label* to, CRegister cr = cr7); |
174 | 177 |
175 // Call and return internally in the generated code in a way that | 178 // Call and return internally in the generated code in a way that |
176 // is GC-safe (i.e., doesn't leave absolute code addresses on the stack) | 179 // is GC-safe (i.e., doesn't leave absolute code addresses on the stack) |
177 inline void SafeCall(Label* to, Condition cond = al); | 180 inline void SafeCall(Label* to, Condition cond = al, CRegister cr = cr7); |
178 inline void SafeReturn(); | 181 inline void SafeReturn(); |
179 inline void SafeCallTarget(Label* name); | 182 inline void SafeCallTarget(Label* name); |
180 | 183 |
181 // Pushes the value of a register on the backtrack stack. Decrements the | 184 // Pushes the value of a register on the backtrack stack. Decrements the |
182 // stack pointer by a word size and stores the register's value there. | 185 // stack pointer by a word size and stores the register's value there. |
183 inline void Push(Register source); | 186 inline void Push(Register source); |
184 | 187 |
185 // Pops a value from the backtrack stack. Reads the word at the stack pointer | 188 // Pops a value from the backtrack stack. Reads the word at the stack pointer |
186 // and increments it by a word size. | 189 // and increments it by a word size. |
187 inline void Pop(Register target); | 190 inline void Pop(Register target); |
(...skipping 13 matching lines...) Expand all Loading... |
201 int num_saved_registers_; | 204 int num_saved_registers_; |
202 | 205 |
203 // Labels used internally. | 206 // Labels used internally. |
204 Label entry_label_; | 207 Label entry_label_; |
205 Label start_label_; | 208 Label start_label_; |
206 Label success_label_; | 209 Label success_label_; |
207 Label backtrack_label_; | 210 Label backtrack_label_; |
208 Label exit_label_; | 211 Label exit_label_; |
209 Label check_preempt_label_; | 212 Label check_preempt_label_; |
210 Label stack_overflow_label_; | 213 Label stack_overflow_label_; |
| 214 Label internal_failure_label_; |
211 }; | 215 }; |
212 | 216 |
| 217 // Set of non-volatile registers saved/restored by generated regexp code. |
| 218 const RegList kRegExpCalleeSaved = |
| 219 1 << 25 | |
| 220 1 << 26 | |
| 221 1 << 27 | |
| 222 1 << 28 | |
| 223 1 << 29 | |
| 224 1 << 30 | |
| 225 1 << 31; |
| 226 |
213 #endif // V8_INTERPRETED_REGEXP | 227 #endif // V8_INTERPRETED_REGEXP |
214 | 228 |
215 | 229 |
216 }} // namespace v8::internal | 230 }} // namespace v8::internal |
217 | 231 |
218 #endif // V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_ | 232 #endif // V8_PPC_REGEXP_MACRO_ASSEMBLER_PPC_H_ |
OLD | NEW |