Commit 5902380f authored by weinig@apple.com's avatar weinig@apple.com

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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29508 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 48f87471
2008-01-15 Sam Weinig <sam@webkit.org>
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:
2008-01-15 Geoffrey Garen <ggaren@apple.com>
Reviewed by Adam Roben.
......
......@@ -159,6 +159,7 @@ __ZN3KJS16ParserRefCounted3refEv
__ZN3KJS16ParserRefCounted5derefEv
__ZN3KJS16RuntimeObjectImp4infoE
__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE
__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_4ListEE
__ZN3KJS19InternalFunctionImp4infoE
__ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
__ZN3KJS4List15expandAndAppendEPNS_7JSValueE
......
......@@ -391,7 +391,7 @@
146AAB2A0B66A84900E55F16 /* JSStringRefCF.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSStringRefCF.h; sourceTree = "<group>"; };
146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSStringRefCF.cpp; sourceTree = "<group>"; };
14760863099C633800437128 /* JSImmediate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImmediate.cpp; sourceTree = "<group>"; };
1482B6EA0A4300B300517CFC /* JSValueRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSValueRef.h; path = ../API/JSValueRef.h; sourceTree = "<group>"; };
1482B6EA0A4300B300517CFC /* JSValueRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSValueRef.h; sourceTree = "<group>"; };
1482B74B0A43032800517CFC /* JSStringRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringRef.h; sourceTree = "<group>"; };
1482B74C0A43032800517CFC /* JSStringRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStringRef.cpp; sourceTree = "<group>"; };
1482B78A0A4305AB00517CFC /* APICast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APICast.h; sourceTree = "<group>"; };
......@@ -741,9 +741,9 @@
1432EBD70A34CAD400717B9F /* API */ = {
isa = PBXGroup;
children = (
1482B78A0A4305AB00517CFC /* APICast.h */,
1CAA8B4A0D32C39A0041BCFF /* JavaScript.h */,
1CAA8B4B0D32C39A0041BCFF /* JavaScriptCore.h */,
1482B78A0A4305AB00517CFC /* APICast.h */,
1421359A0A677F4F00A8195E /* JSBase.cpp */,
142711380A460BBB0080EEEA /* JSBase.h */,
1440F8AD0A508D200005F061 /* JSCallbackConstructor.cpp */,
......@@ -765,6 +765,7 @@
146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */,
146AAB2A0B66A84900E55F16 /* JSStringRefCF.h */,
14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */,
1482B6EA0A4300B300517CFC /* JSValueRef.h */,
);
path = API;
sourceTree = "<group>";
......@@ -930,7 +931,6 @@
65417200039E01BA0058BFEB /* kjs */ = {
isa = PBXGroup;
children = (
14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */,
659126BC0BDD1728001921FB /* AllInOneFile.cpp */,
93ADFCE60CCBD7AC00D30B08 /* array_instance.cpp */,
938772E5038BFE19008635CE /* array_instance.h */,
......@@ -977,7 +977,7 @@
65EA4C99092AF9E20093D800 /* JSLock.cpp */,
65EA4C9A092AF9E20093D800 /* JSLock.h */,
14ABB454099C2A0F00E2A24F /* JSType.h */,
1482B6EA0A4300B300517CFC /* JSValueRef.h */,
14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */,
14F252560D08DD8D004ECFFF /* JSVariableObject.h */,
65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
......
......@@ -42,25 +42,25 @@ const ClassInfo ArrayPrototype::info = {"Array", &ArrayInstance::info, &arrayTab
/* Source for array_object.lut.h
@begin arrayTable 16
toString &ArrayProtoFuncToString::create DontEnum|Function 0
toLocaleString &ArrayProtoFuncToLocaleString::create DontEnum|Function 0
concat &ArrayProtoFuncConcat::create DontEnum|Function 1
join &ArrayProtoFuncJoin::create DontEnum|Function 1
pop &ArrayProtoFuncPop::create DontEnum|Function 0
push &ArrayProtoFuncPush::create DontEnum|Function 1
reverse &ArrayProtoFuncReverse::create DontEnum|Function 0
shift &ArrayProtoFuncShift::create DontEnum|Function 0
slice &ArrayProtoFuncSlice::create DontEnum|Function 2
sort &ArrayProtoFuncSort::create DontEnum|Function 1
splice &ArrayProtoFuncSplice::create DontEnum|Function 2
unshift &ArrayProtoFuncUnShift::create DontEnum|Function 1
every &ArrayProtoFuncEvery::create DontEnum|Function 1
forEach &ArrayProtoFuncForEach::create DontEnum|Function 1
some &ArrayProtoFuncSome::create DontEnum|Function 1
indexOf &ArrayProtoFuncIndexOf::create DontEnum|Function 1
lastIndexOf &ArrayProtoFuncLastIndexOf::create DontEnum|Function 1
filter &ArrayProtoFuncFilter::create DontEnum|Function 1
map &ArrayProtoFuncMap::create DontEnum|Function 1
toString arrayProtoFuncToString DontEnum|Function 0
toLocaleString arrayProtoFuncToLocaleString DontEnum|Function 0
concat arrayProtoFuncConcat DontEnum|Function 1
join arrayProtoFuncJoin DontEnum|Function 1
pop arrayProtoFuncPop DontEnum|Function 0
push arrayProtoFuncPush DontEnum|Function 1
reverse arrayProtoFuncReverse DontEnum|Function 0
shift arrayProtoFuncShift DontEnum|Function 0
slice arrayProtoFuncSlice DontEnum|Function 2
sort arrayProtoFuncSort DontEnum|Function 1
splice arrayProtoFuncSplice DontEnum|Function 2
unshift arrayProtoFuncUnShift DontEnum|Function 1
every arrayProtoFuncEvery DontEnum|Function 1
forEach arrayProtoFuncForEach DontEnum|Function 1
some arrayProtoFuncSome DontEnum|Function 1
indexOf arrayProtoFuncIndexOf DontEnum|Function 1
lastIndexOf arrayProtoFuncLastIndexOf DontEnum|Function 1
filter arrayProtoFuncFilter DontEnum|Function 1
map arrayProtoFuncMap DontEnum|Function 1
@end
*/
......@@ -87,7 +87,7 @@ static JSValue* getProperty(ExecState* exec, JSObject* obj, unsigned index)
return slot.getValue(exec, obj, index);
}
JSValue* ArrayProtoFuncToString::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
JSValue* arrayProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&)
{
if (!thisObj->inherits(&ArrayInstance::info))
return throwError(exec, TypeError);
......@@ -129,7 +129,7 @@ JSValue* ArrayProtoFuncToString::callAsFunction(ExecState* exec, JSObject* thisO
return jsString(str);
}
JSValue* ArrayProtoFuncToLocaleString::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List&)
{
if (!thisObj->inherits(&ArrayInstance::info))
return throwError(exec, TypeError);
......@@ -176,7 +176,7 @@ JSValue* ArrayProtoFuncToLocaleString::callAsFunction(ExecState* exec, JSObject*
return jsString(str);
}
JSValue* ArrayProtoFuncJoin::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject* thisObj, const List& args)
{
static HashSet<JSObject*> visitedElems;
static const UString* empty = new UString("");
......@@ -218,7 +218,7 @@ JSValue* ArrayProtoFuncJoin::callAsFunction(ExecState* exec, JSObject* thisObj,
return jsString(str);
}
JSValue* ArrayProtoFuncConcat::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject* thisObj, const List& args)
{
JSObject* arr = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
int n = 0;
......@@ -253,7 +253,7 @@ JSValue* ArrayProtoFuncConcat::callAsFunction(ExecState* exec, JSObject* thisObj
return arr;
}
JSValue* ArrayProtoFuncPop::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
JSValue* arrayProtoFuncPop(ExecState* exec, JSObject* thisObj, const List&)
{
JSValue* result = 0;
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
......@@ -267,7 +267,7 @@ JSValue* ArrayProtoFuncPop::callAsFunction(ExecState* exec, JSObject* thisObj, c
return result;
}
JSValue* ArrayProtoFuncPush::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncPush(ExecState* exec, JSObject* thisObj, const List& args)
{
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
for (unsigned int n = 0; n < args.size(); n++)
......@@ -277,7 +277,7 @@ JSValue* ArrayProtoFuncPush::callAsFunction(ExecState* exec, JSObject* thisObj,
return jsNumber(length);
}
JSValue* ArrayProtoFuncReverse::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject* thisObj, const List&)
{
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
unsigned int middle = length / 2;
......@@ -300,7 +300,7 @@ JSValue* ArrayProtoFuncReverse::callAsFunction(ExecState* exec, JSObject* thisOb
return thisObj;
}
JSValue* ArrayProtoFuncShift::callAsFunction(ExecState* exec, JSObject* thisObj, const List&)
JSValue* arrayProtoFuncShift(ExecState* exec, JSObject* thisObj, const List&)
{
JSValue* result = 0;
......@@ -322,7 +322,7 @@ JSValue* ArrayProtoFuncShift::callAsFunction(ExecState* exec, JSObject* thisObj,
return result;
}
JSValue* ArrayProtoFuncSlice::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncSlice(ExecState* exec, JSObject* thisObj, const List& args)
{
// http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10
......@@ -365,7 +365,7 @@ JSValue* ArrayProtoFuncSlice::callAsFunction(ExecState* exec, JSObject* thisObj,
return result;
}
JSValue* ArrayProtoFuncSort::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncSort(ExecState* exec, JSObject* thisObj, const List& args)
{
JSObject* sortFunction = 0;
if (!args[0]->isUndefined()) {
......@@ -424,7 +424,7 @@ JSValue* ArrayProtoFuncSort::callAsFunction(ExecState* exec, JSObject* thisObj,
return thisObj;
}
JSValue* ArrayProtoFuncSplice::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject* thisObj, const List& args)
{
// 15.4.4.12
JSObject* resObj = static_cast<JSObject* >(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
......@@ -477,7 +477,7 @@ JSValue* ArrayProtoFuncSplice::callAsFunction(ExecState* exec, JSObject* thisObj
return result;
}
JSValue* ArrayProtoFuncUnShift::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject* thisObj, const List& args)
{
// 15.4.4.13
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
......@@ -495,7 +495,7 @@ JSValue* ArrayProtoFuncUnShift::callAsFunction(ExecState* exec, JSObject* thisOb
return result;
}
JSValue* ArrayProtoFuncFilter::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject* thisObj, const List& args)
{
JSObject* eachFunction = args[0]->toObject(exec);
......@@ -529,7 +529,7 @@ JSValue* ArrayProtoFuncFilter::callAsFunction(ExecState* exec, JSObject* thisObj
return resultArray;
}
JSValue* ArrayProtoFuncMap::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncMap(ExecState* exec, JSObject* thisObj, const List& args)
{
JSObject* eachFunction = args[0]->toObject(exec);
if (!eachFunction->implementsCall())
......@@ -568,7 +568,7 @@ JSValue* ArrayProtoFuncMap::callAsFunction(ExecState* exec, JSObject* thisObj, c
// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach
// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
JSValue* ArrayProtoFuncEvery::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject* thisObj, const List& args)
{
JSObject* eachFunction = args[0]->toObject(exec);
......@@ -603,7 +603,7 @@ JSValue* ArrayProtoFuncEvery::callAsFunction(ExecState* exec, JSObject* thisObj,
return result;
}
JSValue* ArrayProtoFuncForEach::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncForEach(ExecState* exec, JSObject* thisObj, const List& args)
{
JSObject* eachFunction = args[0]->toObject(exec);
......@@ -628,7 +628,7 @@ JSValue* ArrayProtoFuncForEach::callAsFunction(ExecState* exec, JSObject* thisOb
return jsUndefined();
}
JSValue* ArrayProtoFuncSome::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncSome(ExecState* exec, JSObject* thisObj, const List& args)
{
JSObject* eachFunction = args[0]->toObject(exec);
......@@ -660,7 +660,7 @@ JSValue* ArrayProtoFuncSome::callAsFunction(ExecState* exec, JSObject* thisObj,
return result;
}
JSValue* ArrayProtoFuncIndexOf::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const List& args)
{
// JavaScript 1.5 Extension by Mozilla
// Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf
......@@ -689,7 +689,7 @@ JSValue* ArrayProtoFuncIndexOf::callAsFunction(ExecState* exec, JSObject* thisOb
return jsNumber(-1);
}
JSValue* ArrayProtoFuncLastIndexOf::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const List& args)
{
// JavaScript 1.6 Extension by Mozilla
// Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf
......
......@@ -48,29 +48,25 @@ namespace KJS {
};
#define FOR_EACH_CLASS(macro) \
macro(ArrayProtoFuncToString) \
macro(ArrayProtoFuncToLocaleString) \
macro(ArrayProtoFuncConcat) \
macro(ArrayProtoFuncJoin) \
macro(ArrayProtoFuncPop) \
macro(ArrayProtoFuncPush) \
macro(ArrayProtoFuncReverse) \
macro(ArrayProtoFuncShift) \
macro(ArrayProtoFuncSlice) \
macro(ArrayProtoFuncSort) \
macro(ArrayProtoFuncSplice) \
macro(ArrayProtoFuncUnShift) \
macro(ArrayProtoFuncEvery) \
macro(ArrayProtoFuncForEach) \
macro(ArrayProtoFuncSome) \
macro(ArrayProtoFuncIndexOf) \
macro(ArrayProtoFuncFilter) \
macro(ArrayProtoFuncMap) \
macro(ArrayProtoFuncLastIndexOf) \
FOR_EACH_CLASS(KJS_IMPLEMENT_PROTOTYPE_FUNCTION_WITH_CREATE)
#undef FOR_EACH_CLASS
JSValue* arrayProtoFuncToString(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncToLocaleString(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncConcat(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncJoin(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncPop(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncPush(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncReverse(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncShift(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncSlice(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncSort(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncSplice(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncUnShift(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncEvery(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncForEach(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncSome(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncIndexOf(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncFilter(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncMap(ExecState*, JSObject*, const List&);
JSValue* arrayProtoFuncLastIndexOf(ExecState*, JSObject*, const List&);
} // namespace KJS
......
This diff is collapsed.
......@@ -60,64 +60,59 @@ namespace KJS {
};
/**
* @internal
* @internal
*
* Class to implement all methods that are properties of the
* Functions to implement all methods that are properties of the
* Date.prototype object
*/
// Non-normative properties (Appendix B)
// GetYear, SetYear, ToGMTString
#define FOR_EACH_CLASS(macro) \
macro(DateProtoFuncToString) \
macro(DateProtoFuncToUTCString) \
macro(DateProtoFuncToDateString) \
macro(DateProtoFuncToTimeString) \
macro(DateProtoFuncToLocaleString) \
macro(DateProtoFuncToLocaleDateString) \
macro(DateProtoFuncToLocaleTimeString) \
macro(DateProtoFuncValueOf) \
macro(DateProtoFuncGetTime) \
macro(DateProtoFuncGetFullYear) \
macro(DateProtoFuncGetUTCFullYear) \
macro(DateProtoFuncToGMTString) \
macro(DateProtoFuncGetMonth) \
macro(DateProtoFuncGetUTCMonth) \
macro(DateProtoFuncGetDate) \
macro(DateProtoFuncGetUTCDate) \
macro(DateProtoFuncGetDay) \
macro(DateProtoFuncGetUTCDay) \
macro(DateProtoFuncGetHours) \
macro(DateProtoFuncGetUTCHours) \
macro(DateProtoFuncGetMinutes) \
macro(DateProtoFuncGetUTCMinutes) \
macro(DateProtoFuncGetSeconds) \
macro(DateProtoFuncGetUTCSeconds) \
macro(DateProtoFuncGetMilliSeconds) \
macro(DateProtoFuncGetUTCMilliseconds) \
macro(DateProtoFuncGetTimezoneOffset) \
macro(DateProtoFuncSetTime) \
macro(DateProtoFuncSetMilliSeconds) \
macro(DateProtoFuncSetUTCMilliseconds) \
macro(DateProtoFuncSetSeconds) \
macro(DateProtoFuncSetUTCSeconds) \
macro(DateProtoFuncSetMinutes) \
macro(DateProtoFuncSetUTCMinutes) \
macro(DateProtoFuncSetHours) \
macro(DateProtoFuncSetUTCHours) \
macro(DateProtoFuncSetDate) \
macro(DateProtoFuncSetUTCDate) \
macro(DateProtoFuncSetMonth) \
macro(DateProtoFuncSetUTCMonth) \
macro(DateProtoFuncSetFullYear) \
macro(DateProtoFuncSetUTCFullYear) \
macro(DateProtoFuncSetYear) \
macro(DateProtoFuncGetYear) \
FOR_EACH_CLASS(KJS_IMPLEMENT_PROTOTYPE_FUNCTION_WITH_CREATE)
#undef FOR_EACH_CLASS
JSValue* dateProtoFuncToString(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, const List&);
JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, const List&);
/**
* @internal
......
......@@ -856,4 +856,19 @@ JSValue* GlobalFuncImp::callAsFunction(ExecState* exec, JSObject* thisObj, const
return res;
}
} // namespace
// ------------------------------ PrototypeFunction -------------------------------
PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier& name, JSMemberFunction function)
: InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name)
, m_function(function)
{
ASSERT_ARG(function, function);
put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
}
JSValue* PrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
return m_function(exec, thisObj, args);
}
} // namespace KJS
......@@ -138,6 +138,18 @@ namespace KJS {
mutable IndexToNameMap indexToNameMap;
};
class PrototypeFunction : public InternalFunctionImp {
public:
typedef KJS::JSValue* (*JSMemberFunction)(ExecState*, JSObject*, const List&);
PrototypeFunction(ExecState*, int len, const Identifier&, JSMemberFunction);
virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List&);
private: