OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 // and after context disposal. | 2113 // and after context disposal. |
2114 int number_of_disposed_maps_; | 2114 int number_of_disposed_maps_; |
2115 | 2115 |
2116 int global_ic_age_; | 2116 int global_ic_age_; |
2117 | 2117 |
2118 NewSpace* new_space_; | 2118 NewSpace* new_space_; |
2119 OldSpace* old_space_; | 2119 OldSpace* old_space_; |
2120 OldSpace* code_space_; | 2120 OldSpace* code_space_; |
2121 MapSpace* map_space_; | 2121 MapSpace* map_space_; |
2122 LargeObjectSpace* lo_space_; | 2122 LargeObjectSpace* lo_space_; |
| 2123 // Map from the space id to the space. |
| 2124 Space* space_[LAST_SPACE + 1]; |
2123 HeapState gc_state_; | 2125 HeapState gc_state_; |
2124 int gc_post_processing_depth_; | 2126 int gc_post_processing_depth_; |
2125 Address new_space_top_after_last_gc_; | 2127 Address new_space_top_after_last_gc_; |
2126 | 2128 |
2127 // Returns the amount of external memory registered since last global gc. | 2129 // Returns the amount of external memory registered since last global gc. |
2128 int64_t PromotedExternalMemorySize(); | 2130 int64_t PromotedExternalMemorySize(); |
2129 | 2131 |
2130 // How many "runtime allocations" happened. | 2132 // How many "runtime allocations" happened. |
2131 uint32_t allocations_count_; | 2133 uint32_t allocations_count_; |
2132 | 2134 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2421 public: | 2423 public: |
2422 explicit PagedSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {} | 2424 explicit PagedSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {} |
2423 PagedSpace* next(); | 2425 PagedSpace* next(); |
2424 | 2426 |
2425 private: | 2427 private: |
2426 Heap* heap_; | 2428 Heap* heap_; |
2427 int counter_; | 2429 int counter_; |
2428 }; | 2430 }; |
2429 | 2431 |
2430 | 2432 |
2431 // Space iterator for iterating over all spaces of the heap. | |
2432 // For each space an object iterator is provided. The deallocation of the | |
2433 // returned object iterators is handled by the space iterator. | |
2434 class SpaceIterator : public Malloced { | 2433 class SpaceIterator : public Malloced { |
2435 public: | 2434 public: |
2436 explicit SpaceIterator(Heap* heap); | 2435 explicit SpaceIterator(Heap* heap); |
2437 virtual ~SpaceIterator(); | 2436 virtual ~SpaceIterator(); |
2438 | 2437 |
2439 bool has_next(); | 2438 bool has_next(); |
2440 ObjectIterator* next(); | 2439 Space* next(); |
2441 | 2440 |
2442 private: | 2441 private: |
2443 ObjectIterator* CreateIterator(); | |
2444 | |
2445 Heap* heap_; | 2442 Heap* heap_; |
2446 int current_space_; // from enum AllocationSpace. | 2443 int current_space_; // from enum AllocationSpace. |
2447 ObjectIterator* iterator_; // object iterator for the current space. | |
2448 }; | 2444 }; |
2449 | 2445 |
2450 | 2446 |
2451 // A HeapIterator provides iteration over the whole heap. It | 2447 // A HeapIterator provides iteration over the whole heap. It |
2452 // aggregates the specific iterators for the different spaces as | 2448 // aggregates the specific iterators for the different spaces as |
2453 // these can only iterate over one space only. | 2449 // these can only iterate over one space only. |
2454 // | 2450 // |
2455 // HeapIterator ensures there is no allocation during its lifetime | 2451 // HeapIterator ensures there is no allocation during its lifetime |
2456 // (using an embedded DisallowHeapAllocation instance). | 2452 // (using an embedded DisallowHeapAllocation instance). |
2457 // | 2453 // |
(...skipping 25 matching lines...) Expand all Loading... |
2483 // allocations. | 2479 // allocations. |
2484 MakeHeapIterableHelper make_heap_iterable_helper_; | 2480 MakeHeapIterableHelper make_heap_iterable_helper_; |
2485 DisallowHeapAllocation no_heap_allocation_; | 2481 DisallowHeapAllocation no_heap_allocation_; |
2486 | 2482 |
2487 Heap* heap_; | 2483 Heap* heap_; |
2488 HeapObjectsFiltering filtering_; | 2484 HeapObjectsFiltering filtering_; |
2489 HeapObjectsFilter* filter_; | 2485 HeapObjectsFilter* filter_; |
2490 // Space iterator for iterating all the spaces. | 2486 // Space iterator for iterating all the spaces. |
2491 SpaceIterator* space_iterator_; | 2487 SpaceIterator* space_iterator_; |
2492 // Object iterator for the space currently being iterated. | 2488 // Object iterator for the space currently being iterated. |
2493 ObjectIterator* object_iterator_; | 2489 std::unique_ptr<ObjectIterator> object_iterator_; |
2494 }; | 2490 }; |
2495 | 2491 |
2496 // Abstract base class for checking whether a weak object should be retained. | 2492 // Abstract base class for checking whether a weak object should be retained. |
2497 class WeakObjectRetainer { | 2493 class WeakObjectRetainer { |
2498 public: | 2494 public: |
2499 virtual ~WeakObjectRetainer() {} | 2495 virtual ~WeakObjectRetainer() {} |
2500 | 2496 |
2501 // Return whether this object should be retained. If NULL is returned the | 2497 // Return whether this object should be retained. If NULL is returned the |
2502 // object has no references. Otherwise the address of the retained object | 2498 // object has no references. Otherwise the address of the retained object |
2503 // should be returned as in some GC situations the object has been moved. | 2499 // should be returned as in some GC situations the object has been moved. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2614 friend class LargeObjectSpace; | 2610 friend class LargeObjectSpace; |
2615 friend class NewSpace; | 2611 friend class NewSpace; |
2616 friend class PagedSpace; | 2612 friend class PagedSpace; |
2617 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2613 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2618 }; | 2614 }; |
2619 | 2615 |
2620 } // namespace internal | 2616 } // namespace internal |
2621 } // namespace v8 | 2617 } // namespace v8 |
2622 | 2618 |
2623 #endif // V8_HEAP_HEAP_H_ | 2619 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |