OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_ARM_CODE_STUBS_ARM_H_ | 5 #ifndef V8_ARM_CODE_STUBS_ARM_H_ |
6 #define V8_ARM_CODE_STUBS_ARM_H_ | 6 #define V8_ARM_CODE_STUBS_ARM_H_ |
7 | 7 |
8 #include "src/ic-inl.h" | 8 #include "src/ic-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 enum Mode { | 173 enum Mode { |
174 STORE_BUFFER_ONLY, | 174 STORE_BUFFER_ONLY, |
175 INCREMENTAL, | 175 INCREMENTAL, |
176 INCREMENTAL_COMPACTION | 176 INCREMENTAL_COMPACTION |
177 }; | 177 }; |
178 | 178 |
179 virtual bool SometimesSetsUpAFrame() { return false; } | 179 virtual bool SometimesSetsUpAFrame() { return false; } |
180 | 180 |
181 static void PatchBranchIntoNop(MacroAssembler* masm, int pos) { | 181 static void PatchBranchIntoNop(MacroAssembler* masm, int pos) { |
182 masm->instr_at_put(pos, (masm->instr_at(pos) & ~B27) | (B24 | B20)); | 182 masm->instr_at_put(pos, (masm->instr_at(pos) & ~B27) | (B24 | B20)); |
183 ASSERT(Assembler::IsTstImmediate(masm->instr_at(pos))); | 183 DCHECK(Assembler::IsTstImmediate(masm->instr_at(pos))); |
184 } | 184 } |
185 | 185 |
186 static void PatchNopIntoBranch(MacroAssembler* masm, int pos) { | 186 static void PatchNopIntoBranch(MacroAssembler* masm, int pos) { |
187 masm->instr_at_put(pos, (masm->instr_at(pos) & ~(B24 | B20)) | B27); | 187 masm->instr_at_put(pos, (masm->instr_at(pos) & ~(B24 | B20)) | B27); |
188 ASSERT(Assembler::IsBranch(masm->instr_at(pos))); | 188 DCHECK(Assembler::IsBranch(masm->instr_at(pos))); |
189 } | 189 } |
190 | 190 |
191 static Mode GetMode(Code* stub) { | 191 static Mode GetMode(Code* stub) { |
192 Instr first_instruction = Assembler::instr_at(stub->instruction_start()); | 192 Instr first_instruction = Assembler::instr_at(stub->instruction_start()); |
193 Instr second_instruction = Assembler::instr_at(stub->instruction_start() + | 193 Instr second_instruction = Assembler::instr_at(stub->instruction_start() + |
194 Assembler::kInstrSize); | 194 Assembler::kInstrSize); |
195 | 195 |
196 if (Assembler::IsBranch(first_instruction)) { | 196 if (Assembler::IsBranch(first_instruction)) { |
197 return INCREMENTAL; | 197 return INCREMENTAL; |
198 } | 198 } |
199 | 199 |
200 ASSERT(Assembler::IsTstImmediate(first_instruction)); | 200 DCHECK(Assembler::IsTstImmediate(first_instruction)); |
201 | 201 |
202 if (Assembler::IsBranch(second_instruction)) { | 202 if (Assembler::IsBranch(second_instruction)) { |
203 return INCREMENTAL_COMPACTION; | 203 return INCREMENTAL_COMPACTION; |
204 } | 204 } |
205 | 205 |
206 ASSERT(Assembler::IsTstImmediate(second_instruction)); | 206 DCHECK(Assembler::IsTstImmediate(second_instruction)); |
207 | 207 |
208 return STORE_BUFFER_ONLY; | 208 return STORE_BUFFER_ONLY; |
209 } | 209 } |
210 | 210 |
211 static void Patch(Code* stub, Mode mode) { | 211 static void Patch(Code* stub, Mode mode) { |
212 MacroAssembler masm(NULL, | 212 MacroAssembler masm(NULL, |
213 stub->instruction_start(), | 213 stub->instruction_start(), |
214 stub->instruction_size()); | 214 stub->instruction_size()); |
215 switch (mode) { | 215 switch (mode) { |
216 case STORE_BUFFER_ONLY: | 216 case STORE_BUFFER_ONLY: |
217 ASSERT(GetMode(stub) == INCREMENTAL || | 217 DCHECK(GetMode(stub) == INCREMENTAL || |
218 GetMode(stub) == INCREMENTAL_COMPACTION); | 218 GetMode(stub) == INCREMENTAL_COMPACTION); |
219 PatchBranchIntoNop(&masm, 0); | 219 PatchBranchIntoNop(&masm, 0); |
220 PatchBranchIntoNop(&masm, Assembler::kInstrSize); | 220 PatchBranchIntoNop(&masm, Assembler::kInstrSize); |
221 break; | 221 break; |
222 case INCREMENTAL: | 222 case INCREMENTAL: |
223 ASSERT(GetMode(stub) == STORE_BUFFER_ONLY); | 223 DCHECK(GetMode(stub) == STORE_BUFFER_ONLY); |
224 PatchNopIntoBranch(&masm, 0); | 224 PatchNopIntoBranch(&masm, 0); |
225 break; | 225 break; |
226 case INCREMENTAL_COMPACTION: | 226 case INCREMENTAL_COMPACTION: |
227 ASSERT(GetMode(stub) == STORE_BUFFER_ONLY); | 227 DCHECK(GetMode(stub) == STORE_BUFFER_ONLY); |
228 PatchNopIntoBranch(&masm, Assembler::kInstrSize); | 228 PatchNopIntoBranch(&masm, Assembler::kInstrSize); |
229 break; | 229 break; |
230 } | 230 } |
231 ASSERT(GetMode(stub) == mode); | 231 DCHECK(GetMode(stub) == mode); |
232 CpuFeatures::FlushICache(stub->instruction_start(), | 232 CpuFeatures::FlushICache(stub->instruction_start(), |
233 2 * Assembler::kInstrSize); | 233 2 * Assembler::kInstrSize); |
234 } | 234 } |
235 | 235 |
236 private: | 236 private: |
237 // This is a helper class for freeing up 3 scratch registers. The input is | 237 // This is a helper class for freeing up 3 scratch registers. The input is |
238 // two registers that must be preserved and one scratch register provided by | 238 // two registers that must be preserved and one scratch register provided by |
239 // the caller. | 239 // the caller. |
240 class RegisterAllocation { | 240 class RegisterAllocation { |
241 public: | 241 public: |
242 RegisterAllocation(Register object, | 242 RegisterAllocation(Register object, |
243 Register address, | 243 Register address, |
244 Register scratch0) | 244 Register scratch0) |
245 : object_(object), | 245 : object_(object), |
246 address_(address), | 246 address_(address), |
247 scratch0_(scratch0) { | 247 scratch0_(scratch0) { |
248 ASSERT(!AreAliased(scratch0, object, address, no_reg)); | 248 DCHECK(!AreAliased(scratch0, object, address, no_reg)); |
249 scratch1_ = GetRegisterThatIsNotOneOf(object_, address_, scratch0_); | 249 scratch1_ = GetRegisterThatIsNotOneOf(object_, address_, scratch0_); |
250 } | 250 } |
251 | 251 |
252 void Save(MacroAssembler* masm) { | 252 void Save(MacroAssembler* masm) { |
253 ASSERT(!AreAliased(object_, address_, scratch1_, scratch0_)); | 253 DCHECK(!AreAliased(object_, address_, scratch1_, scratch0_)); |
254 // We don't have to save scratch0_ because it was given to us as | 254 // We don't have to save scratch0_ because it was given to us as |
255 // a scratch register. | 255 // a scratch register. |
256 masm->push(scratch1_); | 256 masm->push(scratch1_); |
257 } | 257 } |
258 | 258 |
259 void Restore(MacroAssembler* masm) { | 259 void Restore(MacroAssembler* masm) { |
260 masm->pop(scratch1_); | 260 masm->pop(scratch1_); |
261 } | 261 } |
262 | 262 |
263 // If we have to call into C then we need to save and restore all caller- | 263 // If we have to call into C then we need to save and restore all caller- |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 TargetAddressStorageMode storage_mode() { return storage_mode_; } | 412 TargetAddressStorageMode storage_mode() { return storage_mode_; } |
413 | 413 |
414 private: | 414 private: |
415 TargetAddressStorageMode storage_mode_; | 415 TargetAddressStorageMode storage_mode_; |
416 }; | 416 }; |
417 | 417 |
418 | 418 |
419 } } // namespace v8::internal | 419 } } // namespace v8::internal |
420 | 420 |
421 #endif // V8_ARM_CODE_STUBS_ARM_H_ | 421 #endif // V8_ARM_CODE_STUBS_ARM_H_ |
OLD | NEW |