| Index: src/heap/spaces.h
|
| diff --git a/src/heap/spaces.h b/src/heap/spaces.h
|
| index 40604d424cc425b43871446b53d41599fd395a6c..2d61cdd97e23c5bb8d75b824618042139f568cbc 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,34 @@ class AllocationResult {
|
| STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize);
|
|
|
|
|
| +class LocalAllocationBuffer {
|
| + 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; }
|
| +
|
| + 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 +2026,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 +2767,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 +2819,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 +2863,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_;
|
|
|
|
|