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

Unified Diff: runtime/vm/thread.cc

Issue 2640573003: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. (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/thread.cc
diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
index 620e542d209bec406d2116221d63c4c1a3d72e1a..3ff121d7af1443efd7851151d3453df6ab1198cc 100644
--- a/runtime/vm/thread.cc
+++ b/runtime/vm/thread.cc
@@ -746,6 +746,12 @@ intptr_t Thread::OffsetFromThread(const RuntimeEntry* runtime_entry) {
}
+bool Thread::IsValidHandle(Dart_Handle object) const {
+ return IsValidLocalHandle(object) || IsValidZoneHandle(object) ||
+ IsValidScopedHandle(object);
+}
+
+
bool Thread::IsValidLocalHandle(Dart_Handle object) const {
ApiLocalScope* scope = api_top_scope_;
while (scope != NULL) {
@@ -769,6 +775,18 @@ intptr_t Thread::CountLocalHandles() const {
}
+bool Thread::IsValidZoneHandle(Dart_Handle object) const {
+ Zone* zone = zone_;
+ while (zone != NULL) {
+ if (zone->handles()->IsValidZoneHandle(reinterpret_cast<uword>(object))) {
+ return true;
+ }
+ zone = zone->previous();
+ }
+ return false;
+}
+
+
intptr_t Thread::CountZoneHandles() const {
intptr_t count = 0;
Zone* zone = zone_;
@@ -781,6 +799,18 @@ intptr_t Thread::CountZoneHandles() const {
}
+bool Thread::IsValidScopedHandle(Dart_Handle object) const {
+ Zone* zone = zone_;
+ while (zone != NULL) {
+ if (zone->handles()->IsValidScopedHandle(reinterpret_cast<uword>(object))) {
+ return true;
+ }
+ zone = zone->previous();
+ }
+ return false;
+}
+
+
intptr_t Thread::CountScopedHandles() const {
intptr_t count = 0;
Zone* zone = zone_;

Powered by Google App Engine
This is Rietveld 408576698