Title: [183523] trunk/Source/WebCore
Revision
183523
Author
[email protected]
Date
2015-04-28 19:12:31 -0700 (Tue, 28 Apr 2015)

Log Message

Simplify DOM wrapper destruction, don't deref() in finalizers.
<https://webkit.org/b/144183>

Reviewed by Darin Adler.

DOM JS bindings had two mechanisms to call deref() on the WebCore object,
once through a weak finalizer, and once through the JSCell's regular destructor.

That was once believed to be an optimization, but these days the finalizer will
run just moments before the destructor anyway, all in the same call stack.
And more importantly, the finalizer is not guaranteed to run, for instance in the
case where a Weak is assigned to after going dead, but before the WeakBlock
has been swept by the incremental sweeper.

Simplify this by just removing the deref() from the generated finalizers.
This makes it easier to reason about DOM wrapper destruction, and eliminates
the awkward time window  where a DOM wrapper could have a null impl().

We could spend more time on figuring out a way to have finalizers manage the
destruction of these wrappers, but that would require fundamental changes to
our implementation of JSC::Weak pointers. It would allow us to make JSDOMWrapper
destructor-less, and shrink each wrapper object by 1 pointer (the ClassInfo*.)
However the risk:reward ratio does not seem justified at this point in time.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateImplementation):
* bindings/js/JSCSSValueCustom.cpp:
* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
(WebCore::JSTestActiveDOMObject::~JSTestActiveDOMObject):
(WebCore::JSTestActiveDOMObjectOwner::finalize):
* bindings/scripts/test/JS/JSTestActiveDOMObject.h:
* bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
(WebCore::JSTestCustomNamedGetter::~JSTestCustomNamedGetter):
(WebCore::JSTestCustomNamedGetterOwner::finalize):
* bindings/scripts/test/JS/JSTestCustomNamedGetter.h:
* bindings/scripts/test/JS/JSTestEventConstructor.cpp:
(WebCore::JSTestEventConstructor::~JSTestEventConstructor):
(WebCore::JSTestEventConstructorOwner::finalize):
* bindings/scripts/test/JS/JSTestEventConstructor.h:
* bindings/scripts/test/JS/JSTestEventTarget.cpp:
(WebCore::JSTestEventTarget::~JSTestEventTarget):
(WebCore::JSTestEventTargetOwner::finalize):
* bindings/scripts/test/JS/JSTestEventTarget.h:
* bindings/scripts/test/JS/JSTestException.cpp:
(WebCore::JSTestException::~JSTestException):
(WebCore::JSTestExceptionOwner::finalize):
* bindings/scripts/test/JS/JSTestException.h:
* bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
(WebCore::JSTestGenerateIsReachable::~JSTestGenerateIsReachable):
(WebCore::JSTestGenerateIsReachableOwner::finalize):
* bindings/scripts/test/JS/JSTestGenerateIsReachable.h:
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterface::~JSTestInterface):
(WebCore::JSTestInterfaceOwner::finalize):
* bindings/scripts/test/JS/JSTestInterface.h:
* bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
(WebCore::JSTestMediaQueryListListener::~JSTestMediaQueryListListener):
(WebCore::JSTestMediaQueryListListenerOwner::finalize):
* bindings/scripts/test/JS/JSTestMediaQueryListListener.h:
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
(WebCore::JSTestNamedConstructor::~JSTestNamedConstructor):
(WebCore::JSTestNamedConstructorOwner::finalize):
* bindings/scripts/test/JS/JSTestNamedConstructor.h:
* bindings/scripts/test/JS/JSTestNondeterministic.cpp:
(WebCore::JSTestNondeterministic::~JSTestNondeterministic):
(WebCore::JSTestNondeterministicOwner::finalize):
* bindings/scripts/test/JS/JSTestNondeterministic.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObj::~JSTestObj):
(WebCore::JSTestObjOwner::finalize):
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::JSTestOverloadedConstructors::~JSTestOverloadedConstructors):
(WebCore::JSTestOverloadedConstructorsOwner::finalize):
* bindings/scripts/test/JS/JSTestOverloadedConstructors.h:
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
(WebCore::JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface):
(WebCore::JSTestSerializedScriptValueInterfaceOwner::finalize):
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
(WebCore::JSTestTypedefs::~JSTestTypedefs):
(WebCore::JSTestTypedefsOwner::finalize):
* bindings/scripts/test/JS/JSTestTypedefs.h:
* bindings/scripts/test/JS/JSattribute.cpp:
(WebCore::JSattribute::~JSattribute):
(WebCore::JSattributeOwner::finalize):
* bindings/scripts/test/JS/JSattribute.h:
* bindings/scripts/test/JS/JSreadonly.cpp:
(WebCore::JSreadonly::~JSreadonly):
(WebCore::JSreadonlyOwner::finalize):
* bindings/scripts/test/JS/JSreadonly.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183522 => 183523)


--- trunk/Source/WebCore/ChangeLog	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/ChangeLog	2015-04-29 02:12:31 UTC (rev 183523)
@@ -1,3 +1,98 @@
+2015-04-28  Andreas Kling  <[email protected]>
+
+        Simplify DOM wrapper destruction, don't deref() in finalizers.
+        <https://webkit.org/b/144183>
+
+        Reviewed by Darin Adler.
+
+        DOM JS bindings had two mechanisms to call deref() on the WebCore object,
+        once through a weak finalizer, and once through the JSCell's regular destructor.
+
+        That was once believed to be an optimization, but these days the finalizer will
+        run just moments before the destructor anyway, all in the same call stack.
+        And more importantly, the finalizer is not guaranteed to run, for instance in the
+        case where a Weak is assigned to after going dead, but before the WeakBlock
+        has been swept by the incremental sweeper.
+
+        Simplify this by just removing the deref() from the generated finalizers.
+        This makes it easier to reason about DOM wrapper destruction, and eliminates
+        the awkward time window  where a DOM wrapper could have a null impl().
+
+        We could spend more time on figuring out a way to have finalizers manage the
+        destruction of these wrappers, but that would require fundamental changes to
+        our implementation of JSC::Weak pointers. It would allow us to make JSDOMWrapper
+        destructor-less, and shrink each wrapper object by 1 pointer (the ClassInfo*.)
+        However the risk:reward ratio does not seem justified at this point in time.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHeader):
+        (GenerateImplementation):
+        * bindings/js/JSCSSValueCustom.cpp:
+        * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
+        (WebCore::JSTestActiveDOMObject::~JSTestActiveDOMObject):
+        (WebCore::JSTestActiveDOMObjectOwner::finalize):
+        * bindings/scripts/test/JS/JSTestActiveDOMObject.h:
+        * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
+        (WebCore::JSTestCustomNamedGetter::~JSTestCustomNamedGetter):
+        (WebCore::JSTestCustomNamedGetterOwner::finalize):
+        * bindings/scripts/test/JS/JSTestCustomNamedGetter.h:
+        * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
+        (WebCore::JSTestEventConstructor::~JSTestEventConstructor):
+        (WebCore::JSTestEventConstructorOwner::finalize):
+        * bindings/scripts/test/JS/JSTestEventConstructor.h:
+        * bindings/scripts/test/JS/JSTestEventTarget.cpp:
+        (WebCore::JSTestEventTarget::~JSTestEventTarget):
+        (WebCore::JSTestEventTargetOwner::finalize):
+        * bindings/scripts/test/JS/JSTestEventTarget.h:
+        * bindings/scripts/test/JS/JSTestException.cpp:
+        (WebCore::JSTestException::~JSTestException):
+        (WebCore::JSTestExceptionOwner::finalize):
+        * bindings/scripts/test/JS/JSTestException.h:
+        * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
+        (WebCore::JSTestGenerateIsReachable::~JSTestGenerateIsReachable):
+        (WebCore::JSTestGenerateIsReachableOwner::finalize):
+        * bindings/scripts/test/JS/JSTestGenerateIsReachable.h:
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        (WebCore::JSTestInterface::~JSTestInterface):
+        (WebCore::JSTestInterfaceOwner::finalize):
+        * bindings/scripts/test/JS/JSTestInterface.h:
+        * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
+        (WebCore::JSTestMediaQueryListListener::~JSTestMediaQueryListListener):
+        (WebCore::JSTestMediaQueryListListenerOwner::finalize):
+        * bindings/scripts/test/JS/JSTestMediaQueryListListener.h:
+        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+        (WebCore::JSTestNamedConstructor::~JSTestNamedConstructor):
+        (WebCore::JSTestNamedConstructorOwner::finalize):
+        * bindings/scripts/test/JS/JSTestNamedConstructor.h:
+        * bindings/scripts/test/JS/JSTestNondeterministic.cpp:
+        (WebCore::JSTestNondeterministic::~JSTestNondeterministic):
+        (WebCore::JSTestNondeterministicOwner::finalize):
+        * bindings/scripts/test/JS/JSTestNondeterministic.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::JSTestObj::~JSTestObj):
+        (WebCore::JSTestObjOwner::finalize):
+        * bindings/scripts/test/JS/JSTestObj.h:
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+        (WebCore::JSTestOverloadedConstructors::~JSTestOverloadedConstructors):
+        (WebCore::JSTestOverloadedConstructorsOwner::finalize):
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.h:
+        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
+        (WebCore::JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface):
+        (WebCore::JSTestSerializedScriptValueInterfaceOwner::finalize):
+        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:
+        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+        (WebCore::JSTestTypedefs::~JSTestTypedefs):
+        (WebCore::JSTestTypedefsOwner::finalize):
+        * bindings/scripts/test/JS/JSTestTypedefs.h:
+        * bindings/scripts/test/JS/JSattribute.cpp:
+        (WebCore::JSattribute::~JSattribute):
+        (WebCore::JSattributeOwner::finalize):
+        * bindings/scripts/test/JS/JSattribute.h:
+        * bindings/scripts/test/JS/JSreadonly.cpp:
+        (WebCore::JSreadonly::~JSreadonly):
+        (WebCore::JSreadonlyOwner::finalize):
+        * bindings/scripts/test/JS/JSreadonly.h:
+
 2015-04-28  Alex Christensen  <[email protected]>
 
         Build WinCairo without cygwin.

Modified: trunk/Source/WebCore/bindings/js/JSCSSValueCustom.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/js/JSCSSValueCustom.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/js/JSCSSValueCustom.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -62,7 +62,6 @@
     DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
     world.m_cssValueRoots.remove(&jsCSSValue->impl());
     uncacheWrapper(world, &jsCSSValue->impl(), jsCSSValue);
-    jsCSSValue->releaseImpl();
 }
 
 JSValue toJS(ExecState*, JSDOMGlobalObject* globalObject, CSSValue* value)

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-04-29 02:12:31 UTC (rev 183523)
@@ -1086,14 +1086,7 @@
 
     if (!$hasParent) {
         push(@headerContent, "    $implType& impl() const { return *m_impl; }\n");
-        push(@headerContent, "    void releaseImpl() { m_impl->deref(); m_impl = 0; }\n\n");
-        push(@headerContent, "    void releaseImplIfNotNull()\n");
-        push(@headerContent, "    {\n");
-        push(@headerContent, "        if (m_impl) {\n");
-        push(@headerContent, "            m_impl->deref();\n");
-        push(@headerContent, "            m_impl = 0;\n");
-        push(@headerContent, "        }\n");
-        push(@headerContent, "    }\n\n");
+        push(@headerContent, "    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }\n\n");
         push(@headerContent, "private:\n");
         push(@headerContent, "    $implType* m_impl;\n");
     } else {
@@ -2077,23 +2070,15 @@
     }
 
     if (!$hasParent) {
-        # FIXME: This destroy function should not be necessary, as 
-        # a finalizer should be called for each DOM object wrapper.
-        # However, that seems not to be the case, so this has been
-        # added back to avoid leaking while we figure out why the
-        # finalizers are not always getting called. The work tracking
-        # the finalizer issue is being tracked in http://webkit.org/b/75451
         push(@implContent, "void ${className}::destroy(JSC::JSCell* cell)\n");
         push(@implContent, "{\n");
         push(@implContent, "    ${className}* thisObject = static_cast<${className}*>(cell);\n");
         push(@implContent, "    thisObject->${className}::~${className}();\n");
         push(@implContent, "}\n\n");
 
-        # We also need a destructor for the allocateCell to work properly with the destructor-free part of the heap.
-        # Otherwise, these destroy functions/destructors won't get called.
         push(@implContent, "${className}::~${className}()\n");
         push(@implContent, "{\n");
-        push(@implContent, "    releaseImplIfNotNull();\n");
+        push(@implContent, "    releaseImpl();\n");
         push(@implContent, "}\n\n");
     }
 
@@ -3004,7 +2989,6 @@
         push(@implContent, "    auto* js${interfaceName} = jsCast<JS${interfaceName}*>(handle.slot()->asCell());\n");
         push(@implContent, "    auto& world = *static_cast<DOMWrapperWorld*>(context);\n");
         push(@implContent, "    uncacheWrapper(world, &js${interfaceName}->impl(), js${interfaceName});\n");
-        push(@implContent, "    js${interfaceName}->releaseImpl();\n");
         push(@implContent, "}\n\n");
     }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -163,7 +163,7 @@
 
 JSTestActiveDOMObject::~JSTestActiveDOMObject()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 bool JSTestActiveDOMObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
@@ -250,7 +250,6 @@
     auto* jsTestActiveDOMObject = jsCast<JSTestActiveDOMObject*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestActiveDOMObject->impl(), jsTestActiveDOMObject);
-    jsTestActiveDOMObject->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -53,16 +53,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestActiveDOMObject& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestActiveDOMObject* m_impl;
 public:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -156,7 +156,7 @@
 
 JSTestCustomNamedGetter::~JSTestCustomNamedGetter()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 bool JSTestCustomNamedGetter::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
@@ -224,7 +224,6 @@
     auto* jsTestCustomNamedGetter = jsCast<JSTestCustomNamedGetter*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestCustomNamedGetter->impl(), jsTestCustomNamedGetter);
-    jsTestCustomNamedGetter->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -54,16 +54,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestCustomNamedGetter& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestCustomNamedGetter* m_impl;
 public:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -191,7 +191,7 @@
 
 JSTestEventConstructor::~JSTestEventConstructor()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsTestEventConstructorAttr1(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
@@ -253,7 +253,6 @@
     auto* jsTestEventConstructor = jsCast<JSTestEventConstructor*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestEventConstructor->impl(), jsTestEventConstructor);
-    jsTestEventConstructor->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -54,16 +54,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestEventConstructor& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestEventConstructor* m_impl;
 protected:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -168,7 +168,7 @@
 
 JSTestEventTarget::~JSTestEventTarget()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 bool JSTestEventTarget::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
@@ -326,7 +326,6 @@
     auto* jsTestEventTarget = jsCast<JSTestEventTarget*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestEventTarget->impl(), jsTestEventTarget);
-    jsTestEventTarget->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -58,16 +58,8 @@
     static void visitChildren(JSCell*, JSC::SlotVisitor&);
 
     TestEventTarget& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestEventTarget* m_impl;
 public:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -153,7 +153,7 @@
 
 JSTestException::~JSTestException()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 bool JSTestException::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
@@ -200,7 +200,6 @@
     auto* jsTestException = jsCast<JSTestException*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestException->impl(), jsTestException);
-    jsTestException->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -54,16 +54,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestException& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestException* m_impl;
 public:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -135,7 +135,7 @@
 
 JSTestGenerateIsReachable::~JSTestGenerateIsReachable()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsTestGenerateIsReachableConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
@@ -172,7 +172,6 @@
     auto* jsTestGenerateIsReachable = jsCast<JSTestGenerateIsReachable*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestGenerateIsReachable->impl(), jsTestGenerateIsReachable);
-    jsTestGenerateIsReachable->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -52,16 +52,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestGenerateIsReachable& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestGenerateIsReachable* m_impl;
 protected:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -434,7 +434,7 @@
 
 JSTestInterface::~JSTestInterface()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 bool JSTestInterface::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
@@ -951,7 +951,6 @@
     auto* jsTestInterface = jsCast<JSTestInterface*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestInterface->impl(), jsTestInterface);
-    jsTestInterface->releaseImpl();
 }
 
 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestInterface* impl)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -80,16 +80,8 @@
     JSC::JSValue supplementalMethod3(JSC::ExecState*);
 #endif
     TestInterface& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestInterface* m_impl;
 public:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -143,7 +143,7 @@
 
 JSTestMediaQueryListListener::~JSTestMediaQueryListListener()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsTestMediaQueryListListenerConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
@@ -188,7 +188,6 @@
     auto* jsTestMediaQueryListListener = jsCast<JSTestMediaQueryListListener*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestMediaQueryListListener->impl(), jsTestMediaQueryListListener);
-    jsTestMediaQueryListListener->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -52,16 +52,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestMediaQueryListListener& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestMediaQueryListListener* m_impl;
 protected:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -207,7 +207,7 @@
 
 JSTestNamedConstructor::~JSTestNamedConstructor()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsTestNamedConstructorConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
@@ -242,7 +242,6 @@
     auto* jsTestNamedConstructor = jsCast<JSTestNamedConstructor*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestNamedConstructor->impl(), jsTestNamedConstructor);
-    jsTestNamedConstructor->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -53,16 +53,8 @@
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     static JSC::JSValue getNamedConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestNamedConstructor& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestNamedConstructor* m_impl;
 protected:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -165,7 +165,7 @@
 
 JSTestNondeterministic::~JSTestNondeterministic()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsTestNondeterministicNondeterministicReadonlyAttr(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
@@ -495,7 +495,6 @@
     auto* jsTestNondeterministic = jsCast<JSTestNondeterministic*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestNondeterministic->impl(), jsTestNondeterministic);
-    jsTestNondeterministic->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -52,16 +52,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestNondeterministic& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestNondeterministic* m_impl;
 protected:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -682,7 +682,7 @@
 
 JSTestObj::~JSTestObj()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 bool JSTestObj::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
@@ -4430,7 +4430,6 @@
     auto* jsTestObj = jsCast<JSTestObj*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestObj->impl(), jsTestObj);
-    jsTestObj->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -66,16 +66,8 @@
     JSC::JSValue customMethodWithArgs(JSC::ExecState*);
     static JSC::JSValue classMethod2(JSC::ExecState*);
     TestObj& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestObj* m_impl;
 public:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -216,7 +216,7 @@
 
 JSTestOverloadedConstructors::~JSTestOverloadedConstructors()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsTestOverloadedConstructorsConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
@@ -244,7 +244,6 @@
     auto* jsTestOverloadedConstructors = jsCast<JSTestOverloadedConstructors*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestOverloadedConstructors->impl(), jsTestOverloadedConstructors);
-    jsTestOverloadedConstructors->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -52,16 +52,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestOverloadedConstructors& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestOverloadedConstructors* m_impl;
 protected:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -155,7 +155,7 @@
 
 JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
@@ -323,7 +323,6 @@
     auto* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestSerializedScriptValueInterface->impl(), jsTestSerializedScriptValueInterface);
-    jsTestSerializedScriptValueInterface->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -58,16 +58,8 @@
     static void visitChildren(JSCell*, JSC::SlotVisitor&);
 
     TestSerializedScriptValueInterface& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestSerializedScriptValueInterface* m_impl;
 protected:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -238,7 +238,7 @@
 
 JSTestTypedefs::~JSTestTypedefs()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 bool JSTestTypedefs::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
@@ -730,7 +730,6 @@
     auto* jsTestTypedefs = jsCast<JSTestTypedefs*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsTestTypedefs->impl(), jsTestTypedefs);
-    jsTestTypedefs->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -53,16 +53,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     TestTypedefs& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     TestTypedefs* m_impl;
 public:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -140,7 +140,7 @@
 
 JSattribute::~JSattribute()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsattributeReadonly(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
@@ -185,7 +185,6 @@
     auto* jsattribute = jsCast<JSattribute*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsattribute->impl(), jsattribute);
-    jsattribute->releaseImpl();
 }
 
 #if ENABLE(BINDING_INTEGRITY)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -53,16 +53,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     attribute& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     attribute* m_impl;
 protected:

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp	2015-04-29 02:12:31 UTC (rev 183523)
@@ -135,7 +135,7 @@
 
 JSreadonly::~JSreadonly()
 {
-    releaseImplIfNotNull();
+    releaseImpl();
 }
 
 EncodedJSValue jsreadonlyConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
@@ -163,7 +163,6 @@
     auto* jsreadonly = jsCast<JSreadonly*>(handle.slot()->asCell());
     auto& world = *static_cast<DOMWrapperWorld*>(context);
     uncacheWrapper(world, &jsreadonly->impl(), jsreadonly);
-    jsreadonly->releaseImpl();
 }
 
 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, readonly* impl)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.h (183522 => 183523)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.h	2015-04-29 01:24:47 UTC (rev 183522)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.h	2015-04-29 02:12:31 UTC (rev 183523)
@@ -52,16 +52,8 @@
 
     static JSC::JSValue getConstructor(JSC::VM&, JSC::JSGlobalObject*);
     readonly& impl() const { return *m_impl; }
-    void releaseImpl() { m_impl->deref(); m_impl = 0; }
+    void releaseImpl() { std::exchange(m_impl, nullptr)->deref(); }
 
-    void releaseImplIfNotNull()
-    {
-        if (m_impl) {
-            m_impl->deref();
-            m_impl = 0;
-        }
-    }
-
 private:
     readonly* m_impl;
 protected:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to