| 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/atomic-utils.h" | 9 #include "src/atomic-utils.h" |
| 10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
| (...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2112 | 2112 |
| 2113 // Return size of allocatable area on a page in this space. | 2113 // Return size of allocatable area on a page in this space. |
| 2114 inline int AreaSize() { return area_size_; } | 2114 inline int AreaSize() { return area_size_; } |
| 2115 | 2115 |
| 2116 virtual bool is_local() { return false; } | 2116 virtual bool is_local() { return false; } |
| 2117 | 2117 |
| 2118 // Merges {other} into the current space. Note that this modifies {other}, | 2118 // Merges {other} into the current space. Note that this modifies {other}, |
| 2119 // e.g., removes its bump pointer area and resets statistics. | 2119 // e.g., removes its bump pointer area and resets statistics. |
| 2120 void MergeCompactionSpace(CompactionSpace* other); | 2120 void MergeCompactionSpace(CompactionSpace* other); |
| 2121 | 2121 |
| 2122 void DivideUponCompactionSpaces(CompactionSpaceCollection** other, int num, |
| 2123 intptr_t limit = kCompactionMemoryWanted); |
| 2124 |
| 2122 // Refills the free list from the corresponding free list filled by the | 2125 // Refills the free list from the corresponding free list filled by the |
| 2123 // sweeper. | 2126 // sweeper. |
| 2124 virtual void RefillFreeList(); | 2127 virtual void RefillFreeList(); |
| 2125 | 2128 |
| 2126 protected: | 2129 protected: |
| 2127 void AddMemory(Address start, intptr_t size); | 2130 void AddMemory(Address start, intptr_t size); |
| 2128 | 2131 |
| 2132 FreeSpace* TryRemoveMemory(intptr_t size_in_bytes); |
| 2133 |
| 2129 void MoveOverFreeMemory(PagedSpace* other); | 2134 void MoveOverFreeMemory(PagedSpace* other); |
| 2130 | 2135 |
| 2131 // PagedSpaces that should be included in snapshots have different, i.e., | 2136 // PagedSpaces that should be included in snapshots have different, i.e., |
| 2132 // smaller, initial pages. | 2137 // smaller, initial pages. |
| 2133 virtual bool snapshotable() { return true; } | 2138 virtual bool snapshotable() { return true; } |
| 2134 | 2139 |
| 2135 FreeList* free_list() { return &free_list_; } | 2140 FreeList* free_list() { return &free_list_; } |
| 2136 | 2141 |
| 2137 bool HasPages() { return anchor_.next_page() != &anchor_; } | 2142 bool HasPages() { return anchor_.next_page() != &anchor_; } |
| 2138 | 2143 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2881 }; | 2886 }; |
| 2882 | 2887 |
| 2883 // ----------------------------------------------------------------------------- | 2888 // ----------------------------------------------------------------------------- |
| 2884 // Compaction space that is used temporarily during compaction. | 2889 // Compaction space that is used temporarily during compaction. |
| 2885 | 2890 |
| 2886 class CompactionSpace : public PagedSpace { | 2891 class CompactionSpace : public PagedSpace { |
| 2887 public: | 2892 public: |
| 2888 CompactionSpace(Heap* heap, AllocationSpace id, Executability executable) | 2893 CompactionSpace(Heap* heap, AllocationSpace id, Executability executable) |
| 2889 : PagedSpace(heap, id, executable) {} | 2894 : PagedSpace(heap, id, executable) {} |
| 2890 | 2895 |
| 2896 // Adds external memory starting at {start} of {size_in_bytes} to the space. |
| 2897 void AddExternalMemory(Address start, int size_in_bytes) { |
| 2898 IncreaseCapacity(size_in_bytes); |
| 2899 Free(start, size_in_bytes); |
| 2900 } |
| 2901 |
| 2891 bool is_local() override { return true; } | 2902 bool is_local() override { return true; } |
| 2892 | 2903 |
| 2893 void RefillFreeList() override; | 2904 void RefillFreeList() override; |
| 2894 | 2905 |
| 2895 protected: | 2906 protected: |
| 2896 // The space is temporary and not included in any snapshots. | 2907 // The space is temporary and not included in any snapshots. |
| 2897 bool snapshotable() override { return false; } | 2908 bool snapshotable() override { return false; } |
| 2898 | 2909 |
| 2899 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( | 2910 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( |
| 2900 int size_in_bytes) override; | 2911 int size_in_bytes) override; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3117 count = 0; | 3128 count = 0; |
| 3118 } | 3129 } |
| 3119 // Must be small, since an iteration is used for lookup. | 3130 // Must be small, since an iteration is used for lookup. |
| 3120 static const int kMaxComments = 64; | 3131 static const int kMaxComments = 64; |
| 3121 }; | 3132 }; |
| 3122 #endif | 3133 #endif |
| 3123 } // namespace internal | 3134 } // namespace internal |
| 3124 } // namespace v8 | 3135 } // namespace v8 |
| 3125 | 3136 |
| 3126 #endif // V8_HEAP_SPACES_H_ | 3137 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |