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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 2640573003: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. (Closed)
Patch Set: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. 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_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 22e23911615cecd9d72dcd545b018d2983ff3b1b..e7017cfddfefce0e810db8140fb9521bb33f7486 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()->IsValidPersistentHandle(
+ reinterpret_cast<Dart_PersistentHandle>(handle)) ||
+ isolate->api_state()->IsValidWeakPersistentHandle(
+ 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();
@@ -759,6 +775,11 @@ void FinalizablePersistentHandle::Finalize(
// --- Handles ---
+DART_EXPORT bool Dart_IsValid(Dart_Handle handle) {
+ return Api::IsValid(handle);
+}
siva 2017/01/20 17:40:03 Not needed as you have dropped it from the API.
bkonyi 2017/01/20 23:07:11 Done.
+
+
DART_EXPORT bool Dart_IsError(Dart_Handle handle) {
return Api::IsError(handle);
}

Powered by Google App Engine
This is Rietveld 408576698