Chromium Code Reviews| Index: vm/pages.h |
| =================================================================== |
| --- vm/pages.h (revision 14048) |
| +++ vm/pages.h (working copy) |
| @@ -21,6 +21,12 @@ |
| // able to get to a HeapPage header quickly based on a pointer to an object. |
| class HeapPage { |
| public: |
| + enum PageType { |
| + kData = 0, |
| + kExecutable, |
| + kNumPageTypes |
| + }; |
| + |
| HeapPage* next() const { return next_; } |
| void set_next(HeapPage* next) { next_ = next; } |
| @@ -29,7 +35,8 @@ |
| } |
| uword object_start() const { |
| - return (reinterpret_cast<uword>(this) + sizeof(HeapPage)); |
| + return (reinterpret_cast<uword>(this) + |
| + Utils::RoundUp(sizeof(HeapPage), kObjectAlignment)); |
| } |
| uword object_end() const { |
| return object_end_; |
| @@ -41,6 +48,10 @@ |
| used_ += size; |
| } |
| + PageType type() const { |
| + return executable_ ? kExecutable : kData; |
| + } |
| + |
| void VisitObjects(ObjectVisitor* visitor) const; |
| void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| @@ -54,8 +65,8 @@ |
| object_end_ = val; |
| } |
| - static HeapPage* Initialize(VirtualMemory* memory, bool is_executable); |
| - static HeapPage* Allocate(intptr_t size, bool is_executable); |
| + static HeapPage* Initialize(VirtualMemory* memory, PageType type); |
| + static HeapPage* Allocate(intptr_t size, PageType type); |
| // Deallocate the virtual memory backing this page. The page pointer to this |
| // page becomes immediately inaccessible. |
| @@ -65,6 +76,7 @@ |
| HeapPage* next_; |
| uword used_; |
| uword object_end_; |
| + bool executable_; |
|
siva
2012/10/25 22:29:52
should this just be
PageType type_;
Ivan Posva
2012/10/25 23:45:41
If it really is needed, then I will switch this to
|
| friend class PageSpace; |
| @@ -157,16 +169,18 @@ |
| kForceGrowth |
| }; |
| - PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable = false); |
| + PageSpace(Heap* heap, intptr_t max_capacity); |
| ~PageSpace(); |
| - uword TryAllocate(intptr_t size); |
| - uword TryAllocate(intptr_t size, GrowthPolicy growth_policy); |
| + uword TryAllocate(intptr_t size, |
| + HeapPage::PageType type = HeapPage::kData, |
| + GrowthPolicy growth_policy = kControlGrowth); |
| intptr_t in_use() const { return in_use_; } |
| intptr_t capacity() const { return capacity_; } |
| bool Contains(uword addr) const; |
| + bool Contains(uword addr, HeapPage::PageType type) const; |
| bool IsValidAddress(uword addr) const { |
| return Contains(addr); |
| } |
| @@ -208,9 +222,9 @@ |
| private: |
| static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); |
| - HeapPage* AllocatePage(); |
| + HeapPage* AllocatePage(HeapPage::PageType type); |
| void FreePage(HeapPage* page, HeapPage* previous_page); |
| - HeapPage* AllocateLargePage(intptr_t size); |
| + HeapPage* AllocateLargePage(intptr_t size, HeapPage::PageType type); |
| void FreeLargePage(HeapPage* page, HeapPage* previous_page); |
| void FreePages(HeapPage* pages); |
| @@ -221,7 +235,7 @@ |
| return increase <= (max_capacity_ - capacity_); |
| } |
| - FreeList freelist_; |
| + FreeList freelist_[HeapPage::kNumPageTypes]; |
| Heap* heap_; |
| @@ -239,8 +253,6 @@ |
| // Old-gen GC cycle count. |
| int count_; |
| - bool is_executable_; |
| - |
| // Keep track whether a MarkSweep is currently running. |
| bool sweeping_; |