Ignore:
Timestamp:
Jan 15, 2008, 10:43:15 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Geoffrey Garen.

Fix <rdar://problem/5595552> r27608 introduced a 20% increase in JS binary size, 4% increase in WebCore binary size

  • This changes the way JS functions that use Lookup tables are handled. Instead using one class per function, which allowed specialization of the virtual callAsFunction method, we now use on class, PrototypeFunction, which takes a pointer to a static function to use as the implementation. This significantly decreases the binary size of JavaScriptCore (about 145k on an Intel only build) while still keeping some of the speedup r27608 garnered (SunSpider says this is 1.005x as slow, which should leave some wiggle room from the original 1% speedup) and keeps the functions implementations in separate functions to help with optimizations.
  • JavaScriptCore.exp:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/array_object.cpp: (KJS::arrayProtoFuncToString): (KJS::arrayProtoFuncToLocaleString): (KJS::arrayProtoFuncJoin): (KJS::arrayProtoFuncConcat): (KJS::arrayProtoFuncPop): (KJS::arrayProtoFuncPush): (KJS::arrayProtoFuncReverse): (KJS::arrayProtoFuncShift): (KJS::arrayProtoFuncSlice): (KJS::arrayProtoFuncSort): (KJS::arrayProtoFuncSplice): (KJS::arrayProtoFuncUnShift): (KJS::arrayProtoFuncFilter): (KJS::arrayProtoFuncMap): (KJS::arrayProtoFuncEvery): (KJS::arrayProtoFuncForEach): (KJS::arrayProtoFuncSome): (KJS::arrayProtoFuncIndexOf): (KJS::arrayProtoFuncLastIndexOf):
  • kjs/array_object.h:
  • kjs/date_object.cpp: (KJS::DatePrototype::getOwnPropertySlot): (KJS::dateProtoFuncToString): (KJS::dateProtoFuncToUTCString): (KJS::dateProtoFuncToDateString): (KJS::dateProtoFuncToTimeString): (KJS::dateProtoFuncToLocaleString): (KJS::dateProtoFuncToLocaleDateString): (KJS::dateProtoFuncToLocaleTimeString): (KJS::dateProtoFuncValueOf): (KJS::dateProtoFuncGetTime): (KJS::dateProtoFuncGetFullYear): (KJS::dateProtoFuncGetUTCFullYear): (KJS::dateProtoFuncToGMTString): (KJS::dateProtoFuncGetMonth): (KJS::dateProtoFuncGetUTCMonth): (KJS::dateProtoFuncGetDate): (KJS::dateProtoFuncGetUTCDate): (KJS::dateProtoFuncGetDay): (KJS::dateProtoFuncGetUTCDay): (KJS::dateProtoFuncGetHours): (KJS::dateProtoFuncGetUTCHours): (KJS::dateProtoFuncGetMinutes): (KJS::dateProtoFuncGetUTCMinutes): (KJS::dateProtoFuncGetSeconds): (KJS::dateProtoFuncGetUTCSeconds): (KJS::dateProtoFuncGetMilliSeconds): (KJS::dateProtoFuncGetUTCMilliseconds): (KJS::dateProtoFuncGetTimezoneOffset): (KJS::dateProtoFuncSetTime): (KJS::dateProtoFuncSetMilliSeconds): (KJS::dateProtoFuncSetUTCMilliseconds): (KJS::dateProtoFuncSetSeconds): (KJS::dateProtoFuncSetUTCSeconds): (KJS::dateProtoFuncSetMinutes): (KJS::dateProtoFuncSetUTCMinutes): (KJS::dateProtoFuncSetHours): (KJS::dateProtoFuncSetUTCHours): (KJS::dateProtoFuncSetDate): (KJS::dateProtoFuncSetUTCDate): (KJS::dateProtoFuncSetMonth): (KJS::dateProtoFuncSetUTCMonth): (KJS::dateProtoFuncSetFullYear): (KJS::dateProtoFuncSetUTCFullYear): (KJS::dateProtoFuncSetYear): (KJS::dateProtoFuncGetYear):
  • kjs/date_object.h:
  • kjs/function.cpp: (KJS::PrototypeFunction::PrototypeFunction): (KJS::PrototypeFunction::callAsFunction):
  • kjs/function.h:
  • kjs/lookup.h: (KJS::HashEntry::): (KJS::staticFunctionGetter):
  • kjs/math_object.cpp: (KJS::mathProtoFuncAbs): (KJS::mathProtoFuncACos): (KJS::mathProtoFuncASin): (KJS::mathProtoFuncATan): (KJS::mathProtoFuncATan2): (KJS::mathProtoFuncCeil): (KJS::mathProtoFuncCos): (KJS::mathProtoFuncExp): (KJS::mathProtoFuncFloor): (KJS::mathProtoFuncLog): (KJS::mathProtoFuncMax): (KJS::mathProtoFuncMin): (KJS::mathProtoFuncPow): (KJS::mathProtoFuncRandom): (KJS::mathProtoFuncRound): (KJS::mathProtoFuncSin): (KJS::mathProtoFuncSqrt): (KJS::mathProtoFuncTan):
  • kjs/math_object.h:
  • kjs/string_object.cpp: (KJS::stringProtoFuncToString): (KJS::stringProtoFuncValueOf): (KJS::stringProtoFuncCharAt): (KJS::stringProtoFuncCharCodeAt): (KJS::stringProtoFuncConcat): (KJS::stringProtoFuncIndexOf): (KJS::stringProtoFuncLastIndexOf): (KJS::stringProtoFuncMatch): (KJS::stringProtoFuncSearch): (KJS::stringProtoFuncReplace): (KJS::stringProtoFuncSlice): (KJS::stringProtoFuncSplit): (KJS::stringProtoFuncSubstr): (KJS::stringProtoFuncSubstring): (KJS::stringProtoFuncToLowerCase): (KJS::stringProtoFuncToUpperCase): (KJS::stringProtoFuncToLocaleLowerCase): (KJS::stringProtoFuncToLocaleUpperCase): (KJS::stringProtoFuncLocaleCompare): (KJS::stringProtoFuncBig): (KJS::stringProtoFuncSmall): (KJS::stringProtoFuncBlink): (KJS::stringProtoFuncBold): (KJS::stringProtoFuncFixed): (KJS::stringProtoFuncItalics): (KJS::stringProtoFuncStrike): (KJS::stringProtoFuncSub): (KJS::stringProtoFuncSup): (KJS::stringProtoFuncFontcolor): (KJS::stringProtoFuncFontsize): (KJS::stringProtoFuncAnchor): (KJS::stringProtoFuncLink):
  • kjs/string_object.h:

