Commit 9e0d44d4 authored by jochen@chromium.org's avatar jochen@chromium.org

Remove an unnecessary reinterpret_cast from a persistent to an handle

It's really only required for debug checks, and in debug builds, we can
take the hit of creating a safe handle

BUG=none
R=dcarney@chromium.org

Review URL: https://codereview.chromium.org/670483003

git-svn-id: svn://svn.chromium.org/blink/trunk@184000 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 69679510
......@@ -270,7 +270,9 @@ void ScriptProfiler::visitNodeWrappers(WrappedNodeVisitor* visitor)
public:
DOMNodeWrapperVisitor(WrappedNodeVisitor* visitor, v8::Isolate* isolate)
: m_visitor(visitor)
#if ENABLE(ASSERT)
, m_isolate(isolate)
#endif
{
}
......@@ -278,17 +280,23 @@ void ScriptProfiler::visitNodeWrappers(WrappedNodeVisitor* visitor)
{
if (classId != WrapperTypeInfo::NodeClassId)
return;
// Casting to Handle is safe here, since the Persistent cannot get
// GCd during visiting.
v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object>*>(value);
ASSERT_UNUSED(m_isolate, V8Node::hasInstance(*wrapper, m_isolate));
ASSERT((*wrapper)->IsObject());
m_visitor->visitNode(V8Node::toImpl(*wrapper));
#if ENABLE(ASSERT)
{
v8::HandleScope scope(m_isolate);
v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8::Persistent<v8::Object>::Cast(*value));
ASSERT(V8Node::hasInstance(wrapper, m_isolate));
ASSERT(wrapper->IsObject());
}
#endif
m_visitor->visitNode(toScriptWrappableBase(v8::Persistent<v8::Object>::Cast(*value))->toImpl<Node>());
}
private:
WrappedNodeVisitor* m_visitor;
#if ENABLE(ASSERT)
v8::Isolate* m_isolate;
#endif
} wrapperVisitor(visitor, isolate);
v8::V8::VisitHandlesWithClassIds(isolate, &wrapperVisitor);
......
......@@ -208,6 +208,11 @@ inline T* getInternalField(v8::Handle<v8::Object> wrapper)
return static_cast<T*>(wrapper->GetAlignedPointerFromInternalField(offset));
}
inline ScriptWrappableBase* toScriptWrappableBase(const v8::Persistent<v8::Object>& wrapper)
{
return getInternalField<ScriptWrappableBase, v8DOMWrapperObjectIndex>(wrapper);
}
inline ScriptWrappableBase* toScriptWrappableBase(v8::Handle<v8::Object> wrapper)
{
return getInternalField<ScriptWrappableBase, v8DOMWrapperObjectIndex>(wrapper);
......
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