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

    r29459 r29508  
    4343/* Source for array_object.lut.h
    4444@begin arrayTable 16
    45   toString       &ArrayProtoFuncToString::create       DontEnum|Function 0
    46   toLocaleString &ArrayProtoFuncToLocaleString::create DontEnum|Function 0
    47   concat         &ArrayProtoFuncConcat::create         DontEnum|Function 1
    48   join           &ArrayProtoFuncJoin::create           DontEnum|Function 1
    49   pop            &ArrayProtoFuncPop::create            DontEnum|Function 0
    50   push           &ArrayProtoFuncPush::create           DontEnum|Function 1
    51   reverse        &ArrayProtoFuncReverse::create        DontEnum|Function 0
    52   shift          &ArrayProtoFuncShift::create          DontEnum|Function 0
    53   slice          &ArrayProtoFuncSlice::create          DontEnum|Function 2
    54   sort           &ArrayProtoFuncSort::create           DontEnum|Function 1
    55   splice         &ArrayProtoFuncSplice::create         DontEnum|Function 2
    56   unshift        &ArrayProtoFuncUnShift::create        DontEnum|Function 1
    57   every          &ArrayProtoFuncEvery::create          DontEnum|Function 1
    58   forEach        &ArrayProtoFuncForEach::create        DontEnum|Function 1
    59   some           &ArrayProtoFuncSome::create           DontEnum|Function 1
    60   indexOf        &ArrayProtoFuncIndexOf::create        DontEnum|Function 1
    61   lastIndexOf    &ArrayProtoFuncLastIndexOf::create    DontEnum|Function 1
    62   filter         &ArrayProtoFuncFilter::create         DontEnum|Function 1
    63   map            &ArrayProtoFuncMap::create            DontEnum|Function 1
     45  toString       arrayProtoFuncToString       DontEnum|Function 0
     46  toLocaleString arrayProtoFuncToLocaleString DontEnum|Function 0
     47  concat         arrayProtoFuncConcat         DontEnum|Function 1
     48  join           arrayProtoFuncJoin           DontEnum|Function 1
     49  pop            arrayProtoFuncPop            DontEnum|Function 0
     50  push           arrayProtoFuncPush           DontEnum|Function 1
     51  reverse        arrayProtoFuncReverse        DontEnum|Function 0
     52  shift          arrayProtoFuncShift          DontEnum|Function 0
     53  slice          arrayProtoFuncSlice          DontEnum|Function 2
     54  sort           arrayProtoFuncSort           DontEnum|Function 1
     55  splice         arrayProtoFuncSplice         DontEnum|Function 2
     56  unshift        arrayProtoFuncUnShift        DontEnum|Function 1
     57  every          arrayProtoFuncEvery          DontEnum|Function 1
     58  forEach        arrayProtoFuncForEach        DontEnum|Function 1
     59  some           arrayProtoFuncSome           DontEnum|Function 1
     60  indexOf        arrayProtoFuncIndexOf        DontEnum|Function 1
     61  lastIndexOf    arrayProtoFuncLastIndexOf    DontEnum|Function 1
     62  filter         arrayProtoFuncFilter         DontEnum|Function 1
     63  map            arrayProtoFuncMap            DontEnum|Function 1
    6464@end
    6565*/
     
    8888}
    8989
    90 JSValue* ArrayProtoFuncToString::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
     90JSValue* arrayProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&)
    9191{
    9292    if (!thisObj->inherits(&ArrayInstance::info))
     
    130130}
    131131
    132 JSValue* ArrayProtoFuncToLocaleString::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
     132JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List&)
    133133{
    134134    if (!thisObj->inherits(&ArrayInstance::info))
     
    177177}
    178178
    179 JSValue* ArrayProtoFuncJoin::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     179JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject* thisObj, const List& args)
    180180{
    181181    static HashSet<JSObject*> visitedElems;
     
    219219}
    220220
    221 JSValue* ArrayProtoFuncConcat::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     221JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject* thisObj, const List& args)
    222222{
    223223    JSObject* arr = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
     
    254254}
    255255
    256 JSValue* ArrayProtoFuncPop::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
     256JSValue* arrayProtoFuncPop(ExecState* exec, JSObject* thisObj, const List&)
    257257{
    258258    JSValue* result = 0;
     
    268268}
    269269
    270 JSValue* ArrayProtoFuncPush::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     270JSValue* arrayProtoFuncPush(ExecState* exec, JSObject* thisObj, const List& args)
    271271{
    272272    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    278278}
    279279
    280 JSValue* ArrayProtoFuncReverse::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
     280JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject* thisObj, const List&)
    281281{
    282282    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    301301}
    302302
    303 JSValue* ArrayProtoFuncShift::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
     303JSValue* arrayProtoFuncShift(ExecState* exec, JSObject* thisObj, const List&)
    304304{
    305305    JSValue* result = 0;
     
    323323}
    324324
    325 JSValue* ArrayProtoFuncSlice::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     325JSValue* arrayProtoFuncSlice(ExecState* exec, JSObject* thisObj, const List& args)
    326326{
    327327    // http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10
     
    366366}
    367367
    368 JSValue* ArrayProtoFuncSort::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     368JSValue* arrayProtoFuncSort(ExecState* exec, JSObject* thisObj, const List& args)
    369369{
    370370    JSObject* sortFunction = 0;
     
    425425}
    426426
    427 JSValue* ArrayProtoFuncSplice::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     427JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject* thisObj, const List& args)
    428428{
    429429    // 15.4.4.12
     
    478478}
    479479
    480 JSValue* ArrayProtoFuncUnShift::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     480JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject* thisObj, const List& args)
    481481{
    482482    // 15.4.4.13
     
    496496}
    497497
    498 JSValue* ArrayProtoFuncFilter::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     498JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject* thisObj, const List& args)
    499499{
    500500    JSObject* eachFunction = args[0]->toObject(exec);
     
    530530}
    531531
    532 JSValue* ArrayProtoFuncMap::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     532JSValue* arrayProtoFuncMap(ExecState* exec, JSObject* thisObj, const List& args)
    533533{
    534534    JSObject* eachFunction = args[0]->toObject(exec);
     
    569569// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
    570570
    571 JSValue* ArrayProtoFuncEvery::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     571JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject* thisObj, const List& args)
    572572{
    573573    JSObject* eachFunction = args[0]->toObject(exec);
     
    604604}
    605605
    606 JSValue* ArrayProtoFuncForEach::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     606JSValue* arrayProtoFuncForEach(ExecState* exec, JSObject* thisObj, const List& args)
    607607{
    608608    JSObject* eachFunction = args[0]->toObject(exec);
     
    629629}
    630630
    631 JSValue* ArrayProtoFuncSome::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     631JSValue* arrayProtoFuncSome(ExecState* exec, JSObject* thisObj, const List& args)
    632632{
    633633    JSObject* eachFunction = args[0]->toObject(exec);
     
    661661}
    662662
    663 JSValue* ArrayProtoFuncIndexOf::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     663JSValue* arrayProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const List& args)
    664664{
    665665    // JavaScript 1.5 Extension by Mozilla
     
    690690}
    691691
    692 JSValue* ArrayProtoFuncLastIndexOf::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     692JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const List& args)
    693693{
    694694    // JavaScript 1.6 Extension by Mozilla
Note: See TracChangeset for help on using the changeset viewer.