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

Unified Diff: runtime/vm/dart_api_state.h

Issue 2672833003: Fix for issue #28606. Removed loop which iterated over all threads in the thread registry to check … (Closed)
Patch Set: Created 3 years, 11 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
Index: runtime/vm/dart_api_state.h
diff --git a/runtime/vm/dart_api_state.h b/runtime/vm/dart_api_state.h
index 7946ef8ea5bfcc50162865e52d0b0efcb7e5ee69..8844d162ebd73f56717ae58dedf9caca9693af55 100644
--- a/runtime/vm/dart_api_state.h
+++ b/runtime/vm/dart_api_state.h
@@ -456,6 +456,7 @@ class PersistentHandles : Handles<kPersistentHandleSizeInWords,
: Handles<kPersistentHandleSizeInWords,
kPersistentHandlesPerChunk,
kOffsetOfRawPtrInPersistentHandle>(),
+ mutex_(new Mutex()),
bkonyi 2017/02/02 22:22:34 It looks like PersistentHandles contains shared ha
bkonyi 2017/02/02 22:43:03 As discussed with Siva, this isn't needed. Removed
siva 2017/02/02 22:51:13 FinalizablePersistentHandles has a lock because we
free_list_(NULL) {
if (FLAG_trace_handles) {
OS::PrintErr("*** Starting a new Persistent handle block 0x%" Px "\n",
@@ -463,6 +464,7 @@ class PersistentHandles : Handles<kPersistentHandleSizeInWords,
}
}
~PersistentHandles() {
+ delete mutex_;
free_list_ = NULL;
if (FLAG_trace_handles) {
OS::PrintErr("*** Handle Counts for 0x(%" Px "):Scoped = %d\n",
@@ -478,12 +480,14 @@ class PersistentHandles : Handles<kPersistentHandleSizeInWords,
// Visit all object pointers stored in the various handles.
void VisitObjectPointers(ObjectPointerVisitor* visitor) {
+ MutexLocker ml(mutex_);
Handles<kPersistentHandleSizeInWords, kPersistentHandlesPerChunk,
kOffsetOfRawPtrInPersistentHandle>::VisitObjectPointers(visitor);
}
// Visit all the handles.
void Visit(HandleVisitor* visitor) {
+ MutexLocker ml(mutex_);
Handles<kPersistentHandleSizeInWords, kPersistentHandlesPerChunk,
kOffsetOfRawPtrInPersistentHandle>::Visit(visitor);
}
@@ -491,6 +495,7 @@ class PersistentHandles : Handles<kPersistentHandleSizeInWords,
// Allocates a persistent handle, these have to be destroyed explicitly
// by calling FreeHandle.
PersistentHandle* AllocateHandle() {
+ MutexLocker ml(mutex_);
PersistentHandle* handle;
if (free_list_ != NULL) {
handle = free_list_;
@@ -503,16 +508,19 @@ class PersistentHandles : Handles<kPersistentHandleSizeInWords,
}
void FreeHandle(PersistentHandle* handle) {
+ MutexLocker ml(mutex_);
handle->FreeHandle(free_list());
set_free_list(handle);
}
// Validate if passed in handle is a Persistent Handle.
bool IsValidHandle(Dart_PersistentHandle object) const {
+ MutexLocker ml(mutex_);
return IsValidScopedHandle(reinterpret_cast<uword>(object));
}
bool IsFreeHandle(Dart_PersistentHandle object) const {
+ MutexLocker ml(mutex_);
PersistentHandle* handle = free_list_;
while (handle != NULL) {
if (handle == reinterpret_cast<PersistentHandle*>(object)) {
@@ -527,6 +535,7 @@ class PersistentHandles : Handles<kPersistentHandleSizeInWords,
int CountHandles() const { return CountScopedHandles(); }
private:
+ Mutex* mutex_;
PersistentHandle* free_list_;
DISALLOW_COPY_AND_ASSIGN(PersistentHandles);
};

Powered by Google App Engine
This is Rietveld 408576698