Revision: 24441
Author:   [email protected]
Date:     Tue Oct  7 16:11:31 2014 UTC
Log:      Fix data race on Debug::thread_local_.current_debug_scope_

BUG=v8:3614
[email protected]
LOG=n

Review URL: https://codereview.chromium.org/631223004
https://code.google.com/p/v8/source/detail?r=24441

Modified:
 /branches/bleeding_edge/src/debug.cc
 /branches/bleeding_edge/src/debug.h

=======================================
--- /branches/bleeding_edge/src/debug.cc        Tue Sep 30 15:29:08 2014 UTC
+++ /branches/bleeding_edge/src/debug.cc        Tue Oct  7 16:11:31 2014 UTC
@@ -563,7 +563,8 @@
   thread_local_.step_into_fp_ = 0;
   thread_local_.step_out_fp_ = 0;
   // TODO(isolates): frames_are_dropped_?
-  thread_local_.current_debug_scope_ = NULL;
+  base::NoBarrier_Store(&thread_local_.current_debug_scope_,
+                        static_cast<base::AtomicWord>(NULL));
   thread_local_.restarter_frame_function_pointer_ = NULL;
 }

@@ -3089,7 +3090,8 @@
       no_termination_exceptons_(debug_->isolate_,
                                 StackGuard::TERMINATE_EXECUTION) {
   // Link recursive debugger entry.
-  debug_->thread_local_.current_debug_scope_ = this;
+  base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_,
+                        reinterpret_cast<base::AtomicWord>(this));

   // Store the previous break id and frame id.
   break_id_ = debug_->break_id();
@@ -3126,7 +3128,8 @@
   }

   // Leaving this debugger entry.
-  debug_->thread_local_.current_debug_scope_ = prev_;
+  base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_,
+                        reinterpret_cast<base::AtomicWord>(prev_));

   // Restore to the previous break state.
   debug_->thread_local_.break_frame_id_ = break_frame_id_;
=======================================
--- /branches/bleeding_edge/src/debug.h Tue Sep 30 15:29:08 2014 UTC
+++ /branches/bleeding_edge/src/debug.h Tue Oct  7 16:11:31 2014 UTC
@@ -8,6 +8,7 @@
 #include "src/allocation.h"
 #include "src/arguments.h"
 #include "src/assembler.h"
+#include "src/base/atomicops.h"
 #include "src/base/platform/platform.h"
 #include "src/execution.h"
 #include "src/factory.h"
@@ -459,7 +460,10 @@
   }

   // Flags and states.
- DebugScope* debugger_entry() { return thread_local_.current_debug_scope_; }
+  DebugScope* debugger_entry() {
+    return reinterpret_cast<DebugScope*>(
+        base::NoBarrier_Load(&thread_local_.current_debug_scope_));
+  }
   inline Handle<Context> debug_context() { return debug_context_; }
   void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; }
   bool live_edit_enabled() const {
@@ -470,7 +474,7 @@
   inline bool is_loaded() const { return !debug_context_.is_null(); }
   inline bool has_break_points() const { return has_break_points_; }
   inline bool in_debug_scope() const {
-    return thread_local_.current_debug_scope_ != NULL;
+    return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_);
   }
   void set_disable_break(bool v) { break_disabled_ = v; }

@@ -599,7 +603,7 @@
   class ThreadLocal {
    public:
     // Top debugger entry.
-    DebugScope* current_debug_scope_;
+    base::AtomicWord current_debug_scope_;

     // Counter for generating next break id.
     int break_count_;

--
--
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