Execute a memory barrier when adding a new page to a space to synchronize access...
authorhpayer@chromium.org <hpayer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 14 Mar 2013 09:15:39 +0000 (09:15 +0000)
committerhpayer@chromium.org <hpayer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 14 Mar 2013 09:15:39 +0000 (09:15 +0000)
BUG=

Review URL: https://codereview.chromium.org/12342017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13941 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/spaces.cc

index 701d46f..2952fd5 100644 (file)
@@ -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;
 }