Use PassRefPtr in V8DOMWrapper interface to avoid explicit ref() calls
authoradamk@chromium.org <adamk@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Apr 2012 01:38:28 +0000 (01:38 +0000)
committeradamk@chromium.org <adamk@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Apr 2012 01:38:28 +0000 (01:38 +0000)
commitb369a943126f58e66920e3db8441ebb3df8be03f
tree6696c224922764a6b32ef1f4853c9c3b90f8ce84
parentab4079bef1f0b3d996c8ae8e420f5a2eb073475e
Use PassRefPtr in V8DOMWrapper interface to avoid explicit ref() calls
https://bugs.webkit.org/show_bug.cgi?id=82238

Reviewed by Adam Barth.

Relanding r112163 without modification, as it still seems valid.
Will watch Chrome Canaries closely for any memory issues.

The setJSWrapper* methods previously featured a comment that asked
callers to ref the objects before passing them in. This change makes
that contract explicit (and allows the removal of the comment).

In addition, for ConstructorCallbacks, this change slightly reduces
refcount churn by passing on the initial ref via RefPtr::release().

No new tests, no change in behavior.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateConstructorCallback): Use RefPtr::release() to avoid refcount churn and remove explicit ref() call.
(GenerateNamedConstructorCallback): ditto.
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::V8DOMWindowShell::installDOMWindow): Cast to a PassRefPtr and remove explicit ref call.
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::setJSWrapperForDOMNode): Pass leaked refs into the DOMNodeMaps.
* bindings/v8/V8DOMWrapper.h:
(V8DOMWrapper): Make the setJSWrapperFor* methods take PassRefPtr<T>.
(WebCore::V8DOMWrapper::setJSWrapperForDOMObject): Pass leaked ref into the DOMObjectMap.
(WebCore::V8DOMWrapper::setJSWrapperForActiveDOMObject): Pass leaked ref into the ActiveDOMObjectMap.
* bindings/v8/V8Proxy.h:
(WebCore::toV8): Remove explicit ref.
* bindings/v8/WorkerContextExecutionProxy.cpp:
(WebCore::WorkerContextExecutionProxy::initContextIfNeeded): Cast to a PassRefPTr and remove explicit ref call.
* bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
(WebCore::v8HTMLImageElementConstructorCallback): Use RefPtr::release() to avoid refcount churn and remove explicit ref.
* bindings/v8/custom/V8WebKitMutationObserverCustom.cpp:
(WebCore::V8WebKitMutationObserver::constructorCallback): ditto.
* bindings/v8/custom/V8WebSocketCustom.cpp:
(WebCore::V8WebSocket::constructorCallback): ditto.
* bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
(WebCore::V8XMLHttpRequest::constructorCallback): ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@113272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
Source/WebCore/bindings/v8/V8DOMWrapper.cpp
Source/WebCore/bindings/v8/V8DOMWrapper.h
Source/WebCore/bindings/v8/V8Proxy.h
Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp
Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp
Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp