Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
| index ad6daba1a2ddd0a6b6740cc892f3deaf2dad6e28..9a4f823b171ea40d4637d9068fbaa340bcc807c3 100644 |
| --- a/runtime/vm/dart_api_impl.cc |
| +++ b/runtime/vm/dart_api_impl.cc |
| @@ -534,6 +534,22 @@ Dart_Handle Api::AcquiredError(Isolate* isolate) { |
| } |
| +bool Api::IsValid(Dart_Handle handle) { |
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
| + |
| + // Check against all of the handles in the current isolate as well as the |
| + // read-only handles. |
| + return isolate->thread_registry()->IsValidHandle(handle) || |
| + isolate->api_state()->IsActivePersistentHandle( |
|
bkonyi
2017/01/20 23:07:11
I added IsActive(Weak)PersistentHandle to check if
|
| + reinterpret_cast<Dart_PersistentHandle>(handle)) || |
| + isolate->api_state()->IsActiveWeakPersistentHandle( |
| + reinterpret_cast<Dart_WeakPersistentHandle>(handle)) || |
| + Dart::IsReadOnlyApiHandle(handle) || |
| + Dart::IsReadOnlyHandle(reinterpret_cast<uword>(handle)); |
| +} |
| + |
| + |
| ApiLocalScope* Api::TopScope(Thread* thread) { |
| ASSERT(thread != NULL); |
| ApiLocalScope* scope = thread->api_top_scope(); |