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
diff --git a/JavaScriptCore/kjs/string_object.h b/JavaScriptCore/kjs/string_object.h
index 6c4c800..ad3c52a 100644
--- a/JavaScriptCore/kjs/string_object.h
+++ b/JavaScriptCore/kjs/string_object.h
@@ -25,6 +25,7 @@
#include "function_object.h"
#include "JSWrapperObject.h"
#include "internal.h"
+#include "lookup.h"
namespace KJS {
@@ -80,27 +81,53 @@
/**
* @internal
*
- * Class to implement all methods that are properties of the
+ * Classes to implement all methods that are properties of the
* String.prototype object
*/
- class StringProtoFunc : public InternalFunctionImp {
- public:
- StringProtoFunc(ExecState *exec, int i, int len, const Identifier&);
+#define FOR_EACH_CLASS(macro) \
+ macro(StringProtoFuncToString) \
+ macro(StringProtoFuncValueOf) \
+ macro(StringProtoFuncCharAt) \
+ macro(StringProtoFuncCharCodeAt) \
+ macro(StringProtoFuncConcat) \
+ macro(StringProtoFuncIndexOf) \
+ macro(StringProtoFuncLastIndexOf) \
+ macro(StringProtoFuncMatch) \
+ macro(StringProtoFuncReplace) \
+ macro(StringProtoFuncSearch) \
+ macro(StringProtoFuncSlice) \
+ macro(StringProtoFuncSplit) \
+ macro(StringProtoFuncSubstr) \
+ macro(StringProtoFuncSubstring) \
+ macro(StringProtoFuncToLowerCase) \
+ macro(StringProtoFuncToUpperCase) \
+ macro(StringProtoFuncToLocaleLowerCase) \
+ macro(StringProtoFuncToLocaleUpperCase) \
+ macro(StringProtoFuncLocaleCompare) \
- virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
+#define FOR_EACH_CLASS_NOT_PURE_ECMA(macro) \
+ macro(StringProtoFuncBig) \
+ macro(StringProtoFuncSmall) \
+ macro(StringProtoFuncBlink) \
+ macro(StringProtoFuncBold) \
+ macro(StringProtoFuncFixed) \
+ macro(StringProtoFuncItalics) \
+ macro(StringProtoFuncStrike) \
+ macro(StringProtoFuncSub) \
+ macro(StringProtoFuncSup) \
+ macro(StringProtoFuncFontcolor) \
+ macro(StringProtoFuncFontsize) \
+ macro(StringProtoFuncAnchor) \
+ macro(StringProtoFuncLink) \
- enum { ToString, ValueOf, CharAt, CharCodeAt, Concat, IndexOf, LastIndexOf,
- Match, Replace, Search, Slice, Split,
- Substr, Substring, FromCharCode, ToLowerCase, ToUpperCase,
- ToLocaleLowerCase, ToLocaleUpperCase, LocaleCompare
+FOR_EACH_CLASS(KJS_IMPLEMENT_PROTOTYPE_FUNCTION_WITH_CREATE)
#ifndef KJS_PURE_ECMA
- , Big, Small, Blink, Bold, Fixed, Italics, Strike, Sub, Sup,
- Fontcolor, Fontsize, Anchor, Link
+FOR_EACH_CLASS_NOT_PURE_ECMA(KJS_IMPLEMENT_PROTOTYPE_FUNCTION_WITH_CREATE)
#endif
- };
- private:
- int id;
- };
+
+#undef FOR_EACH_CLASS
+#undef FOR_EACH_CLASS_NOT_PURE_ECMA
+
/**
* @internal