From 966aafbc8155184868499e51ae479a9401a9d08e Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Mon, 18 May 2015 15:13:35 -0700 Subject: [PATCH] Fix fall out from hide isolate pointer change BUG= Review URL: https://codereview.chromium.org//1146523003 --- runtime/vm/debugger_api_impl.cc | 10 ++++++---- runtime/vm/isolate.cc | 17 ++++++++++++++++- runtime/vm/isolate.h | 1 + 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/runtime/vm/debugger_api_impl.cc b/runtime/vm/debugger_api_impl.cc index 194861aef9a..f4f893e14c1 100644 --- a/runtime/vm/debugger_api_impl.cc +++ b/runtime/vm/debugger_api_impl.cc @@ -976,14 +976,16 @@ DART_EXPORT Dart_Handle Dart_SetLibraryDebuggable(intptr_t library_id, DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id) { - Isolate* isolate = PortMap::GetIsolate(isolate_id); - return Api::CastIsolate(isolate); + // Dart_Isolate is now the same as Dart_IsolateId. + // TODO(johnmccutchan): Kill Dart_IsolateId. + return reinterpret_cast(isolate_id); } DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { - Isolate* isolate = Api::CastIsolate(dart_isolate); - return isolate->debugger()->GetIsolateId(); + // Dart_Isolate is now the same as Dart_IsolateId. + // TODO(johnmccutchan): Kill Dart_IsolateId. + return reinterpret_cast(dart_isolate); } } // namespace dart diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index d0fa2bf580b..2f77c59e695 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -1668,7 +1668,8 @@ void Isolate::TrackDeoptimizedCode(const Code& code) { void Isolate::WakePauseEventHandler(Dart_Isolate isolate) { - Isolate* iso = reinterpret_cast(isolate); + Isolate* iso = FindIsolateInList(isolate); + ASSERT(iso != NULL); MonitorLocker ml(iso->pause_loop_monitor_); ml.Notify(); } @@ -1737,6 +1738,20 @@ intptr_t Isolate::IsolateListLength() { } +Isolate* Isolate::FindIsolateInList(Dart_Isolate isolate) { + MonitorLocker ml(isolates_list_monitor_); + Isolate* current = isolates_list_head_; + while (current != NULL) { + if (Api::CastIsolate(current) == isolate) { + // We've found the isolate. + return current; + } + current = current->next_; + } + return NULL; +} + + void Isolate::AddIsolateTolist(Isolate* isolate) { MonitorLocker ml(isolates_list_monitor_); ASSERT(isolate != NULL); diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h index 9ee689f01d6..077789651d7 100644 --- a/runtime/vm/isolate.h +++ b/runtime/vm/isolate.h @@ -819,6 +819,7 @@ class Isolate : public BaseIsolate { static void WakePauseEventHandler(Dart_Isolate isolate); // Manage list of existing isolates. + static Isolate* FindIsolateInList(Dart_Isolate isolate); static void AddIsolateTolist(Isolate* isolate); static void RemoveIsolateFromList(Isolate* isolate); static void CheckForDuplicateThreadState(InterruptableThreadState* state);