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