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

Unified Diff: src/spaces.h

Issue 11782028: Parallel and concurrent sweeping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 months 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
« src/mark-compact.cc ('K') | « src/mark-compact.cc ('k') | src/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index bb7adf7133866eefe6e38b1631da5f0693ce860c..e9c80c1b26c2ce629e90bafaa42121740a39f12d 100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -454,6 +454,18 @@ class MemoryChunk {
// Return all current flags.
intptr_t GetFlags() { return flags_; }
+ intptr_t parallel_sweeping() const {
+ return parallel_sweeping_;
+ }
+
+ void set_parallel_sweeping(intptr_t state) {
+ parallel_sweeping_ = state;
+ }
+
+ bool TryParallelSweeping() {
+ return NoBarrier_CompareAndSwap(&parallel_sweeping_, 1, 0) == 1;
+ }
+
// Manage live byte count (count of bytes known to be live,
// because they are marked black).
void ResetLiveBytes() {
@@ -533,8 +545,8 @@ class MemoryChunk {
static const size_t kWriteBarrierCounterOffset =
kSlotsBufferOffset + kPointerSize + kPointerSize;
- static const size_t kHeaderSize =
- kWriteBarrierCounterOffset + kPointerSize + kIntSize + kIntSize;
+ static const size_t kHeaderSize = kWriteBarrierCounterOffset + kPointerSize +
+ kIntSize + kIntSize + kPointerSize;
static const int kBodyOffset =
CODE_POINTER_ALIGN(kHeaderSize + Bitmap::kSize);
@@ -685,6 +697,8 @@ class MemoryChunk {
// count highest number of bytes ever allocated on the page.
int high_water_mark_;
+ intptr_t parallel_sweeping_;
+
static MemoryChunk* Initialize(Heap* heap,
Address base,
size_t size,
@@ -1385,7 +1399,17 @@ class FreeListNode: public HeapObject {
// the end element of the linked list of free memory blocks.
class FreeListCategory {
public:
- FreeListCategory() : top_(NULL), end_(NULL), available_(0) {}
+ FreeListCategory() :
+ top_(NULL),
+ end_(NULL),
+ mutex_(OS::CreateMutex()),
+ available_(0) {}
+
+ ~FreeListCategory() {
+ delete mutex_;
+ }
+
+ intptr_t Concatenate(FreeListCategory* category);
void Reset();
@@ -1411,6 +1435,8 @@ class FreeListCategory {
int available() const { return available_; }
void set_available(int available) { available_ = available; }
+ Mutex* mutex() { return mutex_; }
+
#ifdef DEBUG
intptr_t SumFreeList();
int FreeListLength();
@@ -1419,6 +1445,7 @@ class FreeListCategory {
private:
FreeListNode* top_;
FreeListNode* end_;
+ Mutex* mutex_;
// Total available bytes in all blocks of this free list category.
int available_;
@@ -1452,6 +1479,8 @@ class FreeList BASE_EMBEDDED {
public:
explicit FreeList(PagedSpace* owner);
+ intptr_t Concatenate(FreeList* free_list);
+
// Clear the free list.
void Reset();
@@ -1499,6 +1528,11 @@ class FreeList BASE_EMBEDDED {
intptr_t EvictFreeListItems(Page* p);
+ FreeListCategory* small_list() { return &small_list_; }
+ FreeListCategory* medium_list() { return &medium_list_; }
+ FreeListCategory* large_list() { return &large_list_; }
+ FreeListCategory* huge_list() { return &huge_list_; }
+
private:
// The size range of blocks, in bytes.
static const int kMinBlockSize = 3 * kPointerSize;
@@ -1713,6 +1747,11 @@ class PagedSpace : public Space {
bool AdvanceSweeper(intptr_t bytes_to_sweep);
+ // When parallel sweeper threads are active this function waits
+ // for them to complete, otherwise AdvanceSweeper with size_in_bytes
+ // is called.
+ bool EnsureSweeperProgress(intptr_t size_in_bytes);
+
bool IsSweepingComplete() {
return !first_unswept_page_->is_valid();
}
@@ -1737,6 +1776,12 @@ class PagedSpace : public Space {
}
protected:
+ FreeList* free_list() { return &free_list_; }
+
+ void AddToAccountingStats(intptr_t bytes) {
+ accounting_stats_.DeallocateBytes(bytes);
+ }
+
int area_size_;
// Maximum capacity of this space.
@@ -1786,6 +1831,7 @@ class PagedSpace : public Space {
MUST_USE_RESULT virtual HeapObject* SlowAllocateRaw(int size_in_bytes);
friend class PageIterator;
+ friend class SweeperThread;
};
« src/mark-compact.cc ('K') | « src/mark-compact.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698