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 "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 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1624 // and limit when the object we need to allocate is 256-2047 words in size. | 1624 // and limit when the object we need to allocate is 256-2047 words in size. |
1625 // These spaces are call large. | 1625 // These spaces are call large. |
1626 // At least 16384 words. This list is for objects of 2048 words or larger. | 1626 // At least 16384 words. This list is for objects of 2048 words or larger. |
1627 // Empty pages are added to this list. These spaces are called huge. | 1627 // Empty pages are added to this list. These spaces are called huge. |
1628 class FreeList { | 1628 class FreeList { |
1629 public: | 1629 public: |
1630 explicit FreeList(PagedSpace* owner); | 1630 explicit FreeList(PagedSpace* owner); |
1631 | 1631 |
1632 intptr_t Concatenate(FreeList* free_list); | 1632 intptr_t Concatenate(FreeList* free_list); |
1633 | 1633 |
1634 // Divide {this} free lists up among {other_free_lists} up to some certain | |
1635 // {limit} of bytes. Note that this operation needs to iterate over nodes | |
1636 // one-by-one, making it a potentially slow operation. | |
1637 void Divide(FreeList** other_free_lists, int num, intptr_t limit); | |
1638 | |
1634 // Clear the free list. | 1639 // Clear the free list. |
1635 void Reset(); | 1640 void Reset(); |
1636 | 1641 |
1637 // Return the number of bytes available on the free list. | 1642 // Return the number of bytes available on the free list. |
1638 intptr_t available() { | 1643 intptr_t available() { |
1639 return small_list_.available() + medium_list_.available() + | 1644 return small_list_.available() + medium_list_.available() + |
1640 large_list_.available() + huge_list_.available(); | 1645 large_list_.available() + huge_list_.available(); |
1641 } | 1646 } |
1642 | 1647 |
1643 // Place a node on the free list. The block of size 'size_in_bytes' | 1648 // Place a node on the free list. The block of size 'size_in_bytes' |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1990 inline int AreaSize() { return area_size_; } | 1995 inline int AreaSize() { return area_size_; } |
1991 | 1996 |
1992 // Merges {other} into the current space. Note that this modifies {other}, | 1997 // Merges {other} into the current space. Note that this modifies {other}, |
1993 // e.g., removes its bump pointer area and resets statistics. | 1998 // e.g., removes its bump pointer area and resets statistics. |
1994 void MergeCompactionSpace(CompactionSpace* other); | 1999 void MergeCompactionSpace(CompactionSpace* other); |
1995 | 2000 |
1996 void MoveOverFreeMemory(PagedSpace* other); | 2001 void MoveOverFreeMemory(PagedSpace* other); |
1997 | 2002 |
1998 virtual bool is_local() { return false; } | 2003 virtual bool is_local() { return false; } |
1999 | 2004 |
2005 // Adds external memory starting at {start} of {size_in_bytes} to the space. | |
2006 void AddExternalMemory(Address start, int size_in_bytes) { | |
Hannes Payer (out of office)
2015/09/23 08:47:22
Call it AddMemory, to get the naming in sync with
| |
2007 IncreaseCapacity(size_in_bytes); | |
2008 Free(start, size_in_bytes); | |
2009 } | |
2010 | |
2011 void RemoveMemory(int size) { accounting_stats_.DecreaseCapacity(size); } | |
Hannes Payer (out of office)
2015/09/23 08:47:22
To make this one dual with AddMemory, it should ac
Michael Lippautz
2015/09/23 11:49:01
Done.
| |
2012 | |
2000 protected: | 2013 protected: |
2001 // PagedSpaces that should be included in snapshots have different, i.e., | 2014 // PagedSpaces that should be included in snapshots have different, i.e., |
2002 // smaller, initial pages. | 2015 // smaller, initial pages. |
2003 virtual bool snapshotable() { return true; } | 2016 virtual bool snapshotable() { return true; } |
2004 | 2017 |
2005 FreeList* free_list() { return &free_list_; } | 2018 FreeList* free_list() { return &free_list_; } |
2006 | 2019 |
2007 bool HasPages() { return anchor_.next_page() != &anchor_; } | 2020 bool HasPages() { return anchor_.next_page() != &anchor_; } |
2008 | 2021 |
2009 // Cleans up the space, frees all pages in this space except those belonging | 2022 // Cleans up the space, frees all pages in this space except those belonging |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2737 }; | 2750 }; |
2738 | 2751 |
2739 // ----------------------------------------------------------------------------- | 2752 // ----------------------------------------------------------------------------- |
2740 // Compaction space that is used temporarily during compaction. | 2753 // Compaction space that is used temporarily during compaction. |
2741 | 2754 |
2742 class CompactionSpace : public PagedSpace { | 2755 class CompactionSpace : public PagedSpace { |
2743 public: | 2756 public: |
2744 CompactionSpace(Heap* heap, AllocationSpace id, Executability executable) | 2757 CompactionSpace(Heap* heap, AllocationSpace id, Executability executable) |
2745 : PagedSpace(heap, id, executable) {} | 2758 : PagedSpace(heap, id, executable) {} |
2746 | 2759 |
2747 // Adds external memory starting at {start} of {size_in_bytes} to the space. | |
2748 void AddExternalMemory(Address start, int size_in_bytes) { | |
2749 IncreaseCapacity(size_in_bytes); | |
2750 Free(start, size_in_bytes); | |
2751 } | |
2752 | |
2753 virtual bool is_local() { return true; } | 2760 virtual bool is_local() { return true; } |
2754 | 2761 |
2755 protected: | 2762 protected: |
2756 // The space is temporary and not included in any snapshots. | 2763 // The space is temporary and not included in any snapshots. |
2757 virtual bool snapshotable() { return false; } | 2764 virtual bool snapshotable() { return false; } |
2758 }; | 2765 }; |
2759 | 2766 |
2760 | 2767 |
2761 // A collection of |CompactionSpace|s used by a single compaction task. | 2768 // A collection of |CompactionSpace|s used by a single compaction task. |
2762 class CompactionSpaceCollection : public Malloced { | 2769 class CompactionSpaceCollection : public Malloced { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2977 count = 0; | 2984 count = 0; |
2978 } | 2985 } |
2979 // Must be small, since an iteration is used for lookup. | 2986 // Must be small, since an iteration is used for lookup. |
2980 static const int kMaxComments = 64; | 2987 static const int kMaxComments = 64; |
2981 }; | 2988 }; |
2982 #endif | 2989 #endif |
2983 } | 2990 } |
2984 } // namespace v8::internal | 2991 } // namespace v8::internal |
2985 | 2992 |
2986 #endif // V8_HEAP_SPACES_H_ | 2993 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |