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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 // MemoryChunk implementation | 907 // MemoryChunk implementation |
908 | 908 |
909 void MemoryChunk::IncrementLiveBytesFromMutator(Address address, int by) { | 909 void MemoryChunk::IncrementLiveBytesFromMutator(Address address, int by) { |
910 MemoryChunk* chunk = MemoryChunk::FromAddress(address); | 910 MemoryChunk* chunk = MemoryChunk::FromAddress(address); |
911 if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->WasSwept()) { | 911 if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->WasSwept()) { |
912 static_cast<PagedSpace*>(chunk->owner())->IncrementUnsweptFreeBytes(-by); | 912 static_cast<PagedSpace*>(chunk->owner())->IncrementUnsweptFreeBytes(-by); |
913 } | 913 } |
914 chunk->IncrementLiveBytes(by); | 914 chunk->IncrementLiveBytes(by); |
915 } | 915 } |
916 | 916 |
| 917 |
917 // ----------------------------------------------------------------------------- | 918 // ----------------------------------------------------------------------------- |
918 // PagedSpace implementation | 919 // PagedSpace implementation |
919 | 920 |
920 PagedSpace::PagedSpace(Heap* heap, | 921 PagedSpace::PagedSpace(Heap* heap, |
921 intptr_t max_capacity, | 922 intptr_t max_capacity, |
922 AllocationSpace id, | 923 AllocationSpace id, |
923 Executability executable) | 924 Executability executable) |
924 : Space(heap, id, executable), | 925 : Space(heap, id, executable), |
925 free_list_(this), | 926 free_list_(this), |
926 was_swept_conservatively_(false), | 927 was_swept_conservatively_(false), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 988 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
988 Address cur = obj->address(); | 989 Address cur = obj->address(); |
989 Address next = cur + obj->Size(); | 990 Address next = cur + obj->Size(); |
990 if ((cur <= addr) && (addr < next)) return obj; | 991 if ((cur <= addr) && (addr < next)) return obj; |
991 } | 992 } |
992 | 993 |
993 UNREACHABLE(); | 994 UNREACHABLE(); |
994 return Failure::Exception(); | 995 return Failure::Exception(); |
995 } | 996 } |
996 | 997 |
| 998 |
997 bool PagedSpace::CanExpand() { | 999 bool PagedSpace::CanExpand() { |
998 ASSERT(max_capacity_ % AreaSize() == 0); | 1000 ASSERT(max_capacity_ % AreaSize() == 0); |
999 | 1001 |
1000 if (Capacity() == max_capacity_) return false; | 1002 if (Capacity() == max_capacity_) return false; |
1001 | 1003 |
1002 ASSERT(Capacity() < max_capacity_); | 1004 ASSERT(Capacity() < max_capacity_); |
1003 | 1005 |
1004 // Are we going to exceed capacity for this space? | 1006 // Are we going to exceed capacity for this space? |
1005 if ((Capacity() + Page::kPageSize) > max_capacity_) return false; | 1007 if ((Capacity() + Page::kPageSize) > max_capacity_) return false; |
1006 | 1008 |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 | 1863 |
1862 | 1864 |
1863 // Support for statistics gathering for --heap-stats and --log-gc. | 1865 // Support for statistics gathering for --heap-stats and --log-gc. |
1864 void NewSpace::ClearHistograms() { | 1866 void NewSpace::ClearHistograms() { |
1865 for (int i = 0; i <= LAST_TYPE; i++) { | 1867 for (int i = 0; i <= LAST_TYPE; i++) { |
1866 allocated_histogram_[i].clear(); | 1868 allocated_histogram_[i].clear(); |
1867 promoted_histogram_[i].clear(); | 1869 promoted_histogram_[i].clear(); |
1868 } | 1870 } |
1869 } | 1871 } |
1870 | 1872 |
| 1873 |
1871 // Because the copying collector does not touch garbage objects, we iterate | 1874 // Because the copying collector does not touch garbage objects, we iterate |
1872 // the new space before a collection to get a histogram of allocated objects. | 1875 // the new space before a collection to get a histogram of allocated objects. |
1873 // This only happens when --log-gc flag is set. | 1876 // This only happens when --log-gc flag is set. |
1874 void NewSpace::CollectStatistics() { | 1877 void NewSpace::CollectStatistics() { |
1875 ClearHistograms(); | 1878 ClearHistograms(); |
1876 SemiSpaceIterator it(this); | 1879 SemiSpaceIterator it(this); |
1877 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) | 1880 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) |
1878 RecordAllocation(obj); | 1881 RecordAllocation(obj); |
1879 } | 1882 } |
1880 | 1883 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 size_t NewSpace::CommittedPhysicalMemory() { | 1957 size_t NewSpace::CommittedPhysicalMemory() { |
1955 if (!VirtualMemory::HasLazyCommits()) return CommittedMemory(); | 1958 if (!VirtualMemory::HasLazyCommits()) return CommittedMemory(); |
1956 MemoryChunk::UpdateHighWaterMark(allocation_info_.top); | 1959 MemoryChunk::UpdateHighWaterMark(allocation_info_.top); |
1957 size_t size = to_space_.CommittedPhysicalMemory(); | 1960 size_t size = to_space_.CommittedPhysicalMemory(); |
1958 if (from_space_.is_committed()) { | 1961 if (from_space_.is_committed()) { |
1959 size += from_space_.CommittedPhysicalMemory(); | 1962 size += from_space_.CommittedPhysicalMemory(); |
1960 } | 1963 } |
1961 return size; | 1964 return size; |
1962 } | 1965 } |
1963 | 1966 |
| 1967 |
1964 // ----------------------------------------------------------------------------- | 1968 // ----------------------------------------------------------------------------- |
1965 // Free lists for old object spaces implementation | 1969 // Free lists for old object spaces implementation |
1966 | 1970 |
1967 void FreeListNode::set_size(Heap* heap, int size_in_bytes) { | 1971 void FreeListNode::set_size(Heap* heap, int size_in_bytes) { |
1968 ASSERT(size_in_bytes > 0); | 1972 ASSERT(size_in_bytes > 0); |
1969 ASSERT(IsAligned(size_in_bytes, kPointerSize)); | 1973 ASSERT(IsAligned(size_in_bytes, kPointerSize)); |
1970 | 1974 |
1971 // We write a map and possibly size information to the block. If the block | 1975 // We write a map and possibly size information to the block. If the block |
1972 // is big enough to be a FreeSpace with at least one extra word (the next | 1976 // is big enough to be a FreeSpace with at least one extra word (the next |
1973 // pointer), we set its map to be the free space map and its size to an | 1977 // pointer), we set its map to be the free space map and its size to an |
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3205 object->ShortPrint(); | 3209 object->ShortPrint(); |
3206 PrintF("\n"); | 3210 PrintF("\n"); |
3207 } | 3211 } |
3208 printf(" --------------------------------------\n"); | 3212 printf(" --------------------------------------\n"); |
3209 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3213 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3210 } | 3214 } |
3211 | 3215 |
3212 #endif // DEBUG | 3216 #endif // DEBUG |
3213 | 3217 |
3214 } } // namespace v8::internal | 3218 } } // namespace v8::internal |
OLD | NEW |