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, ...@@ -228,6 +228,7 @@ typedef void (*NearDeathCallback)(Isolate* isolate,
#define V8_USE_UNSAFE_HANDLES #define V8_USE_UNSAFE_HANDLES
#define V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
/** /**
* An object reference managed by the v8 garbage collector. * An object reference managed by the v8 garbage collector.
...@@ -4135,8 +4136,13 @@ class V8EXPORT ExternalResourceVisitor { // NOLINT ...@@ -4135,8 +4136,13 @@ class V8EXPORT ExternalResourceVisitor { // NOLINT
class V8EXPORT PersistentHandleVisitor { // NOLINT class V8EXPORT PersistentHandleVisitor { // NOLINT
public: public:
virtual ~PersistentHandleVisitor() {} virtual ~PersistentHandleVisitor() {}
#ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
virtual void VisitPersistentHandle(Persistent<Value> value, virtual void VisitPersistentHandle(Persistent<Value> value,
uint16_t class_id) {} 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 { ...@@ -5100,8 +5100,14 @@ class VisitorAdapter : public i::ObjectVisitor {
UNREACHABLE(); UNREACHABLE();
} }
virtual void VisitEmbedderReference(i::Object** p, uint16_t class_id) { 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)), visitor_->VisitPersistentHandle(ToApi<Value>(i::Handle<i::Object>(p)),
class_id); class_id);
#else
Value* value = ToApi<Value>(i::Handle<i::Object>(p));
visitor_->VisitPersistentHandle(
reinterpret_cast<Persistent<Value>*>(&value), class_id);
#endif
} }
private: private:
PersistentHandleVisitor* visitor_; PersistentHandleVisitor* visitor_;
......
...@@ -17785,12 +17785,19 @@ class Visitor42 : public v8::PersistentHandleVisitor { ...@@ -17785,12 +17785,19 @@ class Visitor42 : public v8::PersistentHandleVisitor {
explicit Visitor42(v8::Persistent<v8::Object> object) explicit Visitor42(v8::Persistent<v8::Object> object)
: counter_(0), object_(object) { } : counter_(0), object_(object) { }
#ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
virtual void VisitPersistentHandle(Persistent<Value> value, virtual void VisitPersistentHandle(Persistent<Value> value,
uint16_t class_id) { uint16_t class_id) {
VisitPersistentHandle(&value, class_id);
}
#endif
virtual void VisitPersistentHandle(Persistent<Value>* value,
uint16_t class_id) {
if (class_id == 42) { if (class_id == 42) {
CHECK(value->IsObject()); CHECK((*value)->IsObject());
v8::Persistent<v8::Object> visited = 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(42, visited.WrapperClassId(v8::Isolate::GetCurrent()));
CHECK_EQ(Handle<Value>(*object_), Handle<Value>(*visited)); CHECK_EQ(Handle<Value>(*object_), Handle<Value>(*visited));
++counter_; ++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