Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Unified Diff: src/heap/spaces.h

Issue 1487853002: [heap] Move to LAB-based allocation for newspace evacuation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added non-sticky and sticky bailout mode to old space for the new space allocation Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index 40604d424cc425b43871446b53d41599fd395a6c..ce1c79c6ed90a032b9c384082c5127579c6def37 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -1465,7 +1465,13 @@ class PageIterator BASE_EMBEDDED {
// space.
class AllocationInfo {
public:
- AllocationInfo() : top_(NULL), limit_(NULL) {}
+ AllocationInfo() : top_(nullptr), limit_(nullptr) {}
+ AllocationInfo(Address top, Address limit) : top_(top), limit_(limit) {}
+
+ void Reset(Address top, Address limit) {
+ set_top(top);
+ set_limit(limit);
+ }
INLINE(void set_top(Address top)) {
SLOW_DCHECK(top == NULL ||
@@ -1862,6 +1868,37 @@ class AllocationResult {
STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize);
+class LocalAllocationBuffer {
Hannes Payer (out of office) 2015/12/18 10:29:06 This class needs a bunch of comments, explaining w
Michael Lippautz 2015/12/18 10:53:05 Done.
+ public:
+ static inline LocalAllocationBuffer InvalidBuffer();
+ static inline LocalAllocationBuffer FromResult(Heap* heap,
+ AllocationResult result,
+ intptr_t size);
+
+ ~LocalAllocationBuffer() { Close(); }
+
+ // Convert to C++11 move-semantics once allowed by the style guide.
+ LocalAllocationBuffer(const LocalAllocationBuffer& other);
+ LocalAllocationBuffer& operator=(const LocalAllocationBuffer& other);
+
+ MUST_USE_RESULT inline AllocationResult AllocateRawAligned(
+ int size_in_bytes, AllocationAlignment alignment);
+
+ inline bool IsValid() { return allocation_info_.top() != nullptr; }
+
+ // Try to merge LABs, which is only possible when they are adjacent in memory.
+ inline bool TryMerge(LocalAllocationBuffer* other);
+
+ private:
+ LocalAllocationBuffer(Heap* heap, AllocationInfo allocation_info);
+
+ void Close();
+
+ Heap* heap_;
+ AllocationInfo allocation_info_;
+};
+
+
class PagedSpace : public Space {
public:
static const intptr_t kCompactionMemoryWanted = 500 * KB;
@@ -1992,8 +2029,7 @@ class PagedSpace : public Space {
DCHECK(top == limit ||
Page::FromAddress(top) == Page::FromAddress(limit - 1));
MemoryChunk::UpdateHighWaterMark(allocation_info_.top());
- allocation_info_.set_top(top);
- allocation_info_.set_limit(limit);
+ allocation_info_.Reset(top, limit);
}
// Empty space allocation info, returning unused area to free list.
@@ -2734,6 +2770,9 @@ class NewSpace : public Space {
MUST_USE_RESULT INLINE(AllocationResult AllocateRaw(
int size_in_bytes, AllocationAlignment alignment));
+ MUST_USE_RESULT inline AllocationResult AllocateRawSynchronized(
+ int size_in_bytes, AllocationAlignment alignment);
+
// Reset the allocation pointer to the beginning of the active semispace.
void ResetAllocationInfo();
@@ -2783,6 +2822,7 @@ class NewSpace : public Space {
// are no pages, or the current page is already empty), or true
// if successful.
bool AddFreshPage();
+ bool AddFreshPageSynchronized();
#ifdef VERIFY_HEAP
// Verify the active semispace.
@@ -2826,6 +2866,8 @@ class NewSpace : public Space {
// Update allocation info to match the current to-space page.
void UpdateAllocationInfo();
+ base::Mutex mutex_;
+
Address chunk_base_;
uintptr_t chunk_size_;
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698