Revision: 12904
Author: [email protected]
Date: Thu Nov 8 07:01:26 2012
Log: Implement MarkIndependent(Isolate*) and
MarkPartiallyDependent(Isolate*)
BUG=
TEST=cctest/test-api/IndependentWeakHandle
Review URL: https://codereview.chromium.org/11369131
Patch from Kentaro Hara <[email protected]>.
http://code.google.com/p/v8/source/detail?r=12904
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 Tue Nov 6 09:32:15 2012
+++ /branches/bleeding_edge/include/v8.h Thu Nov 8 07:01:26 2012
@@ -413,6 +413,7 @@
* or followed by a global GC epilogue callback.
*/
inline void MarkIndependent();
+ inline void MarkIndependent(Isolate* isolate);
/**
* Marks the reference to this object partially dependent. Partially
@@ -423,6 +424,7 @@
* after each garbage collection.
*/
inline void MarkPartiallyDependent();
+ inline void MarkPartiallyDependent(Isolate* isolate);
/** Returns true if this handle was previously marked as independent. */
inline bool IsIndependent() const;
@@ -3533,7 +3535,11 @@
WeakReferenceCallback);
static void ClearWeak(internal::Object** global_handle);
static void MarkIndependent(internal::Object** global_handle);
+ static void MarkIndependent(internal::Isolate* isolate,
+ internal::Object** global_handle);
static void MarkPartiallyDependent(internal::Object** global_handle);
+ static void MarkPartiallyDependent(internal::Isolate* isolate,
+ internal::Object** global_handle);
static bool IsGlobalIndependent(internal::Object** global_handle);
static bool IsGlobalIndependent(internal::Isolate* isolate,
internal::Object** global_handle);
@@ -4334,11 +4340,23 @@
void Persistent<T>::MarkIndependent() {
V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this));
}
+
+template <class T>
+void Persistent<T>::MarkIndependent(Isolate* isolate) {
+ V8::MarkIndependent(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(**this));
+}
template <class T>
void Persistent<T>::MarkPartiallyDependent() {
V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this));
}
+
+template <class T>
+void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
+ V8::MarkPartiallyDependent(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(**this));
+}
template <class T>
void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
=======================================
--- /branches/bleeding_edge/src/api.cc Wed Nov 7 00:49:17 2012
+++ /branches/bleeding_edge/src/api.cc Thu Nov 8 07:01:26 2012
@@ -649,6 +649,13 @@
LOG_API(isolate, "MarkIndependent");
isolate->global_handles()->MarkIndependent(object);
}
+
+
+void V8::MarkIndependent(i::Isolate* isolate, i::Object** object) {
+ ASSERT(isolate == i::Isolate::Current());
+ LOG_API(isolate, "MarkIndependent");
+ isolate->global_handles()->MarkIndependent(object);
+}
void V8::MarkPartiallyDependent(i::Object** object) {
@@ -656,6 +663,13 @@
LOG_API(isolate, "MarkPartiallyDependent");
isolate->global_handles()->MarkPartiallyDependent(object);
}
+
+
+void V8::MarkPartiallyDependent(i::Isolate* isolate, i::Object** object) {
+ ASSERT(isolate == i::Isolate::Current());
+ LOG_API(isolate, "MarkPartiallyDependent");
+ isolate->global_handles()->MarkPartiallyDependent(object);
+}
bool V8::IsGlobalIndependent(i::Object** obj) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Thu Nov 8 01:45:47 2012
+++ /branches/bleeding_edge/test/cctest/test-api.cc Thu Nov 8 07:01:26 2012
@@ -2610,14 +2610,15 @@
root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
root.MarkPartiallyDependent();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
// Groups are deleted, rebuild groups.
{
- g1s1.MarkPartiallyDependent();
- g1s2.MarkPartiallyDependent();
- g2s1.MarkPartiallyDependent();
- g2s2.MarkPartiallyDependent();
- g3s1.MarkPartiallyDependent();
- g3s2.MarkPartiallyDependent();
+ g1s1.MarkPartiallyDependent(isolate);
+ g1s2.MarkPartiallyDependent(isolate);
+ g2s1.MarkPartiallyDependent(isolate);
+ g2s2.MarkPartiallyDependent(isolate);
+ g3s1.MarkPartiallyDependent(isolate);
+ g3s2.MarkPartiallyDependent(isolate);
Persistent<Value> g1_objects[] = { g1s1, g1s2 };
Persistent<Value> g2_objects[] = { g2s1, g2s2 };
Persistent<Value> g3_objects[] = { g3s1, g3s2 };
@@ -5505,23 +5506,28 @@
v8::Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
- v8::Persistent<v8::Object> object_a;
+ v8::Persistent<v8::Object> object_a, object_b;
{
v8::HandleScope handle_scope;
object_a = v8::Persistent<v8::Object>::New(v8::Object::New());
+ object_b = v8::Persistent<v8::Object>::New(v8::Object::New());
}
v8::Isolate* isolate = v8::Isolate::GetCurrent();
bool object_a_disposed = false;
+ bool object_b_disposed = false;
object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag);
+ object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag);
CHECK(!object_a.IsIndependent());
- CHECK(!object_a.IsIndependent(isolate));
+ CHECK(!object_b.IsIndependent(isolate));
object_a.MarkIndependent();
+ object_b.MarkIndependent(isolate);
CHECK(object_a.IsIndependent());
- CHECK(object_a.IsIndependent(isolate));
+ CHECK(object_b.IsIndependent(isolate));
HEAP->PerformScavenge();
CHECK(object_a_disposed);
+ CHECK(object_b_disposed);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev