OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 | 226 |
227 | 227 |
228 void MacroAssembler::LoadRoot(Register destination, | 228 void MacroAssembler::LoadRoot(Register destination, |
229 Heap::RootListIndex index, | 229 Heap::RootListIndex index, |
230 Condition cond) { | 230 Condition cond) { |
231 ldr(destination, MemOperand(roots, index << kPointerSizeLog2), cond); | 231 ldr(destination, MemOperand(roots, index << kPointerSizeLog2), cond); |
232 } | 232 } |
233 | 233 |
234 | 234 |
235 // Will clobber 4 registers: object, offset, scratch, ip. The | 235 void MacroAssembler::RecordWriteHelper(Register object, |
236 // register 'object' contains a heap object pointer. The heap object | 236 Register offset, |
237 // tag is shifted away. | 237 Register scratch) { |
238 void MacroAssembler::RecordWrite(Register object, Register offset, | 238 if (FLAG_debug_code) { |
239 Register scratch) { | 239 // Check that the object is not in new space. |
240 // The compiled code assumes that record write doesn't change the | 240 Label not_in_new_space; |
241 // context register, so we check that none of the clobbered | 241 InNewSpace(object, scratch, ne, ¬_in_new_space); |
242 // registers are cp. | 242 Abort("new-space object passed to RecordWriteHelper"); |
243 ASSERT(!object.is(cp) && !offset.is(cp) && !scratch.is(cp)); | 243 bind(¬_in_new_space); |
| 244 } |
244 | 245 |
245 // This is how much we shift the remembered set bit offset to get the | 246 // This is how much we shift the remembered set bit offset to get the |
246 // offset of the word in the remembered set. We divide by kBitsPerInt (32, | 247 // offset of the word in the remembered set. We divide by kBitsPerInt (32, |
247 // shift right 5) and then multiply by kIntSize (4, shift left 2). | 248 // shift right 5) and then multiply by kIntSize (4, shift left 2). |
248 const int kRSetWordShift = 3; | 249 const int kRSetWordShift = 3; |
249 | 250 |
250 Label fast, done; | 251 Label fast; |
251 | |
252 // First, test that the object is not in the new space. We cannot set | |
253 // remembered set bits in the new space. | |
254 // object: heap object pointer (with tag) | |
255 // offset: offset to store location from the object | |
256 and_(scratch, object, Operand(ExternalReference::new_space_mask())); | |
257 cmp(scratch, Operand(ExternalReference::new_space_start())); | |
258 b(eq, &done); | |
259 | 252 |
260 // Compute the bit offset in the remembered set. | 253 // Compute the bit offset in the remembered set. |
261 // object: heap object pointer (with tag) | 254 // object: heap object pointer (with tag) |
262 // offset: offset to store location from the object | 255 // offset: offset to store location from the object |
263 mov(ip, Operand(Page::kPageAlignmentMask)); // load mask only once | 256 mov(ip, Operand(Page::kPageAlignmentMask)); // load mask only once |
264 and_(scratch, object, Operand(ip)); // offset into page of the object | 257 and_(scratch, object, Operand(ip)); // offset into page of the object |
265 add(offset, scratch, Operand(offset)); // add offset into the object | 258 add(offset, scratch, Operand(offset)); // add offset into the object |
266 mov(offset, Operand(offset, LSR, kObjectAlignmentBits)); | 259 mov(offset, Operand(offset, LSR, kObjectAlignmentBits)); |
267 | 260 |
268 // Compute the page address from the heap object pointer. | 261 // Compute the page address from the heap object pointer. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 add(object, object, Operand(scratch, LSR, kRSetWordShift)); | 293 add(object, object, Operand(scratch, LSR, kRSetWordShift)); |
301 // Get bit offset in the rset word. | 294 // Get bit offset in the rset word. |
302 // object: address of remembered set word | 295 // object: address of remembered set word |
303 // offset: bit offset of store position | 296 // offset: bit offset of store position |
304 and_(offset, offset, Operand(kBitsPerInt - 1)); | 297 and_(offset, offset, Operand(kBitsPerInt - 1)); |
305 | 298 |
306 ldr(scratch, MemOperand(object)); | 299 ldr(scratch, MemOperand(object)); |
307 mov(ip, Operand(1)); | 300 mov(ip, Operand(1)); |
308 orr(scratch, scratch, Operand(ip, LSL, offset)); | 301 orr(scratch, scratch, Operand(ip, LSL, offset)); |
309 str(scratch, MemOperand(object)); | 302 str(scratch, MemOperand(object)); |
| 303 } |
| 304 |
| 305 |
| 306 void MacroAssembler::InNewSpace(Register object, |
| 307 Register scratch, |
| 308 Condition cc, |
| 309 Label* branch) { |
| 310 ASSERT(cc == eq || cc == ne); |
| 311 and_(scratch, object, Operand(ExternalReference::new_space_mask())); |
| 312 cmp(scratch, Operand(ExternalReference::new_space_start())); |
| 313 b(cc, branch); |
| 314 } |
| 315 |
| 316 |
| 317 // Will clobber 4 registers: object, offset, scratch, ip. The |
| 318 // register 'object' contains a heap object pointer. The heap object |
| 319 // tag is shifted away. |
| 320 void MacroAssembler::RecordWrite(Register object, Register offset, |
| 321 Register scratch) { |
| 322 // The compiled code assumes that record write doesn't change the |
| 323 // context register, so we check that none of the clobbered |
| 324 // registers are cp. |
| 325 ASSERT(!object.is(cp) && !offset.is(cp) && !scratch.is(cp)); |
| 326 |
| 327 Label done; |
| 328 |
| 329 // First, test that the object is not in the new space. We cannot set |
| 330 // remembered set bits in the new space. |
| 331 InNewSpace(object, scratch, eq, &done); |
| 332 |
| 333 // Record the actual write. |
| 334 RecordWriteHelper(object, offset, scratch); |
310 | 335 |
311 bind(&done); | 336 bind(&done); |
312 | 337 |
313 // Clobber all input registers when running with the debug-code flag | 338 // Clobber all input registers when running with the debug-code flag |
314 // turned on to provoke errors. | 339 // turned on to provoke errors. |
315 if (FLAG_debug_code) { | 340 if (FLAG_debug_code) { |
316 mov(object, Operand(BitCast<int32_t>(kZapValue))); | 341 mov(object, Operand(BitCast<int32_t>(kZapValue))); |
317 mov(offset, Operand(BitCast<int32_t>(kZapValue))); | 342 mov(offset, Operand(BitCast<int32_t>(kZapValue))); |
318 mov(scratch, Operand(BitCast<int32_t>(kZapValue))); | 343 mov(scratch, Operand(BitCast<int32_t>(kZapValue))); |
319 } | 344 } |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 } | 1695 } |
1671 | 1696 |
1672 | 1697 |
1673 void CodePatcher::Emit(Address addr) { | 1698 void CodePatcher::Emit(Address addr) { |
1674 masm()->emit(reinterpret_cast<Instr>(addr)); | 1699 masm()->emit(reinterpret_cast<Instr>(addr)); |
1675 } | 1700 } |
1676 #endif // ENABLE_DEBUGGER_SUPPORT | 1701 #endif // ENABLE_DEBUGGER_SUPPORT |
1677 | 1702 |
1678 | 1703 |
1679 } } // namespace v8::internal | 1704 } } // namespace v8::internal |
OLD | NEW |