| Index: runtime/vm/dart_api_state.h
|
| diff --git a/runtime/vm/dart_api_state.h b/runtime/vm/dart_api_state.h
|
| index 1bff38cb7e745fb840fce9248ad5ed08ecfe3a4c..3ca4f728b0da255ed68ab03ba171bb7cbb50a1b6 100644
|
| --- a/runtime/vm/dart_api_state.h
|
| +++ b/runtime/vm/dart_api_state.h
|
| @@ -512,6 +512,17 @@ class PersistentHandles : Handles<kPersistentHandleSizeInWords,
|
| return IsValidScopedHandle(reinterpret_cast<uword>(object));
|
| }
|
|
|
| + bool IsFreeHandle(Dart_PersistentHandle object) const {
|
| + PersistentHandle* handle = free_list_;
|
| + while (handle != NULL) {
|
| + if (handle == reinterpret_cast<PersistentHandle*>(object)) {
|
| + return true;
|
| + }
|
| + handle = handle->Next();
|
| + }
|
| + return false;
|
| + }
|
| +
|
| // Returns a count of active handles (used for testing purposes).
|
| int CountHandles() const { return CountScopedHandles(); }
|
|
|
| @@ -594,6 +605,18 @@ class FinalizablePersistentHandles
|
| return IsValidScopedHandle(reinterpret_cast<uword>(object));
|
| }
|
|
|
| + bool IsFreeHandle(Dart_WeakPersistentHandle object) const {
|
| + MutexLocker ml(mutex_);
|
| + FinalizablePersistentHandle* handle = free_list_;
|
| + while (handle != NULL) {
|
| + if (handle == reinterpret_cast<FinalizablePersistentHandle*>(object)) {
|
| + return true;
|
| + }
|
| + handle = handle->Next();
|
| + }
|
| + return false;
|
| + }
|
| +
|
| // Returns a count of active handles (used for testing purposes).
|
| int CountHandles() const { return CountScopedHandles(); }
|
|
|
| @@ -742,10 +765,27 @@ class ApiState {
|
| return persistent_handles_.IsValidHandle(object);
|
| }
|
|
|
| + bool IsFreePersistentHandle(Dart_PersistentHandle object) const {
|
| + return persistent_handles_.IsFreeHandle(object);
|
| + }
|
| +
|
| + bool IsActivePersistentHandle(Dart_PersistentHandle object) const {
|
| + return IsValidPersistentHandle(object) && !IsFreePersistentHandle(object);
|
| + }
|
| +
|
| bool IsValidWeakPersistentHandle(Dart_WeakPersistentHandle object) const {
|
| return weak_persistent_handles_.IsValidHandle(object);
|
| }
|
|
|
| + bool IsFreeWeakPersistentHandle(Dart_WeakPersistentHandle object) const {
|
| + return weak_persistent_handles_.IsFreeHandle(object);
|
| + }
|
| +
|
| + bool IsActiveWeakPersistentHandle(Dart_WeakPersistentHandle object) const {
|
| + return IsValidWeakPersistentHandle(object) &&
|
| + !IsFreeWeakPersistentHandle(object);
|
| + }
|
| +
|
| bool IsProtectedHandle(PersistentHandle* object) const {
|
| if (object == NULL) return false;
|
| return object == null_ || object == true_ || object == false_;
|
|
|