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