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 <list> | 8 #include <list> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2229 void Allocate(int bytes) { accounting_stats_.AllocateBytes(bytes); } | 2229 void Allocate(int bytes) { accounting_stats_.AllocateBytes(bytes); } |
2230 | 2230 |
2231 void IncreaseCapacity(int size); | 2231 void IncreaseCapacity(int size); |
2232 | 2232 |
2233 // Releases an unused page and shrinks the space. | 2233 // Releases an unused page and shrinks the space. |
2234 void ReleasePage(Page* page); | 2234 void ReleasePage(Page* page); |
2235 | 2235 |
2236 // The dummy page that anchors the linked list of pages. | 2236 // The dummy page that anchors the linked list of pages. |
2237 Page* anchor() { return &anchor_; } | 2237 Page* anchor() { return &anchor_; } |
2238 | 2238 |
| 2239 // Collect code size related statistics |
| 2240 void CollectCodeStatistics(); |
| 2241 |
| 2242 // Reset code size related statistics |
| 2243 static void ResetCodeAndMetadataStatistics(Isolate* isolate); |
| 2244 |
2239 #ifdef VERIFY_HEAP | 2245 #ifdef VERIFY_HEAP |
2240 // Verify integrity of this space. | 2246 // Verify integrity of this space. |
2241 virtual void Verify(ObjectVisitor* visitor); | 2247 virtual void Verify(ObjectVisitor* visitor); |
2242 | 2248 |
2243 // Overridden by subclasses to verify space-specific object | 2249 // Overridden by subclasses to verify space-specific object |
2244 // properties (e.g., only maps or free-list nodes are in map space). | 2250 // properties (e.g., only maps or free-list nodes are in map space). |
2245 virtual void VerifyObject(HeapObject* obj) {} | 2251 virtual void VerifyObject(HeapObject* obj) {} |
2246 #endif | 2252 #endif |
2247 | 2253 |
2248 #ifdef DEBUG | 2254 #ifdef DEBUG |
2249 // Print meta info and objects in this space. | 2255 // Print meta info and objects in this space. |
2250 void Print() override; | 2256 void Print() override; |
2251 | 2257 |
2252 // Reports statistics for the space | 2258 // Reports statistics for the space |
2253 void ReportStatistics(); | 2259 void ReportStatistics(); |
2254 | 2260 |
2255 // Report code object related statistics | 2261 // Report code object related statistics |
2256 void CollectCodeStatistics(); | |
2257 static void ReportCodeStatistics(Isolate* isolate); | 2262 static void ReportCodeStatistics(Isolate* isolate); |
2258 static void ResetCodeStatistics(Isolate* isolate); | 2263 static void ResetCodeStatistics(Isolate* isolate); |
2259 #endif | 2264 #endif |
2260 | 2265 |
2261 Page* FirstPage() { return anchor_.next_page(); } | 2266 Page* FirstPage() { return anchor_.next_page(); } |
2262 Page* LastPage() { return anchor_.prev_page(); } | 2267 Page* LastPage() { return anchor_.prev_page(); } |
2263 | 2268 |
2264 void EvictEvacuationCandidatesFromLinearAllocationArea(); | 2269 void EvictEvacuationCandidatesFromLinearAllocationArea(); |
2265 | 2270 |
2266 bool CanExpand(size_t size); | 2271 bool CanExpand(size_t size); |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3054 // all objects in the space. May be slow. | 3059 // all objects in the space. May be slow. |
3055 bool ContainsSlow(Address addr) { return FindObject(addr)->IsHeapObject(); } | 3060 bool ContainsSlow(Address addr) { return FindObject(addr)->IsHeapObject(); } |
3056 | 3061 |
3057 // Checks whether the space is empty. | 3062 // Checks whether the space is empty. |
3058 bool IsEmpty() { return first_page_ == NULL; } | 3063 bool IsEmpty() { return first_page_ == NULL; } |
3059 | 3064 |
3060 void AdjustLiveBytes(int by) { objects_size_ += by; } | 3065 void AdjustLiveBytes(int by) { objects_size_ += by; } |
3061 | 3066 |
3062 LargePage* first_page() { return first_page_; } | 3067 LargePage* first_page() { return first_page_; } |
3063 | 3068 |
| 3069 // Collect code statistics. |
| 3070 void CollectCodeStatistics(); |
| 3071 |
3064 #ifdef VERIFY_HEAP | 3072 #ifdef VERIFY_HEAP |
3065 virtual void Verify(); | 3073 virtual void Verify(); |
3066 #endif | 3074 #endif |
3067 | 3075 |
3068 #ifdef DEBUG | 3076 #ifdef DEBUG |
3069 void Print() override; | 3077 void Print() override; |
3070 void ReportStatistics(); | 3078 void ReportStatistics(); |
3071 void CollectCodeStatistics(); | |
3072 #endif | 3079 #endif |
3073 | 3080 |
3074 private: | 3081 private: |
3075 // The head of the linked list of large object chunks. | 3082 // The head of the linked list of large object chunks. |
3076 LargePage* first_page_; | 3083 LargePage* first_page_; |
3077 intptr_t size_; // allocated bytes | 3084 intptr_t size_; // allocated bytes |
3078 int page_count_; // number of chunks | 3085 int page_count_; // number of chunks |
3079 intptr_t objects_size_; // size of objects | 3086 intptr_t objects_size_; // size of objects |
3080 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them | 3087 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them |
3081 HashMap chunk_map_; | 3088 HashMap chunk_map_; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3144 count = 0; | 3151 count = 0; |
3145 } | 3152 } |
3146 // Must be small, since an iteration is used for lookup. | 3153 // Must be small, since an iteration is used for lookup. |
3147 static const int kMaxComments = 64; | 3154 static const int kMaxComments = 64; |
3148 }; | 3155 }; |
3149 #endif | 3156 #endif |
3150 } // namespace internal | 3157 } // namespace internal |
3151 } // namespace v8 | 3158 } // namespace v8 |
3152 | 3159 |
3153 #endif // V8_HEAP_SPACES_H_ | 3160 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |