Ignore:
Timestamp:
Apr 16, 2008, 2:41:23 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Adam Roben.

Cache Gregorian date/time structure on DateInstance objects for 1.027x SunSpider speedup
(1.65x on date-format-xparb, 1.13x on date-format-tofte).

  • kjs/DateMath.h: (KJS::GregorianDateTime::copyFrom): Added. It presumably makes sense to keep GregorianDateTime Noncopiable, so it's not just operator=.
  • kjs/date_object.h: Added a per-object cache.
  • kjs/date_object.cpp: (KJS::DateInstance::DateInstance): (KJS::DateInstance::msToGregorianDateTime): (KJS::dateProtoFuncToString): (KJS::dateProtoFuncToUTCString): (KJS::dateProtoFuncToDateString): (KJS::dateProtoFuncToTimeString): (KJS::dateProtoFuncToLocaleString): (KJS::dateProtoFuncToLocaleDateString): (KJS::dateProtoFuncToLocaleTimeString): (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::dateProtoFuncGetTimezoneOffset): (KJS::setNewValueFromTimeArgs): (KJS::setNewValueFromDateArgs): (KJS::dateProtoFuncSetYear): (KJS::dateProtoFuncGetYear): Use the cache when converting.
File:
1 edited

Legend:

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

    r29508 r31937  
    2222#define DATE_OBJECT_H
    2323
     24#include "DateMath.h"
    2425#include "function.h"
    2526#include "JSWrapperObject.h"
     
    2728
    2829namespace KJS {
    29 
    30     struct GregorianDateTime;
    3130
    3231    class FunctionPrototype;
     
    3635    public:
    3736        DateInstance(JSObject *proto);
     37        virtual ~DateInstance();
    3838       
    3939        bool getTime(GregorianDateTime&, int& offset) const;
     
    4444        virtual const ClassInfo *classInfo() const { return &info; }
    4545        static const ClassInfo info;
     46
     47        void msToGregorianDateTime(double, bool outputIsUTC, GregorianDateTime&) const;
     48
     49    private:
     50        struct Cache {
     51            double m_gregorianDateTimeCachedForMS;
     52            GregorianDateTime m_cachedGregorianDateTime;
     53            double m_gregorianDateTimeUTCCachedForMS;
     54            GregorianDateTime m_cachedGregorianDateTimeUTC;
     55        };
     56
     57        mutable Cache* m_cache;
    4658    };
    4759
Note: See TracChangeset for help on using the changeset viewer.