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