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

Side by Side Diff: runtime/vm/isolate.cc

Issue 2344193002: Make NoReloadScope thread safe (Closed)
Patch Set: 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 unified diff | Download patch
« runtime/vm/isolate.h ('K') | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/isolate.h" 5 #include "vm/isolate.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/text_buffer.h" 10 #include "platform/text_buffer.h"
11 #include "vm/atomic.h"
11 #include "vm/class_finalizer.h" 12 #include "vm/class_finalizer.h"
12 #include "vm/code_observers.h" 13 #include "vm/code_observers.h"
13 #include "vm/compiler.h" 14 #include "vm/compiler.h"
14 #include "vm/compiler_stats.h" 15 #include "vm/compiler_stats.h"
15 #include "vm/dart_api_message.h" 16 #include "vm/dart_api_message.h"
16 #include "vm/dart_api_state.h" 17 #include "vm/dart_api_state.h"
17 #include "vm/dart_entry.h" 18 #include "vm/dart_entry.h"
18 #include "vm/debugger.h" 19 #include "vm/debugger.h"
19 #include "vm/deopt_instructions.h" 20 #include "vm/deopt_instructions.h"
20 #include "vm/flags.h" 21 #include "vm/flags.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 NoOOBMessageScope::NoOOBMessageScope(Thread* thread) : StackResource(thread) { 136 NoOOBMessageScope::NoOOBMessageScope(Thread* thread) : StackResource(thread) {
136 thread->DeferOOBMessageInterrupts(); 137 thread->DeferOOBMessageInterrupts();
137 } 138 }
138 139
139 140
140 NoOOBMessageScope::~NoOOBMessageScope() { 141 NoOOBMessageScope::~NoOOBMessageScope() {
141 thread()->RestoreOOBMessageInterrupts(); 142 thread()->RestoreOOBMessageInterrupts();
142 } 143 }
143 144
144 145
145
146 NoReloadScope::NoReloadScope(Isolate* isolate, Thread* thread) 146 NoReloadScope::NoReloadScope(Isolate* isolate, Thread* thread)
147 : StackResource(thread), 147 : StackResource(thread),
148 isolate_(isolate) { 148 isolate_(isolate) {
149 ASSERT(isolate_ != NULL); 149 ASSERT(isolate_ != NULL);
150 isolate_->no_reload_scope_depth_++; 150 AtomicOperations::FetchAndIncrement(&(isolate_->no_reload_scope_depth_));
151 ASSERT(isolate_->no_reload_scope_depth_ >= 0);
152 } 151 }
153 152
154 153
155 NoReloadScope::~NoReloadScope() { 154 NoReloadScope::~NoReloadScope() {
156 isolate_->no_reload_scope_depth_--; 155 uintptr_t previous_value =
157 ASSERT(isolate_->no_reload_scope_depth_ >= 0); 156 AtomicOperations::FetchAndDecrement(&(isolate_->no_reload_scope_depth_));
157 // If the previous value was 0 we have underflowed.
158 ASSERT(previous_value != 0);
158 } 159 }
159 160
160 161
161 void Isolate::RegisterClass(const Class& cls) { 162 void Isolate::RegisterClass(const Class& cls) {
162 NOT_IN_PRODUCT( 163 NOT_IN_PRODUCT(
163 if (IsReloading()) { 164 if (IsReloading()) {
164 reload_context()->RegisterClass(cls); 165 reload_context()->RegisterClass(cls);
165 return; 166 return;
166 } 167 }
167 ) 168 )
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 } 1068 }
1068 lib.InitExportedNamesCache(); 1069 lib.InitExportedNamesCache();
1069 } 1070 }
1070 TokenStream::CloseSharedTokenList(this); 1071 TokenStream::CloseSharedTokenList(this);
1071 } 1072 }
1072 1073
1073 1074
1074 bool Isolate::CanReload() const { 1075 bool Isolate::CanReload() const {
1075 #ifndef PRODUCT 1076 #ifndef PRODUCT
1076 return !ServiceIsolate::IsServiceIsolateDescendant(this) && 1077 return !ServiceIsolate::IsServiceIsolateDescendant(this) &&
1077 is_runnable() && !IsReloading() && (no_reload_scope_depth_ == 0) && 1078 is_runnable() && !IsReloading() &&
1079 (AtomicOperations::LoadRelaxed(&no_reload_scope_depth_) == 0) &&
1078 IsolateCreationEnabled(); 1080 IsolateCreationEnabled();
1079 #else 1081 #else
1080 return false; 1082 return false;
1081 #endif 1083 #endif
1082 } 1084 }
1083 1085
1084 1086
1085 #ifndef PRODUCT 1087 #ifndef PRODUCT
1086 bool Isolate::ReloadSources(JSONStream* js, 1088 bool Isolate::ReloadSources(JSONStream* js,
1087 bool force_reload, 1089 bool force_reload,
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after
2893 void IsolateSpawnState::DecrementSpawnCount() { 2895 void IsolateSpawnState::DecrementSpawnCount() {
2894 ASSERT(spawn_count_monitor_ != NULL); 2896 ASSERT(spawn_count_monitor_ != NULL);
2895 ASSERT(spawn_count_ != NULL); 2897 ASSERT(spawn_count_ != NULL);
2896 MonitorLocker ml(spawn_count_monitor_); 2898 MonitorLocker ml(spawn_count_monitor_);
2897 ASSERT(*spawn_count_ > 0); 2899 ASSERT(*spawn_count_ > 0);
2898 *spawn_count_ = *spawn_count_ - 1; 2900 *spawn_count_ = *spawn_count_ - 1;
2899 ml.Notify(); 2901 ml.Notify();
2900 } 2902 }
2901 2903
2902 } // namespace dart 2904 } // namespace dart
OLDNEW
« runtime/vm/isolate.h ('K') | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698