From f3bfd04bcfdbc9eedcbb925bdfd10427f821975b Mon Sep 17 00:00:00 2001 From: "haraken@chromium.org" Date: Fri, 17 Oct 2014 00:46:18 +0000 Subject: [PATCH] Pass an Isolate to v8::VisitHandlesWithClassIds The Isolate version of v8::VisitHandlesWithClassIds is needed for https://codereview.chromium.org/651713002/ R=dcarney@chromium.org Review URL: https://codereview.chromium.org/664473002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24671 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 7 +++++++ src/api.cc | 10 ++++++++++ test/cctest/test-api.cc | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/v8.h b/include/v8.h index f2f47a6..a191c07 100644 --- a/include/v8.h +++ b/include/v8.h @@ -5296,6 +5296,13 @@ class V8_EXPORT V8 { static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor); /** + * Iterates through all the persistent handles in isolate's heap that have + * class_ids. + */ + static void VisitHandlesWithClassIds( + Isolate* isolate, PersistentHandleVisitor* visitor); + + /** * Iterates through all the persistent handles in the current isolate's heap * that have class_ids and are candidates to be marked as partially dependent * handles. This will visit handles to young objects created since the last diff --git a/src/api.cc b/src/api.cc index 0febe84..4929fda 100644 --- a/src/api.cc +++ b/src/api.cc @@ -5115,6 +5115,16 @@ class VisitorAdapter : public i::ObjectVisitor { }; +void v8::V8::VisitHandlesWithClassIds(v8::Isolate* exported_isolate, + PersistentHandleVisitor* visitor) { + i::Isolate* isolate = reinterpret_cast(exported_isolate); + i::DisallowHeapAllocation no_allocation; + + VisitorAdapter visitor_adapter(visitor); + isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter); +} + + void v8::V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { i::Isolate* isolate = i::Isolate::Current(); i::DisallowHeapAllocation no_allocation; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 1c67e1f..283bcb8 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -20325,7 +20325,7 @@ TEST(PersistentHandleVisitor) { CHECK_EQ(42, object.WrapperClassId()); Visitor42 visitor(&object); - v8::V8::VisitHandlesWithClassIds(&visitor); + v8::V8::VisitHandlesWithClassIds(isolate, &visitor); CHECK_EQ(1, visitor.counter_); object.Reset(); -- 2.7.4