Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Unified Diff: runtime/vm/isolate.cc

Issue 2344193002: Make NoReloadScope thread safe (Closed)
Patch Set: fschneider review Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/atomic_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index f950d7ef3f2ebf225aa7d76889f380bacc8b343e..a58c7baaf5373bda3593acfe5e392e14a42cb287 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -8,6 +8,7 @@
#include "include/dart_native_api.h"
#include "platform/assert.h"
#include "platform/text_buffer.h"
+#include "vm/atomic.h"
#include "vm/class_finalizer.h"
#include "vm/code_observers.h"
#include "vm/compiler.h"
@@ -142,19 +143,20 @@ NoOOBMessageScope::~NoOOBMessageScope() {
}
-
NoReloadScope::NoReloadScope(Isolate* isolate, Thread* thread)
: StackResource(thread),
isolate_(isolate) {
ASSERT(isolate_ != NULL);
- isolate_->no_reload_scope_depth_++;
- ASSERT(isolate_->no_reload_scope_depth_ >= 0);
+ AtomicOperations::FetchAndIncrement(&(isolate_->no_reload_scope_depth_));
+ ASSERT(
+ AtomicOperations::LoadRelaxed(&(isolate_->no_reload_scope_depth_)) >= 0);
}
NoReloadScope::~NoReloadScope() {
- isolate_->no_reload_scope_depth_--;
- ASSERT(isolate_->no_reload_scope_depth_ >= 0);
+ AtomicOperations::FetchAndDecrement(&(isolate_->no_reload_scope_depth_));
+ ASSERT(
+ AtomicOperations::LoadRelaxed(&(isolate_->no_reload_scope_depth_)) >= 0);
}
@@ -1074,7 +1076,8 @@ void Isolate::DoneLoading() {
bool Isolate::CanReload() const {
#ifndef PRODUCT
return !ServiceIsolate::IsServiceIsolateDescendant(this) &&
- is_runnable() && !IsReloading() && (no_reload_scope_depth_ == 0) &&
+ is_runnable() && !IsReloading() &&
+ (AtomicOperations::LoadRelaxed(&no_reload_scope_depth_) == 0) &&
IsolateCreationEnabled();
#else
return false;
« no previous file with comments | « runtime/vm/atomic_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698