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 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 virtual intptr_t Waste() { return accounting_stats_.Waste(); } | 1707 virtual intptr_t Waste() { return accounting_stats_.Waste(); } |
1708 | 1708 |
1709 // Returns the allocation pointer in this space. | 1709 // Returns the allocation pointer in this space. |
1710 Address top() { return allocation_info_.top; } | 1710 Address top() { return allocation_info_.top; } |
1711 Address limit() { return allocation_info_.limit; } | 1711 Address limit() { return allocation_info_.limit; } |
1712 | 1712 |
1713 // The allocation top and limit addresses. | 1713 // The allocation top and limit addresses. |
1714 Address* allocation_top_address() { return &allocation_info_.top; } | 1714 Address* allocation_top_address() { return &allocation_info_.top; } |
1715 Address* allocation_limit_address() { return &allocation_info_.limit; } | 1715 Address* allocation_limit_address() { return &allocation_info_.limit; } |
1716 | 1716 |
| 1717 enum AllocationType { |
| 1718 NEW_OBJECT, |
| 1719 MOVE_OBJECT |
| 1720 }; |
| 1721 |
1717 // Allocate the requested number of bytes in the space if possible, return a | 1722 // Allocate the requested number of bytes in the space if possible, return a |
1718 // failure object if not. | 1723 // failure object if not. |
1719 MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes); | 1724 MUST_USE_RESULT inline MaybeObject* AllocateRaw( |
| 1725 int size_in_bytes, |
| 1726 AllocationType event = NEW_OBJECT); |
1720 | 1727 |
1721 virtual bool ReserveSpace(int bytes); | 1728 virtual bool ReserveSpace(int bytes); |
1722 | 1729 |
1723 // Give a block of memory to the space's free list. It might be added to | 1730 // Give a block of memory to the space's free list. It might be added to |
1724 // the free list or accounted as waste. | 1731 // the free list or accounted as waste. |
1725 // If add_to_freelist is false then just accounting stats are updated and | 1732 // If add_to_freelist is false then just accounting stats are updated and |
1726 // no attempt to add area to free list is made. | 1733 // no attempt to add area to free list is made. |
1727 int Free(Address start, int size_in_bytes) { | 1734 int Free(Address start, int size_in_bytes) { |
1728 int wasted = free_list_.Free(start, size_in_bytes); | 1735 int wasted = free_list_.Free(start, size_in_bytes); |
1729 accounting_stats_.DeallocateBytes(size_in_bytes - wasted); | 1736 accounting_stats_.DeallocateBytes(size_in_bytes - wasted); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 | 1897 |
1891 // Generic fast case allocation function that tries linear allocation at the | 1898 // Generic fast case allocation function that tries linear allocation at the |
1892 // address denoted by top in allocation_info_. | 1899 // address denoted by top in allocation_info_. |
1893 inline HeapObject* AllocateLinearly(int size_in_bytes); | 1900 inline HeapObject* AllocateLinearly(int size_in_bytes); |
1894 | 1901 |
1895 // Slow path of AllocateRaw. This function is space-dependent. | 1902 // Slow path of AllocateRaw. This function is space-dependent. |
1896 MUST_USE_RESULT virtual HeapObject* SlowAllocateRaw(int size_in_bytes); | 1903 MUST_USE_RESULT virtual HeapObject* SlowAllocateRaw(int size_in_bytes); |
1897 | 1904 |
1898 friend class PageIterator; | 1905 friend class PageIterator; |
1899 friend class SweeperThread; | 1906 friend class SweeperThread; |
| 1907 |
| 1908 private: |
| 1909 inline HeapObject* AllocateRawHelper(int size_in_bytes); |
1900 }; | 1910 }; |
1901 | 1911 |
1902 | 1912 |
1903 class NumberAndSizeInfo BASE_EMBEDDED { | 1913 class NumberAndSizeInfo BASE_EMBEDDED { |
1904 public: | 1914 public: |
1905 NumberAndSizeInfo() : number_(0), bytes_(0) {} | 1915 NumberAndSizeInfo() : number_(0), bytes_(0) {} |
1906 | 1916 |
1907 int number() const { return number_; } | 1917 int number() const { return number_; } |
1908 void increment_number(int num) { number_ += num; } | 1918 void increment_number(int num) { number_ += num; } |
1909 | 1919 |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 } | 2906 } |
2897 // Must be small, since an iteration is used for lookup. | 2907 // Must be small, since an iteration is used for lookup. |
2898 static const int kMaxComments = 64; | 2908 static const int kMaxComments = 64; |
2899 }; | 2909 }; |
2900 #endif | 2910 #endif |
2901 | 2911 |
2902 | 2912 |
2903 } } // namespace v8::internal | 2913 } } // namespace v8::internal |
2904 | 2914 |
2905 #endif // V8_SPACES_H_ | 2915 #endif // V8_SPACES_H_ |
OLD | NEW |