OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 | 1715 |
1716 // Cleans up the space, frees all pages in this space except those belonging | 1716 // Cleans up the space, frees all pages in this space except those belonging |
1717 // to the initial chunk, uncommits addresses in the initial chunk. | 1717 // to the initial chunk, uncommits addresses in the initial chunk. |
1718 void TearDown(); | 1718 void TearDown(); |
1719 | 1719 |
1720 // Checks whether an object/address is in this space. | 1720 // Checks whether an object/address is in this space. |
1721 inline bool Contains(Address a); | 1721 inline bool Contains(Address a); |
1722 bool Contains(HeapObject* o) { return Contains(o->address()); } | 1722 bool Contains(HeapObject* o) { return Contains(o->address()); } |
1723 | 1723 |
1724 // Given an address occupied by a live object, return that object if it is | 1724 // Given an address occupied by a live object, return that object if it is |
1725 // in this space, or Failure::Exception() if it is not. The implementation | 1725 // in this space, or a Smi if it is not. The implementation iterates over |
1726 // iterates over objects in the page containing the address, the cost is | 1726 // objects in the page containing the address, the cost is linear in the |
1727 // linear in the number of objects in the page. It may be slow. | 1727 // number of objects in the page. It may be slow. |
1728 MUST_USE_RESULT MaybeObject* FindObject(Address addr); | 1728 Object* FindObject(Address addr); |
1729 | 1729 |
1730 // During boot the free_space_map is created, and afterwards we may need | 1730 // During boot the free_space_map is created, and afterwards we may need |
1731 // to write it into the free list nodes that were already created. | 1731 // to write it into the free list nodes that were already created. |
1732 void RepairFreeListsAfterBoot(); | 1732 void RepairFreeListsAfterBoot(); |
1733 | 1733 |
1734 // Prepares for a mark-compact GC. | 1734 // Prepares for a mark-compact GC. |
1735 void PrepareForMarkCompact(); | 1735 void PrepareForMarkCompact(); |
1736 | 1736 |
1737 // Current capacity without growing (Size() + Available()). | 1737 // Current capacity without growing (Size() + Available()). |
1738 intptr_t Capacity() { return accounting_stats_.Capacity(); } | 1738 intptr_t Capacity() { return accounting_stats_.Capacity(); } |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2834 return Size(); | 2834 return Size(); |
2835 } | 2835 } |
2836 | 2836 |
2837 // Approximate amount of physical memory committed for this space. | 2837 // Approximate amount of physical memory committed for this space. |
2838 size_t CommittedPhysicalMemory(); | 2838 size_t CommittedPhysicalMemory(); |
2839 | 2839 |
2840 int PageCount() { | 2840 int PageCount() { |
2841 return page_count_; | 2841 return page_count_; |
2842 } | 2842 } |
2843 | 2843 |
2844 // Finds an object for a given address, returns Failure::Exception() | 2844 // Finds an object for a given address, returns a Smi if it is not found. |
2845 // if it is not found. The function iterates through all objects in this | 2845 // The function iterates through all objects in this space, may be slow. |
2846 // space, may be slow. | 2846 Object* FindObject(Address a); |
2847 MaybeObject* FindObject(Address a); | |
2848 | 2847 |
2849 // Finds a large object page containing the given address, returns NULL | 2848 // Finds a large object page containing the given address, returns NULL |
2850 // if such a page doesn't exist. | 2849 // if such a page doesn't exist. |
2851 LargePage* FindPage(Address a); | 2850 LargePage* FindPage(Address a); |
2852 | 2851 |
2853 // Frees unmarked objects. | 2852 // Frees unmarked objects. |
2854 void FreeUnmarkedObjects(); | 2853 void FreeUnmarkedObjects(); |
2855 | 2854 |
2856 // Checks whether a heap object is in this space; O(1). | 2855 // Checks whether a heap object is in this space; O(1). |
2857 bool Contains(HeapObject* obj); | 2856 bool Contains(HeapObject* obj); |
2858 | 2857 |
2859 // Checks whether the space is empty. | 2858 // Checks whether the space is empty. |
2860 bool IsEmpty() { return first_page_ == NULL; } | 2859 bool IsEmpty() { return first_page_ == NULL; } |
2861 | 2860 |
2862 LargePage* first_page() { return first_page_; } | 2861 LargePage* first_page() { return first_page_; } |
2863 | 2862 |
2864 #ifdef VERIFY_HEAP | 2863 #ifdef VERIFY_HEAP |
2865 virtual void Verify(); | 2864 virtual void Verify(); |
2866 #endif | 2865 #endif |
2867 | 2866 |
2868 #ifdef DEBUG | 2867 #ifdef DEBUG |
2869 virtual void Print(); | 2868 virtual void Print(); |
2870 void ReportStatistics(); | 2869 void ReportStatistics(); |
2871 void CollectCodeStatistics(); | 2870 void CollectCodeStatistics(); |
2872 #endif | 2871 #endif |
2873 // Checks whether an address is in the object area in this space. It | 2872 // Checks whether an address is in the object area in this space. It |
2874 // iterates all objects in the space. May be slow. | 2873 // iterates all objects in the space. May be slow. |
2875 bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); } | 2874 bool SlowContains(Address addr) { return FindObject(addr)->IsHeapObject(); } |
2876 | 2875 |
2877 private: | 2876 private: |
2878 intptr_t max_capacity_; | 2877 intptr_t max_capacity_; |
2879 intptr_t maximum_committed_; | 2878 intptr_t maximum_committed_; |
2880 // The head of the linked list of large object chunks. | 2879 // The head of the linked list of large object chunks. |
2881 LargePage* first_page_; | 2880 LargePage* first_page_; |
2882 intptr_t size_; // allocated bytes | 2881 intptr_t size_; // allocated bytes |
2883 int page_count_; // number of chunks | 2882 int page_count_; // number of chunks |
2884 intptr_t objects_size_; // size of objects | 2883 intptr_t objects_size_; // size of objects |
2885 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them | 2884 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2981 } | 2980 } |
2982 // Must be small, since an iteration is used for lookup. | 2981 // Must be small, since an iteration is used for lookup. |
2983 static const int kMaxComments = 64; | 2982 static const int kMaxComments = 64; |
2984 }; | 2983 }; |
2985 #endif | 2984 #endif |
2986 | 2985 |
2987 | 2986 |
2988 } } // namespace v8::internal | 2987 } } // namespace v8::internal |
2989 | 2988 |
2990 #endif // V8_SPACES_H_ | 2989 #endif // V8_SPACES_H_ |
OLD | NEW |