Revision: 12852 Author: [email protected] Date: Mon Nov 5 04:35:51 2012 Log: Implement IsIndependent(Isolate*)
BUG= TEST=cctest/test-api/IndependentWeakHandle Review URL: https://codereview.chromium.org/11368053 Patch from Kentaro Hara <[email protected]>. http://code.google.com/p/v8/source/detail?r=12852 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 02:25:32 2012 +++ /branches/bleeding_edge/include/v8.h Mon Nov 5 04:35:51 2012 @@ -392,6 +392,7 @@ * cell remain and IsEmpty will still return false. */ inline void Dispose(); + inline void Dispose(Isolate* isolate); /** * Make the reference to this object weak. When only weak handles @@ -3511,6 +3512,8 @@ static internal::Object** GlobalizeReference(internal::Object** handle); static void DisposeGlobal(internal::Object** global_handle); + static void DisposeGlobal(internal::Isolate* isolate, + internal::Object** global_handle); static void MakeWeak(internal::Object** global_handle, void* data, WeakReferenceCallback); @@ -4277,6 +4280,14 @@ if (this->IsEmpty()) return; V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this)); } + + +template <class T> +void Persistent<T>::Dispose(Isolate* isolate) { + if (this->IsEmpty()) return; + V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate), + reinterpret_cast<internal::Object**>(**this)); +} template <class T> ======================================= --- /branches/bleeding_edge/src/api.cc Mon Nov 5 02:25:32 2012 +++ /branches/bleeding_edge/src/api.cc Mon Nov 5 04:35:51 2012 @@ -681,6 +681,14 @@ if (!isolate->IsInitialized()) return; isolate->global_handles()->Destroy(obj); } + + +void V8::DisposeGlobal(i::Isolate* isolate, i::Object** obj) { + ASSERT(isolate == i::Isolate::Current()); + LOG_API(isolate, "DisposeGlobal"); + if (!isolate->IsInitialized()) return; + isolate->global_handles()->Destroy(obj); +} // --- H a n d l e s --- ======================================= --- /branches/bleeding_edge/test/cctest/test-api.cc Mon Nov 5 02:25:32 2012 +++ /branches/bleeding_edge/test/cctest/test-api.cc Mon Nov 5 04:35:51 2012 @@ -2345,6 +2345,14 @@ } CHECK_EQ(global->Length(), 3); global.Dispose(); + + { + v8::HandleScope scope; + Local<String> str = v8_str("str"); + global = v8::Persistent<String>::New(str); + } + CHECK_EQ(global->Length(), 3); + global.Dispose(v8::Isolate::GetCurrent()); } -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
