| 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 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1776     accounting_stats_.DeallocateBytes(bytes); | 1776     accounting_stats_.DeallocateBytes(bytes); | 
| 1777   } | 1777   } | 
| 1778 | 1778 | 
| 1779   // Available bytes without growing.  These are the bytes on the free list. | 1779   // Available bytes without growing.  These are the bytes on the free list. | 
| 1780   // The bytes in the linear allocation area are not included in this total | 1780   // The bytes in the linear allocation area are not included in this total | 
| 1781   // because updating the stats would slow down allocation.  New pages are | 1781   // because updating the stats would slow down allocation.  New pages are | 
| 1782   // immediately added to the free list so they show up here. | 1782   // immediately added to the free list so they show up here. | 
| 1783   intptr_t Available() { return free_list_.available(); } | 1783   intptr_t Available() { return free_list_.available(); } | 
| 1784 | 1784 | 
| 1785   // Allocated bytes in this space.  Garbage bytes that were not found due to | 1785   // Allocated bytes in this space.  Garbage bytes that were not found due to | 
| 1786   // lazy sweeping are counted as being allocated!  The bytes in the current | 1786   // concurrent sweeping are counted as being allocated!  The bytes in the | 
| 1787   // linear allocation area (between top and limit) are also counted here. | 1787   // current linear allocation area (between top and limit) are also counted | 
|  | 1788   // here. | 
| 1788   virtual intptr_t Size() { return accounting_stats_.Size(); } | 1789   virtual intptr_t Size() { return accounting_stats_.Size(); } | 
| 1789 | 1790 | 
| 1790   // As size, but the bytes in lazily swept pages are estimated and the bytes | 1791   // As size, but the bytes in lazily swept pages are estimated and the bytes | 
| 1791   // in the current linear allocation area are not included. | 1792   // in the current linear allocation area are not included. | 
| 1792   virtual intptr_t SizeOfObjects(); | 1793   virtual intptr_t SizeOfObjects(); | 
| 1793 | 1794 | 
| 1794   // Wasted bytes in this space.  These are just the bytes that were thrown away | 1795   // Wasted bytes in this space.  These are just the bytes that were thrown away | 
| 1795   // due to being too small to use for allocation.  They do not include the | 1796   // due to being too small to use for allocation.  They do not include the | 
| 1796   // free bytes that were not found at all due to lazy sweeping. | 1797   // free bytes that were not found at all due to lazy sweeping. | 
| 1797   virtual intptr_t Waste() { return accounting_stats_.Waste(); } | 1798   virtual intptr_t Waste() { return accounting_stats_.Waste(); } | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1878   void CollectCodeStatistics(); | 1879   void CollectCodeStatistics(); | 
| 1879   static void ReportCodeStatistics(Isolate* isolate); | 1880   static void ReportCodeStatistics(Isolate* isolate); | 
| 1880   static void ResetCodeStatistics(Isolate* isolate); | 1881   static void ResetCodeStatistics(Isolate* isolate); | 
| 1881 #endif | 1882 #endif | 
| 1882 | 1883 | 
| 1883   bool was_swept_conservatively() { return was_swept_conservatively_; } | 1884   bool was_swept_conservatively() { return was_swept_conservatively_; } | 
| 1884   void set_was_swept_conservatively(bool b) { was_swept_conservatively_ = b; } | 1885   void set_was_swept_conservatively(bool b) { was_swept_conservatively_ = b; } | 
| 1885 | 1886 | 
| 1886   // Evacuation candidates are swept by evacuator.  Needs to return a valid | 1887   // Evacuation candidates are swept by evacuator.  Needs to return a valid | 
| 1887   // result before _and_ after evacuation has finished. | 1888   // result before _and_ after evacuation has finished. | 
| 1888   static bool ShouldBeSweptLazily(Page* p) { | 1889   static bool ShouldBeSweptBySweeperThreads(Page* p) { | 
| 1889     return !p->IsEvacuationCandidate() && | 1890     return !p->IsEvacuationCandidate() && | 
| 1890            !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && | 1891            !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && | 
| 1891            !p->WasSweptPrecisely(); | 1892            !p->WasSweptPrecisely(); | 
| 1892   } | 1893   } | 
| 1893 | 1894 | 
| 1894   void SetPagesToSweep(Page* first) { |  | 
| 1895     ASSERT(unswept_free_bytes_ == 0); |  | 
| 1896     if (first == &anchor_) first = NULL; |  | 
| 1897     first_unswept_page_ = first; |  | 
| 1898   } |  | 
| 1899 |  | 
| 1900   void IncrementUnsweptFreeBytes(intptr_t by) { | 1895   void IncrementUnsweptFreeBytes(intptr_t by) { | 
| 1901     unswept_free_bytes_ += by; | 1896     unswept_free_bytes_ += by; | 
| 1902   } | 1897   } | 
| 1903 | 1898 | 
| 1904   void IncreaseUnsweptFreeBytes(Page* p) { | 1899   void IncreaseUnsweptFreeBytes(Page* p) { | 
| 1905     ASSERT(ShouldBeSweptLazily(p)); | 1900     ASSERT(ShouldBeSweptBySweeperThreads(p)); | 
| 1906     unswept_free_bytes_ += (p->area_size() - p->LiveBytes()); | 1901     unswept_free_bytes_ += (p->area_size() - p->LiveBytes()); | 
| 1907   } | 1902   } | 
| 1908 | 1903 | 
| 1909   void DecrementUnsweptFreeBytes(intptr_t by) { | 1904   void DecrementUnsweptFreeBytes(intptr_t by) { | 
| 1910     unswept_free_bytes_ -= by; | 1905     unswept_free_bytes_ -= by; | 
| 1911   } | 1906   } | 
| 1912 | 1907 | 
| 1913   void DecreaseUnsweptFreeBytes(Page* p) { | 1908   void DecreaseUnsweptFreeBytes(Page* p) { | 
| 1914     ASSERT(ShouldBeSweptLazily(p)); | 1909     ASSERT(ShouldBeSweptBySweeperThreads(p)); | 
| 1915     unswept_free_bytes_ -= (p->area_size() - p->LiveBytes()); | 1910     unswept_free_bytes_ -= (p->area_size() - p->LiveBytes()); | 
| 1916   } | 1911   } | 
| 1917 | 1912 | 
| 1918   void ResetUnsweptFreeBytes() { | 1913   void ResetUnsweptFreeBytes() { | 
| 1919     unswept_free_bytes_ = 0; | 1914     unswept_free_bytes_ = 0; | 
| 1920   } | 1915   } | 
| 1921 | 1916 | 
| 1922   bool AdvanceSweeper(intptr_t bytes_to_sweep); | 1917   // This function tries to steal size_in_bytes memory from the sweeper threads | 
| 1923 | 1918   // free-lists. If it does not succeed stealing enough memory, it will wait | 
| 1924   // When parallel sweeper threads are active and the main thread finished | 1919   // for the sweeper threads to finish sweeping. | 
| 1925   // its sweeping phase, this function waits for them to complete, otherwise | 1920   // It returns true when sweeping is completed and false otherwise. | 
| 1926   // AdvanceSweeper with size_in_bytes is called. |  | 
| 1927   bool EnsureSweeperProgress(intptr_t size_in_bytes); | 1921   bool EnsureSweeperProgress(intptr_t size_in_bytes); | 
| 1928 | 1922 | 
| 1929   bool IsLazySweepingComplete() { |  | 
| 1930     return !first_unswept_page_->is_valid(); |  | 
| 1931   } |  | 
| 1932 |  | 
| 1933   Page* FirstPage() { return anchor_.next_page(); } | 1923   Page* FirstPage() { return anchor_.next_page(); } | 
| 1934   Page* LastPage() { return anchor_.prev_page(); } | 1924   Page* LastPage() { return anchor_.prev_page(); } | 
| 1935 | 1925 | 
| 1936   void EvictEvacuationCandidatesFromFreeLists(); | 1926   void EvictEvacuationCandidatesFromFreeLists(); | 
| 1937 | 1927 | 
| 1938   bool CanExpand(); | 1928   bool CanExpand(); | 
| 1939 | 1929 | 
| 1940   // Returns the number of total pages in this space. | 1930   // Returns the number of total pages in this space. | 
| 1941   int CountTotalPages(); | 1931   int CountTotalPages(); | 
| 1942 | 1932 | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 1962   Page anchor_; | 1952   Page anchor_; | 
| 1963 | 1953 | 
| 1964   // The space's free list. | 1954   // The space's free list. | 
| 1965   FreeList free_list_; | 1955   FreeList free_list_; | 
| 1966 | 1956 | 
| 1967   // Normal allocation information. | 1957   // Normal allocation information. | 
| 1968   AllocationInfo allocation_info_; | 1958   AllocationInfo allocation_info_; | 
| 1969 | 1959 | 
| 1970   bool was_swept_conservatively_; | 1960   bool was_swept_conservatively_; | 
| 1971 | 1961 | 
| 1972   // The first page to be swept when the lazy sweeper advances. Is set |  | 
| 1973   // to NULL when all pages have been swept. |  | 
| 1974   Page* first_unswept_page_; |  | 
| 1975 |  | 
| 1976   // The number of free bytes which could be reclaimed by advancing the | 1962   // The number of free bytes which could be reclaimed by advancing the | 
| 1977   // lazy sweeper.  This is only an estimation because lazy sweeping is | 1963   // concurrent sweeper threads.  This is only an estimation because concurrent | 
| 1978   // done conservatively. | 1964   // sweeping is done conservatively. | 
| 1979   intptr_t unswept_free_bytes_; | 1965   intptr_t unswept_free_bytes_; | 
| 1980 | 1966 | 
| 1981   // Expands the space by allocating a fixed number of pages. Returns false if | 1967   // Expands the space by allocating a fixed number of pages. Returns false if | 
| 1982   // it cannot allocate requested number of pages from OS, or if the hard heap | 1968   // it cannot allocate requested number of pages from OS, or if the hard heap | 
| 1983   // size limit has been hit. | 1969   // size limit has been hit. | 
| 1984   bool Expand(); | 1970   bool Expand(); | 
| 1985 | 1971 | 
| 1986   // Generic fast case allocation function that tries linear allocation at the | 1972   // Generic fast case allocation function that tries linear allocation at the | 
| 1987   // address denoted by top in allocation_info_. | 1973   // address denoted by top in allocation_info_. | 
| 1988   inline HeapObject* AllocateLinearly(int size_in_bytes); | 1974   inline HeapObject* AllocateLinearly(int size_in_bytes); | 
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2980   } | 2966   } | 
| 2981   // Must be small, since an iteration is used for lookup. | 2967   // Must be small, since an iteration is used for lookup. | 
| 2982   static const int kMaxComments = 64; | 2968   static const int kMaxComments = 64; | 
| 2983 }; | 2969 }; | 
| 2984 #endif | 2970 #endif | 
| 2985 | 2971 | 
| 2986 | 2972 | 
| 2987 } }  // namespace v8::internal | 2973 } }  // namespace v8::internal | 
| 2988 | 2974 | 
| 2989 #endif  // V8_SPACES_H_ | 2975 #endif  // V8_SPACES_H_ | 
| OLD | NEW | 
|---|