This gets rid of more places where Persistent handles are copied
(see crbug.com/236290 ).
Transition plan: after this CL, Blink will be modified to work both with and
without the #define, then the #define will be removed from V8.
The corresponding Blink side changes are in https://codereview.chromium.org/
15670010/ .
BUG=
R=dcarney@chromium.org, svenpanne@chromium.org
Review URL: https://codereview.chromium.org/
15974006
Patch from Marja Hölttä <marja@chromium.org>.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14871
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
#define V8_USE_UNSAFE_HANDLES
+#define V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
/**
* An object reference managed by the v8 garbage collector.
class V8EXPORT PersistentHandleVisitor { // NOLINT
public:
virtual ~PersistentHandleVisitor() {}
+#ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
virtual void VisitPersistentHandle(Persistent<Value> value,
uint16_t class_id) {}
+#else
+ virtual void VisitPersistentHandle(Persistent<Value>* value,
+ uint16_t class_id) {}
+#endif
};
UNREACHABLE();
}
virtual void VisitEmbedderReference(i::Object** p, uint16_t class_id) {
+#ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
visitor_->VisitPersistentHandle(ToApi<Value>(i::Handle<i::Object>(p)),
class_id);
+#else
+ Value* value = ToApi<Value>(i::Handle<i::Object>(p));
+ visitor_->VisitPersistentHandle(
+ reinterpret_cast<Persistent<Value>*>(&value), class_id);
+#endif
}
private:
PersistentHandleVisitor* visitor_;
explicit Visitor42(v8::Persistent<v8::Object> object)
: counter_(0), object_(object) { }
+#ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
virtual void VisitPersistentHandle(Persistent<Value> value,
uint16_t class_id) {
+ VisitPersistentHandle(&value, class_id);
+ }
+#endif
+
+ virtual void VisitPersistentHandle(Persistent<Value>* value,
+ uint16_t class_id) {
if (class_id == 42) {
- CHECK(value->IsObject());
+ CHECK((*value)->IsObject());
v8::Persistent<v8::Object> visited =
- v8::Persistent<v8::Object>::Cast(value);
+ v8::Persistent<v8::Object>::Cast(*value);
CHECK_EQ(42, visited.WrapperClassId(v8::Isolate::GetCurrent()));
CHECK_EQ(Handle<Value>(*object_), Handle<Value>(*visited));
++counter_;