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

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

Issue 2006183003: Revert of [heap] Fine-grained JSArrayBuffer tracking (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months 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/heap/scavenger.cc ('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 <list> 8 #include <list>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
11 #include "src/base/atomic-utils.h" 11 #include "src/base/atomic-utils.h"
12 #include "src/base/atomicops.h" 12 #include "src/base/atomicops.h"
13 #include "src/base/bits.h" 13 #include "src/base/bits.h"
14 #include "src/base/platform/mutex.h" 14 #include "src/base/platform/mutex.h"
15 #include "src/flags.h" 15 #include "src/flags.h"
16 #include "src/hashmap.h" 16 #include "src/hashmap.h"
17 #include "src/heap/array-buffer-tracker.h"
18 #include "src/list.h" 17 #include "src/list.h"
19 #include "src/objects.h" 18 #include "src/objects.h"
20 #include "src/utils.h" 19 #include "src/utils.h"
21 20
22 namespace v8 { 21 namespace v8 {
23 namespace internal { 22 namespace internal {
24 23
25 class AllocationInfo; 24 class AllocationInfo;
26 class AllocationObserver; 25 class AllocationObserver;
27 class CompactionSpace; 26 class CompactionSpace;
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 static const size_t kMinHeaderSize = 516 static const size_t kMinHeaderSize =
518 kWriteBarrierCounterOffset + 517 kWriteBarrierCounterOffset +
519 kIntptrSize // intptr_t write_barrier_counter_ 518 kIntptrSize // intptr_t write_barrier_counter_
520 + kPointerSize // AtomicValue high_water_mark_ 519 + kPointerSize // AtomicValue high_water_mark_
521 + kPointerSize // base::Mutex* mutex_ 520 + kPointerSize // base::Mutex* mutex_
522 + kPointerSize // base::AtomicWord concurrent_sweeping_ 521 + kPointerSize // base::AtomicWord concurrent_sweeping_
523 + 2 * kPointerSize // AtomicNumber free-list statistics 522 + 2 * kPointerSize // AtomicNumber free-list statistics
524 + kPointerSize // AtomicValue next_chunk_ 523 + kPointerSize // AtomicValue next_chunk_
525 + kPointerSize // AtomicValue prev_chunk_ 524 + kPointerSize // AtomicValue prev_chunk_
526 // FreeListCategory categories_[kNumberOfCategories] 525 // FreeListCategory categories_[kNumberOfCategories]
527 + FreeListCategory::kSize * kNumberOfCategories + 526 + FreeListCategory::kSize * kNumberOfCategories;
528 kPointerSize; // LocalArrayBufferTracker tracker_
529 527
530 // We add some more space to the computed header size to amount for missing 528 // We add some more space to the computed header size to amount for missing
531 // alignment requirements in our computation. 529 // alignment requirements in our computation.
532 // Try to get kHeaderSize properly aligned on 32-bit and 64-bit machines. 530 // Try to get kHeaderSize properly aligned on 32-bit and 64-bit machines.
533 static const size_t kHeaderSize = kMinHeaderSize; 531 static const size_t kHeaderSize = kMinHeaderSize;
534 532
535 static const int kBodyOffset = 533 static const int kBodyOffset =
536 CODE_POINTER_ALIGN(kHeaderSize + Bitmap::kSize); 534 CODE_POINTER_ALIGN(kHeaderSize + Bitmap::kSize);
537 535
538 // The start offset of the object area in a page. Aligned to both maps and 536 // The start offset of the object area in a page. Aligned to both maps and
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 base::AtomicNumber<intptr_t> available_in_free_list_; 817 base::AtomicNumber<intptr_t> available_in_free_list_;
820 base::AtomicNumber<intptr_t> wasted_memory_; 818 base::AtomicNumber<intptr_t> wasted_memory_;
821 819
822 // next_chunk_ holds a pointer of type MemoryChunk 820 // next_chunk_ holds a pointer of type MemoryChunk
823 base::AtomicValue<MemoryChunk*> next_chunk_; 821 base::AtomicValue<MemoryChunk*> next_chunk_;
824 // prev_chunk_ holds a pointer of type MemoryChunk 822 // prev_chunk_ holds a pointer of type MemoryChunk
825 base::AtomicValue<MemoryChunk*> prev_chunk_; 823 base::AtomicValue<MemoryChunk*> prev_chunk_;
826 824
827 FreeListCategory categories_[kNumberOfCategories]; 825 FreeListCategory categories_[kNumberOfCategories];
828 826
829 LocalArrayBufferTracker* local_tracker_;
830
831 private: 827 private:
832 void InitializeReservedMemory() { reservation_.Reset(); } 828 void InitializeReservedMemory() { reservation_.Reset(); }
833 829
834 friend class MemoryAllocator; 830 friend class MemoryAllocator;
835 friend class MemoryChunkValidator; 831 friend class MemoryChunkValidator;
836 }; 832 };
837 833
838 // ----------------------------------------------------------------------------- 834 // -----------------------------------------------------------------------------
839 // A page is a memory chunk of a size 1MB. Large object pages may be larger. 835 // A page is a memory chunk of a size 1MB. Large object pages may be larger.
840 // 836 //
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 947
952 bool is_anchor() { return IsFlagSet(Page::ANCHOR); } 948 bool is_anchor() { return IsFlagSet(Page::ANCHOR); }
953 949
954 intptr_t wasted_memory() { return wasted_memory_.Value(); } 950 intptr_t wasted_memory() { return wasted_memory_.Value(); }
955 void add_wasted_memory(intptr_t waste) { wasted_memory_.Increment(waste); } 951 void add_wasted_memory(intptr_t waste) { wasted_memory_.Increment(waste); }
956 intptr_t available_in_free_list() { return available_in_free_list_.Value(); } 952 intptr_t available_in_free_list() { return available_in_free_list_.Value(); }
957 void add_available_in_free_list(intptr_t available) { 953 void add_available_in_free_list(intptr_t available) {
958 available_in_free_list_.Increment(available); 954 available_in_free_list_.Increment(available);
959 } 955 }
960 956
961 LocalArrayBufferTracker* local_tracker() {
962 if (local_tracker_ == nullptr) {
963 local_tracker_ = new LocalArrayBufferTracker(heap_);
964 }
965 return local_tracker_;
966 }
967
968 void FreeDeadArrayBuffers() {
969 if (local_tracker_ != nullptr) {
970 local_tracker_->FreeDead();
971 if (local_tracker_->IsEmpty()) {
972 delete local_tracker_;
973 local_tracker_ = nullptr;
974 }
975 }
976 }
977
978 template <LocalArrayBufferTracker::LivenessIndicator liveness_indicator>
979 void ScanAndFreeDeadArrayBuffers() {
980 if (local_tracker_ != nullptr) {
981 local_tracker_->ScanAndFreeDead<liveness_indicator>();
982 if (local_tracker_->IsEmpty()) {
983 delete local_tracker_;
984 local_tracker_ = nullptr;
985 }
986 }
987 }
988
989 void ResetTracker() {
990 if (local_tracker_ != nullptr) {
991 local_tracker_->Reset();
992 }
993 }
994
995 #ifdef DEBUG 957 #ifdef DEBUG
996 void Print(); 958 void Print();
997 #endif // DEBUG 959 #endif // DEBUG
998 960
999 private: 961 private:
1000 enum InitializationMode { kFreeMemory, kDoNotFreeMemory }; 962 enum InitializationMode { kFreeMemory, kDoNotFreeMemory };
1001 963
1002 template <InitializationMode mode = kFreeMemory> 964 template <InitializationMode mode = kFreeMemory>
1003 static inline Page* Initialize(Heap* heap, MemoryChunk* chunk, 965 static inline Page* Initialize(Heap* heap, MemoryChunk* chunk,
1004 Executability executable, PagedSpace* owner); 966 Executability executable, PagedSpace* owner);
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 // sweeper. 2288 // sweeper.
2327 virtual void RefillFreeList(); 2289 virtual void RefillFreeList();
2328 2290
2329 FreeList* free_list() { return &free_list_; } 2291 FreeList* free_list() { return &free_list_; }
2330 2292
2331 base::Mutex* mutex() { return &space_mutex_; } 2293 base::Mutex* mutex() { return &space_mutex_; }
2332 2294
2333 inline void UnlinkFreeListCategories(Page* page); 2295 inline void UnlinkFreeListCategories(Page* page);
2334 inline intptr_t RelinkFreeListCategories(Page* page); 2296 inline intptr_t RelinkFreeListCategories(Page* page);
2335 2297
2336 // Callback signature:
2337 // void Callback(Page*);
2338 template <typename Callback>
2339 void ForAllPages(Callback callback) {
2340 PageIterator it(this);
2341 while (it.has_next()) {
2342 callback(it.next());
2343 }
2344 }
2345
2346 protected: 2298 protected:
2347 // PagedSpaces that should be included in snapshots have different, i.e., 2299 // PagedSpaces that should be included in snapshots have different, i.e.,
2348 // smaller, initial pages. 2300 // smaller, initial pages.
2349 virtual bool snapshotable() { return true; } 2301 virtual bool snapshotable() { return true; }
2350 2302
2351 bool HasPages() { return anchor_.next_page() != &anchor_; } 2303 bool HasPages() { return anchor_.next_page() != &anchor_; }
2352 2304
2353 // Cleans up the space, frees all pages in this space except those belonging 2305 // Cleans up the space, frees all pages in this space except those belonging
2354 // to the initial chunk, uncommits addresses in the initial chunk. 2306 // to the initial chunk, uncommits addresses in the initial chunk.
2355 void TearDown(); 2307 void TearDown();
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 count = 0; 3149 count = 0;
3198 } 3150 }
3199 // Must be small, since an iteration is used for lookup. 3151 // Must be small, since an iteration is used for lookup.
3200 static const int kMaxComments = 64; 3152 static const int kMaxComments = 64;
3201 }; 3153 };
3202 #endif 3154 #endif
3203 } // namespace internal 3155 } // namespace internal
3204 } // namespace v8 3156 } // namespace v8
3205 3157
3206 #endif // V8_HEAP_SPACES_H_ 3158 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/scavenger.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698