Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: src/heap/spaces.h

Issue 1412223018: [presubmit] Enabling readability/inheritance linter checking. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/full-codegen/full-codegen.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 class HeapObjectIterator : public ObjectIterator { 1415 class HeapObjectIterator : public ObjectIterator {
1416 public: 1416 public:
1417 // Creates a new object iterator in a given space. 1417 // Creates a new object iterator in a given space.
1418 explicit HeapObjectIterator(PagedSpace* space); 1418 explicit HeapObjectIterator(PagedSpace* space);
1419 explicit HeapObjectIterator(Page* page); 1419 explicit HeapObjectIterator(Page* page);
1420 1420
1421 // Advance to the next object, skipping free spaces and other fillers and 1421 // Advance to the next object, skipping free spaces and other fillers and
1422 // skipping the special garbage section of which there is one per space. 1422 // skipping the special garbage section of which there is one per space.
1423 // Returns NULL when the iteration has ended. 1423 // Returns NULL when the iteration has ended.
1424 inline HeapObject* Next(); 1424 inline HeapObject* Next();
1425 virtual inline HeapObject* next_object(); 1425 inline HeapObject* next_object() override;
1426 1426
1427 private: 1427 private:
1428 enum PageMode { kOnePageOnly, kAllPagesInSpace }; 1428 enum PageMode { kOnePageOnly, kAllPagesInSpace };
1429 1429
1430 Address cur_addr_; // Current iteration point. 1430 Address cur_addr_; // Current iteration point.
1431 Address cur_end_; // End iteration point. 1431 Address cur_end_; // End iteration point.
1432 PagedSpace* space_; 1432 PagedSpace* space_;
1433 PageMode page_mode_; 1433 PageMode page_mode_;
1434 1434
1435 // Fast (inlined) path of next(). 1435 // Fast (inlined) path of next().
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize); 1870 STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize);
1871 1871
1872 1872
1873 class PagedSpace : public Space { 1873 class PagedSpace : public Space {
1874 public: 1874 public:
1875 static const intptr_t kCompactionMemoryWanted = 500 * KB; 1875 static const intptr_t kCompactionMemoryWanted = 500 * KB;
1876 1876
1877 // Creates a space with an id. 1877 // Creates a space with an id.
1878 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); 1878 PagedSpace(Heap* heap, AllocationSpace id, Executability executable);
1879 1879
1880 virtual ~PagedSpace() { TearDown(); } 1880 ~PagedSpace() override { TearDown(); }
1881 1881
1882 // Set up the space using the given address range of virtual memory (from 1882 // Set up the space using the given address range of virtual memory (from
1883 // the memory allocator's initial chunk) if possible. If the block of 1883 // the memory allocator's initial chunk) if possible. If the block of
1884 // addresses is not big enough to contain a single page-aligned page, a 1884 // addresses is not big enough to contain a single page-aligned page, a
1885 // fresh chunk will be allocated. 1885 // fresh chunk will be allocated.
1886 bool SetUp(); 1886 bool SetUp();
1887 1887
1888 // Returns true if the space has been successfully set up and not 1888 // Returns true if the space has been successfully set up and not
1889 // subsequently torn down. 1889 // subsequently torn down.
1890 bool HasBeenSetUp(); 1890 bool HasBeenSetUp();
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2463 // semispace) to the top of the semispace. New objects allocated after the 2463 // semispace) to the top of the semispace. New objects allocated after the
2464 // iterator is created are not iterated. 2464 // iterator is created are not iterated.
2465 class SemiSpaceIterator : public ObjectIterator { 2465 class SemiSpaceIterator : public ObjectIterator {
2466 public: 2466 public:
2467 // Create an iterator over the allocated objects in the given to-space. 2467 // Create an iterator over the allocated objects in the given to-space.
2468 explicit SemiSpaceIterator(NewSpace* space); 2468 explicit SemiSpaceIterator(NewSpace* space);
2469 2469
2470 inline HeapObject* Next(); 2470 inline HeapObject* Next();
2471 2471
2472 // Implementation of the ObjectIterator functions. 2472 // Implementation of the ObjectIterator functions.
2473 virtual inline HeapObject* next_object(); 2473 inline HeapObject* next_object() override;
2474 2474
2475 private: 2475 private:
2476 void Initialize(Address start, Address end); 2476 void Initialize(Address start, Address end);
2477 2477
2478 // The current iteration point. 2478 // The current iteration point.
2479 Address current_; 2479 Address current_;
2480 // The end of iteration. 2480 // The end of iteration.
2481 Address limit_; 2481 Address limit_;
2482 }; 2482 };
2483 2483
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 public: 2832 public:
2833 CompactionSpace(Heap* heap, AllocationSpace id, Executability executable) 2833 CompactionSpace(Heap* heap, AllocationSpace id, Executability executable)
2834 : PagedSpace(heap, id, executable) {} 2834 : PagedSpace(heap, id, executable) {}
2835 2835
2836 // Adds external memory starting at {start} of {size_in_bytes} to the space. 2836 // Adds external memory starting at {start} of {size_in_bytes} to the space.
2837 void AddExternalMemory(Address start, int size_in_bytes) { 2837 void AddExternalMemory(Address start, int size_in_bytes) {
2838 IncreaseCapacity(size_in_bytes); 2838 IncreaseCapacity(size_in_bytes);
2839 Free(start, size_in_bytes); 2839 Free(start, size_in_bytes);
2840 } 2840 }
2841 2841
2842 virtual bool is_local() override { return true; } 2842 bool is_local() override { return true; }
2843 2843
2844 virtual void RefillFreeList() override; 2844 void RefillFreeList() override;
2845 2845
2846 protected: 2846 protected:
2847 // The space is temporary and not included in any snapshots. 2847 // The space is temporary and not included in any snapshots.
2848 virtual bool snapshotable() override { return false; } 2848 bool snapshotable() override { return false; }
2849 2849
2850 MUST_USE_RESULT virtual HeapObject* SweepAndRetryAllocation( 2850 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation(
2851 int size_in_bytes) override; 2851 int size_in_bytes) override;
2852 }; 2852 };
2853 2853
2854 2854
2855 // A collection of |CompactionSpace|s used by a single compaction task. 2855 // A collection of |CompactionSpace|s used by a single compaction task.
2856 class CompactionSpaceCollection : public Malloced { 2856 class CompactionSpaceCollection : public Malloced {
2857 public: 2857 public:
2858 explicit CompactionSpaceCollection(Heap* heap) 2858 explicit CompactionSpaceCollection(Heap* heap)
2859 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), 2859 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE),
2860 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE) {} 2860 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE) {}
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 public: 2905 public:
2906 // Creates a map space object. 2906 // Creates a map space object.
2907 MapSpace(Heap* heap, AllocationSpace id) 2907 MapSpace(Heap* heap, AllocationSpace id)
2908 : PagedSpace(heap, id, NOT_EXECUTABLE), 2908 : PagedSpace(heap, id, NOT_EXECUTABLE),
2909 max_map_space_pages_(kMaxMapPageIndex - 1) {} 2909 max_map_space_pages_(kMaxMapPageIndex - 1) {}
2910 2910
2911 // Given an index, returns the page address. 2911 // Given an index, returns the page address.
2912 // TODO(1600): this limit is artifical just to keep code compilable 2912 // TODO(1600): this limit is artifical just to keep code compilable
2913 static const int kMaxMapPageIndex = 1 << 16; 2913 static const int kMaxMapPageIndex = 1 << 16;
2914 2914
2915 virtual int RoundSizeDownToObjectAlignment(int size) { 2915 int RoundSizeDownToObjectAlignment(int size) override {
2916 if (base::bits::IsPowerOfTwo32(Map::kSize)) { 2916 if (base::bits::IsPowerOfTwo32(Map::kSize)) {
2917 return RoundDown(size, Map::kSize); 2917 return RoundDown(size, Map::kSize);
2918 } else { 2918 } else {
2919 return (size / Map::kSize) * Map::kSize; 2919 return (size / Map::kSize) * Map::kSize;
2920 } 2920 }
2921 } 2921 }
2922 2922
2923 protected: 2923 #ifdef VERIFY_HEAP
2924 virtual void VerifyObject(HeapObject* obj); 2924 void VerifyObject(HeapObject* obj) override;
2925 #endif
2925 2926
2926 private: 2927 private:
2927 static const int kMapsPerPage = Page::kAllocatableMemory / Map::kSize; 2928 static const int kMapsPerPage = Page::kAllocatableMemory / Map::kSize;
2928 2929
2929 // Do map space compaction if there is a page gap. 2930 // Do map space compaction if there is a page gap.
2930 int CompactionThreshold() { 2931 int CompactionThreshold() {
2931 return kMapsPerPage * (max_map_space_pages_ - 1); 2932 return kMapsPerPage * (max_map_space_pages_ - 1);
2932 } 2933 }
2933 2934
2934 const int max_map_space_pages_; 2935 const int max_map_space_pages_;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3067 count = 0; 3068 count = 0;
3068 } 3069 }
3069 // Must be small, since an iteration is used for lookup. 3070 // Must be small, since an iteration is used for lookup.
3070 static const int kMaxComments = 64; 3071 static const int kMaxComments = 64;
3071 }; 3072 };
3072 #endif 3073 #endif
3073 } // namespace internal 3074 } // namespace internal
3074 } // namespace v8 3075 } // namespace v8
3075 3076
3076 #endif // V8_HEAP_SPACES_H_ 3077 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698