Index: runtime/bin/loader.cc |
diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc |
index 79e856a595b16f44d19cc3cd668292edefdb2a0f..58496c92def297030a6a65bf60374b2002a828f1 100644 |
--- a/runtime/bin/loader.cc |
+++ b/runtime/bin/loader.cc |
@@ -468,7 +468,8 @@ intptr_t Loader::loader_infos_capacity_ = 0; |
// correct loader. |
// This happens whenever an isolate begins loading. |
void Loader::AddLoader(Dart_Port port, IsolateData* isolate_data) { |
- ASSERT(LoaderFor(port) == NULL); |
+ MutexLocker ml(&loader_infos_lock_); |
+ ASSERT(LoaderForLocked(port) == NULL); |
if (loader_infos_length_ == loader_infos_capacity_) { |
// Grow to an initial capacity or double in size. |
loader_infos_capacity_ = |
@@ -488,13 +489,14 @@ void Loader::AddLoader(Dart_Port port, IsolateData* isolate_data) { |
loader_infos_[loader_infos_length_].port = port; |
loader_infos_[loader_infos_length_].isolate_data = isolate_data; |
loader_infos_length_++; |
- ASSERT(LoaderFor(port) != NULL); |
+ ASSERT(LoaderForLocked(port) != NULL); |
} |
// Remove |port| from the map. |
// This happens once an isolate has finished loading. |
void Loader::RemoveLoader(Dart_Port port) { |
+ MutexLocker ml(&loader_infos_lock_); |
const intptr_t index = LoaderIndexFor(port); |
ASSERT(index >= 0); |
const intptr_t last = loader_infos_length_ - 1; |
@@ -517,7 +519,7 @@ intptr_t Loader::LoaderIndexFor(Dart_Port port) { |
} |
-Loader* Loader::LoaderFor(Dart_Port port) { |
+Loader* Loader::LoaderForLocked(Dart_Port port) { |
zra
2016/06/07 04:51:46
ASSERT(loader_infos_lock_.IsOwnedByCurrentThread()
Cutch
2016/06/07 14:22:15
The threads interface under bin/ does not have IsO
|
intptr_t index = LoaderIndexFor(port); |
if (index < 0) { |
return NULL; |
@@ -526,9 +528,16 @@ Loader* Loader::LoaderFor(Dart_Port port) { |
} |
+Loader* Loader::LoaderFor(Dart_Port port) { |
+ MutexLocker ml(&loader_infos_lock_); |
+ return LoaderForLocked(port); |
+} |
+ |
+ |
void Loader::NativeMessageHandler(Dart_Port dest_port_id, |
Dart_CObject* message) { |
- Loader* loader = LoaderFor(dest_port_id); |
+ MutexLocker ml(&loader_infos_lock_); |
+ Loader* loader = LoaderForLocked(dest_port_id); |
if (loader == NULL) { |
return; |
} |