Ignore:
Timestamp:
Nov 8, 2007, 12:31:26 PM (18 years ago)
Author:
[email protected]
Message:

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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/math_object.h

    r13821 r27608  
    2424
    2525#include "function_object.h"
     26#include "lookup.h"
    2627
    2728namespace KJS {
     
    2930  class MathObjectImp : public JSObject {
    3031  public:
    31     MathObjectImp(ExecState *exec,
    32                   ObjectPrototype *objProto);
    33     bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    34     JSValue *getValueProperty(ExecState *exec, int token) const;
    35     virtual const ClassInfo *classInfo() const { return &info; }
     32    MathObjectImp(ExecState*, ObjectPrototype*);
     33
     34    bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     35    JSValue* getValueProperty(ExecState*, int token) const;
     36
     37    virtual const ClassInfo* classInfo() const { return &info; }
    3638    static const ClassInfo info;
    37     enum { Euler, Ln2, Ln10, Log2E, Log10E, Pi, Sqrt1_2, Sqrt2,
    38            Abs, ACos, ASin, ATan, ATan2, Ceil, Cos, Pow,
    39            Exp, Floor, Log, Max, Min, Random, Round, Sin, Sqrt, Tan };
     39
     40    enum { Euler, Ln2, Ln10, Log2E, Log10E, Pi, Sqrt1_2, Sqrt2 };
    4041  };
    4142
    42   class MathFuncImp : public InternalFunctionImp {
    43   public:
    44     MathFuncImp(ExecState *exec, int i, int l, const Identifier&);
    45     virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
    46   private:
    47     int id;
    48   };
    4943
    50 } // namespace
     44#define FOR_EACH_CLASS(macro) \
     45    macro(MathProtoFuncAbs) \
     46    macro(MathProtoFuncACos) \
     47    macro(MathProtoFuncASin) \
     48    macro(MathProtoFuncATan) \
     49    macro(MathProtoFuncATan2) \
     50    macro(MathProtoFuncCeil) \
     51    macro(MathProtoFuncCos) \
     52    macro(MathProtoFuncExp) \
     53    macro(MathProtoFuncFloor) \
     54    macro(MathProtoFuncLog) \
     55    macro(MathProtoFuncMax) \
     56    macro(MathProtoFuncMin) \
     57    macro(MathProtoFuncPow) \
     58    macro(MathProtoFuncRandom) \
     59    macro(MathProtoFuncRound) \
     60    macro(MathProtoFuncSin) \
     61    macro(MathProtoFuncSqrt) \
     62    macro(MathProtoFuncTan) \
    5163
    52 #endif
     64FOR_EACH_CLASS(KJS_IMPLEMENT_PROTOTYPE_FUNCTION_WITH_CREATE)
     65#undef FOR_EACH_CLASS
     66
     67
     68} // namespace KJS
     69
     70#endif // MATH_OBJECT_H_
Note: See TracChangeset for help on using the changeset viewer.