Reviewers: Michael Starzinger,

Message:
AlwaysAllocateScope is soon used from multiple threads.


https://codereview.chromium.org/1325173003/diff/40001/src/heap/heap.h
File src/heap/heap.h (left):

https://codereview.chromium.org/1325173003/diff/40001/src/heap/heap.h#oldcode780
src/heap/heap.h:780: Address always_allocate_scope_depth_address() {
Don't even think about it...

Description:
[heap] Make AlwaysAlloceScope thread-safe.

BUG=chromium:524425
LOG=N
[email protected]

Please review this at https://codereview.chromium.org/1325173003/

Base URL: https://chromium.googlesource.com/v8/v8.git@concurrency-support

Affected files (+8, -8 lines):
  M src/heap/heap.h
  M src/heap/heap.cc
  M src/heap/heap-inl.h


Index: src/heap/heap-inl.h
diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h
index 29ba854846a5acd4dfa97b1afd1c54d1ddc920f2..36e56a0aba75e8e8e50b558d549885210c23d028 100644
--- a/src/heap/heap-inl.h
+++ b/src/heap/heap-inl.h
@@ -749,12 +749,12 @@ void Heap::SetSetterStubDeoptPCOffset(int pc_offset) {

 AlwaysAllocateScope::AlwaysAllocateScope(Isolate* isolate)
     : heap_(isolate->heap()), daf_(isolate) {
-  heap_->always_allocate_scope_depth_++;
+  heap_->always_allocate_scope_count_.Increment(1);
 }


 AlwaysAllocateScope::~AlwaysAllocateScope() {
-  heap_->always_allocate_scope_depth_--;
+  heap_->always_allocate_scope_count_.Increment(-1);
 }


Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 9c6a2a1690cdba36130ba3147302a84acf43d45d..0c47d8c4b7aa3f3122d23bf94ff0139866a7f2ce 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -74,7 +74,7 @@ Heap::Heap()
       maximum_committed_(0),
       survived_since_last_expansion_(0),
       survived_last_scavenge_(0),
-      always_allocate_scope_depth_(0),
+      always_allocate_scope_count_(0),
       contexts_disposed_(0),
       global_ic_age_(0),
       scan_on_scavenge_pages_(0),
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index d74d9cff958dfc1e316b425f4138e662de11f345..6e3b4cfa7021034902863b85bacf9b407bcf23bd 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -10,6 +10,7 @@

 #include "src/allocation.h"
 #include "src/assert-scope.h"
+#include "src/atomic-utils.h"
 #include "src/globals.h"
 #include "src/heap/gc-idle-time-handler.h"
 #include "src/heap/incremental-marking.h"
@@ -776,10 +777,7 @@ class Heap {
     return old_generation_allocation_limit_;
   }

-  bool always_allocate() { return always_allocate_scope_depth_ != 0; }
-  Address always_allocate_scope_depth_address() {
-    return reinterpret_cast<Address>(&always_allocate_scope_depth_);
-  }
+ bool always_allocate() { return always_allocate_scope_count_.Value() != 0; }

   Address* NewSpaceAllocationTopAddress() {
     return new_space_.allocation_top_address();
@@ -2134,7 +2132,9 @@ class Heap {
   // ... and since the last scavenge.
   int survived_last_scavenge_;

-  int always_allocate_scope_depth_;
+ // This is not the depth of nested AlwaysAllocateScope's but rather a single
+  // count, as scopes can be acquired from multiple tasks (read: threads).
+  AtomicValue always_allocate_scope_count_;

   // For keeping track of context disposals.
   int contexts_disposed_;


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to