| 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" |
| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // not be performed on that page. Sweeper threads that are done with their | 466 // not be performed on that page. Sweeper threads that are done with their |
| 468 // work will set this value and not touch the page anymore. | 467 // work will set this value and not touch the page anymore. |
| 469 // |kSweepingPending|: This page is ready for parallel sweeping. | 468 // |kSweepingPending|: This page is ready for parallel sweeping. |
| 470 // |kSweepingInProgress|: This page is currently swept by a sweeper thread. | 469 // |kSweepingInProgress|: This page is currently swept by a sweeper thread. |
| 471 enum ConcurrentSweepingState { | 470 enum ConcurrentSweepingState { |
| 472 kSweepingDone, | 471 kSweepingDone, |
| 473 kSweepingPending, | 472 kSweepingPending, |
| 474 kSweepingInProgress, | 473 kSweepingInProgress, |
| 475 }; | 474 }; |
| 476 | 475 |
| 477 enum ArrayBufferTrackerAccessMode { kDontCreate, kCreateIfNotPresent }; | |
| 478 | |
| 479 // Every n write barrier invocations we go to runtime even though | 476 // Every n write barrier invocations we go to runtime even though |
| 480 // we could have handled it in generated code. This lets us check | 477 // we could have handled it in generated code. This lets us check |
| 481 // whether we have hit the limit and should do some more marking. | 478 // whether we have hit the limit and should do some more marking. |
| 482 static const int kWriteBarrierCounterGranularity = 500; | 479 static const int kWriteBarrierCounterGranularity = 500; |
| 483 | 480 |
| 484 static const int kPointersToHereAreInterestingMask = | 481 static const int kPointersToHereAreInterestingMask = |
| 485 1 << POINTERS_TO_HERE_ARE_INTERESTING; | 482 1 << POINTERS_TO_HERE_ARE_INTERESTING; |
| 486 | 483 |
| 487 static const int kPointersFromHereAreInterestingMask = | 484 static const int kPointersFromHereAreInterestingMask = |
| 488 1 << POINTERS_FROM_HERE_ARE_INTERESTING; | 485 1 << POINTERS_FROM_HERE_ARE_INTERESTING; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 static const size_t kMinHeaderSize = | 521 static const size_t kMinHeaderSize = |
| 525 kWriteBarrierCounterOffset + | 522 kWriteBarrierCounterOffset + |
| 526 kIntptrSize // intptr_t write_barrier_counter_ | 523 kIntptrSize // intptr_t write_barrier_counter_ |
| 527 + kPointerSize // AtomicValue high_water_mark_ | 524 + kPointerSize // AtomicValue high_water_mark_ |
| 528 + kPointerSize // base::Mutex* mutex_ | 525 + kPointerSize // base::Mutex* mutex_ |
| 529 + kPointerSize // base::AtomicWord concurrent_sweeping_ | 526 + kPointerSize // base::AtomicWord concurrent_sweeping_ |
| 530 + 2 * kPointerSize // AtomicNumber free-list statistics | 527 + 2 * kPointerSize // AtomicNumber free-list statistics |
| 531 + kPointerSize // AtomicValue next_chunk_ | 528 + kPointerSize // AtomicValue next_chunk_ |
| 532 + kPointerSize // AtomicValue prev_chunk_ | 529 + kPointerSize // AtomicValue prev_chunk_ |
| 533 // FreeListCategory categories_[kNumberOfCategories] | 530 // FreeListCategory categories_[kNumberOfCategories] |
| 534 + FreeListCategory::kSize * kNumberOfCategories + | 531 + FreeListCategory::kSize * kNumberOfCategories; |
| 535 kPointerSize; // LocalArrayBufferTracker tracker_ | |
| 536 | 532 |
| 537 // We add some more space to the computed header size to amount for missing | 533 // We add some more space to the computed header size to amount for missing |
| 538 // alignment requirements in our computation. | 534 // alignment requirements in our computation. |
| 539 // Try to get kHeaderSize properly aligned on 32-bit and 64-bit machines. | 535 // Try to get kHeaderSize properly aligned on 32-bit and 64-bit machines. |
| 540 static const size_t kHeaderSize = kMinHeaderSize; | 536 static const size_t kHeaderSize = kMinHeaderSize; |
| 541 | 537 |
| 542 static const int kBodyOffset = | 538 static const int kBodyOffset = |
| 543 CODE_POINTER_ALIGN(kHeaderSize + Bitmap::kSize); | 539 CODE_POINTER_ALIGN(kHeaderSize + Bitmap::kSize); |
| 544 | 540 |
| 545 // The start offset of the object area in a page. Aligned to both maps and | 541 // The start offset of the object area in a page. Aligned to both maps and |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 | 640 |
| 645 void AllocateOldToNewSlots(); | 641 void AllocateOldToNewSlots(); |
| 646 void ReleaseOldToNewSlots(); | 642 void ReleaseOldToNewSlots(); |
| 647 void AllocateOldToOldSlots(); | 643 void AllocateOldToOldSlots(); |
| 648 void ReleaseOldToOldSlots(); | 644 void ReleaseOldToOldSlots(); |
| 649 void AllocateTypedOldToNewSlots(); | 645 void AllocateTypedOldToNewSlots(); |
| 650 void ReleaseTypedOldToNewSlots(); | 646 void ReleaseTypedOldToNewSlots(); |
| 651 void AllocateTypedOldToOldSlots(); | 647 void AllocateTypedOldToOldSlots(); |
| 652 void ReleaseTypedOldToOldSlots(); | 648 void ReleaseTypedOldToOldSlots(); |
| 653 | 649 |
| 654 template <ArrayBufferTrackerAccessMode tracker_access> | |
| 655 inline LocalArrayBufferTracker* local_tracker() { | |
| 656 LocalArrayBufferTracker* tracker = local_tracker_.Value(); | |
| 657 if (tracker == nullptr && tracker_access == kCreateIfNotPresent) { | |
| 658 tracker = new LocalArrayBufferTracker(heap_); | |
| 659 if (!local_tracker_.TrySetValue(nullptr, tracker)) { | |
| 660 tracker = local_tracker_.Value(); | |
| 661 } | |
| 662 DCHECK_NOT_NULL(tracker); | |
| 663 } | |
| 664 return tracker; | |
| 665 } | |
| 666 | |
| 667 void ReleaseLocalTracker(); | |
| 668 | |
| 669 Address area_start() { return area_start_; } | 650 Address area_start() { return area_start_; } |
| 670 Address area_end() { return area_end_; } | 651 Address area_end() { return area_end_; } |
| 671 int area_size() { return static_cast<int>(area_end() - area_start()); } | 652 int area_size() { return static_cast<int>(area_end() - area_start()); } |
| 672 | 653 |
| 673 bool CommitArea(size_t requested); | 654 bool CommitArea(size_t requested); |
| 674 | 655 |
| 675 // Approximate amount of physical memory committed for this chunk. | 656 // Approximate amount of physical memory committed for this chunk. |
| 676 size_t CommittedPhysicalMemory() { return high_water_mark_.Value(); } | 657 size_t CommittedPhysicalMemory() { return high_water_mark_.Value(); } |
| 677 | 658 |
| 678 Address HighWaterMark() { return address() + high_water_mark_.Value(); } | 659 Address HighWaterMark() { return address() + high_water_mark_.Value(); } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 base::AtomicNumber<intptr_t> available_in_free_list_; | 825 base::AtomicNumber<intptr_t> available_in_free_list_; |
| 845 base::AtomicNumber<intptr_t> wasted_memory_; | 826 base::AtomicNumber<intptr_t> wasted_memory_; |
| 846 | 827 |
| 847 // next_chunk_ holds a pointer of type MemoryChunk | 828 // next_chunk_ holds a pointer of type MemoryChunk |
| 848 base::AtomicValue<MemoryChunk*> next_chunk_; | 829 base::AtomicValue<MemoryChunk*> next_chunk_; |
| 849 // prev_chunk_ holds a pointer of type MemoryChunk | 830 // prev_chunk_ holds a pointer of type MemoryChunk |
| 850 base::AtomicValue<MemoryChunk*> prev_chunk_; | 831 base::AtomicValue<MemoryChunk*> prev_chunk_; |
| 851 | 832 |
| 852 FreeListCategory categories_[kNumberOfCategories]; | 833 FreeListCategory categories_[kNumberOfCategories]; |
| 853 | 834 |
| 854 base::AtomicValue<LocalArrayBufferTracker*> local_tracker_; | |
| 855 | |
| 856 private: | 835 private: |
| 857 void InitializeReservedMemory() { reservation_.Reset(); } | 836 void InitializeReservedMemory() { reservation_.Reset(); } |
| 858 | 837 |
| 859 friend class MemoryAllocator; | 838 friend class MemoryAllocator; |
| 860 friend class MemoryChunkValidator; | 839 friend class MemoryChunkValidator; |
| 861 }; | 840 }; |
| 862 | 841 |
| 863 // ----------------------------------------------------------------------------- | 842 // ----------------------------------------------------------------------------- |
| 864 // A page is a memory chunk of a size 1MB. Large object pages may be larger. | 843 // A page is a memory chunk of a size 1MB. Large object pages may be larger. |
| 865 // | 844 // |
| (...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3162 count = 0; | 3141 count = 0; |
| 3163 } | 3142 } |
| 3164 // Must be small, since an iteration is used for lookup. | 3143 // Must be small, since an iteration is used for lookup. |
| 3165 static const int kMaxComments = 64; | 3144 static const int kMaxComments = 64; |
| 3166 }; | 3145 }; |
| 3167 #endif | 3146 #endif |
| 3168 } // namespace internal | 3147 } // namespace internal |
| 3169 } // namespace v8 | 3148 } // namespace v8 |
| 3170 | 3149 |
| 3171 #endif // V8_HEAP_SPACES_H_ | 3150 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |