Use mutex in PostponeInterruptScope.
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 5 Feb 2014 11:28:55 +0000 (11:28 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 5 Feb 2014 11:28:55 +0000 (11:28 +0000)
To avoid race with e.g. StackGuard::RequestInstallCode called from another
thread when both access postpone_interrupts_nesting_.

R=mvstanton@chromium.org
BUG=290964
LOG=N

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

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

src/isolate.h

index 8b935fb..d93a862 100644 (file)
@@ -1491,18 +1491,21 @@ class StackLimitCheck BASE_EMBEDDED {
 class PostponeInterruptsScope BASE_EMBEDDED {
  public:
   explicit PostponeInterruptsScope(Isolate* isolate)
-      : stack_guard_(isolate->stack_guard()) {
+      : stack_guard_(isolate->stack_guard()), isolate_(isolate) {
+    ExecutionAccess access(isolate_);
     stack_guard_->thread_local_.postpone_interrupts_nesting_++;
     stack_guard_->DisableInterrupts();
   }
 
   ~PostponeInterruptsScope() {
+    ExecutionAccess access(isolate_);
     if (--stack_guard_->thread_local_.postpone_interrupts_nesting_ == 0) {
       stack_guard_->EnableInterrupts();
     }
   }
  private:
   StackGuard* stack_guard_;
+  Isolate* isolate_;
 };