Changeset 29588 in webkit for trunk/JavaScriptCore/kjs/function.h


Ignore:
Timestamp:
Jan 17, 2008, 11:27:33 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

Fix for http://bugs.webkit.org/show_bug.cgi?id=16901
Convert remaining JS function objects to use the new PrototypeFunction class

  • Moves Boolean, Function, RegExp, Number, Object and Global functions to their own static function implementations so that they can be used with the PrototypeFunction class. SunSpider says this is 1.003x as fast.
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::reset):
  • kjs/array_object.h:
  • kjs/bool_object.cpp: (KJS::BooleanInstance::BooleanInstance): (KJS::BooleanPrototype::BooleanPrototype): (KJS::booleanProtoFuncToString): (KJS::booleanProtoFuncValueOf): (KJS::BooleanObjectImp::BooleanObjectImp): (KJS::BooleanObjectImp::implementsConstruct): (KJS::BooleanObjectImp::construct): (KJS::BooleanObjectImp::callAsFunction):
  • kjs/bool_object.h: (KJS::BooleanInstance::classInfo):
  • kjs/error_object.cpp: (KJS::ErrorPrototype::ErrorPrototype): (KJS::errorProtoFuncToString):
  • kjs/error_object.h:
  • kjs/function.cpp: (KJS::globalFuncEval): (KJS::globalFuncParseInt): (KJS::globalFuncParseFloat): (KJS::globalFuncIsNaN): (KJS::globalFuncIsFinite): (KJS::globalFuncDecodeURI): (KJS::globalFuncDecodeURIComponent): (KJS::globalFuncEncodeURI): (KJS::globalFuncEncodeURIComponent): (KJS::globalFuncEscape): (KJS::globalFuncUnEscape): (KJS::globalFuncKJSPrint): (KJS::PrototypeFunction::PrototypeFunction):
  • kjs/function.h:
  • kjs/function_object.cpp: (KJS::FunctionPrototype::FunctionPrototype): (KJS::functionProtoFuncToString): (KJS::functionProtoFuncApply): (KJS::functionProtoFuncCall):
  • kjs/function_object.h:
  • kjs/number_object.cpp: (KJS::NumberPrototype::NumberPrototype): (KJS::numberProtoFuncToString): (KJS::numberProtoFuncToLocaleString): (KJS::numberProtoFuncValueOf): (KJS::numberProtoFuncToFixed): (KJS::numberProtoFuncToExponential): (KJS::numberProtoFuncToPrecision):
  • kjs/number_object.h: (KJS::NumberInstance::classInfo): (KJS::NumberObjectImp::classInfo): (KJS::NumberObjectImp::):
  • kjs/object_object.cpp: (KJS::ObjectPrototype::ObjectPrototype): (KJS::objectProtoFuncValueOf): (KJS::objectProtoFuncHasOwnProperty): (KJS::objectProtoFuncIsPrototypeOf): (KJS::objectProtoFuncDefineGetter): (KJS::objectProtoFuncDefineSetter): (KJS::objectProtoFuncLookupGetter): (KJS::objectProtoFuncLookupSetter): (KJS::objectProtoFuncPropertyIsEnumerable): (KJS::objectProtoFuncToLocaleString): (KJS::objectProtoFuncToString):
  • kjs/object_object.h:
  • kjs/regexp_object.cpp: (KJS::RegExpPrototype::RegExpPrototype): (KJS::regExpProtoFuncTest): (KJS::regExpProtoFuncExec): (KJS::regExpProtoFuncCompile): (KJS::regExpProtoFuncToString):
  • kjs/regexp_object.h:
File:
1 edited

Legend:

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

    r29508 r29588  
    5555  private:
    5656    Identifier m_name;
    57   };
    58 
    59   /**
    60    * @internal
    61    *
    62    * The initial value of Function.prototype (and thus all objects created
    63    * with the Function constructor)
    64    */
    65   class FunctionPrototype : public InternalFunctionImp {
    66   public:
    67     FunctionPrototype(ExecState *exec);
    68     virtual ~FunctionPrototype();
    69 
    70     virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
    7157  };
    7258
     
    144130
    145131    PrototypeFunction(ExecState*, int len, const Identifier&, JSMemberFunction);
     132    PrototypeFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction);
    146133
    147134    virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List&);
     
    151138  };
    152139
    153   class GlobalFuncImp : public InternalFunctionImp {
    154   public:
    155     GlobalFuncImp(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
    156     virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List& args);
    157     enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape,
    158            DecodeURI, DecodeURIComponent, EncodeURI, EncodeURIComponent
     140
     141    // Global Functions
     142    JSValue* globalFuncEval(ExecState*, JSObject*, const List&);
     143    JSValue* globalFuncParseInt(ExecState*, JSObject*, const List&);
     144    JSValue* globalFuncParseFloat(ExecState*, JSObject*, const List&);
     145    JSValue* globalFuncIsNaN(ExecState*, JSObject*, const List&);
     146    JSValue* globalFuncIsFinite(ExecState*, JSObject*, const List&);
     147    JSValue* globalFuncDecodeURI(ExecState*, JSObject*, const List&);
     148    JSValue* globalFuncDecodeURIComponent(ExecState*, JSObject*, const List&);
     149    JSValue* globalFuncEncodeURI(ExecState*, JSObject*, const List&);
     150    JSValue* globalFuncEncodeURIComponent(ExecState*, JSObject*, const List&);
     151    JSValue* globalFuncEscape(ExecState*, JSObject*, const List&);
     152    JSValue* globalFuncUnescape(ExecState*, JSObject*, const List&);
    159153#ifndef NDEBUG
    160            , KJSPrint
     154    JSValue* globalFuncKJSPrint(ExecState*, JSObject*, const List&);
    161155#endif
    162 };
    163   private:
    164     int id;
    165   };
    166156
    167   static const double mantissaOverflowLowerBound = 9007199254740992.0;
    168   double parseIntOverflow(const char* s, int length, int radix);
     157    static const double mantissaOverflowLowerBound = 9007199254740992.0;
     158    double parseIntOverflow(const char*, int length, int radix);
    169159
    170160} // namespace
Note: See TracChangeset for help on using the changeset viewer.