Index: src/spaces.cc |
diff --git a/src/spaces.cc b/src/spaces.cc |
index 701d46f38bc63473e56cc367caddabfc210f8657..2952fd52cf9319126a87068af1003272b96e6d5e 100644 |
--- a/src/spaces.cc |
+++ b/src/spaces.cc |
@@ -537,6 +537,17 @@ bool MemoryChunk::CommitArea(size_t requested) { |
void MemoryChunk::InsertAfter(MemoryChunk* other) { |
next_chunk_ = other->next_chunk_; |
prev_chunk_ = other; |
+ |
+ // This memory barrier is needed since concurrent sweeper threads may iterate |
+ // over the list of pages while a new page is inserted. |
+ // TODO(hpayer): find a cleaner way to guarantee that the page list can be |
+ // expanded concurrently |
+ MemoryBarrier(); |
+ |
+ // The following two write operations can take effect in arbitrary order |
+ // since pages are always iterated by the sweeper threads in LIFO order, i.e, |
+ // the inserted page becomes visible for the sweeper threads after |
+ // other->next_chunk_ = this; |
other->next_chunk_->prev_chunk_ = this; |
other->next_chunk_ = this; |
} |