Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/spaces.h

Issue 5188006: Push version 2.5.7 to trunk.... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/serialize.cc ('k') | src/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 : id_(id), executable_(executable) {} 364 : id_(id), executable_(executable) {}
365 365
366 virtual ~Space() {} 366 virtual ~Space() {}
367 367
368 // Does the space need executable memory? 368 // Does the space need executable memory?
369 Executability executable() { return executable_; } 369 Executability executable() { return executable_; }
370 370
371 // Identity used in error reporting. 371 // Identity used in error reporting.
372 AllocationSpace identity() { return id_; } 372 AllocationSpace identity() { return id_; }
373 373
374 // Returns allocated size.
374 virtual intptr_t Size() = 0; 375 virtual intptr_t Size() = 0;
375 376
377 // Returns size of objects. Can differ from the allocated size
378 // (e.g. see LargeObjectSpace).
379 virtual intptr_t SizeOfObjects() { return Size(); }
380
376 #ifdef ENABLE_HEAP_PROTECTION 381 #ifdef ENABLE_HEAP_PROTECTION
377 // Protect/unprotect the space by marking it read-only/writable. 382 // Protect/unprotect the space by marking it read-only/writable.
378 virtual void Protect() = 0; 383 virtual void Protect() = 0;
379 virtual void Unprotect() = 0; 384 virtual void Unprotect() = 0;
380 #endif 385 #endif
381 386
382 #ifdef DEBUG 387 #ifdef DEBUG
383 virtual void Print() = 0; 388 virtual void Print() = 0;
384 #endif 389 #endif
385 390
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 589
585 // Returns the maximum available bytes of heaps. 590 // Returns the maximum available bytes of heaps.
586 static intptr_t Available() { 591 static intptr_t Available() {
587 return capacity_ < size_ ? 0 : capacity_ - size_; 592 return capacity_ < size_ ? 0 : capacity_ - size_;
588 } 593 }
589 594
590 // Returns allocated spaces in bytes. 595 // Returns allocated spaces in bytes.
591 static intptr_t Size() { return size_; } 596 static intptr_t Size() { return size_; }
592 597
593 // Returns the maximum available executable bytes of heaps. 598 // Returns the maximum available executable bytes of heaps.
594 static int AvailableExecutable() { 599 static intptr_t AvailableExecutable() {
595 if (capacity_executable_ < size_executable_) return 0; 600 if (capacity_executable_ < size_executable_) return 0;
596 return capacity_executable_ - size_executable_; 601 return capacity_executable_ - size_executable_;
597 } 602 }
598 603
599 // Returns allocated executable spaces in bytes. 604 // Returns allocated executable spaces in bytes.
600 static intptr_t SizeExecutable() { return size_executable_; } 605 static intptr_t SizeExecutable() { return size_executable_; }
601 606
602 // Returns maximum available bytes that the old space can have. 607 // Returns maximum available bytes that the old space can have.
603 static intptr_t MaxAvailable() { 608 static intptr_t MaxAvailable() {
604 return (Available() / Page::kPageSize) * Page::kObjectAreaSize; 609 return (Available() / Page::kPageSize) * Page::kObjectAreaSize;
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 // ie, its contents will be destroyed. The start address should be word 1713 // ie, its contents will be destroyed. The start address should be word
1709 // aligned, and the size should be a non-zero multiple of the word size. 1714 // aligned, and the size should be a non-zero multiple of the word size.
1710 int Free(Address start, int size_in_bytes); 1715 int Free(Address start, int size_in_bytes);
1711 1716
1712 // Allocate a block of size 'size_in_bytes' from the free list. The block 1717 // Allocate a block of size 'size_in_bytes' from the free list. The block
1713 // is unitialized. A failure is returned if no block is available. The 1718 // is unitialized. A failure is returned if no block is available. The
1714 // number of bytes lost to fragmentation is returned in the output parameter 1719 // number of bytes lost to fragmentation is returned in the output parameter
1715 // 'wasted_bytes'. The size should be a non-zero multiple of the word size. 1720 // 'wasted_bytes'. The size should be a non-zero multiple of the word size.
1716 MUST_USE_RESULT MaybeObject* Allocate(int size_in_bytes, int* wasted_bytes); 1721 MUST_USE_RESULT MaybeObject* Allocate(int size_in_bytes, int* wasted_bytes);
1717 1722
1723 void MarkNodes();
1724
1718 private: 1725 private:
1719 // The size range of blocks, in bytes. (Smaller allocations are allowed, but 1726 // The size range of blocks, in bytes. (Smaller allocations are allowed, but
1720 // will always result in waste.) 1727 // will always result in waste.)
1721 static const int kMinBlockSize = 2 * kPointerSize; 1728 static const int kMinBlockSize = 2 * kPointerSize;
1722 static const int kMaxBlockSize = Page::kMaxHeapObjectSize; 1729 static const int kMaxBlockSize = Page::kMaxHeapObjectSize;
1723 1730
1724 // The identity of the owning space, for building allocation Failure 1731 // The identity of the owning space, for building allocation Failure
1725 // objects. 1732 // objects.
1726 AllocationSpace owner_; 1733 AllocationSpace owner_;
1727 1734
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 // Place a node on the free list. The block starting at 'start' (assumed to 1813 // Place a node on the free list. The block starting at 'start' (assumed to
1807 // have size object_size_) is placed on the free list. Bookkeeping 1814 // have size object_size_) is placed on the free list. Bookkeeping
1808 // information will be written to the block, ie, its contents will be 1815 // information will be written to the block, ie, its contents will be
1809 // destroyed. The start address should be word aligned. 1816 // destroyed. The start address should be word aligned.
1810 void Free(Address start); 1817 void Free(Address start);
1811 1818
1812 // Allocate a fixed sized block from the free list. The block is unitialized. 1819 // Allocate a fixed sized block from the free list. The block is unitialized.
1813 // A failure is returned if no block is available. 1820 // A failure is returned if no block is available.
1814 MUST_USE_RESULT MaybeObject* Allocate(); 1821 MUST_USE_RESULT MaybeObject* Allocate();
1815 1822
1823 void MarkNodes();
1824
1816 private: 1825 private:
1817 // Available bytes on the free list. 1826 // Available bytes on the free list.
1818 intptr_t available_; 1827 intptr_t available_;
1819 1828
1820 // The head of the free list. 1829 // The head of the free list.
1821 Address head_; 1830 Address head_;
1822 1831
1823 // The tail of the free list. 1832 // The tail of the free list.
1824 Address tail_; 1833 Address tail_;
1825 1834
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 // Prepare for full garbage collection. Resets the relocation pointer and 1886 // Prepare for full garbage collection. Resets the relocation pointer and
1878 // clears the free list. 1887 // clears the free list.
1879 virtual void PrepareForMarkCompact(bool will_compact); 1888 virtual void PrepareForMarkCompact(bool will_compact);
1880 1889
1881 // Updates the allocation pointer to the relocation top after a mark-compact 1890 // Updates the allocation pointer to the relocation top after a mark-compact
1882 // collection. 1891 // collection.
1883 virtual void MCCommitRelocationInfo(); 1892 virtual void MCCommitRelocationInfo();
1884 1893
1885 virtual void PutRestOfCurrentPageOnFreeList(Page* current_page); 1894 virtual void PutRestOfCurrentPageOnFreeList(Page* current_page);
1886 1895
1896 void MarkFreeListNodes() { free_list_.MarkNodes(); }
1897
1887 #ifdef DEBUG 1898 #ifdef DEBUG
1888 // Reports statistics for the space 1899 // Reports statistics for the space
1889 void ReportStatistics(); 1900 void ReportStatistics();
1890 #endif 1901 #endif
1891 1902
1892 protected: 1903 protected:
1893 // Virtual function in the superclass. Slow path of AllocateRaw. 1904 // Virtual function in the superclass. Slow path of AllocateRaw.
1894 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); 1905 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes);
1895 1906
1896 // Virtual function in the superclass. Allocate linearly at the start of 1907 // Virtual function in the superclass. Allocate linearly at the start of
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 1955
1945 // Updates the allocation pointer to the relocation top after a mark-compact 1956 // Updates the allocation pointer to the relocation top after a mark-compact
1946 // collection. 1957 // collection.
1947 virtual void MCCommitRelocationInfo(); 1958 virtual void MCCommitRelocationInfo();
1948 1959
1949 virtual void PutRestOfCurrentPageOnFreeList(Page* current_page); 1960 virtual void PutRestOfCurrentPageOnFreeList(Page* current_page);
1950 1961
1951 virtual void DeallocateBlock(Address start, 1962 virtual void DeallocateBlock(Address start,
1952 int size_in_bytes, 1963 int size_in_bytes,
1953 bool add_to_freelist); 1964 bool add_to_freelist);
1965
1966 void MarkFreeListNodes() { free_list_.MarkNodes(); }
1967
1954 #ifdef DEBUG 1968 #ifdef DEBUG
1955 // Reports statistic info of the space 1969 // Reports statistic info of the space
1956 void ReportStatistics(); 1970 void ReportStatistics();
1957 #endif 1971 #endif
1958 1972
1959 protected: 1973 protected:
1960 // Virtual function in the superclass. Slow path of AllocateRaw. 1974 // Virtual function in the superclass. Slow path of AllocateRaw.
1961 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); 1975 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes);
1962 1976
1963 // Virtual function in the superclass. Allocate linearly at the start of 1977 // Virtual function in the superclass. Allocate linearly at the start of
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 2198
2185 // Available bytes for objects in this space. 2199 // Available bytes for objects in this space.
2186 intptr_t Available() { 2200 intptr_t Available() {
2187 return LargeObjectChunk::ObjectSizeFor(MemoryAllocator::Available()); 2201 return LargeObjectChunk::ObjectSizeFor(MemoryAllocator::Available());
2188 } 2202 }
2189 2203
2190 virtual intptr_t Size() { 2204 virtual intptr_t Size() {
2191 return size_; 2205 return size_;
2192 } 2206 }
2193 2207
2208 virtual intptr_t SizeOfObjects() {
2209 return objects_size_;
2210 }
2211
2194 int PageCount() { 2212 int PageCount() {
2195 return page_count_; 2213 return page_count_;
2196 } 2214 }
2197 2215
2198 // Finds an object for a given address, returns Failure::Exception() 2216 // Finds an object for a given address, returns Failure::Exception()
2199 // if it is not found. The function iterates through all objects in this 2217 // if it is not found. The function iterates through all objects in this
2200 // space, may be slow. 2218 // space, may be slow.
2201 MaybeObject* FindObject(Address a); 2219 MaybeObject* FindObject(Address a);
2202 2220
2203 // Finds a large object page containing the given pc, returns NULL 2221 // Finds a large object page containing the given pc, returns NULL
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 #endif 2253 #endif
2236 // Checks whether an address is in the object area in this space. It 2254 // Checks whether an address is in the object area in this space. It
2237 // iterates all objects in the space. May be slow. 2255 // iterates all objects in the space. May be slow.
2238 bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); } 2256 bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); }
2239 2257
2240 private: 2258 private:
2241 // The head of the linked list of large object chunks. 2259 // The head of the linked list of large object chunks.
2242 LargeObjectChunk* first_chunk_; 2260 LargeObjectChunk* first_chunk_;
2243 intptr_t size_; // allocated bytes 2261 intptr_t size_; // allocated bytes
2244 int page_count_; // number of chunks 2262 int page_count_; // number of chunks
2245 2263 intptr_t objects_size_; // size of objects
2246 2264
2247 // Shared implementation of AllocateRaw, AllocateRawCode and 2265 // Shared implementation of AllocateRaw, AllocateRawCode and
2248 // AllocateRawFixedArray. 2266 // AllocateRawFixedArray.
2249 MUST_USE_RESULT MaybeObject* AllocateRawInternal(int requested_size, 2267 MUST_USE_RESULT MaybeObject* AllocateRawInternal(int requested_size,
2250 int object_size, 2268 int object_size,
2251 Executability executable); 2269 Executability executable);
2252 2270
2253 friend class LargeObjectIterator; 2271 friend class LargeObjectIterator;
2254 2272
2255 public: 2273 public:
(...skipping 13 matching lines...) Expand all
2269 2287
2270 private: 2288 private:
2271 LargeObjectChunk* current_; 2289 LargeObjectChunk* current_;
2272 HeapObjectCallback size_func_; 2290 HeapObjectCallback size_func_;
2273 }; 2291 };
2274 2292
2275 2293
2276 } } // namespace v8::internal 2294 } } // namespace v8::internal
2277 2295
2278 #endif // V8_SPACES_H_ 2296 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698