Commit 515aec20 authored by dcarney@chromium.org's avatar dcarney@chromium.org

Transforming PersistentHandleVisitor to not need to copy Persistent handles.

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
parent fec64cd6
......@@ -228,6 +228,7 @@ typedef void (*NearDeathCallback)(Isolate* isolate,
#define V8_USE_UNSAFE_HANDLES
#define V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
/**
* An object reference managed by the v8 garbage collector.
......@@ -4135,8 +4136,13 @@ class V8EXPORT ExternalResourceVisitor { // NOLINT
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
};
......
......@@ -5100,8 +5100,14 @@ class VisitorAdapter : public i::ObjectVisitor {
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_;
......
......@@ -17785,12 +17785,19 @@ class Visitor42 : public v8::PersistentHandleVisitor {
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_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment