| 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 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 bool Contains(HeapObject* o) { return Contains(o->address()); } | 1676 bool Contains(HeapObject* o) { return Contains(o->address()); } |
| 1677 | 1677 |
| 1678 // Given an address occupied by a live object, return that object if it is | 1678 // Given an address occupied by a live object, return that object if it is |
| 1679 // in this space, or Failure::Exception() if it is not. The implementation | 1679 // in this space, or Failure::Exception() if it is not. The implementation |
| 1680 // iterates over objects in the page containing the address, the cost is | 1680 // iterates over objects in the page containing the address, the cost is |
| 1681 // linear in the number of objects in the page. It may be slow. | 1681 // linear in the number of objects in the page. It may be slow. |
| 1682 MUST_USE_RESULT MaybeObject* FindObject(Address addr); | 1682 MUST_USE_RESULT MaybeObject* FindObject(Address addr); |
| 1683 | 1683 |
| 1684 // During boot the free_space_map is created, and afterwards we may need | 1684 // During boot the free_space_map is created, and afterwards we may need |
| 1685 // to write it into the free list nodes that were already created. | 1685 // to write it into the free list nodes that were already created. |
| 1686 virtual void RepairFreeListsAfterBoot(); | 1686 void RepairFreeListsAfterBoot(); |
| 1687 | 1687 |
| 1688 // Prepares for a mark-compact GC. | 1688 // Prepares for a mark-compact GC. |
| 1689 virtual void PrepareForMarkCompact(); | 1689 void PrepareForMarkCompact(); |
| 1690 | 1690 |
| 1691 // Current capacity without growing (Size() + Available()). | 1691 // Current capacity without growing (Size() + Available()). |
| 1692 intptr_t Capacity() { return accounting_stats_.Capacity(); } | 1692 intptr_t Capacity() { return accounting_stats_.Capacity(); } |
| 1693 | 1693 |
| 1694 // Total amount of memory committed for this space. For paged | 1694 // Total amount of memory committed for this space. For paged |
| 1695 // spaces this equals the capacity. | 1695 // spaces this equals the capacity. |
| 1696 intptr_t CommittedMemory() { return Capacity(); } | 1696 intptr_t CommittedMemory() { return Capacity(); } |
| 1697 | 1697 |
| 1698 // The maximum amount of memory ever committed for this space. | 1698 // The maximum amount of memory ever committed for this space. |
| 1699 intptr_t MaximumCommittedMemory() { return accounting_stats_.MaxCapacity(); } | 1699 intptr_t MaximumCommittedMemory() { return accounting_stats_.MaxCapacity(); } |
| (...skipping 61 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 |
| 1783 void ResetFreeList() { | 1781 void ResetFreeList() { |
| 1784 free_list_.Reset(); | 1782 free_list_.Reset(); |
| 1785 } | 1783 } |
| 1786 | 1784 |
| 1787 // Set space allocation info. | 1785 // Set space allocation info. |
| 1788 void SetTop(Address top, Address limit) { | 1786 void SetTopAndLimit(Address top, Address limit) { |
| 1789 ASSERT(top == limit || | 1787 ASSERT(top == limit || |
| 1790 Page::FromAddress(top) == Page::FromAddress(limit - 1)); | 1788 Page::FromAddress(top) == Page::FromAddress(limit - 1)); |
| 1791 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); | 1789 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); |
| 1792 allocation_info_.set_top(top); | 1790 allocation_info_.set_top(top); |
| 1793 allocation_info_.set_limit(limit); | 1791 allocation_info_.set_limit(limit); |
| 1794 } | 1792 } |
| 1795 | 1793 |
| 1794 // Empty space allocation info, returning unused area to free list. |
| 1795 void EmptyAllocationInfo() { |
| 1796 // Mark the old linear allocation area with a free space map so it can be |
| 1797 // skipped when scanning the heap. |
| 1798 int old_linear_size = static_cast<int>(limit() - top()); |
| 1799 Free(top(), old_linear_size); |
| 1800 SetTopAndLimit(NULL, NULL); |
| 1801 } |
| 1802 |
| 1796 void Allocate(int bytes) { | 1803 void Allocate(int bytes) { |
| 1797 accounting_stats_.AllocateBytes(bytes); | 1804 accounting_stats_.AllocateBytes(bytes); |
| 1798 } | 1805 } |
| 1799 | 1806 |
| 1800 void IncreaseCapacity(int size); | 1807 void IncreaseCapacity(int size); |
| 1801 | 1808 |
| 1802 // Releases an unused page and shrinks the space. | 1809 // Releases an unused page and shrinks the space. |
| 1803 void ReleasePage(Page* page, bool unlink); | 1810 void ReleasePage(Page* page, bool unlink); |
| 1804 | 1811 |
| 1805 // The dummy page that anchors the linked list of pages. | 1812 // The dummy page that anchors the linked list of pages. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 | 1914 |
| 1908 // The dummy page that anchors the double linked list of pages. | 1915 // The dummy page that anchors the double linked list of pages. |
| 1909 Page anchor_; | 1916 Page anchor_; |
| 1910 | 1917 |
| 1911 // The space's free list. | 1918 // The space's free list. |
| 1912 FreeList free_list_; | 1919 FreeList free_list_; |
| 1913 | 1920 |
| 1914 // Normal allocation information. | 1921 // Normal allocation information. |
| 1915 AllocationInfo allocation_info_; | 1922 AllocationInfo allocation_info_; |
| 1916 | 1923 |
| 1917 // Bytes of each page that cannot be allocated. Possibly non-zero | |
| 1918 // for pages in spaces with only fixed-size objects. Always zero | |
| 1919 // for pages in spaces with variable sized objects (those pages are | |
| 1920 // padded with free-list nodes). | |
| 1921 int page_extra_; | |
| 1922 | |
| 1923 bool was_swept_conservatively_; | 1924 bool was_swept_conservatively_; |
| 1924 | 1925 |
| 1925 // The first page to be swept when the lazy sweeper advances. Is set | 1926 // The first page to be swept when the lazy sweeper advances. Is set |
| 1926 // to NULL when all pages have been swept. | 1927 // to NULL when all pages have been swept. |
| 1927 Page* first_unswept_page_; | 1928 Page* first_unswept_page_; |
| 1928 | 1929 |
| 1929 // The number of free bytes which could be reclaimed by advancing the | 1930 // The number of free bytes which could be reclaimed by advancing the |
| 1930 // lazy sweeper. This is only an estimation because lazy sweeping is | 1931 // lazy sweeper. This is only an estimation because lazy sweeping is |
| 1931 // done conservatively. | 1932 // done conservatively. |
| 1932 intptr_t unswept_free_bytes_; | 1933 intptr_t unswept_free_bytes_; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; | 2161 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; |
| 2161 } | 2162 } |
| 2162 | 2163 |
| 2163 // If we don't have these here then SemiSpace will be abstract. However | 2164 // If we don't have these here then SemiSpace will be abstract. However |
| 2164 // they should never be called. | 2165 // they should never be called. |
| 2165 virtual intptr_t Size() { | 2166 virtual intptr_t Size() { |
| 2166 UNREACHABLE(); | 2167 UNREACHABLE(); |
| 2167 return 0; | 2168 return 0; |
| 2168 } | 2169 } |
| 2169 | 2170 |
| 2170 virtual bool ReserveSpace(int bytes) { | |
| 2171 UNREACHABLE(); | |
| 2172 return false; | |
| 2173 } | |
| 2174 | |
| 2175 bool is_committed() { return committed_; } | 2171 bool is_committed() { return committed_; } |
| 2176 bool Commit(); | 2172 bool Commit(); |
| 2177 bool Uncommit(); | 2173 bool Uncommit(); |
| 2178 | 2174 |
| 2179 NewSpacePage* first_page() { return anchor_.next_page(); } | 2175 NewSpacePage* first_page() { return anchor_.next_page(); } |
| 2180 NewSpacePage* current_page() { return current_page_; } | 2176 NewSpacePage* current_page() { return current_page_; } |
| 2181 | 2177 |
| 2182 #ifdef VERIFY_HEAP | 2178 #ifdef VERIFY_HEAP |
| 2183 virtual void Verify(); | 2179 virtual void Verify(); |
| 2184 #endif | 2180 #endif |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 // The allocation limit address. | 2480 // The allocation limit address. |
| 2485 Address* allocation_limit_address() { | 2481 Address* allocation_limit_address() { |
| 2486 return allocation_info_.limit_address(); | 2482 return allocation_info_.limit_address(); |
| 2487 } | 2483 } |
| 2488 | 2484 |
| 2489 MUST_USE_RESULT INLINE(MaybeObject* AllocateRaw(int size_in_bytes)); | 2485 MUST_USE_RESULT INLINE(MaybeObject* AllocateRaw(int size_in_bytes)); |
| 2490 | 2486 |
| 2491 // Reset the allocation pointer to the beginning of the active semispace. | 2487 // Reset the allocation pointer to the beginning of the active semispace. |
| 2492 void ResetAllocationInfo(); | 2488 void ResetAllocationInfo(); |
| 2493 | 2489 |
| 2490 void UpdateInlineAllocationLimit(int size_in_bytes); |
| 2494 void LowerInlineAllocationLimit(intptr_t step) { | 2491 void LowerInlineAllocationLimit(intptr_t step) { |
| 2495 inline_allocation_limit_step_ = step; | 2492 inline_allocation_limit_step_ = step; |
| 2496 if (step == 0) { | 2493 UpdateInlineAllocationLimit(0); |
| 2497 allocation_info_.set_limit(to_space_.page_high()); | |
| 2498 } else { | |
| 2499 Address new_limit = Min( | |
| 2500 allocation_info_.top() + inline_allocation_limit_step_, | |
| 2501 allocation_info_.limit()); | |
| 2502 allocation_info_.set_limit(new_limit); | |
| 2503 } | |
| 2504 top_on_previous_step_ = allocation_info_.top(); | 2494 top_on_previous_step_ = allocation_info_.top(); |
| 2505 } | 2495 } |
| 2506 | 2496 |
| 2507 // Get the extent of the inactive semispace (for use as a marking stack, | 2497 // Get the extent of the inactive semispace (for use as a marking stack, |
| 2508 // or to zap it). Notice: space-addresses are not necessarily on the | 2498 // or to zap it). Notice: space-addresses are not necessarily on the |
| 2509 // same page, so FromSpaceStart() might be above FromSpaceEnd(). | 2499 // same page, so FromSpaceStart() might be above FromSpaceEnd(). |
| 2510 Address FromSpacePageLow() { return from_space_.page_low(); } | 2500 Address FromSpacePageLow() { return from_space_.page_low(); } |
| 2511 Address FromSpacePageHigh() { return from_space_.page_high(); } | 2501 Address FromSpacePageHigh() { return from_space_.page_high(); } |
| 2512 Address FromSpaceStart() { return from_space_.space_start(); } | 2502 Address FromSpaceStart() { return from_space_.space_start(); } |
| 2513 Address FromSpaceEnd() { return from_space_.space_end(); } | 2503 Address FromSpaceEnd() { return from_space_.space_end(); } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2528 // semispace). | 2518 // semispace). |
| 2529 inline bool ToSpaceContains(Object* o) { return to_space_.Contains(o); } | 2519 inline bool ToSpaceContains(Object* o) { return to_space_.Contains(o); } |
| 2530 inline bool FromSpaceContains(Object* o) { return from_space_.Contains(o); } | 2520 inline bool FromSpaceContains(Object* o) { return from_space_.Contains(o); } |
| 2531 | 2521 |
| 2532 // Try to switch the active semispace to a new, empty, page. | 2522 // Try to switch the active semispace to a new, empty, page. |
| 2533 // Returns false if this isn't possible or reasonable (i.e., there | 2523 // 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 | 2524 // are no pages, or the current page is already empty), or true |
| 2535 // if successful. | 2525 // if successful. |
| 2536 bool AddFreshPage(); | 2526 bool AddFreshPage(); |
| 2537 | 2527 |
| 2538 virtual bool ReserveSpace(int bytes); | |
| 2539 | |
| 2540 #ifdef VERIFY_HEAP | 2528 #ifdef VERIFY_HEAP |
| 2541 // Verify the active semispace. | 2529 // Verify the active semispace. |
| 2542 virtual void Verify(); | 2530 virtual void Verify(); |
| 2543 #endif | 2531 #endif |
| 2544 | 2532 |
| 2545 #ifdef DEBUG | 2533 #ifdef DEBUG |
| 2546 // Print the active semispace. | 2534 // Print the active semispace. |
| 2547 virtual void Print() { to_space_.Print(); } | 2535 virtual void Print() { to_space_.Print(); } |
| 2548 #endif | 2536 #endif |
| 2549 | 2537 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2625 | 2613 |
| 2626 class OldSpace : public PagedSpace { | 2614 class OldSpace : public PagedSpace { |
| 2627 public: | 2615 public: |
| 2628 // Creates an old space object with a given maximum capacity. | 2616 // Creates an old space object with a given maximum capacity. |
| 2629 // The constructor does not allocate pages from OS. | 2617 // The constructor does not allocate pages from OS. |
| 2630 OldSpace(Heap* heap, | 2618 OldSpace(Heap* heap, |
| 2631 intptr_t max_capacity, | 2619 intptr_t max_capacity, |
| 2632 AllocationSpace id, | 2620 AllocationSpace id, |
| 2633 Executability executable) | 2621 Executability executable) |
| 2634 : PagedSpace(heap, max_capacity, id, executable) { | 2622 : PagedSpace(heap, max_capacity, id, executable) { |
| 2635 page_extra_ = 0; | |
| 2636 } | |
| 2637 | |
| 2638 // The limit of allocation for a page in this space. | |
| 2639 virtual Address PageAllocationLimit(Page* page) { | |
| 2640 return page->area_end(); | |
| 2641 } | 2623 } |
| 2642 | 2624 |
| 2643 public: | 2625 public: |
| 2644 TRACK_MEMORY("OldSpace") | 2626 TRACK_MEMORY("OldSpace") |
| 2645 }; | 2627 }; |
| 2646 | 2628 |
| 2647 | 2629 |
| 2648 // For contiguous spaces, top should be in the space (or at the end) and limit | 2630 // For contiguous spaces, top should be in the space (or at the end) and limit |
| 2649 // should be the end of the space. | 2631 // should be the end of the space. |
| 2650 #define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \ | 2632 #define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \ |
| 2651 SLOW_ASSERT((space).page_low() <= (info).top() \ | 2633 SLOW_ASSERT((space).page_low() <= (info).top() \ |
| 2652 && (info).top() <= (space).page_high() \ | 2634 && (info).top() <= (space).page_high() \ |
| 2653 && (info).limit() <= (space).page_high()) | 2635 && (info).limit() <= (space).page_high()) |
| 2654 | 2636 |
| 2655 | 2637 |
| 2656 // ----------------------------------------------------------------------------- | 2638 // ----------------------------------------------------------------------------- |
| 2657 // Old space for objects of a fixed size | |
| 2658 | |
| 2659 class FixedSpace : public PagedSpace { | |
| 2660 public: | |
| 2661 FixedSpace(Heap* heap, | |
| 2662 intptr_t max_capacity, | |
| 2663 AllocationSpace id, | |
| 2664 int object_size_in_bytes) | |
| 2665 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE), | |
| 2666 object_size_in_bytes_(object_size_in_bytes) { | |
| 2667 page_extra_ = Page::kNonCodeObjectAreaSize % object_size_in_bytes; | |
| 2668 } | |
| 2669 | |
| 2670 // The limit of allocation for a page in this space. | |
| 2671 virtual Address PageAllocationLimit(Page* page) { | |
| 2672 return page->area_end() - page_extra_; | |
| 2673 } | |
| 2674 | |
| 2675 int object_size_in_bytes() { return object_size_in_bytes_; } | |
| 2676 | |
| 2677 // Prepares for a mark-compact GC. | |
| 2678 virtual void PrepareForMarkCompact(); | |
| 2679 | |
| 2680 private: | |
| 2681 // The size of objects in this space. | |
| 2682 int object_size_in_bytes_; | |
| 2683 }; | |
| 2684 | |
| 2685 | |
| 2686 // ----------------------------------------------------------------------------- | |
| 2687 // Old space for all map objects | 2639 // Old space for all map objects |
| 2688 | 2640 |
| 2689 class MapSpace : public FixedSpace { | 2641 class MapSpace : public PagedSpace { |
| 2690 public: | 2642 public: |
| 2691 // Creates a map space object with a maximum capacity. | 2643 // Creates a map space object with a maximum capacity. |
| 2692 MapSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) | 2644 MapSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) |
| 2693 : FixedSpace(heap, max_capacity, id, Map::kSize), | 2645 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE), |
| 2694 max_map_space_pages_(kMaxMapPageIndex - 1) { | 2646 max_map_space_pages_(kMaxMapPageIndex - 1) { |
| 2695 } | 2647 } |
| 2696 | 2648 |
| 2697 // Given an index, returns the page address. | 2649 // Given an index, returns the page address. |
| 2698 // TODO(1600): this limit is artifical just to keep code compilable | 2650 // TODO(1600): this limit is artifical just to keep code compilable |
| 2699 static const int kMaxMapPageIndex = 1 << 16; | 2651 static const int kMaxMapPageIndex = 1 << 16; |
| 2700 | 2652 |
| 2701 virtual int RoundSizeDownToObjectAlignment(int size) { | 2653 virtual int RoundSizeDownToObjectAlignment(int size) { |
| 2702 if (IsPowerOf2(Map::kSize)) { | 2654 if (IsPowerOf2(Map::kSize)) { |
| 2703 return RoundDown(size, Map::kSize); | 2655 return RoundDown(size, Map::kSize); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2720 const int max_map_space_pages_; | 2672 const int max_map_space_pages_; |
| 2721 | 2673 |
| 2722 public: | 2674 public: |
| 2723 TRACK_MEMORY("MapSpace") | 2675 TRACK_MEMORY("MapSpace") |
| 2724 }; | 2676 }; |
| 2725 | 2677 |
| 2726 | 2678 |
| 2727 // ----------------------------------------------------------------------------- | 2679 // ----------------------------------------------------------------------------- |
| 2728 // Old space for simple property cell objects | 2680 // Old space for simple property cell objects |
| 2729 | 2681 |
| 2730 class CellSpace : public FixedSpace { | 2682 class CellSpace : public PagedSpace { |
| 2731 public: | 2683 public: |
| 2732 // Creates a property cell space object with a maximum capacity. | 2684 // Creates a property cell space object with a maximum capacity. |
| 2733 CellSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) | 2685 CellSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) |
| 2734 : FixedSpace(heap, max_capacity, id, Cell::kSize) | 2686 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE) { |
| 2735 {} | 2687 } |
| 2736 | 2688 |
| 2737 virtual int RoundSizeDownToObjectAlignment(int size) { | 2689 virtual int RoundSizeDownToObjectAlignment(int size) { |
| 2738 if (IsPowerOf2(Cell::kSize)) { | 2690 if (IsPowerOf2(Cell::kSize)) { |
| 2739 return RoundDown(size, Cell::kSize); | 2691 return RoundDown(size, Cell::kSize); |
| 2740 } else { | 2692 } else { |
| 2741 return (size / Cell::kSize) * Cell::kSize; | 2693 return (size / Cell::kSize) * Cell::kSize; |
| 2742 } | 2694 } |
| 2743 } | 2695 } |
| 2744 | 2696 |
| 2745 protected: | 2697 protected: |
| 2746 virtual void VerifyObject(HeapObject* obj); | 2698 virtual void VerifyObject(HeapObject* obj); |
| 2747 | 2699 |
| 2748 public: | 2700 public: |
| 2749 TRACK_MEMORY("CellSpace") | 2701 TRACK_MEMORY("CellSpace") |
| 2750 }; | 2702 }; |
| 2751 | 2703 |
| 2752 | 2704 |
| 2753 // ----------------------------------------------------------------------------- | 2705 // ----------------------------------------------------------------------------- |
| 2754 // Old space for all global object property cell objects | 2706 // Old space for all global object property cell objects |
| 2755 | 2707 |
| 2756 class PropertyCellSpace : public FixedSpace { | 2708 class PropertyCellSpace : public PagedSpace { |
| 2757 public: | 2709 public: |
| 2758 // Creates a property cell space object with a maximum capacity. | 2710 // Creates a property cell space object with a maximum capacity. |
| 2759 PropertyCellSpace(Heap* heap, intptr_t max_capacity, | 2711 PropertyCellSpace(Heap* heap, intptr_t max_capacity, |
| 2760 AllocationSpace id) | 2712 AllocationSpace id) |
| 2761 : FixedSpace(heap, max_capacity, id, PropertyCell::kSize) | 2713 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE) { |
| 2762 {} | 2714 } |
| 2763 | 2715 |
| 2764 virtual int RoundSizeDownToObjectAlignment(int size) { | 2716 virtual int RoundSizeDownToObjectAlignment(int size) { |
| 2765 if (IsPowerOf2(PropertyCell::kSize)) { | 2717 if (IsPowerOf2(PropertyCell::kSize)) { |
| 2766 return RoundDown(size, PropertyCell::kSize); | 2718 return RoundDown(size, PropertyCell::kSize); |
| 2767 } else { | 2719 } else { |
| 2768 return (size / PropertyCell::kSize) * PropertyCell::kSize; | 2720 return (size / PropertyCell::kSize) * PropertyCell::kSize; |
| 2769 } | 2721 } |
| 2770 } | 2722 } |
| 2771 | 2723 |
| 2772 protected: | 2724 protected: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 | 2794 |
| 2843 // Frees unmarked objects. | 2795 // Frees unmarked objects. |
| 2844 void FreeUnmarkedObjects(); | 2796 void FreeUnmarkedObjects(); |
| 2845 | 2797 |
| 2846 // Checks whether a heap object is in this space; O(1). | 2798 // Checks whether a heap object is in this space; O(1). |
| 2847 bool Contains(HeapObject* obj); | 2799 bool Contains(HeapObject* obj); |
| 2848 | 2800 |
| 2849 // Checks whether the space is empty. | 2801 // Checks whether the space is empty. |
| 2850 bool IsEmpty() { return first_page_ == NULL; } | 2802 bool IsEmpty() { return first_page_ == NULL; } |
| 2851 | 2803 |
| 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_; } | 2804 LargePage* first_page() { return first_page_; } |
| 2858 | 2805 |
| 2859 #ifdef VERIFY_HEAP | 2806 #ifdef VERIFY_HEAP |
| 2860 virtual void Verify(); | 2807 virtual void Verify(); |
| 2861 #endif | 2808 #endif |
| 2862 | 2809 |
| 2863 #ifdef DEBUG | 2810 #ifdef DEBUG |
| 2864 virtual void Print(); | 2811 virtual void Print(); |
| 2865 void ReportStatistics(); | 2812 void ReportStatistics(); |
| 2866 void CollectCodeStatistics(); | 2813 void CollectCodeStatistics(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2976 } | 2923 } |
| 2977 // Must be small, since an iteration is used for lookup. | 2924 // Must be small, since an iteration is used for lookup. |
| 2978 static const int kMaxComments = 64; | 2925 static const int kMaxComments = 64; |
| 2979 }; | 2926 }; |
| 2980 #endif | 2927 #endif |
| 2981 | 2928 |
| 2982 | 2929 |
| 2983 } } // namespace v8::internal | 2930 } } // namespace v8::internal |
| 2984 | 2931 |
| 2985 #endif // V8_SPACES_H_ | 2932 #endif // V8_SPACES_H_ |
| OLD | NEW |