Revision: 12854
Author: [email protected]
Date: Mon Nov 5 05:20:45 2012
Log: Implement IsIndependent(Isolate*)
BUG=
TEST=cctest/test-api/IndependentWeakHandle
Committed: https://code.google.com/p/v8/source/detail?r=12852
Review URL: https://codereview.chromium.org/11368053
Patch from Kentaro Hara <[email protected]>.
http://code.google.com/p/v8/source/detail?r=12854
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Mon Nov 5 04:35:51 2012
+++ /branches/bleeding_edge/include/v8.h Mon Nov 5 05:20:45 2012
@@ -416,6 +416,7 @@
/** 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;
@@ -3520,6 +3521,8 @@
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,
@@ -4259,6 +4262,14 @@
if (this->IsEmpty()) return false;
return
V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this));
}
+
+
+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>
=======================================
--- /branches/bleeding_edge/src/api.cc Mon Nov 5 04:35:51 2012
+++ /branches/bleeding_edge/src/api.cc Mon Nov 5 05:20:45 2012
@@ -657,6 +657,14 @@
if (!isolate->IsInitialized()) return false;
return i::GlobalHandles::IsIndependent(obj);
}
+
+
+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) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Mon Nov 5 04:35:51 2012
+++ /branches/bleeding_edge/test/cctest/test-api.cc Mon Nov 5 05:20:45 2012
@@ -5419,11 +5419,14 @@
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);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev