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 #ifndef V8_HEAP_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 FreeBlock(void* start_arg, size_t size_arg) | 973 FreeBlock(void* start_arg, size_t size_arg) |
974 : start(static_cast<Address>(start_arg)), size(size_arg) { | 974 : start(static_cast<Address>(start_arg)), size(size_arg) { |
975 DCHECK(IsAddressAligned(start, MemoryChunk::kAlignment)); | 975 DCHECK(IsAddressAligned(start, MemoryChunk::kAlignment)); |
976 DCHECK(size >= static_cast<size_t>(Page::kPageSize)); | 976 DCHECK(size >= static_cast<size_t>(Page::kPageSize)); |
977 } | 977 } |
978 | 978 |
979 Address start; | 979 Address start; |
980 size_t size; | 980 size_t size; |
981 }; | 981 }; |
982 | 982 |
983 // All access to free_list_ require to take the free_list_mutex_. GC threads | |
984 // may access the free_list_ concurrently to the main thread. | |
985 base::Mutex free_list_mutex_; | |
986 | |
983 // Freed blocks of memory are added to the free list. When the allocation | 987 // Freed blocks of memory are added to the free list. When the allocation |
984 // list is exhausted, the free list is sorted and merged to make the new | 988 // list is exhausted, the free list is sorted and merged to make the new |
985 // allocation list. | 989 // allocation list. |
986 List<FreeBlock> free_list_; | 990 List<FreeBlock> free_list_; |
991 | |
987 // Memory is allocated from the free blocks on the allocation list. | 992 // Memory is allocated from the free blocks on the allocation list. |
988 // The block at current_allocation_block_index_ is the current block. | 993 // The block at current_allocation_block_index_ is the current block. |
989 List<FreeBlock> allocation_list_; | 994 List<FreeBlock> allocation_list_; |
990 int current_allocation_block_index_; | 995 int current_allocation_block_index_; |
991 | 996 |
992 // Emergency block guarantees that we can always allocate a page for | 997 // Emergency block guarantees that we can always allocate a page for |
993 // evacuation candidates when code space is compacted. Emergency block is | 998 // evacuation candidates when code space is compacted. Emergency block is |
994 // reserved immediately after GC and is released immedietely before | 999 // reserved immediately after GC and is released immedietely before |
995 // allocating a page for evacuation. | 1000 // allocating a page for evacuation. |
996 FreeBlock emergency_block_; | 1001 FreeBlock emergency_block_; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 bool SetUp(intptr_t max_capacity, intptr_t capacity_executable); | 1077 bool SetUp(intptr_t max_capacity, intptr_t capacity_executable); |
1073 | 1078 |
1074 void TearDown(); | 1079 void TearDown(); |
1075 | 1080 |
1076 Page* AllocatePage(intptr_t size, PagedSpace* owner, | 1081 Page* AllocatePage(intptr_t size, PagedSpace* owner, |
1077 Executability executable); | 1082 Executability executable); |
1078 | 1083 |
1079 LargePage* AllocateLargePage(intptr_t object_size, Space* owner, | 1084 LargePage* AllocateLargePage(intptr_t object_size, Space* owner, |
1080 Executability executable); | 1085 Executability executable); |
1081 | 1086 |
1087 // PreFree logically frees the object, i.e., it takes care of the size | |
1088 // bookkeeping and calls the allocation callback. | |
Michael Lippautz
2015/08/24 13:43:12
Can we extend this comment to clarify that this co
| |
1089 void PreFreeMemory(MemoryChunk* chunk); | |
1090 | |
1091 // FreeMemory can be called concurrently when PreFree was executed before. | |
1092 void PerformFreeMemory(MemoryChunk* chunk); | |
1093 | |
1094 // Free is a wrapper method, which calls PreFree and PerformFreeMemory | |
1095 // together. | |
1082 void Free(MemoryChunk* chunk); | 1096 void Free(MemoryChunk* chunk); |
1083 | 1097 |
1084 // Returns the maximum available bytes of heaps. | 1098 // Returns the maximum available bytes of heaps. |
1085 intptr_t Available() { return capacity_ < size_ ? 0 : capacity_ - size_; } | 1099 intptr_t Available() { return capacity_ < size_ ? 0 : capacity_ - size_; } |
1086 | 1100 |
1087 // Returns allocated spaces in bytes. | 1101 // Returns allocated spaces in bytes. |
1088 intptr_t Size() { return size_; } | 1102 intptr_t Size() { return size_; } |
1089 | 1103 |
1090 // Returns the maximum available executable bytes of heaps. | 1104 // Returns the maximum available executable bytes of heaps. |
1091 intptr_t AvailableExecutable() { | 1105 intptr_t AvailableExecutable() { |
(...skipping 29 matching lines...) Expand all Loading... | |
1121 Executability executable, Space* space); | 1135 Executability executable, Space* space); |
1122 | 1136 |
1123 Address ReserveAlignedMemory(size_t requested, size_t alignment, | 1137 Address ReserveAlignedMemory(size_t requested, size_t alignment, |
1124 base::VirtualMemory* controller); | 1138 base::VirtualMemory* controller); |
1125 Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size, | 1139 Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size, |
1126 size_t alignment, Executability executable, | 1140 size_t alignment, Executability executable, |
1127 base::VirtualMemory* controller); | 1141 base::VirtualMemory* controller); |
1128 | 1142 |
1129 bool CommitMemory(Address addr, size_t size, Executability executable); | 1143 bool CommitMemory(Address addr, size_t size, Executability executable); |
1130 | 1144 |
1145 void FreeNewSpaceMemory(Address addr, base::VirtualMemory* reservation, | |
1146 Executability executable); | |
1131 void FreeMemory(base::VirtualMemory* reservation, Executability executable); | 1147 void FreeMemory(base::VirtualMemory* reservation, Executability executable); |
1132 void FreeMemory(Address addr, size_t size, Executability executable); | 1148 void FreeMemory(Address addr, size_t size, Executability executable); |
1133 | 1149 |
1134 // Commit a contiguous block of memory from the initial chunk. Assumes that | 1150 // Commit a contiguous block of memory from the initial chunk. Assumes that |
1135 // the address is not NULL, the size is greater than zero, and that the | 1151 // the address is not NULL, the size is greater than zero, and that the |
1136 // block is contained in the initial chunk. Returns true if it succeeded | 1152 // block is contained in the initial chunk. Returns true if it succeeded |
1137 // and false otherwise. | 1153 // and false otherwise. |
1138 bool CommitBlock(Address start, size_t size, Executability executable); | 1154 bool CommitBlock(Address start, size_t size, Executability executable); |
1139 | 1155 |
1140 // Uncommit a contiguous block of memory [start..(start+size)[. | 1156 // Uncommit a contiguous block of memory [start..(start+size)[. |
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2828 count = 0; | 2844 count = 0; |
2829 } | 2845 } |
2830 // Must be small, since an iteration is used for lookup. | 2846 // Must be small, since an iteration is used for lookup. |
2831 static const int kMaxComments = 64; | 2847 static const int kMaxComments = 64; |
2832 }; | 2848 }; |
2833 #endif | 2849 #endif |
2834 } | 2850 } |
2835 } // namespace v8::internal | 2851 } // namespace v8::internal |
2836 | 2852 |
2837 #endif // V8_HEAP_SPACES_H_ | 2853 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |