/** Returns true if this handle was previously marked as independent. */
inline bool IsIndependent() const;
+ inline bool IsIndependent(Isolate* isolate) const;
/** Checks if the handle holds the only reference to an object. */
inline bool IsNearDeath() const;
static void ClearWeak(internal::Object** global_handle);
static void MarkIndependent(internal::Object** global_handle);
static bool IsGlobalIndependent(internal::Object** global_handle);
+ static bool IsGlobalIndependent(internal::Isolate* isolate,
+ internal::Object** global_handle);
static bool IsGlobalNearDeath(internal::Object** global_handle);
static bool IsGlobalWeak(internal::Object** global_handle);
static void SetWrapperClassId(internal::Object** global_handle,
template <class T>
+bool Persistent<T>::IsIndependent(Isolate* isolate) const {
+ if (this->IsEmpty()) return false;
+ return V8::IsGlobalIndependent(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(**this));
+}
+
+
+template <class T>
bool Persistent<T>::IsNearDeath() const {
if (this->IsEmpty()) return false;
return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this));
}
+bool V8::IsGlobalIndependent(i::Isolate* isolate, i::Object** obj) {
+ ASSERT(isolate == i::Isolate::Current());
+ LOG_API(isolate, "IsGlobalIndependent");
+ if (!isolate->IsInitialized()) return false;
+ return i::GlobalHandles::IsIndependent(obj);
+}
+
+
bool V8::IsGlobalNearDeath(i::Object** obj) {
i::Isolate* isolate = i::Isolate::Current();
LOG_API(isolate, "IsGlobalNearDeath");
object_a = v8::Persistent<v8::Object>::New(v8::Object::New());
}
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
bool object_a_disposed = false;
object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag);
CHECK(!object_a.IsIndependent());
+ CHECK(!object_a.IsIndependent(isolate));
object_a.MarkIndependent();
CHECK(object_a.IsIndependent());
+ CHECK(object_a.IsIndependent(isolate));
HEAP->PerformScavenge();
CHECK(object_a_disposed);
}