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_size(); |
| 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 NewSpacePageIterator it(this); |
| 1413 while (it.has_next()) { |
| 1414 size += it.next()->CommittedPhysicalMemory(); |
| 1415 } |
| 1416 return size; |
| 1417 } |
| 1418 |
| 1419 |
1387 bool SemiSpace::GrowTo(int new_capacity) { | 1420 bool SemiSpace::GrowTo(int new_capacity) { |
1388 if (!is_committed()) { | 1421 if (!is_committed()) { |
1389 if (!Commit()) return false; | 1422 if (!Commit()) return false; |
1390 } | 1423 } |
1391 ASSERT((new_capacity & Page::kPageAlignmentMask) == 0); | 1424 ASSERT((new_capacity & Page::kPageAlignmentMask) == 0); |
1392 ASSERT(new_capacity <= maximum_capacity_); | 1425 ASSERT(new_capacity <= maximum_capacity_); |
1393 ASSERT(new_capacity > capacity_); | 1426 ASSERT(new_capacity > capacity_); |
1394 int pages_before = capacity_ / Page::kPageSize; | 1427 int pages_before = capacity_ / Page::kPageSize; |
1395 int pages_after = new_capacity / Page::kPageSize; | 1428 int pages_after = new_capacity / Page::kPageSize; |
1396 | 1429 |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2683 reinterpret_cast<Object**>(object->address())[0] = | 2716 reinterpret_cast<Object**>(object->address())[0] = |
2684 heap()->fixed_array_map(); | 2717 heap()->fixed_array_map(); |
2685 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); | 2718 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); |
2686 #endif | 2719 #endif |
2687 | 2720 |
2688 heap()->incremental_marking()->OldSpaceStep(object_size); | 2721 heap()->incremental_marking()->OldSpaceStep(object_size); |
2689 return object; | 2722 return object; |
2690 } | 2723 } |
2691 | 2724 |
2692 | 2725 |
| 2726 size_t LargeObjectSpace::CommittedPhysicalMemory() { |
| 2727 size_t size = 0; |
| 2728 LargePage* current = first_page_; |
| 2729 while (current != NULL) { |
| 2730 size += current->CommittedPhysicalMemory(); |
| 2731 current = current->next_page(); |
| 2732 } |
| 2733 return size; |
| 2734 } |
| 2735 |
| 2736 |
2693 // GC support | 2737 // GC support |
2694 MaybeObject* LargeObjectSpace::FindObject(Address a) { | 2738 MaybeObject* LargeObjectSpace::FindObject(Address a) { |
2695 LargePage* page = FindPage(a); | 2739 LargePage* page = FindPage(a); |
2696 if (page != NULL) { | 2740 if (page != NULL) { |
2697 return page->GetObject(); | 2741 return page->GetObject(); |
2698 } | 2742 } |
2699 return Failure::Exception(); | 2743 return Failure::Exception(); |
2700 } | 2744 } |
2701 | 2745 |
2702 | 2746 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 object->ShortPrint(); | 2931 object->ShortPrint(); |
2888 PrintF("\n"); | 2932 PrintF("\n"); |
2889 } | 2933 } |
2890 printf(" --------------------------------------\n"); | 2934 printf(" --------------------------------------\n"); |
2891 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 2935 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
2892 } | 2936 } |
2893 | 2937 |
2894 #endif // DEBUG | 2938 #endif // DEBUG |
2895 | 2939 |
2896 } } // namespace v8::internal | 2940 } } // namespace v8::internal |
OLD | NEW |