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 15 matching lines...) Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_SPACES_H_ | 28 #ifndef V8_SPACES_H_ |
29 #define V8_SPACES_H_ | 29 #define V8_SPACES_H_ |
30 | 30 |
31 #include "allocation.h" | 31 #include "allocation.h" |
32 #include "hashmap.h" | 32 #include "hashmap.h" |
33 #include "list.h" | 33 #include "list.h" |
34 #include "log.h" | 34 #include "log.h" |
35 #include "platform/mutex.h" | 35 #include "platform/mutex.h" |
| 36 #include "platform/virtual-memory.h" |
36 #include "v8utils.h" | 37 #include "v8utils.h" |
37 | 38 |
38 namespace v8 { | 39 namespace v8 { |
39 namespace internal { | 40 namespace internal { |
40 | 41 |
41 class Isolate; | 42 class Isolate; |
42 | 43 |
43 // ----------------------------------------------------------------------------- | 44 // ----------------------------------------------------------------------------- |
44 // Heap structures: | 45 // Heap structures: |
45 // | 46 // |
(...skipping 520 matching lines...) Loading... |
566 | 567 |
567 void set_size(size_t size) { | 568 void set_size(size_t size) { |
568 size_ = size; | 569 size_ = size; |
569 } | 570 } |
570 | 571 |
571 void SetArea(Address area_start, Address area_end) { | 572 void SetArea(Address area_start, Address area_end) { |
572 area_start_ = area_start; | 573 area_start_ = area_start; |
573 area_end_ = area_end; | 574 area_end_ = area_end; |
574 } | 575 } |
575 | 576 |
576 Executability executable() { | 577 VirtualMemory::Executability executability() { |
577 return IsFlagSet(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE; | 578 return IsFlagSet(IS_EXECUTABLE) |
| 579 ? VirtualMemory::EXECUTABLE |
| 580 : VirtualMemory::NOT_EXECUTABLE; |
578 } | 581 } |
579 | 582 |
580 bool ContainsOnlyData() { | 583 bool ContainsOnlyData() { |
581 return IsFlagSet(CONTAINS_ONLY_DATA); | 584 return IsFlagSet(CONTAINS_ONLY_DATA); |
582 } | 585 } |
583 | 586 |
584 bool InNewSpace() { | 587 bool InNewSpace() { |
585 return (flags_ & ((1 << IN_FROM_SPACE) | (1 << IN_TO_SPACE))) != 0; | 588 return (flags_ & ((1 << IN_FROM_SPACE) | (1 << IN_TO_SPACE))) != 0; |
586 } | 589 } |
587 | 590 |
(...skipping 121 matching lines...) Loading... |
709 intptr_t available_in_medium_free_list_; | 712 intptr_t available_in_medium_free_list_; |
710 intptr_t available_in_large_free_list_; | 713 intptr_t available_in_large_free_list_; |
711 intptr_t available_in_huge_free_list_; | 714 intptr_t available_in_huge_free_list_; |
712 intptr_t non_available_small_blocks_; | 715 intptr_t non_available_small_blocks_; |
713 | 716 |
714 static MemoryChunk* Initialize(Heap* heap, | 717 static MemoryChunk* Initialize(Heap* heap, |
715 Address base, | 718 Address base, |
716 size_t size, | 719 size_t size, |
717 Address area_start, | 720 Address area_start, |
718 Address area_end, | 721 Address area_end, |
719 Executability executable, | 722 VirtualMemory::Executability executability, |
720 Space* owner); | 723 Space* owner); |
721 | 724 |
722 friend class MemoryAllocator; | 725 friend class MemoryAllocator; |
723 }; | 726 }; |
724 | 727 |
725 | 728 |
726 STATIC_CHECK(sizeof(MemoryChunk) <= MemoryChunk::kHeaderSize); | 729 STATIC_CHECK(sizeof(MemoryChunk) <= MemoryChunk::kHeaderSize); |
727 | 730 |
728 | 731 |
729 // ----------------------------------------------------------------------------- | 732 // ----------------------------------------------------------------------------- |
(...skipping 59 matching lines...) Loading... |
789 static const int kMaxNonCodeHeapObjectSize = | 792 static const int kMaxNonCodeHeapObjectSize = |
790 kNonCodeObjectAreaSize - kPointerSize; | 793 kNonCodeObjectAreaSize - kPointerSize; |
791 | 794 |
792 // Page size mask. | 795 // Page size mask. |
793 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; | 796 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; |
794 | 797 |
795 inline void ClearGCFields(); | 798 inline void ClearGCFields(); |
796 | 799 |
797 static inline Page* Initialize(Heap* heap, | 800 static inline Page* Initialize(Heap* heap, |
798 MemoryChunk* chunk, | 801 MemoryChunk* chunk, |
799 Executability executable, | 802 VirtualMemory::Executability executable, |
800 PagedSpace* owner); | 803 PagedSpace* owner); |
801 | 804 |
802 void InitializeAsAnchor(PagedSpace* owner); | 805 void InitializeAsAnchor(PagedSpace* owner); |
803 | 806 |
804 bool WasSweptPrecisely() { return IsFlagSet(WAS_SWEPT_PRECISELY); } | 807 bool WasSweptPrecisely() { return IsFlagSet(WAS_SWEPT_PRECISELY); } |
805 bool WasSweptConservatively() { return IsFlagSet(WAS_SWEPT_CONSERVATIVELY); } | 808 bool WasSweptConservatively() { return IsFlagSet(WAS_SWEPT_CONSERVATIVELY); } |
806 bool WasSwept() { return WasSweptPrecisely() || WasSweptConservatively(); } | 809 bool WasSwept() { return WasSweptPrecisely() || WasSweptConservatively(); } |
807 | 810 |
808 void MarkSweptPrecisely() { SetFlag(WAS_SWEPT_PRECISELY); } | 811 void MarkSweptPrecisely() { SetFlag(WAS_SWEPT_PRECISELY); } |
809 void MarkSweptConservatively() { SetFlag(WAS_SWEPT_CONSERVATIVELY); } | 812 void MarkSweptConservatively() { SetFlag(WAS_SWEPT_CONSERVATIVELY); } |
(...skipping 45 matching lines...) Loading... |
855 | 858 |
856 friend class MemoryAllocator; | 859 friend class MemoryAllocator; |
857 }; | 860 }; |
858 | 861 |
859 STATIC_CHECK(sizeof(LargePage) <= MemoryChunk::kHeaderSize); | 862 STATIC_CHECK(sizeof(LargePage) <= MemoryChunk::kHeaderSize); |
860 | 863 |
861 // ---------------------------------------------------------------------------- | 864 // ---------------------------------------------------------------------------- |
862 // Space is the abstract superclass for all allocation spaces. | 865 // Space is the abstract superclass for all allocation spaces. |
863 class Space : public Malloced { | 866 class Space : public Malloced { |
864 public: | 867 public: |
865 Space(Heap* heap, AllocationSpace id, Executability executable) | 868 Space(Heap* heap, |
866 : heap_(heap), id_(id), executable_(executable) {} | 869 AllocationSpace id, |
| 870 VirtualMemory::Executability executability) |
| 871 : heap_(heap), id_(id), executability_(executability) {} |
867 | 872 |
868 virtual ~Space() {} | 873 virtual ~Space() {} |
869 | 874 |
870 Heap* heap() const { return heap_; } | 875 Heap* heap() const { return heap_; } |
871 | 876 |
872 // Does the space need executable memory? | 877 // Does the space need executable memory? |
873 Executability executable() { return executable_; } | 878 VirtualMemory::Executability executability() { return executability_; } |
874 | 879 |
875 // Identity used in error reporting. | 880 // Identity used in error reporting. |
876 AllocationSpace identity() { return id_; } | 881 AllocationSpace identity() { return id_; } |
877 | 882 |
878 // Returns allocated size. | 883 // Returns allocated size. |
879 virtual intptr_t Size() = 0; | 884 virtual intptr_t Size() = 0; |
880 | 885 |
881 // Returns size of objects. Can differ from the allocated size | 886 // Returns size of objects. Can differ from the allocated size |
882 // (e.g. see LargeObjectSpace). | 887 // (e.g. see LargeObjectSpace). |
883 virtual intptr_t SizeOfObjects() { return Size(); } | 888 virtual intptr_t SizeOfObjects() { return Size(); } |
884 | 889 |
885 virtual int RoundSizeDownToObjectAlignment(int size) { | 890 virtual int RoundSizeDownToObjectAlignment(int size) { |
886 if (id_ == CODE_SPACE) { | 891 if (id_ == CODE_SPACE) { |
887 return RoundDown(size, kCodeAlignment); | 892 return RoundDown(size, kCodeAlignment); |
888 } else { | 893 } else { |
889 return RoundDown(size, kPointerSize); | 894 return RoundDown(size, kPointerSize); |
890 } | 895 } |
891 } | 896 } |
892 | 897 |
893 #ifdef DEBUG | 898 #ifdef DEBUG |
894 virtual void Print() = 0; | 899 virtual void Print() = 0; |
895 #endif | 900 #endif |
896 | 901 |
897 private: | 902 private: |
898 Heap* heap_; | 903 Heap* heap_; |
899 AllocationSpace id_; | 904 AllocationSpace id_; |
900 Executability executable_; | 905 VirtualMemory::Executability executability_; |
901 }; | 906 }; |
902 | 907 |
903 | 908 |
904 // ---------------------------------------------------------------------------- | 909 // ---------------------------------------------------------------------------- |
905 // All heap objects containing executable code (code objects) must be allocated | 910 // All heap objects containing executable code (code objects) must be allocated |
906 // from a 2 GB range of memory, so that they can call each other using 32-bit | 911 // from a 2 GB range of memory, so that they can call each other using 32-bit |
907 // displacements. This happens automatically on 32-bit platforms, where 32-bit | 912 // displacements. This happens automatically on 32-bit platforms, where 32-bit |
908 // displacements cover the entire 4GB virtual address space. On 64-bit | 913 // displacements cover the entire 4GB virtual address space. On 64-bit |
909 // platforms, we support this using the CodeRange object, which reserves and | 914 // platforms, we support this using the CodeRange object, which reserves and |
910 // manages a range of virtual memory. | 915 // manages a range of virtual memory. |
(...skipping 137 matching lines...) Loading... |
1048 class MemoryAllocator { | 1053 class MemoryAllocator { |
1049 public: | 1054 public: |
1050 explicit MemoryAllocator(Isolate* isolate); | 1055 explicit MemoryAllocator(Isolate* isolate); |
1051 | 1056 |
1052 // Initializes its internal bookkeeping structures. | 1057 // Initializes its internal bookkeeping structures. |
1053 // Max capacity of the total space and executable memory limit. | 1058 // Max capacity of the total space and executable memory limit. |
1054 bool SetUp(intptr_t max_capacity, intptr_t capacity_executable); | 1059 bool SetUp(intptr_t max_capacity, intptr_t capacity_executable); |
1055 | 1060 |
1056 void TearDown(); | 1061 void TearDown(); |
1057 | 1062 |
1058 Page* AllocatePage( | 1063 Page* AllocatePage(intptr_t size, |
1059 intptr_t size, PagedSpace* owner, Executability executable); | 1064 PagedSpace* owner, |
| 1065 VirtualMemory::Executability executability); |
1060 | 1066 |
1061 LargePage* AllocateLargePage( | 1067 LargePage* AllocateLargePage(intptr_t object_size, |
1062 intptr_t object_size, Space* owner, Executability executable); | 1068 Space* owner, |
| 1069 VirtualMemory::Executability executability); |
1063 | 1070 |
1064 void Free(MemoryChunk* chunk); | 1071 void Free(MemoryChunk* chunk); |
1065 | 1072 |
1066 // Returns the maximum available bytes of heaps. | 1073 // Returns the maximum available bytes of heaps. |
1067 intptr_t Available() { return capacity_ < size_ ? 0 : capacity_ - size_; } | 1074 intptr_t Available() { return capacity_ < size_ ? 0 : capacity_ - size_; } |
1068 | 1075 |
1069 // Returns allocated spaces in bytes. | 1076 // Returns allocated spaces in bytes. |
1070 intptr_t Size() { return size_; } | 1077 intptr_t Size() { return size_; } |
1071 | 1078 |
1072 // Returns the maximum available executable bytes of heaps. | 1079 // Returns the maximum available executable bytes of heaps. |
(...skipping 20 matching lines...) Loading... |
1093 #ifdef DEBUG | 1100 #ifdef DEBUG |
1094 // Reports statistic info of the space. | 1101 // Reports statistic info of the space. |
1095 void ReportStatistics(); | 1102 void ReportStatistics(); |
1096 #endif | 1103 #endif |
1097 | 1104 |
1098 // Returns a MemoryChunk in which the memory region from commit_area_size to | 1105 // Returns a MemoryChunk in which the memory region from commit_area_size to |
1099 // reserve_area_size of the chunk area is reserved but not committed, it | 1106 // reserve_area_size of the chunk area is reserved but not committed, it |
1100 // could be committed later by calling MemoryChunk::CommitArea. | 1107 // could be committed later by calling MemoryChunk::CommitArea. |
1101 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, | 1108 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, |
1102 intptr_t commit_area_size, | 1109 intptr_t commit_area_size, |
1103 Executability executable, | 1110 VirtualMemory::Executability executability, |
1104 Space* space); | 1111 Space* space); |
1105 | 1112 |
1106 Address ReserveAlignedMemory(size_t requested, | 1113 Address ReserveAlignedMemory(size_t requested, |
1107 size_t alignment, | 1114 size_t alignment, |
1108 VirtualMemory* controller); | 1115 VirtualMemory* controller); |
1109 Address AllocateAlignedMemory(size_t reserve_size, | 1116 Address AllocateAlignedMemory(size_t reserve_size, |
1110 size_t commit_size, | 1117 size_t commit_size, |
1111 size_t alignment, | 1118 size_t alignment, |
1112 Executability executable, | 1119 VirtualMemory::Executability executability, |
1113 VirtualMemory* controller); | 1120 VirtualMemory* controller); |
1114 | 1121 |
1115 bool CommitMemory(Address addr, size_t size, Executability executable); | 1122 bool CommitMemory(Address addr, |
| 1123 size_t size, |
| 1124 VirtualMemory::Executability executability); |
1116 | 1125 |
1117 void FreeMemory(VirtualMemory* reservation, Executability executable); | 1126 void FreeMemory(VirtualMemory* reservation, |
1118 void FreeMemory(Address addr, size_t size, Executability executable); | 1127 VirtualMemory::Executability executability); |
| 1128 void FreeMemory(Address addr, |
| 1129 size_t size, |
| 1130 VirtualMemory::Executability executability); |
1119 | 1131 |
1120 // Commit a contiguous block of memory from the initial chunk. Assumes that | 1132 // Commit a contiguous block of memory from the initial chunk. Assumes that |
1121 // the address is not NULL, the size is greater than zero, and that the | 1133 // the address is not NULL, the size is greater than zero, and that the |
1122 // block is contained in the initial chunk. Returns true if it succeeded | 1134 // block is contained in the initial chunk. Returns true if it succeeded |
1123 // and false otherwise. | 1135 // and false otherwise. |
1124 bool CommitBlock(Address start, size_t size, Executability executable); | 1136 bool CommitBlock(Address start, |
| 1137 size_t size, |
| 1138 VirtualMemory::Executability executability); |
1125 | 1139 |
1126 // Uncommit a contiguous block of memory [start..(start+size)[. | 1140 // Uncommit a contiguous block of memory [start..(start+size)[. |
1127 // start is not NULL, the size is greater than zero, and the | 1141 // start is not NULL, the size is greater than zero, and the |
1128 // block is contained in the initial chunk. Returns true if it succeeded | 1142 // block is contained in the initial chunk. Returns true if it succeeded |
1129 // and false otherwise. | 1143 // and false otherwise. |
1130 bool UncommitBlock(Address start, size_t size); | 1144 bool UncommitBlock(Address start, size_t size); |
1131 | 1145 |
1132 // Zaps a contiguous block of memory [start..(start+size)[ thus | 1146 // Zaps a contiguous block of memory [start..(start+size)[ thus |
1133 // filling it up with a recognizable non-NULL bit pattern. | 1147 // filling it up with a recognizable non-NULL bit pattern. |
1134 void ZapBlock(Address start, size_t size); | 1148 void ZapBlock(Address start, size_t size); |
(...skipping 470 matching lines...) Loading... |
1605 DISALLOW_IMPLICIT_CONSTRUCTORS(FreeList); | 1619 DISALLOW_IMPLICIT_CONSTRUCTORS(FreeList); |
1606 }; | 1620 }; |
1607 | 1621 |
1608 | 1622 |
1609 class PagedSpace : public Space { | 1623 class PagedSpace : public Space { |
1610 public: | 1624 public: |
1611 // Creates a space with a maximum capacity, and an id. | 1625 // Creates a space with a maximum capacity, and an id. |
1612 PagedSpace(Heap* heap, | 1626 PagedSpace(Heap* heap, |
1613 intptr_t max_capacity, | 1627 intptr_t max_capacity, |
1614 AllocationSpace id, | 1628 AllocationSpace id, |
1615 Executability executable); | 1629 VirtualMemory::Executability executability); |
1616 | 1630 |
1617 virtual ~PagedSpace() {} | 1631 virtual ~PagedSpace() {} |
1618 | 1632 |
1619 // Set up the space using the given address range of virtual memory (from | 1633 // Set up the space using the given address range of virtual memory (from |
1620 // the memory allocator's initial chunk) if possible. If the block of | 1634 // the memory allocator's initial chunk) if possible. If the block of |
1621 // addresses is not big enough to contain a single page-aligned page, a | 1635 // addresses is not big enough to contain a single page-aligned page, a |
1622 // fresh chunk will be allocated. | 1636 // fresh chunk will be allocated. |
1623 bool SetUp(); | 1637 bool SetUp(); |
1624 | 1638 |
1625 // Returns true if the space has been successfully set up and not | 1639 // Returns true if the space has been successfully set up and not |
(...skipping 404 matching lines...) Loading... |
2030 // SemiSpace in young generation | 2044 // SemiSpace in young generation |
2031 // | 2045 // |
2032 // A semispace is a contiguous chunk of memory holding page-like memory | 2046 // A semispace is a contiguous chunk of memory holding page-like memory |
2033 // chunks. The mark-compact collector uses the memory of the first page in | 2047 // chunks. The mark-compact collector uses the memory of the first page in |
2034 // the from space as a marking stack when tracing live objects. | 2048 // the from space as a marking stack when tracing live objects. |
2035 | 2049 |
2036 class SemiSpace : public Space { | 2050 class SemiSpace : public Space { |
2037 public: | 2051 public: |
2038 // Constructor. | 2052 // Constructor. |
2039 SemiSpace(Heap* heap, SemiSpaceId semispace) | 2053 SemiSpace(Heap* heap, SemiSpaceId semispace) |
2040 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 2054 : Space(heap, NEW_SPACE, VirtualMemory::NOT_EXECUTABLE), |
2041 start_(NULL), | 2055 start_(NULL), |
2042 age_mark_(NULL), | 2056 age_mark_(NULL), |
2043 id_(semispace), | 2057 id_(semispace), |
2044 anchor_(this), | 2058 anchor_(this), |
2045 current_page_(NULL) { } | 2059 current_page_(NULL) { } |
2046 | 2060 |
2047 // Sets up the semispace using the given chunk. | 2061 // Sets up the semispace using the given chunk. |
2048 void SetUp(Address start, int initial_capacity, int maximum_capacity); | 2062 void SetUp(Address start, int initial_capacity, int maximum_capacity); |
2049 | 2063 |
2050 // Tear down the space. Heap memory was not allocated by the space, so it | 2064 // Tear down the space. Heap memory was not allocated by the space, so it |
(...skipping 232 matching lines...) Loading... |
2283 // ----------------------------------------------------------------------------- | 2297 // ----------------------------------------------------------------------------- |
2284 // The young generation space. | 2298 // The young generation space. |
2285 // | 2299 // |
2286 // The new space consists of a contiguous pair of semispaces. It simply | 2300 // The new space consists of a contiguous pair of semispaces. It simply |
2287 // forwards most functions to the appropriate semispace. | 2301 // forwards most functions to the appropriate semispace. |
2288 | 2302 |
2289 class NewSpace : public Space { | 2303 class NewSpace : public Space { |
2290 public: | 2304 public: |
2291 // Constructor. | 2305 // Constructor. |
2292 explicit NewSpace(Heap* heap) | 2306 explicit NewSpace(Heap* heap) |
2293 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 2307 : Space(heap, NEW_SPACE, VirtualMemory::NOT_EXECUTABLE), |
2294 to_space_(heap, kToSpace), | 2308 to_space_(heap, kToSpace), |
2295 from_space_(heap, kFromSpace), | 2309 from_space_(heap, kFromSpace), |
2296 reservation_(), | 2310 reservation_(), |
2297 inline_allocation_limit_step_(0) {} | 2311 inline_allocation_limit_step_(0) {} |
2298 | 2312 |
2299 // Sets up the new space using the given chunk. | 2313 // Sets up the new space using the given chunk. |
2300 bool SetUp(int reserved_semispace_size_, int max_semispace_size); | 2314 bool SetUp(int reserved_semispace_size_, int max_semispace_size); |
2301 | 2315 |
2302 // Tears down the space. Heap memory was not allocated by the space, so it | 2316 // Tears down the space. Heap memory was not allocated by the space, so it |
2303 // is not deallocated here. | 2317 // is not deallocated here. |
(...skipping 244 matching lines...) Loading... |
2548 // ----------------------------------------------------------------------------- | 2562 // ----------------------------------------------------------------------------- |
2549 // Old object space (excluding map objects) | 2563 // Old object space (excluding map objects) |
2550 | 2564 |
2551 class OldSpace : public PagedSpace { | 2565 class OldSpace : public PagedSpace { |
2552 public: | 2566 public: |
2553 // Creates an old space object with a given maximum capacity. | 2567 // Creates an old space object with a given maximum capacity. |
2554 // The constructor does not allocate pages from OS. | 2568 // The constructor does not allocate pages from OS. |
2555 OldSpace(Heap* heap, | 2569 OldSpace(Heap* heap, |
2556 intptr_t max_capacity, | 2570 intptr_t max_capacity, |
2557 AllocationSpace id, | 2571 AllocationSpace id, |
2558 Executability executable) | 2572 VirtualMemory::Executability executability) |
2559 : PagedSpace(heap, max_capacity, id, executable) { | 2573 : PagedSpace(heap, max_capacity, id, executability) { |
2560 page_extra_ = 0; | 2574 page_extra_ = 0; |
2561 } | 2575 } |
2562 | 2576 |
2563 // The limit of allocation for a page in this space. | 2577 // The limit of allocation for a page in this space. |
2564 virtual Address PageAllocationLimit(Page* page) { | 2578 virtual Address PageAllocationLimit(Page* page) { |
2565 return page->area_end(); | 2579 return page->area_end(); |
2566 } | 2580 } |
2567 | 2581 |
2568 public: | 2582 public: |
2569 TRACK_MEMORY("OldSpace") | 2583 TRACK_MEMORY("OldSpace") |
(...skipping 10 matching lines...) Loading... |
2580 | 2594 |
2581 // ----------------------------------------------------------------------------- | 2595 // ----------------------------------------------------------------------------- |
2582 // Old space for objects of a fixed size | 2596 // Old space for objects of a fixed size |
2583 | 2597 |
2584 class FixedSpace : public PagedSpace { | 2598 class FixedSpace : public PagedSpace { |
2585 public: | 2599 public: |
2586 FixedSpace(Heap* heap, | 2600 FixedSpace(Heap* heap, |
2587 intptr_t max_capacity, | 2601 intptr_t max_capacity, |
2588 AllocationSpace id, | 2602 AllocationSpace id, |
2589 int object_size_in_bytes) | 2603 int object_size_in_bytes) |
2590 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE), | 2604 : PagedSpace(heap, max_capacity, id, VirtualMemory::NOT_EXECUTABLE), |
2591 object_size_in_bytes_(object_size_in_bytes) { | 2605 object_size_in_bytes_(object_size_in_bytes) { |
2592 page_extra_ = Page::kNonCodeObjectAreaSize % object_size_in_bytes; | 2606 page_extra_ = Page::kNonCodeObjectAreaSize % object_size_in_bytes; |
2593 } | 2607 } |
2594 | 2608 |
2595 // The limit of allocation for a page in this space. | 2609 // The limit of allocation for a page in this space. |
2596 virtual Address PageAllocationLimit(Page* page) { | 2610 virtual Address PageAllocationLimit(Page* page) { |
2597 return page->area_end() - page_extra_; | 2611 return page->area_end() - page_extra_; |
2598 } | 2612 } |
2599 | 2613 |
2600 int object_size_in_bytes() { return object_size_in_bytes_; } | 2614 int object_size_in_bytes() { return object_size_in_bytes_; } |
(...skipping 119 matching lines...) Loading... |
2720 // Releases internal resources, frees objects in this space. | 2734 // Releases internal resources, frees objects in this space. |
2721 void TearDown(); | 2735 void TearDown(); |
2722 | 2736 |
2723 static intptr_t ObjectSizeFor(intptr_t chunk_size) { | 2737 static intptr_t ObjectSizeFor(intptr_t chunk_size) { |
2724 if (chunk_size <= (Page::kPageSize + Page::kObjectStartOffset)) return 0; | 2738 if (chunk_size <= (Page::kPageSize + Page::kObjectStartOffset)) return 0; |
2725 return chunk_size - Page::kPageSize - Page::kObjectStartOffset; | 2739 return chunk_size - Page::kPageSize - Page::kObjectStartOffset; |
2726 } | 2740 } |
2727 | 2741 |
2728 // Shared implementation of AllocateRaw, AllocateRawCode and | 2742 // Shared implementation of AllocateRaw, AllocateRawCode and |
2729 // AllocateRawFixedArray. | 2743 // AllocateRawFixedArray. |
2730 MUST_USE_RESULT MaybeObject* AllocateRaw(int object_size, | 2744 MUST_USE_RESULT MaybeObject* AllocateRaw( |
2731 Executability executable); | 2745 int object_size, VirtualMemory::Executability executability); |
2732 | 2746 |
2733 // Available bytes for objects in this space. | 2747 // Available bytes for objects in this space. |
2734 inline intptr_t Available(); | 2748 inline intptr_t Available(); |
2735 | 2749 |
2736 virtual intptr_t Size() { | 2750 virtual intptr_t Size() { |
2737 return size_; | 2751 return size_; |
2738 } | 2752 } |
2739 | 2753 |
2740 virtual intptr_t SizeOfObjects() { | 2754 virtual intptr_t SizeOfObjects() { |
2741 return objects_size_; | 2755 return objects_size_; |
(...skipping 154 matching lines...) Loading... |
2896 } | 2910 } |
2897 // Must be small, since an iteration is used for lookup. | 2911 // Must be small, since an iteration is used for lookup. |
2898 static const int kMaxComments = 64; | 2912 static const int kMaxComments = 64; |
2899 }; | 2913 }; |
2900 #endif | 2914 #endif |
2901 | 2915 |
2902 | 2916 |
2903 } } // namespace v8::internal | 2917 } } // namespace v8::internal |
2904 | 2918 |
2905 #endif // V8_SPACES_H_ | 2919 #endif // V8_SPACES_H_ |
OLD | NEW |