| OLD | NEW |
| 1 // Copyright 2006-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2010 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 318 |
| 319 | 319 |
| 320 void Heap::CopyBlock(Address dst, Address src, int byte_size) { | 320 void Heap::CopyBlock(Address dst, Address src, int byte_size) { |
| 321 ASSERT(IsAligned(byte_size, kPointerSize)); | 321 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 322 CopyWords(reinterpret_cast<Object**>(dst), | 322 CopyWords(reinterpret_cast<Object**>(dst), |
| 323 reinterpret_cast<Object**>(src), | 323 reinterpret_cast<Object**>(src), |
| 324 byte_size / kPointerSize); | 324 byte_size / kPointerSize); |
| 325 } | 325 } |
| 326 | 326 |
| 327 | 327 |
| 328 void Heap::CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst, | 328 void Heap::CopyBlockToOldSpaceAndUpdateWriteBarrier(Address dst, |
| 329 Address src, | 329 Address src, |
| 330 int byte_size) { | 330 int byte_size) { |
| 331 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 332 ASSERT(IsAligned(byte_size, kPointerSize)); | 331 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 333 | 332 |
| 334 Page* page = Page::FromAddress(dst); | |
| 335 uint32_t marks = page->GetRegionMarks(); | |
| 336 | |
| 337 for (int remaining = byte_size / kPointerSize; | 333 for (int remaining = byte_size / kPointerSize; |
| 338 remaining > 0; | 334 remaining > 0; |
| 339 remaining--) { | 335 remaining--) { |
| 340 Memory::Object_at(dst) = Memory::Object_at(src); | 336 Memory::Object_at(dst) = Memory::Object_at(src); |
| 341 | 337 |
| 342 if (Heap::InNewSpace(Memory::Object_at(dst))) { | 338 if (Heap::InNewSpace(Memory::Object_at(dst))) { |
| 343 marks |= page->GetRegionMaskForAddress(dst); | 339 StoreBuffer::Mark(dst); |
| 344 } | 340 } |
| 345 | 341 |
| 346 dst += kPointerSize; | 342 dst += kPointerSize; |
| 347 src += kPointerSize; | 343 src += kPointerSize; |
| 348 } | 344 } |
| 349 | |
| 350 page->SetRegionMarks(marks); | |
| 351 #else | |
| 352 CopyBlock(dst, src, byte_size); | |
| 353 #endif | |
| 354 } | 345 } |
| 355 | 346 |
| 356 | 347 |
| 357 void Heap::MoveBlock(Address dst, Address src, int byte_size) { | 348 void Heap::MoveBlock(Address dst, Address src, int byte_size) { |
| 358 ASSERT(IsAligned(byte_size, kPointerSize)); | 349 ASSERT(IsAligned(byte_size, kPointerSize)); |
| 359 | 350 |
| 360 int size_in_words = byte_size / kPointerSize; | 351 int size_in_words = byte_size / kPointerSize; |
| 361 | 352 |
| 362 if ((dst < src) || (dst >= (src + size_in_words))) { | 353 if ((dst < src) || (dst >= (src + size_in_words))) { |
| 363 ASSERT((dst >= (src + size_in_words)) || | 354 ASSERT((dst >= (src + size_in_words)) || |
| 364 ((OffsetFrom(reinterpret_cast<Address>(src)) - | 355 ((OffsetFrom(reinterpret_cast<Address>(src)) - |
| 365 OffsetFrom(reinterpret_cast<Address>(dst))) >= kPointerSize)); | 356 OffsetFrom(reinterpret_cast<Address>(dst))) >= kPointerSize)); |
| 366 | 357 |
| 367 Object** src_slot = reinterpret_cast<Object**>(src); | 358 Object** src_slot = reinterpret_cast<Object**>(src); |
| 368 Object** dst_slot = reinterpret_cast<Object**>(dst); | 359 Object** dst_slot = reinterpret_cast<Object**>(dst); |
| 369 Object** end_slot = src_slot + size_in_words; | 360 Object** end_slot = src_slot + size_in_words; |
| 370 | 361 |
| 371 while (src_slot != end_slot) { | 362 while (src_slot != end_slot) { |
| 372 *dst_slot++ = *src_slot++; | 363 *dst_slot++ = *src_slot++; |
| 373 } | 364 } |
| 374 } else { | 365 } else { |
| 375 memmove(dst, src, byte_size); | 366 memmove(dst, src, byte_size); |
| 376 } | 367 } |
| 377 } | 368 } |
| 378 | 369 |
| 379 | 370 |
| 380 void Heap::MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst, | |
| 381 Address src, | |
| 382 int byte_size) { | |
| 383 ASSERT(IsAligned(byte_size, kPointerSize)); | |
| 384 ASSERT((dst >= (src + byte_size)) || | |
| 385 ((OffsetFrom(src) - OffsetFrom(dst)) >= kPointerSize)); | |
| 386 | |
| 387 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 388 CopyBlockToOldSpaceAndUpdateRegionMarks(dst, src, byte_size); | |
| 389 #else | |
| 390 MoveBlock(dst, src, byte_size); | |
| 391 #endif | |
| 392 } | |
| 393 | |
| 394 | |
| 395 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { | 371 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { |
| 396 ASSERT(InFromSpace(object)); | 372 ASSERT(InFromSpace(object)); |
| 397 | 373 |
| 398 // We use the first word (where the map pointer usually is) of a heap | 374 // We use the first word (where the map pointer usually is) of a heap |
| 399 // object to record the forwarding pointer. A forwarding pointer can | 375 // object to record the forwarding pointer. A forwarding pointer can |
| 400 // point to an old space, the code space, or the to space of the new | 376 // point to an old space, the code space, or the to space of the new |
| 401 // generation. | 377 // generation. |
| 402 MapWord first_word = object->map_word(); | 378 MapWord first_word = object->map_word(); |
| 403 | 379 |
| 404 // If the first word is a forwarding address, the object has already been | 380 // If the first word is a forwarding address, the object has already been |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 563 |
| 588 | 564 |
| 589 void ExternalStringTable::ShrinkNewStrings(int position) { | 565 void ExternalStringTable::ShrinkNewStrings(int position) { |
| 590 new_space_strings_.Rewind(position); | 566 new_space_strings_.Rewind(position); |
| 591 Verify(); | 567 Verify(); |
| 592 } | 568 } |
| 593 | 569 |
| 594 } } // namespace v8::internal | 570 } } // namespace v8::internal |
| 595 | 571 |
| 596 #endif // V8_HEAP_INL_H_ | 572 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |