OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 heap_->decrement_scan_on_scavenge_pages(); | 480 heap_->decrement_scan_on_scavenge_pages(); |
481 ClearFlag(SCAN_ON_SCAVENGE); | 481 ClearFlag(SCAN_ON_SCAVENGE); |
482 } | 482 } |
483 next_chunk_->prev_chunk_ = prev_chunk_; | 483 next_chunk_->prev_chunk_ = prev_chunk_; |
484 prev_chunk_->next_chunk_ = next_chunk_; | 484 prev_chunk_->next_chunk_ = next_chunk_; |
485 prev_chunk_ = NULL; | 485 prev_chunk_ = NULL; |
486 next_chunk_ = NULL; | 486 next_chunk_ = NULL; |
487 } | 487 } |
488 | 488 |
489 | 489 |
490 size_t MemoryChunk::CommittedPhysicalMemory() { | |
491 size_t physical; | |
492 size_t size = area_end_ - area_start_; | |
Michael Starzinger
2012/09/27 09:46:16
Can we use area_size() for this calculation?
alph
2012/09/27 12:51:13
Let's try. Hopefully it won't go beyond 2GB limit.
| |
493 if (VirtualMemory::CommittedPhysicalSizeInRegion( | |
494 area_start_, size, &physical)) { | |
495 return physical; | |
496 } else { | |
497 return size; | |
498 } | |
499 } | |
500 | |
501 | |
490 MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t body_size, | 502 MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t body_size, |
491 Executability executable, | 503 Executability executable, |
492 Space* owner) { | 504 Space* owner) { |
493 size_t chunk_size; | 505 size_t chunk_size; |
494 Heap* heap = isolate_->heap(); | 506 Heap* heap = isolate_->heap(); |
495 Address base = NULL; | 507 Address base = NULL; |
496 VirtualMemory reservation; | 508 VirtualMemory reservation; |
497 Address area_start = NULL; | 509 Address area_start = NULL; |
498 Address area_end = NULL; | 510 Address area_end = NULL; |
499 if (executable == EXECUTABLE) { | 511 if (executable == EXECUTABLE) { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 PageIterator iterator(this); | 824 PageIterator iterator(this); |
813 while (iterator.has_next()) { | 825 while (iterator.has_next()) { |
814 heap()->isolate()->memory_allocator()->Free(iterator.next()); | 826 heap()->isolate()->memory_allocator()->Free(iterator.next()); |
815 } | 827 } |
816 anchor_.set_next_page(&anchor_); | 828 anchor_.set_next_page(&anchor_); |
817 anchor_.set_prev_page(&anchor_); | 829 anchor_.set_prev_page(&anchor_); |
818 accounting_stats_.Clear(); | 830 accounting_stats_.Clear(); |
819 } | 831 } |
820 | 832 |
821 | 833 |
834 size_t PagedSpace::CommittedPhysicalMemory() { | |
835 size_t size = 0; | |
836 PageIterator it(this); | |
837 while (it.has_next()) { | |
838 size += it.next()->CommittedPhysicalMemory(); | |
839 } | |
840 return size; | |
841 } | |
842 | |
843 | |
822 MaybeObject* PagedSpace::FindObject(Address addr) { | 844 MaybeObject* PagedSpace::FindObject(Address addr) { |
823 // Note: this function can only be called on precisely swept spaces. | 845 // Note: this function can only be called on precisely swept spaces. |
824 ASSERT(!heap()->mark_compact_collector()->in_use()); | 846 ASSERT(!heap()->mark_compact_collector()->in_use()); |
825 | 847 |
826 if (!Contains(addr)) return Failure::Exception(); | 848 if (!Contains(addr)) return Failure::Exception(); |
827 | 849 |
828 Page* p = Page::FromAddress(addr); | 850 Page* p = Page::FromAddress(addr); |
829 HeapObjectIterator it(p, NULL); | 851 HeapObjectIterator it(p, NULL); |
830 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 852 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
831 Address cur = obj->address(); | 853 Address cur = obj->address(); |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1377 return false; | 1399 return false; |
1378 } | 1400 } |
1379 anchor()->set_next_page(anchor()); | 1401 anchor()->set_next_page(anchor()); |
1380 anchor()->set_prev_page(anchor()); | 1402 anchor()->set_prev_page(anchor()); |
1381 | 1403 |
1382 committed_ = false; | 1404 committed_ = false; |
1383 return true; | 1405 return true; |
1384 } | 1406 } |
1385 | 1407 |
1386 | 1408 |
1409 size_t SemiSpace::CommittedPhysicalMemory() { | |
1410 if (!is_committed()) return 0; | |
1411 size_t size = 0; | |
1412 NewSpacePage* page = anchor_.next_page(); | |
Michael Starzinger
2012/09/27 09:46:16
Can we use NewSpacePageIterator for this iteration
alph
2012/09/27 12:51:13
Done.
| |
1413 CHECK(anchor_.semi_space() == this); | |
1414 while (page != &anchor_) { | |
1415 size += page->CommittedPhysicalMemory(); | |
1416 page = page->next_page(); | |
1417 } | |
1418 return size; | |
1419 } | |
1420 | |
1421 | |
1387 bool SemiSpace::GrowTo(int new_capacity) { | 1422 bool SemiSpace::GrowTo(int new_capacity) { |
1388 if (!is_committed()) { | 1423 if (!is_committed()) { |
1389 if (!Commit()) return false; | 1424 if (!Commit()) return false; |
1390 } | 1425 } |
1391 ASSERT((new_capacity & Page::kPageAlignmentMask) == 0); | 1426 ASSERT((new_capacity & Page::kPageAlignmentMask) == 0); |
1392 ASSERT(new_capacity <= maximum_capacity_); | 1427 ASSERT(new_capacity <= maximum_capacity_); |
1393 ASSERT(new_capacity > capacity_); | 1428 ASSERT(new_capacity > capacity_); |
1394 int pages_before = capacity_ / Page::kPageSize; | 1429 int pages_before = capacity_ / Page::kPageSize; |
1395 int pages_after = new_capacity / Page::kPageSize; | 1430 int pages_after = new_capacity / Page::kPageSize; |
1396 | 1431 |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2683 reinterpret_cast<Object**>(object->address())[0] = | 2718 reinterpret_cast<Object**>(object->address())[0] = |
2684 heap()->fixed_array_map(); | 2719 heap()->fixed_array_map(); |
2685 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); | 2720 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); |
2686 #endif | 2721 #endif |
2687 | 2722 |
2688 heap()->incremental_marking()->OldSpaceStep(object_size); | 2723 heap()->incremental_marking()->OldSpaceStep(object_size); |
2689 return object; | 2724 return object; |
2690 } | 2725 } |
2691 | 2726 |
2692 | 2727 |
2728 size_t LargeObjectSpace::CommittedPhysicalMemory() { | |
2729 size_t size = 0; | |
2730 LargePage* current = first_page_; | |
2731 while (current != NULL) { | |
Michael Starzinger
2012/09/27 09:46:16
Can we use LargeObjectIterator for this iteration?
alph
2012/09/27 12:51:13
I'm not sure. It returns not a page, but a HeapObj
Michael Starzinger
2012/09/27 13:13:28
You are right, my bad.
| |
2732 size += current->CommittedPhysicalMemory(); | |
2733 current = current->next_page(); | |
2734 } | |
2735 return size; | |
2736 } | |
2737 | |
2738 | |
2693 // GC support | 2739 // GC support |
2694 MaybeObject* LargeObjectSpace::FindObject(Address a) { | 2740 MaybeObject* LargeObjectSpace::FindObject(Address a) { |
2695 LargePage* page = FindPage(a); | 2741 LargePage* page = FindPage(a); |
2696 if (page != NULL) { | 2742 if (page != NULL) { |
2697 return page->GetObject(); | 2743 return page->GetObject(); |
2698 } | 2744 } |
2699 return Failure::Exception(); | 2745 return Failure::Exception(); |
2700 } | 2746 } |
2701 | 2747 |
2702 | 2748 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2887 object->ShortPrint(); | 2933 object->ShortPrint(); |
2888 PrintF("\n"); | 2934 PrintF("\n"); |
2889 } | 2935 } |
2890 printf(" --------------------------------------\n"); | 2936 printf(" --------------------------------------\n"); |
2891 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 2937 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
2892 } | 2938 } |
2893 | 2939 |
2894 #endif // DEBUG | 2940 #endif // DEBUG |
2895 | 2941 |
2896 } } // namespace v8::internal | 2942 } } // namespace v8::internal |
OLD | NEW |