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" |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 | 621 |
622 int write_barrier_counter() { | 622 int write_barrier_counter() { |
623 return static_cast<int>(write_barrier_counter_); | 623 return static_cast<int>(write_barrier_counter_); |
624 } | 624 } |
625 | 625 |
626 void set_write_barrier_counter(int counter) { | 626 void set_write_barrier_counter(int counter) { |
627 write_barrier_counter_ = counter; | 627 write_barrier_counter_ = counter; |
628 } | 628 } |
629 | 629 |
630 size_t size() const { return size_; } | 630 size_t size() const { return size_; } |
631 void set_size(size_t size) { size_ = size; } | |
632 | 631 |
633 inline Heap* heap() const { return heap_; } | 632 inline Heap* heap() const { return heap_; } |
634 | 633 |
635 inline SkipList* skip_list() { return skip_list_; } | 634 inline SkipList* skip_list() { return skip_list_; } |
636 | 635 |
637 inline void set_skip_list(SkipList* skip_list) { skip_list_ = skip_list; } | 636 inline void set_skip_list(SkipList* skip_list) { skip_list_ = skip_list; } |
638 | 637 |
639 inline SlotSet* old_to_new_slots() { return old_to_new_slots_; } | 638 inline SlotSet* old_to_new_slots() { return old_to_new_slots_; } |
640 inline SlotSet* old_to_old_slots() { return old_to_old_slots_; } | 639 inline SlotSet* old_to_old_slots() { return old_to_old_slots_; } |
641 inline TypedSlotSet* typed_old_to_new_slots() { | 640 inline TypedSlotSet* typed_old_to_new_slots() { |
(...skipping 15 matching lines...) Expand all Loading... |
657 void AllocateLocalTracker(); | 656 void AllocateLocalTracker(); |
658 void ReleaseLocalTracker(); | 657 void ReleaseLocalTracker(); |
659 | 658 |
660 Address area_start() { return area_start_; } | 659 Address area_start() { return area_start_; } |
661 Address area_end() { return area_end_; } | 660 Address area_end() { return area_end_; } |
662 int area_size() { return static_cast<int>(area_end() - area_start()); } | 661 int area_size() { return static_cast<int>(area_end() - area_start()); } |
663 | 662 |
664 bool CommitArea(size_t requested); | 663 bool CommitArea(size_t requested); |
665 | 664 |
666 // Approximate amount of physical memory committed for this chunk. | 665 // Approximate amount of physical memory committed for this chunk. |
667 size_t CommittedPhysicalMemory(); | 666 size_t CommittedPhysicalMemory() { return high_water_mark_.Value(); } |
668 | 667 |
669 Address HighWaterMark() { return address() + high_water_mark_.Value(); } | 668 Address HighWaterMark() { return address() + high_water_mark_.Value(); } |
670 | 669 |
671 int progress_bar() { | 670 int progress_bar() { |
672 DCHECK(IsFlagSet(HAS_PROGRESS_BAR)); | 671 DCHECK(IsFlagSet(HAS_PROGRESS_BAR)); |
673 return progress_bar_; | 672 return progress_bar_; |
674 } | 673 } |
675 | 674 |
676 void set_progress_bar(int progress_bar) { | 675 void set_progress_bar(int progress_bar) { |
677 DCHECK(IsFlagSet(HAS_PROGRESS_BAR)); | 676 DCHECK(IsFlagSet(HAS_PROGRESS_BAR)); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 class LargePage : public MemoryChunk { | 996 class LargePage : public MemoryChunk { |
998 public: | 997 public: |
999 HeapObject* GetObject() { return HeapObject::FromAddress(area_start()); } | 998 HeapObject* GetObject() { return HeapObject::FromAddress(area_start()); } |
1000 | 999 |
1001 inline LargePage* next_page() { | 1000 inline LargePage* next_page() { |
1002 return static_cast<LargePage*>(next_chunk()); | 1001 return static_cast<LargePage*>(next_chunk()); |
1003 } | 1002 } |
1004 | 1003 |
1005 inline void set_next_page(LargePage* page) { set_next_chunk(page); } | 1004 inline void set_next_page(LargePage* page) { set_next_chunk(page); } |
1006 | 1005 |
1007 // Uncommit memory that is not in use anymore by the object. If the object | |
1008 // cannot be shrunk 0 is returned. | |
1009 Address GetAddressToShrink(); | |
1010 | |
1011 void ClearOutOfLiveRangeSlots(Address free_start); | |
1012 | |
1013 // A limit to guarantee that we do not overflow typed slot offset in | 1006 // A limit to guarantee that we do not overflow typed slot offset in |
1014 // the old to old remembered set. | 1007 // the old to old remembered set. |
1015 // Note that this limit is higher than what assembler already imposes on | 1008 // Note that this limit is higher than what assembler already imposes on |
1016 // x64 and ia32 architectures. | 1009 // x64 and ia32 architectures. |
1017 static const int kMaxCodePageSize = 512 * MB; | 1010 static const int kMaxCodePageSize = 512 * MB; |
1018 | 1011 |
1019 private: | 1012 private: |
1020 static inline LargePage* Initialize(Heap* heap, MemoryChunk* chunk, | 1013 static inline LargePage* Initialize(Heap* heap, MemoryChunk* chunk, |
1021 Executability executable, Space* owner); | 1014 Executability executable, Space* owner); |
1022 | 1015 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 | 1447 |
1455 Address ReserveAlignedMemory(size_t requested, size_t alignment, | 1448 Address ReserveAlignedMemory(size_t requested, size_t alignment, |
1456 base::VirtualMemory* controller); | 1449 base::VirtualMemory* controller); |
1457 Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size, | 1450 Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size, |
1458 size_t alignment, Executability executable, | 1451 size_t alignment, Executability executable, |
1459 base::VirtualMemory* controller); | 1452 base::VirtualMemory* controller); |
1460 | 1453 |
1461 bool CommitMemory(Address addr, size_t size, Executability executable); | 1454 bool CommitMemory(Address addr, size_t size, Executability executable); |
1462 | 1455 |
1463 void FreeMemory(base::VirtualMemory* reservation, Executability executable); | 1456 void FreeMemory(base::VirtualMemory* reservation, Executability executable); |
1464 void PartialFreeMemory(MemoryChunk* chunk, Address start_free); | |
1465 void FreeMemory(Address addr, size_t size, Executability executable); | 1457 void FreeMemory(Address addr, size_t size, Executability executable); |
1466 | 1458 |
1467 // Commit a contiguous block of memory from the initial chunk. Assumes that | 1459 // Commit a contiguous block of memory from the initial chunk. Assumes that |
1468 // the address is not NULL, the size is greater than zero, and that the | 1460 // the address is not NULL, the size is greater than zero, and that the |
1469 // block is contained in the initial chunk. Returns true if it succeeded | 1461 // block is contained in the initial chunk. Returns true if it succeeded |
1470 // and false otherwise. | 1462 // and false otherwise. |
1471 bool CommitBlock(Address start, size_t size, Executability executable); | 1463 bool CommitBlock(Address start, size_t size, Executability executable); |
1472 | 1464 |
1473 // Uncommit a contiguous block of memory [start..(start+size)[. | 1465 // Uncommit a contiguous block of memory [start..(start+size)[. |
1474 // start is not NULL, the size is greater than zero, and the | 1466 // start is not NULL, the size is greater than zero, and the |
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3076 // Finds a large object page containing the given address, returns NULL | 3068 // Finds a large object page containing the given address, returns NULL |
3077 // if such a page doesn't exist. | 3069 // if such a page doesn't exist. |
3078 LargePage* FindPage(Address a); | 3070 LargePage* FindPage(Address a); |
3079 | 3071 |
3080 // Clears the marking state of live objects. | 3072 // Clears the marking state of live objects. |
3081 void ClearMarkingStateOfLiveObjects(); | 3073 void ClearMarkingStateOfLiveObjects(); |
3082 | 3074 |
3083 // Frees unmarked objects. | 3075 // Frees unmarked objects. |
3084 void FreeUnmarkedObjects(); | 3076 void FreeUnmarkedObjects(); |
3085 | 3077 |
3086 void InsertChunkMapEntries(LargePage* page); | |
3087 void RemoveChunkMapEntries(LargePage* page); | |
3088 void RemoveChunkMapEntries(LargePage* page, Address free_start); | |
3089 | |
3090 // Checks whether a heap object is in this space; O(1). | 3078 // Checks whether a heap object is in this space; O(1). |
3091 bool Contains(HeapObject* obj); | 3079 bool Contains(HeapObject* obj); |
3092 // Checks whether an address is in the object area in this space. Iterates | 3080 // Checks whether an address is in the object area in this space. Iterates |
3093 // all objects in the space. May be slow. | 3081 // all objects in the space. May be slow. |
3094 bool ContainsSlow(Address addr) { return FindObject(addr)->IsHeapObject(); } | 3082 bool ContainsSlow(Address addr) { return FindObject(addr)->IsHeapObject(); } |
3095 | 3083 |
3096 // Checks whether the space is empty. | 3084 // Checks whether the space is empty. |
3097 bool IsEmpty() { return first_page_ == NULL; } | 3085 bool IsEmpty() { return first_page_ == NULL; } |
3098 | 3086 |
3099 void AdjustLiveBytes(int by) { objects_size_ += by; } | 3087 void AdjustLiveBytes(int by) { objects_size_ += by; } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3174 count = 0; | 3162 count = 0; |
3175 } | 3163 } |
3176 // Must be small, since an iteration is used for lookup. | 3164 // Must be small, since an iteration is used for lookup. |
3177 static const int kMaxComments = 64; | 3165 static const int kMaxComments = 64; |
3178 }; | 3166 }; |
3179 #endif | 3167 #endif |
3180 } // namespace internal | 3168 } // namespace internal |
3181 } // namespace v8 | 3169 } // namespace v8 |
3182 | 3170 |
3183 #endif // V8_HEAP_SPACES_H_ | 3171 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |