Commit a73c15f5 authored by weinig@apple.com's avatar weinig@apple.com

JavaScriptCore:

        Reviewed by Darin.

        Convert JavaScript internal function objects to use one class per
        function.  This avoids a switch statement inside what used to be
        the shared function classes and will allow Shark to better analyze
        the code.

        To make this switch, the value property of the HashEntry was changed
        to a union of an intptr_t (which is used to continue handle valueGetters)
        and function pointer which points to a static constructor for the
        individual new function objects.

        SunSpider claims this is a 0.5% speedup. 

        * kjs/array_object.cpp:
        (KJS::ArrayPrototype::getOwnPropertySlot):
        (KJS::getProperty):
        (KJS::ArrayProtoFuncToString::callAsFunction):
        (KJS::ArrayProtoFuncToLocaleString::callAsFunction):
        (KJS::ArrayProtoFuncJoin::callAsFunction):
        (KJS::ArrayProtoFuncConcat::callAsFunction):
        (KJS::ArrayProtoFuncPop::callAsFunction):
        (KJS::ArrayProtoFuncPush::callAsFunction):
        (KJS::ArrayProtoFuncReverse::callAsFunction):
        (KJS::ArrayProtoFuncShift::callAsFunction):
        (KJS::ArrayProtoFuncSlice::callAsFunction):
        (KJS::ArrayProtoFuncSort::callAsFunction):
        (KJS::ArrayProtoFuncSplice::callAsFunction):
        (KJS::ArrayProtoFuncUnShift::callAsFunction):
        (KJS::ArrayProtoFuncFilter::callAsFunction):
        (KJS::ArrayProtoFuncMap::callAsFunction):
        (KJS::ArrayProtoFuncEvery::callAsFunction):
        (KJS::ArrayProtoFuncForEach::callAsFunction):
        (KJS::ArrayProtoFuncSome::callAsFunction):
        (KJS::ArrayProtoFuncIndexOf::callAsFunction):
        (KJS::ArrayProtoFuncLastIndexOf::callAsFunction):
        * kjs/array_object.h:
        (KJS::ArrayPrototype::classInfo):
        * kjs/create_hash_table:
        * kjs/date_object.cpp:
        (KJS::DatePrototype::getOwnPropertySlot):
        (KJS::DateProtoFuncToString::callAsFunction):
        (KJS::DateProtoFuncToUTCString::callAsFunction):
        (KJS::DateProtoFuncToDateString::callAsFunction):
        (KJS::DateProtoFuncToTimeString::callAsFunction):
        (KJS::DateProtoFuncToLocaleString::callAsFunction):
        (KJS::DateProtoFuncToLocaleDateString::callAsFunction):
        (KJS::DateProtoFuncToLocaleTimeString::callAsFunction):
        (KJS::DateProtoFuncValueOf::callAsFunction):
        (KJS::DateProtoFuncGetTime::callAsFunction):
        (KJS::DateProtoFuncGetFullYear::callAsFunction):
        (KJS::DateProtoFuncGetUTCFullYear::callAsFunction):
        (KJS::DateProtoFuncToGMTString::callAsFunction):
        (KJS::DateProtoFuncGetMonth::callAsFunction):
        (KJS::DateProtoFuncGetUTCMonth::callAsFunction):
        (KJS::DateProtoFuncGetDate::callAsFunction):
        (KJS::DateProtoFuncGetUTCDate::callAsFunction):
        (KJS::DateProtoFuncGetDay::callAsFunction):
        (KJS::DateProtoFuncGetUTCDay::callAsFunction):
        (KJS::DateProtoFuncGetHours::callAsFunction):
        (KJS::DateProtoFuncGetUTCHours::callAsFunction):
        (KJS::DateProtoFuncGetMinutes::callAsFunction):
        (KJS::DateProtoFuncGetUTCMinutes::callAsFunction):
        (KJS::DateProtoFuncGetSeconds::callAsFunction):
        (KJS::DateProtoFuncGetUTCSeconds::callAsFunction):
        (KJS::DateProtoFuncGetMilliSeconds::callAsFunction):
        (KJS::DateProtoFuncGetUTCMilliseconds::callAsFunction):
        (KJS::DateProtoFuncGetTimezoneOffset::callAsFunction):
        (KJS::DateProtoFuncSetTime::callAsFunction):
        (KJS::DateProtoFuncSetMilliSeconds::callAsFunction):
        (KJS::DateProtoFuncSetUTCMilliseconds::callAsFunction):
        (KJS::DateProtoFuncSetSeconds::callAsFunction):
        (KJS::DateProtoFuncSetUTCSeconds::callAsFunction):
        (KJS::DateProtoFuncSetMinutes::callAsFunction):
        (KJS::DateProtoFuncSetUTCMinutes::callAsFunction):
        (KJS::DateProtoFuncSetHours::callAsFunction):
        (KJS::DateProtoFuncSetUTCHours::callAsFunction):
        (KJS::DateProtoFuncSetDate::callAsFunction):
        (KJS::DateProtoFuncSetUTCDate::callAsFunction):
        (KJS::DateProtoFuncSetMonth::callAsFunction):
        (KJS::DateProtoFuncSetUTCMonth::callAsFunction):
        (KJS::DateProtoFuncSetFullYear::callAsFunction):
        (KJS::DateProtoFuncSetUTCFullYear::callAsFunction):
        (KJS::DateProtoFuncSetYear::callAsFunction):
        (KJS::DateProtoFuncGetYear::callAsFunction):
        * kjs/date_object.h:
        * kjs/lookup.cpp:
        (KJS::Lookup::find):
        * kjs/lookup.h:
        (KJS::HashEntry::):
        (KJS::staticFunctionGetter):
        (KJS::staticValueGetter):
        (KJS::getStaticPropertySlot):
        (KJS::getStaticFunctionSlot):
        (KJS::lookupPut):
        * kjs/math_object.cpp:
        (KJS::MathObjectImp::getOwnPropertySlot):
        (KJS::MathProtoFuncAbs::callAsFunction):
        (KJS::MathProtoFuncACos::callAsFunction):
        (KJS::MathProtoFuncASin::callAsFunction):
        (KJS::MathProtoFuncATan::callAsFunction):
        (KJS::MathProtoFuncATan2::callAsFunction):
        (KJS::MathProtoFuncCeil::callAsFunction):
        (KJS::MathProtoFuncCos::callAsFunction):
        (KJS::MathProtoFuncExp::callAsFunction):
        (KJS::MathProtoFuncFloor::callAsFunction):
        (KJS::MathProtoFuncLog::callAsFunction):
        (KJS::MathProtoFuncMax::callAsFunction):
        (KJS::MathProtoFuncMin::callAsFunction):
        (KJS::MathProtoFuncPow::callAsFunction):
        (KJS::MathProtoFuncRandom::callAsFunction):
        (KJS::MathProtoFuncRound::callAsFunction):
        (KJS::MathProtoFuncSin::callAsFunction):
        (KJS::MathProtoFuncSqrt::callAsFunction):
        (KJS::MathProtoFuncTan::callAsFunction):
        * kjs/math_object.h:
        (KJS::MathObjectImp::classInfo):
        (KJS::MathObjectImp::):
        * kjs/string_object.cpp:
        (KJS::StringPrototype::getOwnPropertySlot):
        (KJS::StringProtoFuncToString::callAsFunction):
        (KJS::StringProtoFuncValueOf::callAsFunction):
        (KJS::StringProtoFuncCharAt::callAsFunction):
        (KJS::StringProtoFuncCharCodeAt::callAsFunction):
        (KJS::StringProtoFuncConcat::callAsFunction):
        (KJS::StringProtoFuncIndexOf::callAsFunction):
        (KJS::StringProtoFuncLastIndexOf::callAsFunction):
        (KJS::StringProtoFuncMatch::callAsFunction):
        (KJS::StringProtoFuncSearch::callAsFunction):
        (KJS::StringProtoFuncReplace::callAsFunction):
        (KJS::StringProtoFuncSlice::callAsFunction):
        (KJS::StringProtoFuncSplit::callAsFunction):
        (KJS::StringProtoFuncSubstr::callAsFunction):
        (KJS::StringProtoFuncSubstring::callAsFunction):
        (KJS::StringProtoFuncToLowerCase::callAsFunction):
        (KJS::StringProtoFuncToUpperCase::callAsFunction):
        (KJS::StringProtoFuncToLocaleLowerCase::callAsFunction):
        (KJS::StringProtoFuncToLocaleUpperCase::callAsFunction):
        (KJS::StringProtoFuncLocaleCompare::callAsFunction):
        (KJS::StringProtoFuncBig::callAsFunction):
        (KJS::StringProtoFuncSmall::callAsFunction):
        (KJS::StringProtoFuncBlink::callAsFunction):
        (KJS::StringProtoFuncBold::callAsFunction):
        (KJS::StringProtoFuncFixed::callAsFunction):
        (KJS::StringProtoFuncItalics::callAsFunction):
        (KJS::StringProtoFuncStrike::callAsFunction):
        (KJS::StringProtoFuncSub::callAsFunction):
        (KJS::StringProtoFuncSup::callAsFunction):
        (KJS::StringProtoFuncFontcolor::callAsFunction):
        (KJS::StringProtoFuncFontsize::callAsFunction):
        (KJS::StringProtoFuncAnchor::callAsFunction):
        (KJS::StringProtoFuncLink::callAsFunction):
        * kjs/string_object.h:

WebCore:

        Reviewed by Darin.

        Convert JavaScript internal function objects to use one class per
        function.  This avoids a switch statement inside what used to be
        the shared function classes and will allow Shark to better analyze
        the code.

        To make this switch, the value property of the HashEntry was changed
        to a union of an intptr_t (which is used to continue handle valueGetters)
        and function pointer which points to a static constructor for the
        individual new function objects.

        SunSpider claims this is a 0.5% speedup.

        - On the WebCore side, I updated CodeGeneratorJS.pm to generate the
          new classes and hand updated the remain non-generated (groan) classes.

        * bindings/js/JSDOMWindowCustom.cpp:
        (WebCore::JSDOMWindow::customGetOwnPropertySlot):
        * bindings/js/JSEventTargetNode.cpp:
        (WebCore::JSEventTargetNodePrototypeFunctionAddEventListener::callAsFunction):
        (WebCore::JSEventTargetNodePrototypeFunctionRemoveEventListener::callAsFunction):
        (WebCore::JSEventTargetNodePrototypeFunctionDispatchEvent::callAsFunction):
        * bindings/js/JSEventTargetNode.h:
        * bindings/js/JSHTMLInputElementBase.cpp:
        (WebCore::JSHTMLInputElementBaseFunctionSetSelectionRange::callAsFunction):
        (WebCore::JSHTMLInputElementBase::getOwnPropertySlot):
        * bindings/js/JSHTMLInputElementBase.h:
        (WebCore::JSHTMLInputElementBase::):
        * bindings/js/JSXMLHttpRequest.cpp:
        (KJS::JSXMLHttpRequestPrototypeFunctionAbort::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionGetAllResponseHeaders::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionGetResponseHeader::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionOpen::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionSend::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionSetRequestHeader::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionOverrideMIMEType::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionAddEventListener::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionRemoveEventListener::callAsFunction):
        (KJS::JSXMLHttpRequestPrototypeFunctionDispatchEvent::callAsFunction):
        * bindings/js/JSXMLHttpRequest.h:
        (KJS::JSXMLHttpRequest::impl):
        * bindings/js/JSXSLTProcessor.cpp:
        (KJS::JSXSLTProcessorPrototypeFunctionImportStylesheet::callAsFunction):
        (KJS::JSXSLTProcessorPrototypeFunctionTransformToFragment::callAsFunction):
        (KJS::JSXSLTProcessorPrototypeFunctionTransformToDocument::callAsFunction):
        (KJS::JSXSLTProcessorPrototypeFunctionSetParameter::callAsFunction):
        (KJS::JSXSLTProcessorPrototypeFunctionGetParameter::callAsFunction):
        (KJS::JSXSLTProcessorPrototypeFunctionRemoveParameter::callAsFunction):
        (KJS::JSXSLTProcessorPrototypeFunctionClearParameters::callAsFunction):
        (KJS::JSXSLTProcessorPrototypeFunctionReset::callAsFunction):
        * bindings/js/JSXSLTProcessor.h:
        * bindings/js/kjs_events.cpp:
        (WebCore::JSClipboardPrototypeFunctionClearData::callAsFunction):
        (WebCore::JSClipboardPrototypeFunctionGetData::callAsFunction):
        (WebCore::JSClipboardPrototypeFunctionSetData::callAsFunction):
        (WebCore::JSClipboardPrototypeFunctionSetDragImage::callAsFunction):
        * bindings/js/kjs_events.h:
        * bindings/js/kjs_navigator.cpp:
        (KJS::Plugins::):
        (KJS::Navigator::getOwnPropertySlot):
        (KJS::Plugins::getOwnPropertySlot):
        (KJS::PluginsFunctionRefresh::callAsFunction):
        (KJS::NavigatorProtoFuncJavaEnabled::callAsFunction):
        * bindings/js/kjs_navigator.h:
        (KJS::Navigator::):
        * bindings/js/kjs_window.cpp:
        (KJS::Window::getOwnPropertySlot):
        (KJS::Window::put):
        (KJS::WindowProtoFuncAToB::callAsFunction):
        (KJS::WindowProtoFuncBToA::callAsFunction):
        (KJS::WindowProtoFuncOpen::callAsFunction):
        (KJS::WindowProtoFuncScrollBy::callAsFunction):
        (KJS::WindowProtoFuncScrollTo::callAsFunction):
        (KJS::WindowProtoFuncMoveBy::callAsFunction):
        (KJS::WindowProtoFuncMoveTo::callAsFunction):
        (KJS::WindowProtoFuncResizeBy::callAsFunction):
        (KJS::WindowProtoFuncResizeTo::callAsFunction):
        (KJS::WindowProtoFuncSetTimeout::callAsFunction):
        (KJS::WindowProtoFuncClearTimeout::callAsFunction):
        (KJS::WindowProtoFuncSetInterval::callAsFunction):
        (KJS::WindowProtoFuncAddEventListener::callAsFunction):
        (KJS::WindowProtoFuncRemoveEventListener::callAsFunction):
        (KJS::WindowProtoFuncShowModalDialog::callAsFunction):
        (KJS::WindowProtoFuncNotImplemented::callAsFunction):
        (KJS::Location::getOwnPropertySlot):
        (KJS::Location::put):
        (KJS::LocationProtoFuncReplace::callAsFunction):
        (KJS::LocationProtoFuncReload::callAsFunction):
        (KJS::LocationProtoFuncAssign::callAsFunction):
        (KJS::LocationProtoFuncToString::callAsFunction):
        * bindings/js/kjs_window.h:
        (KJS::Window::):
        * bindings/scripts/CodeGeneratorJS.pm:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27608 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 62f20d99
2007-11-08 Sam Weinig <sam@webkit.org>
Reviewed by Darin.
Convert JavaScript internal function objects to use one class per
function. This avoids a switch statement inside what used to be
the shared function classes and will allow Shark to better analyze
the code.
To make this switch, the value property of the HashEntry was changed
to a union of an intptr_t (which is used to continue handle valueGetters)
and function pointer which points to a static constructor for the
individual new function objects.
SunSpider claims this is a 0.5% speedup.
* kjs/array_object.cpp:
(KJS::ArrayPrototype::getOwnPropertySlot):
(KJS::getProperty):
(KJS::ArrayProtoFuncToString::callAsFunction):
(KJS::ArrayProtoFuncToLocaleString::callAsFunction):
(KJS::ArrayProtoFuncJoin::callAsFunction):
(KJS::ArrayProtoFuncConcat::callAsFunction):
(KJS::ArrayProtoFuncPop::callAsFunction):
(KJS::ArrayProtoFuncPush::callAsFunction):
(KJS::ArrayProtoFuncReverse::callAsFunction):
(KJS::ArrayProtoFuncShift::callAsFunction):
(KJS::ArrayProtoFuncSlice::callAsFunction):
(KJS::ArrayProtoFuncSort::callAsFunction):
(KJS::ArrayProtoFuncSplice::callAsFunction):
(KJS::ArrayProtoFuncUnShift::callAsFunction):
(KJS::ArrayProtoFuncFilter::callAsFunction):
(KJS::ArrayProtoFuncMap::callAsFunction):
(KJS::ArrayProtoFuncEvery::callAsFunction):
(KJS::ArrayProtoFuncForEach::callAsFunction):
(KJS::ArrayProtoFuncSome::callAsFunction):
(KJS::ArrayProtoFuncIndexOf::callAsFunction):
(KJS::ArrayProtoFuncLastIndexOf::callAsFunction):
* kjs/array_object.h:
(KJS::ArrayPrototype::classInfo):
* kjs/create_hash_table:
* kjs/date_object.cpp:
(KJS::DatePrototype::getOwnPropertySlot):
(KJS::DateProtoFuncToString::callAsFunction):
(KJS::DateProtoFuncToUTCString::callAsFunction):
(KJS::DateProtoFuncToDateString::callAsFunction):
(KJS::DateProtoFuncToTimeString::callAsFunction):
(KJS::DateProtoFuncToLocaleString::callAsFunction):
(KJS::DateProtoFuncToLocaleDateString::callAsFunction):
(KJS::DateProtoFuncToLocaleTimeString::callAsFunction):
(KJS::DateProtoFuncValueOf::callAsFunction):
(KJS::DateProtoFuncGetTime::callAsFunction):
(KJS::DateProtoFuncGetFullYear::callAsFunction):
(KJS::DateProtoFuncGetUTCFullYear::callAsFunction):
(KJS::DateProtoFuncToGMTString::callAsFunction):
(KJS::DateProtoFuncGetMonth::callAsFunction):
(KJS::DateProtoFuncGetUTCMonth::callAsFunction):
(KJS::DateProtoFuncGetDate::callAsFunction):
(KJS::DateProtoFuncGetUTCDate::callAsFunction):
(KJS::DateProtoFuncGetDay::callAsFunction):
(KJS::DateProtoFuncGetUTCDay::callAsFunction):
(KJS::DateProtoFuncGetHours::callAsFunction):
(KJS::DateProtoFuncGetUTCHours::callAsFunction):
(KJS::DateProtoFuncGetMinutes::callAsFunction):
(KJS::DateProtoFuncGetUTCMinutes::callAsFunction):
(KJS::DateProtoFuncGetSeconds::callAsFunction):
(KJS::DateProtoFuncGetUTCSeconds::callAsFunction):
(KJS::DateProtoFuncGetMilliSeconds::callAsFunction):
(KJS::DateProtoFuncGetUTCMilliseconds::callAsFunction):
(KJS::DateProtoFuncGetTimezoneOffset::callAsFunction):
(KJS::DateProtoFuncSetTime::callAsFunction):
(KJS::DateProtoFuncSetMilliSeconds::callAsFunction):
(KJS::DateProtoFuncSetUTCMilliseconds::callAsFunction):
(KJS::DateProtoFuncSetSeconds::callAsFunction):
(KJS::DateProtoFuncSetUTCSeconds::callAsFunction):
(KJS::DateProtoFuncSetMinutes::callAsFunction):
(KJS::DateProtoFuncSetUTCMinutes::callAsFunction):
(KJS::DateProtoFuncSetHours::callAsFunction):
(KJS::DateProtoFuncSetUTCHours::callAsFunction):
(KJS::DateProtoFuncSetDate::callAsFunction):
(KJS::DateProtoFuncSetUTCDate::callAsFunction):
(KJS::DateProtoFuncSetMonth::callAsFunction):
(KJS::DateProtoFuncSetUTCMonth::callAsFunction):
(KJS::DateProtoFuncSetFullYear::callAsFunction):
(KJS::DateProtoFuncSetUTCFullYear::callAsFunction):
(KJS::DateProtoFuncSetYear::callAsFunction):
(KJS::DateProtoFuncGetYear::callAsFunction):
* kjs/date_object.h:
* kjs/lookup.cpp:
(KJS::Lookup::find):
* kjs/lookup.h:
(KJS::HashEntry::):
(KJS::staticFunctionGetter):
(KJS::staticValueGetter):
(KJS::getStaticPropertySlot):
(KJS::getStaticFunctionSlot):
(KJS::lookupPut):
* kjs/math_object.cpp:
(KJS::MathObjectImp::getOwnPropertySlot):
(KJS::MathProtoFuncAbs::callAsFunction):
(KJS::MathProtoFuncACos::callAsFunction):
(KJS::MathProtoFuncASin::callAsFunction):
(KJS::MathProtoFuncATan::callAsFunction):
(KJS::MathProtoFuncATan2::callAsFunction):
(KJS::MathProtoFuncCeil::callAsFunction):
(KJS::MathProtoFuncCos::callAsFunction):
(KJS::MathProtoFuncExp::callAsFunction):
(KJS::MathProtoFuncFloor::callAsFunction):
(KJS::MathProtoFuncLog::callAsFunction):
(KJS::MathProtoFuncMax::callAsFunction):
(KJS::MathProtoFuncMin::callAsFunction):
(KJS::MathProtoFuncPow::callAsFunction):
(KJS::MathProtoFuncRandom::callAsFunction):
(KJS::MathProtoFuncRound::callAsFunction):
(KJS::MathProtoFuncSin::callAsFunction):
(KJS::MathProtoFuncSqrt::callAsFunction):
(KJS::MathProtoFuncTan::callAsFunction):
* kjs/math_object.h:
(KJS::MathObjectImp::classInfo):
(KJS::MathObjectImp::):
* kjs/string_object.cpp:
(KJS::StringPrototype::getOwnPropertySlot):
(KJS::StringProtoFuncToString::callAsFunction):
(KJS::StringProtoFuncValueOf::callAsFunction):
(KJS::StringProtoFuncCharAt::callAsFunction):
(KJS::StringProtoFuncCharCodeAt::callAsFunction):
(KJS::StringProtoFuncConcat::callAsFunction):
(KJS::StringProtoFuncIndexOf::callAsFunction):
(KJS::StringProtoFuncLastIndexOf::callAsFunction):
(KJS::StringProtoFuncMatch::callAsFunction):
(KJS::StringProtoFuncSearch::callAsFunction):
(KJS::StringProtoFuncReplace::callAsFunction):
(KJS::StringProtoFuncSlice::callAsFunction):
(KJS::StringProtoFuncSplit::callAsFunction):
(KJS::StringProtoFuncSubstr::callAsFunction):
(KJS::StringProtoFuncSubstring::callAsFunction):
(KJS::StringProtoFuncToLowerCase::callAsFunction):
(KJS::StringProtoFuncToUpperCase::callAsFunction):
(KJS::StringProtoFuncToLocaleLowerCase::callAsFunction):
(KJS::StringProtoFuncToLocaleUpperCase::callAsFunction):
(KJS::StringProtoFuncLocaleCompare::callAsFunction):
(KJS::StringProtoFuncBig::callAsFunction):
(KJS::StringProtoFuncSmall::callAsFunction):
(KJS::StringProtoFuncBlink::callAsFunction):
(KJS::StringProtoFuncBold::callAsFunction):
(KJS::StringProtoFuncFixed::callAsFunction):
(KJS::StringProtoFuncItalics::callAsFunction):
(KJS::StringProtoFuncStrike::callAsFunction):
(KJS::StringProtoFuncSub::callAsFunction):
(KJS::StringProtoFuncSup::callAsFunction):
(KJS::StringProtoFuncFontcolor::callAsFunction):
(KJS::StringProtoFuncFontsize::callAsFunction):
(KJS::StringProtoFuncAnchor::callAsFunction):
(KJS::StringProtoFuncLink::callAsFunction):
* kjs/string_object.h:
2007-11-08 Adam Roben <aroben@apple.com>
Windows build fix
......
This diff is collapsed.
......@@ -2,6 +2,7 @@
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -24,43 +25,53 @@
#include "array_instance.h"
#include "function_object.h"
#include "lookup.h"
namespace KJS {
class ArrayPrototype : public ArrayInstance {
public:
ArrayPrototype(ExecState *exec,
ObjectPrototype *objProto);
bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
};
class ArrayProtoFunc : public InternalFunctionImp {
public:
ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name);
ArrayPrototype(ExecState*, ObjectPrototype*);
virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
enum { ToString, ToLocaleString, Concat, Join, Pop, Push,
Reverse, Shift, Slice, Sort, Splice, UnShift,
Every, ForEach, Some, IndexOf, Filter, Map, LastIndexOf };
private:
int id;
bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
};
class ArrayObjectImp : public InternalFunctionImp {
public:
ArrayObjectImp(ExecState *exec,
FunctionPrototype *funcProto,
ArrayPrototype *arrayProto);
ArrayObjectImp(ExecState*, FunctionPrototype*, ArrayPrototype*);
virtual bool implementsConstruct() const;
virtual JSObject *construct(ExecState *exec, const List &args);
virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
virtual JSObject* construct(ExecState*, const List&);
virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&);
};
} // namespace
#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
} // namespace KJS
#endif
#endif // ARRAY_OBJECT_H_
......@@ -225,7 +225,7 @@ sub output() {
if (defined($entry)) {
my $key = $keys[$entry];
print " \{ \"" . $key . "\"";
print ", " . $values[$entry];
print ", { (intptr_t)" . $values[$entry] . " }";
print ", " . $attrs[$entry];
print ", " . $params[$entry];
print ", ";
......@@ -236,7 +236,7 @@ sub output() {
}
print "/* " . $hashes[$entry] . " */ ";
} else {
print " { 0, 0, 0, 0, 0 }";
print " { 0, { 0 }, 0, 0, 0 }";
}
print "," unless ($i == $size - 1);
print "\n";
......
This diff is collapsed.
......@@ -23,6 +23,7 @@
#include "function.h"
#include "JSWrapperObject.h"
#include "lookup.h"
namespace KJS {
......@@ -64,24 +65,59 @@ namespace KJS {
* Class to implement all methods that are properties of the
* Date.prototype object
*/
class DateProtoFunc : public InternalFunctionImp {
public:
DateProtoFunc(ExecState *, int i, int len, const Identifier& date);
// Non-normative properties (Appendix B)
// GetYear, SetYear, ToGMTString
virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args);
#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
enum { ToString, ToDateString, ToTimeString, ToLocaleString,
ToLocaleDateString, ToLocaleTimeString, ValueOf, GetTime,
GetFullYear, GetMonth, GetDate, GetDay, GetHours, GetMinutes,
GetSeconds, GetMilliSeconds, GetTimezoneOffset, SetTime,
SetMilliSeconds, SetSeconds, SetMinutes, SetHours, SetDate,
SetMonth, SetFullYear, ToUTCString,
// non-normative properties (Appendix B)
GetYear, SetYear, ToGMTString };
private:
int id;
bool utc;
};
/**
* @internal
......
......@@ -66,7 +66,7 @@ int Lookup::find(const struct HashTable *table, const UChar *c, unsigned int len
{
const HashEntry *entry = KJS::findEntry(table, UString::Rep::computeHash(c, len), c, len);
if (entry)
return entry->value;
return entry->value.intValue;
return -1;
}
......@@ -74,7 +74,7 @@ int Lookup::find(const struct HashTable* table, const Identifier& s)
{
const HashEntry* entry = KJS::findEntry(table, s.ustring().rep()->computedHash(), s.data(), s.size());
if (entry)
return entry->value;
return entry->value.intValue;
return -1;
}
......
......@@ -36,15 +36,21 @@ namespace KJS {
* An entry in a hash table.
*/
struct HashEntry {
typedef InternalFunctionImp* (*ConstructFunctionObject)(ExecState*, int, const Identifier&);
/**
* s is the key (e.g. a property name)
*/
const char* s;
/**
* value is the result value (usually an enum value)
* value is the result value (enum value for properties and a function pointer to a constructor factory for functions)
*/
int value;
union {
intptr_t intValue;
ConstructFunctionObject functionValue;
} value;
/**
* attr is a set for flags (e.g. the property flags, see object.h)
*/
......@@ -119,7 +125,6 @@ namespace KJS {
* @internal
* Helper for getStaticFunctionSlot and getStaticPropertySlot
*/
template <class FuncImp>
inline JSValue* staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
{
// Look for cached value in dynamic map of properties (in JSObject)
......@@ -129,7 +134,7 @@ namespace KJS {
return cachedVal;
const HashEntry* entry = slot.staticEntry();
JSValue* val = new FuncImp(exec, entry->value, entry->params, propertyName);
JSValue* val = entry->value.functionValue(exec, entry->params, propertyName);
thisObj->putDirect(propertyName, val, entry->attr);
return val;
}
......@@ -143,7 +148,7 @@ namespace KJS {
{
ThisImp* thisObj = static_cast<ThisImp*>(slot.slotBase());
const HashEntry* entry = slot.staticEntry();
return thisObj->getValueProperty(exec, entry->value);
return thisObj->getValueProperty(exec, entry->value.intValue);
}
/**
......@@ -166,7 +171,7 @@ namespace KJS {
* @param table the static hashtable for this class
* @param thisObj "this"
*/
template <class FuncImp, class ThisImp, class ParentImp>
template <class ThisImp, class ParentImp>
inline bool getStaticPropertySlot(ExecState* exec, const HashTable* table,
ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot)
{
......@@ -176,7 +181,7 @@ namespace KJS {
return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot);
if (entry->attr & Function)
slot.setStaticEntry(thisObj, entry, staticFunctionGetter<FuncImp>);
slot.setStaticEntry(thisObj, entry, staticFunctionGetter);
else
slot.setStaticEntry(thisObj, entry, staticValueGetter<ThisImp>);
......@@ -188,7 +193,7 @@ namespace KJS {
* Using this instead of getStaticPropertySlot allows 'this' to avoid implementing
* a dummy getValueProperty.
*/
template <class FuncImp, class ParentImp>
template <class ParentImp>
inline bool getStaticFunctionSlot(ExecState* exec, const HashTable* table,
JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot)
{
......@@ -199,7 +204,7 @@ namespace KJS {
ASSERT(entry->attr & Function);
slot.setStaticEntry(thisObj, entry, staticFunctionGetter<FuncImp>);
slot.setStaticEntry(thisObj, entry, staticFunctionGetter);
return true;
}
......@@ -240,7 +245,7 @@ namespace KJS {
if (entry->attr & Function) // function: put as override property
thisObj->JSObject::put(exec, propertyName, value, attr);
else if (!(entry->attr & ReadOnly))
thisObj->putValueProperty(exec, entry->value, value, attr);
thisObj->putValueProperty(exec, entry->value.intValue, value, attr);
return true;
}
......@@ -325,7 +330,7 @@ namespace KJS {
\
};
#define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassPrototype, ClassFunction) \
#define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassPrototype) \
const ClassInfo ClassPrototype::info = { ClassName"Prototype", 0, &ClassPrototype##Table }; \
JSObject* ClassPrototype::self(ExecState* exec) \
{ \
......@@ -334,22 +339,24 @@ namespace KJS {
} \
bool ClassPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \
{ \
return getStaticFunctionSlot<ClassFunction, JSObject>(exec, &ClassPrototype##Table, this, propertyName, slot); \
return getStaticFunctionSlot<JSObject>(exec, &ClassPrototype##Table, this, propertyName, slot); \
}
#define KJS_IMPLEMENT_PROTOTYPE_FUNCTION(ClassFunction) \
class ClassFunction : public InternalFunctionImp { \
public: \
ClassFunction(ExecState* exec, int i, int len, const Identifier& name) \
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) \
, id(i) \
{ \
put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
} \
/* Macro user needs to implement the callAsFunction function. */ \
virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List& args); \
private: \
int id; \
};
#define KJS_IMPLEMENT_PROTOTYPE_FUNCTION_WITH_CREATE(ClassFunction) \
class ClassFunction : public KJS::InternalFunctionImp { \
public: \
static KJS::InternalFunctionImp* create(KJS::ExecState* exec, int len, const KJS::Identifier& name) \
{ \
return new ClassFunction(exec, len, name); \
} \
ClassFunction(KJS::ExecState* exec, int len, const KJS::Identifier& name) \
: KJS::InternalFunctionImp(static_cast<KJS::FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) \
{ \
put(exec, exec->propertyNames().length, KJS::jsNumber(len), KJS::DontDelete | KJS::ReadOnly | KJS::DontEnum); \
} \
\
/* Macro user needs to implement the callAsFunction function. */ \
virtual KJS::JSValue* callAsFunction(KJS::ExecState*, KJS::JSObject*, const KJS::List&); \
}; \
#endif // KJS_lookup_h
......@@ -28,7 +28,7 @@
#include <wtf/Assertions.h>
#include <wtf/MathExtras.h>
using namespace KJS;
namespace KJS {
// ------------------------------ MathObjectImp --------------------------------
......@@ -36,32 +36,32 @@ const ClassInfo MathObjectImp::info = { "Math", 0, &mathTable };
/* Source for math_object.lut.h
@begin mathTable 21
E MathObjectImp::Euler DontEnum|DontDelete|ReadOnly
LN2 MathObjectImp::Ln2 DontEnum|DontDelete|ReadOnly
LN10 MathObjectImp::Ln10 DontEnum|DontDelete|ReadOnly
LOG2E MathObjectImp::Log2E DontEnum|DontDelete|ReadOnly
LOG10E MathObjectImp::Log10E DontEnum|DontDelete|ReadOnly
PI MathObjectImp::Pi DontEnum|DontDelete|ReadOnly
SQRT1_2 MathObjectImp::Sqrt1_2 DontEnum|DontDelete|ReadOnly
SQRT2 MathObjectImp::Sqrt2 DontEnum|DontDelete|ReadOnly
abs MathObjectImp::Abs DontEnum|Function 1
acos MathObjectImp::ACos DontEnum|Function 1
asin MathObjectImp::ASin DontEnum|Function 1
atan MathObjectImp::ATan DontEnum|Function 1
atan2 MathObjectImp::ATan2 DontEnum|Function 2
ceil MathObjectImp::Ceil DontEnum|Function 1
cos MathObjectImp::Cos DontEnum|Function 1
exp MathObjectImp::Exp DontEnum|Function 1
floor MathObjectImp::Floor DontEnum|Function 1
log MathObjectImp::Log DontEnum|Function 1
max MathObjectImp::Max DontEnum|Function 2
min MathObjectImp::Min DontEnum|Function 2
pow MathObjectImp::Pow DontEnum|Function 2
random MathObjectImp::Random DontEnum|Function 0
round MathObjectImp::Round DontEnum|Function 1
sin MathObjectImp::Sin DontEnum|Function 1
sqrt MathObjectImp::Sqrt DontEnum|Function 1
tan MathObjectImp::Tan DontEnum|Function 1
E MathObjectImp::Euler DontEnum|DontDelete|ReadOnly
LN2 MathObjectImp::Ln2 DontEnum|DontDelete|ReadOnly
LN10 MathObjectImp::Ln10 DontEnum|DontDelete|ReadOnly
LOG2E MathObjectImp::Log2E DontEnum|DontDelete|ReadOnly
LOG10E MathObjectImp::Log10E DontEnum|DontDelete|ReadOnly
PI MathObjectImp::Pi DontEnum|DontDelete|ReadOnly
SQRT1_2 MathObjectImp::Sqrt1_2 DontEnum|DontDelete|ReadOnly
SQRT2 MathObjectImp::Sqrt2 DontEnum|DontDelete|ReadOnly
abs &MathProtoFuncAbs::create DontEnum|Function 1
acos &MathProtoFuncACos::create DontEnum|Function 1
asin &MathProtoFuncASin::create DontEnum|Function 1
atan &MathProtoFuncATan::create DontEnum|Function 1
atan2 &MathProtoFuncATan2::create DontEnum|Function 2
ceil &MathProtoFuncCeil::create DontEnum|Function 1
cos &MathProtoFuncCos::create DontEnum|Function 1
exp &MathProtoFuncExp::create DontEnum|Function 1
floor &MathProtoFuncFloor::create DontEnum|Function 1
log &MathProtoFuncLog::create DontEnum|Function 1
max &MathProtoFuncMax::create DontEnum|Function 2
min &MathProtoFuncMin::create DontEnum|Function 2
pow &MathProtoFuncPow::create DontEnum|Function 2
random &MathProtoFuncRandom::create DontEnum|Function 0
round &MathProtoFuncRound::create DontEnum|Function 1
sin &MathProtoFuncSin::create DontEnum|Function 1
sqrt &MathProtoFuncSqrt::create DontEnum|Function 1
tan &MathProtoFuncTan::create DontEnum|Function 1
@end
*/
......@@ -75,7 +75,7 @@ MathObjectImp::MathObjectImp(ExecState * /*exec*/,
bool MathObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
{
return getStaticPropertySlot<MathFuncImp, MathObjectImp, JSObject>(exec, &mathTable, this, propertyName, slot);
return getStaticPropertySlot<MathObjectImp, JSObject>(exec, &mathTable, this, propertyName, slot);
}
JSValue *MathObjectImp::getValueProperty(ExecState *, int token) const
......@@ -113,126 +113,154 @@ JSValue *MathObjectImp::getValueProperty(ExecState *, int token) const
return jsNumber(d);
}
// ------------------------------ MathObjectImp --------------------------------
// ------------------------------ Functions --------------------------------
static bool didInitRandom;
JSValue* MathProtoFuncAbs::callAsFunction(ExecState* exec, JSObject*, const List& args)
{
double arg = args[0]->toNumber(exec);
return signbit(arg) ? jsNumber(-arg) : jsNumber(arg);
}
MathFuncImp::MathFuncImp(ExecState* exec, int i, int l, const Identifier& name)
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, id(i)
JSValue* MathProtoFuncACos::callAsFunction(ExecState* exec, JSObject*, const List& args)
{
putDirect(exec->propertyNames().length, l, DontDelete|ReadOnly|DontEnum);
double arg = args[0]->toNumber(exec);
return jsNumber(acos(arg));
}
JSValue *MathFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
JSValue* MathProtoFuncASin::callAsFunction(ExecState* exec, JSObject*, const List& args)
{
double arg = args[0]->toNumber(exec);
double arg2 = args[1]->toNumber(exec);
double result;
double arg = args[0]->toNumber(exec);
return jsNumber(asin(arg));
}
switch (id) {
case MathObjectImp::Abs:
result = signbit(arg) ? -arg : arg;
break;
case MathObjectImp::ACos:
result = acos(arg);
break;
case MathObjectImp::ASin:
result = asin(arg);