| 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 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 | 1761 |
| 1762 // The allocation limit address. | 1762 // The allocation limit address. |
| 1763 Address* allocation_limit_address() { | 1763 Address* allocation_limit_address() { |
| 1764 return allocation_info_.limit_address(); | 1764 return allocation_info_.limit_address(); |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 // Allocate the requested number of bytes in the space if possible, return a | 1767 // Allocate the requested number of bytes in the space if possible, return a |
| 1768 // failure object if not. | 1768 // failure object if not. |
| 1769 MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes); | 1769 MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes); |
| 1770 | 1770 |
| 1771 virtual bool ReserveSpace(int bytes); | |
| 1772 | |
| 1773 // Give a block of memory to the space's free list. It might be added to | 1771 // Give a block of memory to the space's free list. It might be added to |
| 1774 // the free list or accounted as waste. | 1772 // the free list or accounted as waste. |
| 1775 // If add_to_freelist is false then just accounting stats are updated and | 1773 // If add_to_freelist is false then just accounting stats are updated and |
| 1776 // no attempt to add area to free list is made. | 1774 // no attempt to add area to free list is made. |
| 1777 int Free(Address start, int size_in_bytes) { | 1775 int Free(Address start, int size_in_bytes) { |
| 1778 int wasted = free_list_.Free(start, size_in_bytes); | 1776 int wasted = free_list_.Free(start, size_in_bytes); |
| 1779 accounting_stats_.DeallocateBytes(size_in_bytes - wasted); | 1777 accounting_stats_.DeallocateBytes(size_in_bytes - wasted); |
| 1780 return size_in_bytes - wasted; | 1778 return size_in_bytes - wasted; |
| 1781 } | 1779 } |
| 1782 | 1780 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; | 2158 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; |
| 2161 } | 2159 } |
| 2162 | 2160 |
| 2163 // If we don't have these here then SemiSpace will be abstract. However | 2161 // If we don't have these here then SemiSpace will be abstract. However |
| 2164 // they should never be called. | 2162 // they should never be called. |
| 2165 virtual intptr_t Size() { | 2163 virtual intptr_t Size() { |
| 2166 UNREACHABLE(); | 2164 UNREACHABLE(); |
| 2167 return 0; | 2165 return 0; |
| 2168 } | 2166 } |
| 2169 | 2167 |
| 2170 virtual bool ReserveSpace(int bytes) { | |
| 2171 UNREACHABLE(); | |
| 2172 return false; | |
| 2173 } | |
| 2174 | |
| 2175 bool is_committed() { return committed_; } | 2168 bool is_committed() { return committed_; } |
| 2176 bool Commit(); | 2169 bool Commit(); |
| 2177 bool Uncommit(); | 2170 bool Uncommit(); |
| 2178 | 2171 |
| 2179 NewSpacePage* first_page() { return anchor_.next_page(); } | 2172 NewSpacePage* first_page() { return anchor_.next_page(); } |
| 2180 NewSpacePage* current_page() { return current_page_; } | 2173 NewSpacePage* current_page() { return current_page_; } |
| 2181 | 2174 |
| 2182 #ifdef VERIFY_HEAP | 2175 #ifdef VERIFY_HEAP |
| 2183 virtual void Verify(); | 2176 virtual void Verify(); |
| 2184 #endif | 2177 #endif |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2528 // semispace). | 2521 // semispace). |
| 2529 inline bool ToSpaceContains(Object* o) { return to_space_.Contains(o); } | 2522 inline bool ToSpaceContains(Object* o) { return to_space_.Contains(o); } |
| 2530 inline bool FromSpaceContains(Object* o) { return from_space_.Contains(o); } | 2523 inline bool FromSpaceContains(Object* o) { return from_space_.Contains(o); } |
| 2531 | 2524 |
| 2532 // Try to switch the active semispace to a new, empty, page. | 2525 // Try to switch the active semispace to a new, empty, page. |
| 2533 // Returns false if this isn't possible or reasonable (i.e., there | 2526 // Returns false if this isn't possible or reasonable (i.e., there |
| 2534 // are no pages, or the current page is already empty), or true | 2527 // are no pages, or the current page is already empty), or true |
| 2535 // if successful. | 2528 // if successful. |
| 2536 bool AddFreshPage(); | 2529 bool AddFreshPage(); |
| 2537 | 2530 |
| 2538 virtual bool ReserveSpace(int bytes); | |
| 2539 | |
| 2540 #ifdef VERIFY_HEAP | 2531 #ifdef VERIFY_HEAP |
| 2541 // Verify the active semispace. | 2532 // Verify the active semispace. |
| 2542 virtual void Verify(); | 2533 virtual void Verify(); |
| 2543 #endif | 2534 #endif |
| 2544 | 2535 |
| 2545 #ifdef DEBUG | 2536 #ifdef DEBUG |
| 2546 // Print the active semispace. | 2537 // Print the active semispace. |
| 2547 virtual void Print() { to_space_.Print(); } | 2538 virtual void Print() { to_space_.Print(); } |
| 2548 #endif | 2539 #endif |
| 2549 | 2540 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 | 2833 |
| 2843 // Frees unmarked objects. | 2834 // Frees unmarked objects. |
| 2844 void FreeUnmarkedObjects(); | 2835 void FreeUnmarkedObjects(); |
| 2845 | 2836 |
| 2846 // Checks whether a heap object is in this space; O(1). | 2837 // Checks whether a heap object is in this space; O(1). |
| 2847 bool Contains(HeapObject* obj); | 2838 bool Contains(HeapObject* obj); |
| 2848 | 2839 |
| 2849 // Checks whether the space is empty. | 2840 // Checks whether the space is empty. |
| 2850 bool IsEmpty() { return first_page_ == NULL; } | 2841 bool IsEmpty() { return first_page_ == NULL; } |
| 2851 | 2842 |
| 2852 // See the comments for ReserveSpace in the Space class. This has to be | |
| 2853 // called after ReserveSpace has been called on the paged spaces, since they | |
| 2854 // may use some memory, leaving less for large objects. | |
| 2855 virtual bool ReserveSpace(int bytes); | |
| 2856 | |
| 2857 LargePage* first_page() { return first_page_; } | 2843 LargePage* first_page() { return first_page_; } |
| 2858 | 2844 |
| 2859 #ifdef VERIFY_HEAP | 2845 #ifdef VERIFY_HEAP |
| 2860 virtual void Verify(); | 2846 virtual void Verify(); |
| 2861 #endif | 2847 #endif |
| 2862 | 2848 |
| 2863 #ifdef DEBUG | 2849 #ifdef DEBUG |
| 2864 virtual void Print(); | 2850 virtual void Print(); |
| 2865 void ReportStatistics(); | 2851 void ReportStatistics(); |
| 2866 void CollectCodeStatistics(); | 2852 void CollectCodeStatistics(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2976 } | 2962 } |
| 2977 // Must be small, since an iteration is used for lookup. | 2963 // Must be small, since an iteration is used for lookup. |
| 2978 static const int kMaxComments = 64; | 2964 static const int kMaxComments = 64; |
| 2979 }; | 2965 }; |
| 2980 #endif | 2966 #endif |
| 2981 | 2967 |
| 2982 | 2968 |
| 2983 } } // namespace v8::internal | 2969 } } // namespace v8::internal |
| 2984 | 2970 |
| 2985 #endif // V8_SPACES_H_ | 2971 #endif // V8_SPACES_H_ |
| OLD | NEW |