| 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 #include "src/store-buffer.h" | 5 #include "src/store-buffer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } | 410 } |
| 411 | 411 |
| 412 | 412 |
| 413 // Compute end address of the first map preceding given addr. | 413 // Compute end address of the first map preceding given addr. |
| 414 static inline Address MapEndAlign(Address addr) { | 414 static inline Address MapEndAlign(Address addr) { |
| 415 Address page = Page::FromAllocationTop(addr)->area_start(); | 415 Address page = Page::FromAllocationTop(addr)->area_start(); |
| 416 return page + ((addr - page) / Map::kSize * Map::kSize); | 416 return page + ((addr - page) / Map::kSize * Map::kSize); |
| 417 } | 417 } |
| 418 | 418 |
| 419 | 419 |
| 420 void StoreBuffer::FindPointersToNewSpaceInMaps( | |
| 421 Address start, | |
| 422 Address end, | |
| 423 ObjectSlotCallback slot_callback, | |
| 424 bool clear_maps) { | |
| 425 ASSERT(MapStartAlign(start) == start); | |
| 426 ASSERT(MapEndAlign(end) == end); | |
| 427 | |
| 428 Address map_address = start; | |
| 429 while (map_address < end) { | |
| 430 ASSERT(!heap_->InNewSpace(Memory::Object_at(map_address))); | |
| 431 ASSERT(Memory::Object_at(map_address)->IsMap()); | |
| 432 | |
| 433 Address pointer_fields_start = map_address + Map::kPointerFieldsBeginOffset; | |
| 434 Address pointer_fields_end = map_address + Map::kPointerFieldsEndOffset; | |
| 435 | |
| 436 FindPointersToNewSpaceInRegion(pointer_fields_start, | |
| 437 pointer_fields_end, | |
| 438 slot_callback, | |
| 439 clear_maps); | |
| 440 map_address += Map::kSize; | |
| 441 } | |
| 442 } | |
| 443 | |
| 444 | |
| 445 void StoreBuffer::FindPointersToNewSpaceInMapsRegion( | |
| 446 Address start, | |
| 447 Address end, | |
| 448 ObjectSlotCallback slot_callback, | |
| 449 bool clear_maps) { | |
| 450 Address map_aligned_start = MapStartAlign(start); | |
| 451 Address map_aligned_end = MapEndAlign(end); | |
| 452 | |
| 453 ASSERT(map_aligned_start == start); | |
| 454 ASSERT(map_aligned_start <= map_aligned_end && map_aligned_end <= end); | |
| 455 | |
| 456 FindPointersToNewSpaceInMaps(map_aligned_start, | |
| 457 map_aligned_end, | |
| 458 slot_callback, | |
| 459 clear_maps); | |
| 460 } | |
| 461 | |
| 462 | |
| 463 void StoreBuffer::IteratePointersInStoreBuffer( | 420 void StoreBuffer::IteratePointersInStoreBuffer( |
| 464 ObjectSlotCallback slot_callback, | 421 ObjectSlotCallback slot_callback, |
| 465 bool clear_maps) { | 422 bool clear_maps) { |
| 466 Address* limit = old_top_; | 423 Address* limit = old_top_; |
| 467 old_top_ = old_start_; | 424 old_top_ = old_start_; |
| 468 { | 425 { |
| 469 DontMoveStoreBufferEntriesScope scope(this); | 426 DontMoveStoreBufferEntriesScope scope(this); |
| 470 for (Address* current = old_start_; current < limit; current++) { | 427 for (Address* current = old_start_; current < limit; current++) { |
| 471 #ifdef DEBUG | 428 #ifdef DEBUG |
| 472 Address* saved_top = old_top_; | 429 Address* saved_top = old_top_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 ASSERT(array->IsFixedArray()); | 499 ASSERT(array->IsFixedArray()); |
| 543 Address start = array->address(); | 500 Address start = array->address(); |
| 544 Address end = start + array->Size(); | 501 Address end = start + array->Size(); |
| 545 FindPointersToNewSpaceInRegion(start, end, slot_callback, clear_maps); | 502 FindPointersToNewSpaceInRegion(start, end, slot_callback, clear_maps); |
| 546 } else { | 503 } else { |
| 547 Page* page = reinterpret_cast<Page*>(chunk); | 504 Page* page = reinterpret_cast<Page*>(chunk); |
| 548 PagedSpace* owner = reinterpret_cast<PagedSpace*>(page->owner()); | 505 PagedSpace* owner = reinterpret_cast<PagedSpace*>(page->owner()); |
| 549 Address start = page->area_start(); | 506 Address start = page->area_start(); |
| 550 Address end = page->area_end(); | 507 Address end = page->area_end(); |
| 551 if (owner == heap_->map_space()) { | 508 if (owner == heap_->map_space()) { |
| 552 FindPointersToNewSpaceInMapsRegion( | 509 ASSERT(page->WasSweptPrecisely()); |
| 553 start, end, slot_callback, clear_maps); | 510 HeapObjectIterator iterator(page, NULL); |
| 511 for (HeapObject* heap_object = iterator.Next(); heap_object != NULL; |
| 512 heap_object = iterator.Next()) { |
| 513 // We skip free space objects. |
| 514 if (!heap_object->IsFiller()) { |
| 515 FindPointersToNewSpaceInRegion( |
| 516 heap_object->address() + HeapObject::kHeaderSize, |
| 517 heap_object->address() + heap_object->Size(), slot_callback, |
| 518 clear_maps); |
| 519 } |
| 520 } |
| 554 } else { | 521 } else { |
| 555 FindPointersToNewSpaceInRegion( | 522 FindPointersToNewSpaceInRegion( |
| 556 start, end, slot_callback, clear_maps); | 523 start, end, slot_callback, clear_maps); |
| 557 } | 524 } |
| 558 } | 525 } |
| 559 } | 526 } |
| 560 } | 527 } |
| 561 if (callback_ != NULL) { | 528 if (callback_ != NULL) { |
| 562 (*callback_)(heap_, NULL, kStoreBufferScanningPageEvent); | 529 (*callback_)(heap_, NULL, kStoreBufferScanningPageEvent); |
| 563 } | 530 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 } | 579 } |
| 613 old_buffer_is_sorted_ = false; | 580 old_buffer_is_sorted_ = false; |
| 614 old_buffer_is_filtered_ = false; | 581 old_buffer_is_filtered_ = false; |
| 615 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); | 582 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); |
| 616 ASSERT(old_top_ <= old_limit_); | 583 ASSERT(old_top_ <= old_limit_); |
| 617 } | 584 } |
| 618 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); | 585 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); |
| 619 } | 586 } |
| 620 | 587 |
| 621 } } // namespace v8::internal | 588 } } // namespace v8::internal |
| OLD | NEW |