Title: [148648] trunk/Source/WebCore
Revision
148648
Author
[email protected]
Date
2013-04-17 16:53:23 -0700 (Wed, 17 Apr 2013)

Log Message

Automate generation of toJS function for classes that need to report extra memory usage
https://bugs.webkit.org/show_bug.cgi?id=114768

Reviewed by Geoff Garen.

Only really used by AudioBuffer for now.  The other classes that need it can be
trivially refactored at a later date.

* Modules/webaudio/AudioBuffer.idl:
* bindings/js/JSAudioBufferCustom.cpp:
* bindings/js/JSDOMBinding.h:
(WebCore):
(HasMemoryCost):
(NoType):
(BaseMixin):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (148647 => 148648)


--- trunk/Source/WebCore/ChangeLog	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/ChangeLog	2013-04-17 23:53:23 UTC (rev 148648)
@@ -1,3 +1,23 @@
+2013-04-17  Oliver Hunt  <[email protected]>
+
+        Automate generation of toJS function for classes that need to report extra memory usage
+        https://bugs.webkit.org/show_bug.cgi?id=114768
+
+        Reviewed by Geoff Garen.
+
+        Only really used by AudioBuffer for now.  The other classes that need it can be
+        trivially refactored at a later date.
+
+        * Modules/webaudio/AudioBuffer.idl:
+        * bindings/js/JSAudioBufferCustom.cpp:
+        * bindings/js/JSDOMBinding.h:
+        (WebCore):
+        (HasMemoryCost):
+        (NoType):
+        (BaseMixin):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+
 2013-04-17  Dirk Schulze  <[email protected]>
 
         BasicShapeFunctions should use RenderStyle instead of StyleResolver

Modified: trunk/Source/WebCore/Modules/webaudio/AudioBuffer.idl (148647 => 148648)


--- trunk/Source/WebCore/Modules/webaudio/AudioBuffer.idl	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBuffer.idl	2013-04-17 23:53:23 UTC (rev 148648)
@@ -28,7 +28,6 @@
 
 [
     Conditional=WEB_AUDIO,
-    CustomToJSObject,
     ImplementationLacksVTable
 ] interface AudioBuffer {
     readonly attribute long length; // in sample-frames

Modified: trunk/Source/WebCore/bindings/js/JSAudioBufferCustom.cpp (148647 => 148648)


--- trunk/Source/WebCore/bindings/js/JSAudioBufferCustom.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/js/JSAudioBufferCustom.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -34,22 +34,6 @@
 
 namespace WebCore {
 
-JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, AudioBuffer* audioBuffer)
-{
-    if (!audioBuffer)
-        return jsNull();
-
-    JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), audioBuffer);
-    if (wrapper)
-        return wrapper;
-
-    wrapper = CREATE_DOM_WRAPPER(exec, globalObject, AudioBuffer, audioBuffer);
-
-    exec->heap()->reportExtraMemoryCost(audioBuffer->memoryCost());
-
-    return wrapper;
 }
 
-}
-
 #endif // ENABLE(WEB_AUDIO)

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (148647 => 148648)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2013-04-17 23:53:23 UTC (rev 148648)
@@ -523,6 +523,30 @@
         return 0;
     }
 
+    template<typename T>
+    class HasMemoryCostMemberFunction {
+        typedef char YesType;
+        struct NoType {
+            char padding[8];
+        };
+
+        struct BaseMixin {
+            size_t memoryCost();
+        };
+
+        struct Base : public T, public BaseMixin { };
+
+        template<typename U, U> struct
+        TypeChecker { };
+
+        template<typename U>
+        static NoType dummy(U*, TypeChecker<size_t (BaseMixin::*)(), &U::memoryCost>* = 0);
+        static YesType dummy(...);
+
+    public:
+        static const bool value = sizeof(dummy(static_cast<Base*>(0))) == sizeof(YesType);
+    };
+
 } // namespace WebCore
 
 #endif // JSDOMBinding_h

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (148647 => 148648)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-04-17 23:53:23 UTC (rev 148648)
@@ -2714,6 +2714,21 @@
 #endif
 #endif
 END
+push(@implContent, <<END);
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
+END
+
         push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* impl)\n");
         push(@implContent, "{\n");
         push(@implContent, <<END);
@@ -2756,6 +2771,9 @@
     COMPILE_ASSERT(!__is_polymorphic($implType), ${implType}_is_polymorphic_but_idl_claims_not_to_be);
 #endif
 END
+        push(@implContent, <<END);
+    ReportMemoryCost<$implType>::reportMemoryCost(exec, impl);
+END
 
         if ($svgPropertyType) {
             push(@implContent, "    return createNewWrapper<$className, $implType>(exec, globalObject, impl);\n");

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -243,6 +243,18 @@
 extern "C" { extern void* _ZTVN7WebCore19TestActiveDOMObjectE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestActiveDOMObject* impl)
 {
     if (!impl)
@@ -267,6 +279,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestActiveDOMObject>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestActiveDOMObject>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -227,6 +227,18 @@
 extern "C" { extern void* _ZTVN7WebCore21TestCustomNamedGetterE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestCustomNamedGetter* impl)
 {
     if (!impl)
@@ -251,6 +263,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestCustomNamedGetter>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestCustomNamedGetter>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -242,6 +242,18 @@
 extern "C" { extern void* _ZTVN7WebCore20TestEventConstructorE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestEventConstructor* impl)
 {
     if (!impl)
@@ -266,6 +278,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestEventConstructor>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestEventConstructor>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -348,6 +348,18 @@
 extern "C" { extern void* _ZTVN7WebCore15TestEventTargetE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestEventTarget* impl)
 {
     if (!impl)
@@ -372,6 +384,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestEventTarget>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestEventTarget>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -184,6 +184,18 @@
 extern "C" { extern void* _ZTVN7WebCore13TestExceptionE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestException* impl)
 {
     if (!impl)
@@ -208,6 +220,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestException>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestException>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -499,6 +499,18 @@
     jsTestInterface->releaseImpl();
 }
 
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestInterface* impl)
 {
     if (!impl)
@@ -511,6 +523,7 @@
     // attribute to TestInterface.
     COMPILE_ASSERT(!__is_polymorphic(TestInterface), TestInterface_is_polymorphic_but_idl_claims_not_to_be);
 #endif
+    ReportMemoryCost<TestInterface>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestInterface>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -205,6 +205,18 @@
 extern "C" { extern void* _ZTVN7WebCore26TestMediaQueryListListenerE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestMediaQueryListListener* impl)
 {
     if (!impl)
@@ -229,6 +241,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestMediaQueryListListener>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestMediaQueryListListener>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -219,6 +219,18 @@
 extern "C" { extern void* _ZTVN7WebCore20TestNamedConstructorE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestNamedConstructor* impl)
 {
     if (!impl)
@@ -243,6 +255,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestNamedConstructor>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestNamedConstructor>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -3089,6 +3089,18 @@
 extern "C" { extern void* _ZTVN7WebCore7TestObjE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* impl)
 {
     if (!impl)
@@ -3113,6 +3125,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestObj>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestObj>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -249,6 +249,18 @@
 extern "C" { extern void* _ZTVN7WebCore26TestOverloadedConstructorsE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl)
 {
     if (!impl)
@@ -273,6 +285,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestOverloadedConstructors>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestOverloadedConstructors>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -397,6 +397,18 @@
 extern "C" { extern void* _ZTVN7WebCore34TestSerializedScriptValueInterfaceE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl)
 {
     if (!impl)
@@ -421,6 +433,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestSerializedScriptValueInterface>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestSerializedScriptValueInterface>(exec, globalObject, impl);
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2013-04-17 23:38:51 UTC (rev 148647)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2013-04-17 23:53:23 UTC (rev 148648)
@@ -635,6 +635,18 @@
 extern "C" { extern void* _ZTVN7WebCore12TestTypedefsE[]; }
 #endif
 #endif
+template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost;
+template <typename T> struct ReportMemoryCost<T, true> {
+    static void reportMemoryCost(ExecState* exec, T* impl)
+    {
+        exec->heap()->reportExtraMemoryCost(impl->memoryCost());
+    }
+};
+template <typename T> struct ReportMemoryCost<T, false> {
+    static void reportMemoryCost(ExecState*, T*)
+    {
+    }
+};
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestTypedefs* impl)
 {
     if (!impl)
@@ -659,6 +671,7 @@
     // by adding the SkipVTableValidation attribute to the interface IDL definition
     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 #endif
+    ReportMemoryCost<TestTypedefs>::reportMemoryCost(exec, impl);
     return createNewWrapper<JSTestTypedefs>(exec, globalObject, impl);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to