WebCore:

Reviewed by Geoffrey Garen.

Fix <rdar://problem/5595552> r27608 introduced a 20% increase in JS binary size, 4% increase in WebCore binary size

  • Update JS Function implementations to use a static function based method. This decreases the binary size of an Intel only build by 1013.5K.
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::customGetOwnPropertySlot):
  • bindings/js/JSEventTargetBase.cpp: (WebCore::jsEventTargetAddEventListener): (WebCore::jsEventTargetRemoveEventListener): (WebCore::jsEventTargetDispatchEvent): (WebCore::retrieveEventTargetAndCorrespondingNode):
  • bindings/js/JSEventTargetBase.h:
  • bindings/js/JSHTMLInputElementBase.cpp: (WebCore::jsHTMLInputElementBaseFunctionSetSelectionRange): (WebCore::JSHTMLInputElementBase::getOwnPropertySlot):
  • bindings/js/JSHTMLInputElementBase.h:
  • bindings/js/JSLocation.cpp: (WebCore::JSLocation::getOwnPropertySlot): (WebCore::jsLocationProtoFuncReplace): (WebCore::jsLocationProtoFuncReload): (WebCore::jsLocationProtoFuncAssign): (WebCore::jsLocationProtoFuncToString):
  • bindings/js/JSLocation.h:
  • bindings/js/JSXMLHttpRequest.cpp: (KJS::jsXMLHttpRequestPrototypeFunctionAbort): (KJS::jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders): (KJS::jsXMLHttpRequestPrototypeFunctionGetResponseHeader): (KJS::jsXMLHttpRequestPrototypeFunctionOpen): (KJS::jsXMLHttpRequestPrototypeFunctionSend): (KJS::jsXMLHttpRequestPrototypeFunctionSetRequestHeader): (KJS::jsXMLHttpRequestPrototypeFunctionOverrideMIMEType): (KJS::jsXMLHttpRequestPrototypeFunctionAddEventListener): (KJS::jsXMLHttpRequestPrototypeFunctionRemoveEventListener): (KJS::jsXMLHttpRequestPrototypeFunctionDispatchEvent):
  • bindings/js/JSXMLHttpRequest.h:
  • bindings/js/JSXSLTProcessor.cpp: (KJS::jsXSLTProcessorPrototypeFunctionImportStylesheet): (KJS::jsXSLTProcessorPrototypeFunctionTransformToFragment): (KJS::jsXSLTProcessorPrototypeFunctionTransformToDocument): (KJS::jsXSLTProcessorPrototypeFunctionSetParameter): (KJS::jsXSLTProcessorPrototypeFunctionGetParameter): (KJS::jsXSLTProcessorPrototypeFunctionRemoveParameter): (KJS::jsXSLTProcessorPrototypeFunctionClearParameters): (KJS::jsXSLTProcessorPrototypeFunctionReset):
  • bindings/js/JSXSLTProcessor.h:
  • bindings/js/kjs_events.cpp: (WebCore::jsClipboardPrototypeFunctionClearData): (WebCore::jsClipboardPrototypeFunctionGetData): (WebCore::jsClipboardPrototypeFunctionSetData): (WebCore::jsClipboardPrototypeFunctionSetDragImage):
  • bindings/js/kjs_events.h:
  • bindings/js/kjs_navigator.cpp: (KJS::pluginsFunctionRefresh): (KJS::navigatorProtoFuncJavaEnabled):
  • bindings/js/kjs_navigator.h:
  • bindings/js/kjs_window.cpp: (KJS::Window::getOwnPropertySlot): (KJS::windowProtoFuncAToB): (KJS::windowProtoFuncBToA): (KJS::windowProtoFuncOpen): (KJS::windowProtoFuncSetTimeout): (KJS::windowProtoFuncClearTimeout): (KJS::windowProtoFuncSetInterval): (KJS::windowProtoFuncAddEventListener): (KJS::windowProtoFuncRemoveEventListener): (KJS::windowProtoFuncShowModalDialog): (KJS::windowProtoFuncNotImplemented):
  • bindings/js/kjs_window.h:
  • bindings/scripts/CodeGenerator.pm:
  • bindings/scripts/CodeGeneratorJS.pm:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/date_object.h

    r28907 r29508  
    6161
    6262    /**
    63         * @internal
     63     * @internal
    6464     *
    65      * Class to implement all methods that are properties of the
     65     * Functions to implement all methods that are properties of the
    6666     * Date.prototype object
    6767     */
     
    7070    // GetYear, SetYear, ToGMTString
    7171
    72 #define FOR_EACH_CLASS(macro) \
    73     macro(DateProtoFuncToString) \
    74     macro(DateProtoFuncToUTCString) \
    75     macro(DateProtoFuncToDateString) \
    76     macro(DateProtoFuncToTimeString) \
    77     macro(DateProtoFuncToLocaleString) \
    78     macro(DateProtoFuncToLocaleDateString) \
    79     macro(DateProtoFuncToLocaleTimeString) \
    80     macro(DateProtoFuncValueOf) \
    81     macro(DateProtoFuncGetTime) \
    82     macro(DateProtoFuncGetFullYear) \
    83     macro(DateProtoFuncGetUTCFullYear) \
    84     macro(DateProtoFuncToGMTString) \
    85     macro(DateProtoFuncGetMonth) \
    86     macro(DateProtoFuncGetUTCMonth) \
    87     macro(DateProtoFuncGetDate) \
    88     macro(DateProtoFuncGetUTCDate) \
    89     macro(DateProtoFuncGetDay) \
    90     macro(DateProtoFuncGetUTCDay) \
    91     macro(DateProtoFuncGetHours) \
    92     macro(DateProtoFuncGetUTCHours) \
    93     macro(DateProtoFuncGetMinutes) \
    94     macro(DateProtoFuncGetUTCMinutes) \
    95     macro(DateProtoFuncGetSeconds) \
    96     macro(DateProtoFuncGetUTCSeconds) \
    97     macro(DateProtoFuncGetMilliSeconds) \
    98     macro(DateProtoFuncGetUTCMilliseconds) \
    99     macro(DateProtoFuncGetTimezoneOffset) \
    100     macro(DateProtoFuncSetTime) \
    101     macro(DateProtoFuncSetMilliSeconds) \
    102     macro(DateProtoFuncSetUTCMilliseconds) \
    103     macro(DateProtoFuncSetSeconds) \
    104     macro(DateProtoFuncSetUTCSeconds) \
    105     macro(DateProtoFuncSetMinutes) \
    106     macro(DateProtoFuncSetUTCMinutes) \
    107     macro(DateProtoFuncSetHours) \
    108     macro(DateProtoFuncSetUTCHours) \
    109     macro(DateProtoFuncSetDate) \
    110     macro(DateProtoFuncSetUTCDate) \
    111     macro(DateProtoFuncSetMonth) \
    112     macro(DateProtoFuncSetUTCMonth) \
    113     macro(DateProtoFuncSetFullYear) \
    114     macro(DateProtoFuncSetUTCFullYear) \
    115     macro(DateProtoFuncSetYear) \
    116     macro(DateProtoFuncGetYear) \
    117 
    118 FOR_EACH_CLASS(KJS_IMPLEMENT_PROTOTYPE_FUNCTION_WITH_CREATE)
    119 #undef FOR_EACH_CLASS
    120 
     72    JSValue* dateProtoFuncToString(ExecState*, JSObject*, const List&);
     73    JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, const List&);
     74    JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, const List&);
     75    JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, const List&);
     76    JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, const List&);
     77    JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, const List&);
     78    JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, const List&);
     79    JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, const List&);
     80    JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, const List&);
     81    JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, const List&);
     82    JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, const List&);
     83    JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, const List&);
     84    JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, const List&);
     85    JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, const List&);
     86    JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, const List&);
     87    JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, const List&);
     88    JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, const List&);
     89    JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, const List&);
     90    JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, const List&);
     91    JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, const List&);
     92    JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, const List&);
     93    JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, const List&);
     94    JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, const List&);
     95    JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, const List&);
     96    JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, const List&);
     97    JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, const List&);
     98    JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, const List&);
     99    JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, const List&);
     100    JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, const List&);
     101    JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, const List&);
     102    JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, const List&);
     103    JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, const List&);
     104    JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, const List&);
     105    JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, const List&);
     106    JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, const List&);
     107    JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, const List&);
     108    JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, const List&);
     109    JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, const List&);
     110    JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, const List&);
     111    JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, const List&);
     112    JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, const List&);
     113    JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, const List&);
     114    JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, const List&);
     115    JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, const List&);
    121116
    122117    /**
Note: See TracChangeset for help on using the changeset viewer.