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/math_object.cpp

    r27608 r29508  
    4545  SQRT1_2       MathObjectImp::Sqrt1_2         DontEnum|DontDelete|ReadOnly
    4646  SQRT2         MathObjectImp::Sqrt2           DontEnum|DontDelete|ReadOnly
    47   abs           &MathProtoFuncAbs::create      DontEnum|Function 1
    48   acos          &MathProtoFuncACos::create     DontEnum|Function 1
    49   asin          &MathProtoFuncASin::create     DontEnum|Function 1
    50   atan          &MathProtoFuncATan::create     DontEnum|Function 1
    51   atan2         &MathProtoFuncATan2::create    DontEnum|Function 2
    52   ceil          &MathProtoFuncCeil::create     DontEnum|Function 1
    53   cos           &MathProtoFuncCos::create      DontEnum|Function 1
    54   exp           &MathProtoFuncExp::create      DontEnum|Function 1
    55   floor         &MathProtoFuncFloor::create    DontEnum|Function 1
    56   log           &MathProtoFuncLog::create      DontEnum|Function 1
    57   max           &MathProtoFuncMax::create      DontEnum|Function 2
    58   min           &MathProtoFuncMin::create      DontEnum|Function 2
    59   pow           &MathProtoFuncPow::create      DontEnum|Function 2
    60   random        &MathProtoFuncRandom::create   DontEnum|Function 0
    61   round         &MathProtoFuncRound::create    DontEnum|Function 1
    62   sin           &MathProtoFuncSin::create      DontEnum|Function 1
    63   sqrt          &MathProtoFuncSqrt::create     DontEnum|Function 1
    64   tan           &MathProtoFuncTan::create      DontEnum|Function 1
     47  abs           mathProtoFuncAbs               DontEnum|Function 1
     48  acos          mathProtoFuncACos              DontEnum|Function 1
     49  asin          mathProtoFuncASin              DontEnum|Function 1
     50  atan          mathProtoFuncATan              DontEnum|Function 1
     51  atan2         mathProtoFuncATan2             DontEnum|Function 2
     52  ceil          mathProtoFuncCeil              DontEnum|Function 1
     53  cos           mathProtoFuncCos               DontEnum|Function 1
     54  exp           mathProtoFuncExp               DontEnum|Function 1
     55  floor         mathProtoFuncFloor             DontEnum|Function 1
     56  log           mathProtoFuncLog               DontEnum|Function 1
     57  max           mathProtoFuncMax               DontEnum|Function 2
     58  min           mathProtoFuncMin               DontEnum|Function 2
     59  pow           mathProtoFuncPow               DontEnum|Function 2
     60  random        mathProtoFuncRandom            DontEnum|Function 0
     61  round         mathProtoFuncRound             DontEnum|Function 1
     62  sin           mathProtoFuncSin               DontEnum|Function 1
     63  sqrt          mathProtoFuncSqrt              DontEnum|Function 1
     64  tan           mathProtoFuncTan               DontEnum|Function 1
    6565@end
    6666*/
     
    116116// ------------------------------ Functions --------------------------------
    117117
    118 JSValue* MathProtoFuncAbs::callAsFunction(ExecState* exec, JSObject*, const List& args)
     118JSValue* mathProtoFuncAbs(ExecState* exec, JSObject*, const List& args)
    119119{
    120120    double arg = args[0]->toNumber(exec);
     
    122122}
    123123
    124 JSValue* MathProtoFuncACos::callAsFunction(ExecState* exec, JSObject*, const List& args)
     124JSValue* mathProtoFuncACos(ExecState* exec, JSObject*, const List& args)
    125125{
    126126    double arg = args[0]->toNumber(exec);
     
    128128}
    129129
    130 JSValue* MathProtoFuncASin::callAsFunction(ExecState* exec, JSObject*, const List& args)
     130JSValue* mathProtoFuncASin(ExecState* exec, JSObject*, const List& args)
    131131{
    132132    double arg = args[0]->toNumber(exec);
     
    134134}
    135135
    136 JSValue* MathProtoFuncATan::callAsFunction(ExecState* exec, JSObject*, const List& args)
     136JSValue* mathProtoFuncATan(ExecState* exec, JSObject*, const List& args)
    137137{
    138138    double arg = args[0]->toNumber(exec);
     
    140140}
    141141
    142 JSValue* MathProtoFuncATan2::callAsFunction(ExecState* exec, JSObject*, const List& args)
     142JSValue* mathProtoFuncATan2(ExecState* exec, JSObject*, const List& args)
    143143{
    144144    double arg = args[0]->toNumber(exec);
     
    147147}
    148148
    149 JSValue* MathProtoFuncCeil::callAsFunction(ExecState* exec, JSObject*, const List& args)
     149JSValue* mathProtoFuncCeil(ExecState* exec, JSObject*, const List& args)
    150150{
    151151    double arg = args[0]->toNumber(exec);
     
    155155}
    156156
    157 JSValue* MathProtoFuncCos::callAsFunction(ExecState* exec, JSObject*, const List& args)
     157JSValue* mathProtoFuncCos(ExecState* exec, JSObject*, const List& args)
    158158{
    159159    double arg = args[0]->toNumber(exec);
     
    161161}
    162162
    163 JSValue* MathProtoFuncExp::callAsFunction(ExecState* exec, JSObject*, const List& args)
     163JSValue* mathProtoFuncExp(ExecState* exec, JSObject*, const List& args)
    164164{
    165165    double arg = args[0]->toNumber(exec);
     
    167167}
    168168
    169 JSValue* MathProtoFuncFloor::callAsFunction(ExecState* exec, JSObject*, const List& args)
     169JSValue* mathProtoFuncFloor(ExecState* exec, JSObject*, const List& args)
    170170{
    171171    double arg = args[0]->toNumber(exec);
     
    175175}
    176176
    177 JSValue* MathProtoFuncLog::callAsFunction(ExecState* exec, JSObject*, const List& args)
     177JSValue* mathProtoFuncLog(ExecState* exec, JSObject*, const List& args)
    178178{
    179179    double arg = args[0]->toNumber(exec);
     
    181181}
    182182
    183 JSValue* MathProtoFuncMax::callAsFunction(ExecState* exec, JSObject*, const List& args)
     183JSValue* mathProtoFuncMax(ExecState* exec, JSObject*, const List& args)
    184184{
    185185    unsigned argsCount = args.size();
     
    197197}
    198198
    199 JSValue* MathProtoFuncMin::callAsFunction(ExecState* exec, JSObject*, const List& args)
     199JSValue* mathProtoFuncMin(ExecState* exec, JSObject*, const List& args)
    200200{
    201201    unsigned argsCount = args.size();
     
    213213}
    214214
    215 JSValue* MathProtoFuncPow::callAsFunction(ExecState* exec, JSObject*, const List& args)
     215JSValue* mathProtoFuncPow(ExecState* exec, JSObject*, const List& args)
    216216{
    217217    // ECMA 15.8.2.1.13
     
    229229static bool didInitRandom;
    230230
    231 JSValue* MathProtoFuncRandom::callAsFunction(ExecState*, JSObject*, const List&)
     231JSValue* mathProtoFuncRandom(ExecState*, JSObject*, const List&)
    232232{
    233233    if (!didInitRandom) {
     
    238238}
    239239
    240 JSValue* MathProtoFuncRound::callAsFunction(ExecState* exec, JSObject*, const List& args)
     240JSValue* mathProtoFuncRound(ExecState* exec, JSObject*, const List& args)
    241241{
    242242    double arg = args[0]->toNumber(exec);
     
    246246}
    247247
    248 JSValue* MathProtoFuncSin::callAsFunction(ExecState* exec, JSObject*, const List& args)
     248JSValue* mathProtoFuncSin(ExecState* exec, JSObject*, const List& args)
    249249{
    250250    double arg = args[0]->toNumber(exec);
     
    252252}
    253253
    254 JSValue* MathProtoFuncSqrt::callAsFunction(ExecState* exec, JSObject*, const List& args)
     254JSValue* mathProtoFuncSqrt(ExecState* exec, JSObject*, const List& args)
    255255{
    256256    double arg = args[0]->toNumber(exec);
     
    258258}
    259259
    260 JSValue* MathProtoFuncTan::callAsFunction(ExecState* exec, JSObject*, const List& args)
     260JSValue* mathProtoFuncTan(ExecState* exec, JSObject*, const List& args)
    261261{
    262262    double arg = args[0]->toNumber(exec);
Note: See TracChangeset for help on using the changeset viewer.