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 #ifndef V8_MIPS_CODE_STUBS_ARM_H_ | 5 #ifndef V8_MIPS_CODE_STUBS_ARM_H_ |
6 #define V8_MIPS_CODE_STUBS_ARM_H_ | 6 #define V8_MIPS_CODE_STUBS_ARM_H_ |
7 | 7 |
8 #include "src/ic-inl.h" | 8 #include "src/ic-inl.h" |
9 | 9 |
10 | 10 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 WriteInt32ToHeapNumberStub(Isolate* isolate, | 148 WriteInt32ToHeapNumberStub(Isolate* isolate, |
149 Register the_int, | 149 Register the_int, |
150 Register the_heap_number, | 150 Register the_heap_number, |
151 Register scratch, | 151 Register scratch, |
152 Register scratch2) | 152 Register scratch2) |
153 : PlatformCodeStub(isolate), | 153 : PlatformCodeStub(isolate), |
154 the_int_(the_int), | 154 the_int_(the_int), |
155 the_heap_number_(the_heap_number), | 155 the_heap_number_(the_heap_number), |
156 scratch_(scratch), | 156 scratch_(scratch), |
157 sign_(scratch2) { | 157 sign_(scratch2) { |
158 ASSERT(IntRegisterBits::is_valid(the_int_.code())); | 158 DCHECK(IntRegisterBits::is_valid(the_int_.code())); |
159 ASSERT(HeapNumberRegisterBits::is_valid(the_heap_number_.code())); | 159 DCHECK(HeapNumberRegisterBits::is_valid(the_heap_number_.code())); |
160 ASSERT(ScratchRegisterBits::is_valid(scratch_.code())); | 160 DCHECK(ScratchRegisterBits::is_valid(scratch_.code())); |
161 ASSERT(SignRegisterBits::is_valid(sign_.code())); | 161 DCHECK(SignRegisterBits::is_valid(sign_.code())); |
162 } | 162 } |
163 | 163 |
164 static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate); | 164 static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate); |
165 | 165 |
166 private: | 166 private: |
167 Register the_int_; | 167 Register the_int_; |
168 Register the_heap_number_; | 168 Register the_heap_number_; |
169 Register scratch_; | 169 Register scratch_; |
170 Register sign_; | 170 Register sign_; |
171 | 171 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 INCREMENTAL, | 212 INCREMENTAL, |
213 INCREMENTAL_COMPACTION | 213 INCREMENTAL_COMPACTION |
214 }; | 214 }; |
215 | 215 |
216 virtual bool SometimesSetsUpAFrame() { return false; } | 216 virtual bool SometimesSetsUpAFrame() { return false; } |
217 | 217 |
218 static void PatchBranchIntoNop(MacroAssembler* masm, int pos) { | 218 static void PatchBranchIntoNop(MacroAssembler* masm, int pos) { |
219 const unsigned offset = masm->instr_at(pos) & kImm16Mask; | 219 const unsigned offset = masm->instr_at(pos) & kImm16Mask; |
220 masm->instr_at_put(pos, BNE | (zero_reg.code() << kRsShift) | | 220 masm->instr_at_put(pos, BNE | (zero_reg.code() << kRsShift) | |
221 (zero_reg.code() << kRtShift) | (offset & kImm16Mask)); | 221 (zero_reg.code() << kRtShift) | (offset & kImm16Mask)); |
222 ASSERT(Assembler::IsBne(masm->instr_at(pos))); | 222 DCHECK(Assembler::IsBne(masm->instr_at(pos))); |
223 } | 223 } |
224 | 224 |
225 static void PatchNopIntoBranch(MacroAssembler* masm, int pos) { | 225 static void PatchNopIntoBranch(MacroAssembler* masm, int pos) { |
226 const unsigned offset = masm->instr_at(pos) & kImm16Mask; | 226 const unsigned offset = masm->instr_at(pos) & kImm16Mask; |
227 masm->instr_at_put(pos, BEQ | (zero_reg.code() << kRsShift) | | 227 masm->instr_at_put(pos, BEQ | (zero_reg.code() << kRsShift) | |
228 (zero_reg.code() << kRtShift) | (offset & kImm16Mask)); | 228 (zero_reg.code() << kRtShift) | (offset & kImm16Mask)); |
229 ASSERT(Assembler::IsBeq(masm->instr_at(pos))); | 229 DCHECK(Assembler::IsBeq(masm->instr_at(pos))); |
230 } | 230 } |
231 | 231 |
232 static Mode GetMode(Code* stub) { | 232 static Mode GetMode(Code* stub) { |
233 Instr first_instruction = Assembler::instr_at(stub->instruction_start()); | 233 Instr first_instruction = Assembler::instr_at(stub->instruction_start()); |
234 Instr second_instruction = Assembler::instr_at(stub->instruction_start() + | 234 Instr second_instruction = Assembler::instr_at(stub->instruction_start() + |
235 2 * Assembler::kInstrSize); | 235 2 * Assembler::kInstrSize); |
236 | 236 |
237 if (Assembler::IsBeq(first_instruction)) { | 237 if (Assembler::IsBeq(first_instruction)) { |
238 return INCREMENTAL; | 238 return INCREMENTAL; |
239 } | 239 } |
240 | 240 |
241 ASSERT(Assembler::IsBne(first_instruction)); | 241 DCHECK(Assembler::IsBne(first_instruction)); |
242 | 242 |
243 if (Assembler::IsBeq(second_instruction)) { | 243 if (Assembler::IsBeq(second_instruction)) { |
244 return INCREMENTAL_COMPACTION; | 244 return INCREMENTAL_COMPACTION; |
245 } | 245 } |
246 | 246 |
247 ASSERT(Assembler::IsBne(second_instruction)); | 247 DCHECK(Assembler::IsBne(second_instruction)); |
248 | 248 |
249 return STORE_BUFFER_ONLY; | 249 return STORE_BUFFER_ONLY; |
250 } | 250 } |
251 | 251 |
252 static void Patch(Code* stub, Mode mode) { | 252 static void Patch(Code* stub, Mode mode) { |
253 MacroAssembler masm(NULL, | 253 MacroAssembler masm(NULL, |
254 stub->instruction_start(), | 254 stub->instruction_start(), |
255 stub->instruction_size()); | 255 stub->instruction_size()); |
256 switch (mode) { | 256 switch (mode) { |
257 case STORE_BUFFER_ONLY: | 257 case STORE_BUFFER_ONLY: |
258 ASSERT(GetMode(stub) == INCREMENTAL || | 258 DCHECK(GetMode(stub) == INCREMENTAL || |
259 GetMode(stub) == INCREMENTAL_COMPACTION); | 259 GetMode(stub) == INCREMENTAL_COMPACTION); |
260 PatchBranchIntoNop(&masm, 0); | 260 PatchBranchIntoNop(&masm, 0); |
261 PatchBranchIntoNop(&masm, 2 * Assembler::kInstrSize); | 261 PatchBranchIntoNop(&masm, 2 * Assembler::kInstrSize); |
262 break; | 262 break; |
263 case INCREMENTAL: | 263 case INCREMENTAL: |
264 ASSERT(GetMode(stub) == STORE_BUFFER_ONLY); | 264 DCHECK(GetMode(stub) == STORE_BUFFER_ONLY); |
265 PatchNopIntoBranch(&masm, 0); | 265 PatchNopIntoBranch(&masm, 0); |
266 break; | 266 break; |
267 case INCREMENTAL_COMPACTION: | 267 case INCREMENTAL_COMPACTION: |
268 ASSERT(GetMode(stub) == STORE_BUFFER_ONLY); | 268 DCHECK(GetMode(stub) == STORE_BUFFER_ONLY); |
269 PatchNopIntoBranch(&masm, 2 * Assembler::kInstrSize); | 269 PatchNopIntoBranch(&masm, 2 * Assembler::kInstrSize); |
270 break; | 270 break; |
271 } | 271 } |
272 ASSERT(GetMode(stub) == mode); | 272 DCHECK(GetMode(stub) == mode); |
273 CpuFeatures::FlushICache(stub->instruction_start(), | 273 CpuFeatures::FlushICache(stub->instruction_start(), |
274 4 * Assembler::kInstrSize); | 274 4 * Assembler::kInstrSize); |
275 } | 275 } |
276 | 276 |
277 private: | 277 private: |
278 // This is a helper class for freeing up 3 scratch registers. The input is | 278 // This is a helper class for freeing up 3 scratch registers. The input is |
279 // two registers that must be preserved and one scratch register provided by | 279 // two registers that must be preserved and one scratch register provided by |
280 // the caller. | 280 // the caller. |
281 class RegisterAllocation { | 281 class RegisterAllocation { |
282 public: | 282 public: |
283 RegisterAllocation(Register object, | 283 RegisterAllocation(Register object, |
284 Register address, | 284 Register address, |
285 Register scratch0) | 285 Register scratch0) |
286 : object_(object), | 286 : object_(object), |
287 address_(address), | 287 address_(address), |
288 scratch0_(scratch0) { | 288 scratch0_(scratch0) { |
289 ASSERT(!AreAliased(scratch0, object, address, no_reg)); | 289 DCHECK(!AreAliased(scratch0, object, address, no_reg)); |
290 scratch1_ = GetRegisterThatIsNotOneOf(object_, address_, scratch0_); | 290 scratch1_ = GetRegisterThatIsNotOneOf(object_, address_, scratch0_); |
291 } | 291 } |
292 | 292 |
293 void Save(MacroAssembler* masm) { | 293 void Save(MacroAssembler* masm) { |
294 ASSERT(!AreAliased(object_, address_, scratch1_, scratch0_)); | 294 DCHECK(!AreAliased(object_, address_, scratch1_, scratch0_)); |
295 // We don't have to save scratch0_ because it was given to us as | 295 // We don't have to save scratch0_ because it was given to us as |
296 // a scratch register. | 296 // a scratch register. |
297 masm->push(scratch1_); | 297 masm->push(scratch1_); |
298 } | 298 } |
299 | 299 |
300 void Restore(MacroAssembler* masm) { | 300 void Restore(MacroAssembler* masm) { |
301 masm->pop(scratch1_); | 301 masm->pop(scratch1_); |
302 } | 302 } |
303 | 303 |
304 // If we have to call into C then we need to save and restore all caller- | 304 // If we have to call into C then we need to save and restore all caller- |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 class LookupModeBits: public BitField<LookupMode, 0, 1> {}; | 441 class LookupModeBits: public BitField<LookupMode, 0, 1> {}; |
442 | 442 |
443 LookupMode mode_; | 443 LookupMode mode_; |
444 }; | 444 }; |
445 | 445 |
446 | 446 |
447 } } // namespace v8::internal | 447 } } // namespace v8::internal |
448 | 448 |
449 #endif // V8_MIPS_CODE_STUBS_ARM_H_ | 449 #endif // V8_MIPS_CODE_STUBS_ARM_H_ |
OLD | NEW |