Changeset 148648 in webkit
- Timestamp:
- Apr 17, 2013 4:53:23 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r148645 r148648 1 2013-04-17 Oliver Hunt <oliver@apple.com> 2 3 Automate generation of toJS function for classes that need to report extra memory usage 4 https://bugs.webkit.org/show_bug.cgi?id=114768 5 6 Reviewed by Geoff Garen. 7 8 Only really used by AudioBuffer for now. The other classes that need it can be 9 trivially refactored at a later date. 10 11 * Modules/webaudio/AudioBuffer.idl: 12 * bindings/js/JSAudioBufferCustom.cpp: 13 * bindings/js/JSDOMBinding.h: 14 (WebCore): 15 (HasMemoryCost): 16 (NoType): 17 (BaseMixin): 18 * bindings/scripts/CodeGeneratorJS.pm: 19 (GenerateImplementation): 20 1 21 2013-04-17 Dirk Schulze <krit@webkit.org> 2 22 -
trunk/Source/WebCore/Modules/webaudio/AudioBuffer.idl
r148566 r148648 29 29 [ 30 30 Conditional=WEB_AUDIO, 31 CustomToJSObject,32 31 ImplementationLacksVTable 33 32 ] interface AudioBuffer { -
trunk/Source/WebCore/bindings/js/JSAudioBufferCustom.cpp
r148579 r148648 35 35 namespace WebCore { 36 36 37 JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, AudioBuffer* audioBuffer)38 {39 if (!audioBuffer)40 return jsNull();41 42 JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), audioBuffer);43 if (wrapper)44 return wrapper;45 46 wrapper = CREATE_DOM_WRAPPER(exec, globalObject, AudioBuffer, audioBuffer);47 48 exec->heap()->reportExtraMemoryCost(audioBuffer->memoryCost());49 50 return wrapper;51 }52 53 37 } 54 38 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r148257 r148648 524 524 } 525 525 526 template<typename T> 527 class HasMemoryCostMemberFunction { 528 typedef char YesType; 529 struct NoType { 530 char padding[8]; 531 }; 532 533 struct BaseMixin { 534 size_t memoryCost(); 535 }; 536 537 struct Base : public T, public BaseMixin { }; 538 539 template<typename U, U> struct 540 TypeChecker { }; 541 542 template<typename U> 543 static NoType dummy(U*, TypeChecker<size_t (BaseMixin::*)(), &U::memoryCost>* = 0); 544 static YesType dummy(...); 545 546 public: 547 static const bool value = sizeof(dummy(static_cast<Base*>(0))) == sizeof(YesType); 548 }; 549 526 550 } // namespace WebCore 527 551 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r148593 r148648 2715 2715 #endif 2716 2716 END 2717 push(@implContent, <<END); 2718 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 2719 template <typename T> struct ReportMemoryCost<T, true> { 2720 static void reportMemoryCost(ExecState* exec, T* impl) 2721 { 2722 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 2723 } 2724 }; 2725 template <typename T> struct ReportMemoryCost<T, false> { 2726 static void reportMemoryCost(ExecState*, T*) 2727 { 2728 } 2729 }; 2730 END 2731 2717 2732 push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* impl)\n"); 2718 2733 push(@implContent, "{\n"); … … 2756 2771 COMPILE_ASSERT(!__is_polymorphic($implType), ${implType}_is_polymorphic_but_idl_claims_not_to_be); 2757 2772 #endif 2773 END 2774 push(@implContent, <<END); 2775 ReportMemoryCost<$implType>::reportMemoryCost(exec, impl); 2758 2776 END 2759 2777 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
r148301 r148648 244 244 #endif 245 245 #endif 246 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 247 template <typename T> struct ReportMemoryCost<T, true> { 248 static void reportMemoryCost(ExecState* exec, T* impl) 249 { 250 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 251 } 252 }; 253 template <typename T> struct ReportMemoryCost<T, false> { 254 static void reportMemoryCost(ExecState*, T*) 255 { 256 } 257 }; 246 258 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestActiveDOMObject* impl) 247 259 { … … 268 280 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 269 281 #endif 282 ReportMemoryCost<TestActiveDOMObject>::reportMemoryCost(exec, impl); 270 283 return createNewWrapper<JSTestActiveDOMObject>(exec, globalObject, impl); 271 284 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
r148301 r148648 228 228 #endif 229 229 #endif 230 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 231 template <typename T> struct ReportMemoryCost<T, true> { 232 static void reportMemoryCost(ExecState* exec, T* impl) 233 { 234 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 235 } 236 }; 237 template <typename T> struct ReportMemoryCost<T, false> { 238 static void reportMemoryCost(ExecState*, T*) 239 { 240 } 241 }; 230 242 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestCustomNamedGetter* impl) 231 243 { … … 252 264 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 253 265 #endif 266 ReportMemoryCost<TestCustomNamedGetter>::reportMemoryCost(exec, impl); 254 267 return createNewWrapper<JSTestCustomNamedGetter>(exec, globalObject, impl); 255 268 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp
r148301 r148648 243 243 #endif 244 244 #endif 245 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 246 template <typename T> struct ReportMemoryCost<T, true> { 247 static void reportMemoryCost(ExecState* exec, T* impl) 248 { 249 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 250 } 251 }; 252 template <typename T> struct ReportMemoryCost<T, false> { 253 static void reportMemoryCost(ExecState*, T*) 254 { 255 } 256 }; 245 257 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestEventConstructor* impl) 246 258 { … … 267 279 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 268 280 #endif 281 ReportMemoryCost<TestEventConstructor>::reportMemoryCost(exec, impl); 269 282 return createNewWrapper<JSTestEventConstructor>(exec, globalObject, impl); 270 283 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
r148301 r148648 349 349 #endif 350 350 #endif 351 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 352 template <typename T> struct ReportMemoryCost<T, true> { 353 static void reportMemoryCost(ExecState* exec, T* impl) 354 { 355 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 356 } 357 }; 358 template <typename T> struct ReportMemoryCost<T, false> { 359 static void reportMemoryCost(ExecState*, T*) 360 { 361 } 362 }; 351 363 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestEventTarget* impl) 352 364 { … … 373 385 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 374 386 #endif 387 ReportMemoryCost<TestEventTarget>::reportMemoryCost(exec, impl); 375 388 return createNewWrapper<JSTestEventTarget>(exec, globalObject, impl); 376 389 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp
r148301 r148648 185 185 #endif 186 186 #endif 187 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 188 template <typename T> struct ReportMemoryCost<T, true> { 189 static void reportMemoryCost(ExecState* exec, T* impl) 190 { 191 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 192 } 193 }; 194 template <typename T> struct ReportMemoryCost<T, false> { 195 static void reportMemoryCost(ExecState*, T*) 196 { 197 } 198 }; 187 199 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestException* impl) 188 200 { … … 209 221 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 210 222 #endif 223 ReportMemoryCost<TestException>::reportMemoryCost(exec, impl); 211 224 return createNewWrapper<JSTestException>(exec, globalObject, impl); 212 225 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
r148303 r148648 500 500 } 501 501 502 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 503 template <typename T> struct ReportMemoryCost<T, true> { 504 static void reportMemoryCost(ExecState* exec, T* impl) 505 { 506 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 507 } 508 }; 509 template <typename T> struct ReportMemoryCost<T, false> { 510 static void reportMemoryCost(ExecState*, T*) 511 { 512 } 513 }; 502 514 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestInterface* impl) 503 515 { … … 512 524 COMPILE_ASSERT(!__is_polymorphic(TestInterface), TestInterface_is_polymorphic_but_idl_claims_not_to_be); 513 525 #endif 526 ReportMemoryCost<TestInterface>::reportMemoryCost(exec, impl); 514 527 return createNewWrapper<JSTestInterface>(exec, globalObject, impl); 515 528 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
r148301 r148648 206 206 #endif 207 207 #endif 208 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 209 template <typename T> struct ReportMemoryCost<T, true> { 210 static void reportMemoryCost(ExecState* exec, T* impl) 211 { 212 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 213 } 214 }; 215 template <typename T> struct ReportMemoryCost<T, false> { 216 static void reportMemoryCost(ExecState*, T*) 217 { 218 } 219 }; 208 220 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestMediaQueryListListener* impl) 209 221 { … … 230 242 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 231 243 #endif 244 ReportMemoryCost<TestMediaQueryListListener>::reportMemoryCost(exec, impl); 232 245 return createNewWrapper<JSTestMediaQueryListListener>(exec, globalObject, impl); 233 246 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
r148301 r148648 220 220 #endif 221 221 #endif 222 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 223 template <typename T> struct ReportMemoryCost<T, true> { 224 static void reportMemoryCost(ExecState* exec, T* impl) 225 { 226 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 227 } 228 }; 229 template <typename T> struct ReportMemoryCost<T, false> { 230 static void reportMemoryCost(ExecState*, T*) 231 { 232 } 233 }; 222 234 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestNamedConstructor* impl) 223 235 { … … 244 256 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 245 257 #endif 258 ReportMemoryCost<TestNamedConstructor>::reportMemoryCost(exec, impl); 246 259 return createNewWrapper<JSTestNamedConstructor>(exec, globalObject, impl); 247 260 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r148301 r148648 3090 3090 #endif 3091 3091 #endif 3092 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 3093 template <typename T> struct ReportMemoryCost<T, true> { 3094 static void reportMemoryCost(ExecState* exec, T* impl) 3095 { 3096 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 3097 } 3098 }; 3099 template <typename T> struct ReportMemoryCost<T, false> { 3100 static void reportMemoryCost(ExecState*, T*) 3101 { 3102 } 3103 }; 3092 3104 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* impl) 3093 3105 { … … 3114 3126 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 3115 3127 #endif 3128 ReportMemoryCost<TestObj>::reportMemoryCost(exec, impl); 3116 3129 return createNewWrapper<JSTestObj>(exec, globalObject, impl); 3117 3130 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
r148301 r148648 250 250 #endif 251 251 #endif 252 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 253 template <typename T> struct ReportMemoryCost<T, true> { 254 static void reportMemoryCost(ExecState* exec, T* impl) 255 { 256 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 257 } 258 }; 259 template <typename T> struct ReportMemoryCost<T, false> { 260 static void reportMemoryCost(ExecState*, T*) 261 { 262 } 263 }; 252 264 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl) 253 265 { … … 274 286 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 275 287 #endif 288 ReportMemoryCost<TestOverloadedConstructors>::reportMemoryCost(exec, impl); 276 289 return createNewWrapper<JSTestOverloadedConstructors>(exec, globalObject, impl); 277 290 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp
r148301 r148648 398 398 #endif 399 399 #endif 400 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 401 template <typename T> struct ReportMemoryCost<T, true> { 402 static void reportMemoryCost(ExecState* exec, T* impl) 403 { 404 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 405 } 406 }; 407 template <typename T> struct ReportMemoryCost<T, false> { 408 static void reportMemoryCost(ExecState*, T*) 409 { 410 } 411 }; 400 412 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl) 401 413 { … … 422 434 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 423 435 #endif 436 ReportMemoryCost<TestSerializedScriptValueInterface>::reportMemoryCost(exec, impl); 424 437 return createNewWrapper<JSTestSerializedScriptValueInterface>(exec, globalObject, impl); 425 438 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
r148301 r148648 636 636 #endif 637 637 #endif 638 template <typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction<T>::value > struct ReportMemoryCost; 639 template <typename T> struct ReportMemoryCost<T, true> { 640 static void reportMemoryCost(ExecState* exec, T* impl) 641 { 642 exec->heap()->reportExtraMemoryCost(impl->memoryCost()); 643 } 644 }; 645 template <typename T> struct ReportMemoryCost<T, false> { 646 static void reportMemoryCost(ExecState*, T*) 647 { 648 } 649 }; 638 650 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestTypedefs* impl) 639 651 { … … 660 672 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 661 673 #endif 674 ReportMemoryCost<TestTypedefs>::reportMemoryCost(exec, impl); 662 675 return createNewWrapper<JSTestTypedefs>(exec, globalObject, impl); 663 676 }
Note: See TracChangeset
for help on using the changeset viewer.