Ignore:
Timestamp:
Nov 5, 2009, 10:26:47 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore: https://bugs.webkit.org/show_bug.cgi?id=31197
Implemented a timezone cache not based on Mac OS X's notify_check API.

Patch by Geoffrey Garen <[email protected]> on 2009-11-05
Reviewed by Oliver Hunt.

If the VM calculates the local timezone offset from UTC, it caches the
result until the end of the current VM invocation. (We don't want to cache
forever, because the user's timezone may change over time.)

This removes notify_* overhead on Mac, and, more significantly, removes
OS time and date call overhead on non-Mac platforms.

~8% speedup on Date microbenchmark on Mac. SunSpider reports maybe a tiny
speedup on Mac. (Speedup on non-Mac platforms should be even more noticeable.)

  • interpreter/CachedCall.h:

(JSC::CachedCall::CachedCall):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):

  • runtime/JSGlobalObject.h:

(JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): Made the
DynamicGlobalObjectScope constructor responsible for checking whether a
dynamicGlobalObject has already been set. This eliminated some duplicate
client code, and allowed me to avoid adding even more duplicate client
code. Made DynamicGlobalObjectScope responsible for resetting the
local timezone cache upon first entry to the VM.

  • runtime/DateConstructor.cpp:

(JSC::constructDate):
(JSC::callDate):
(JSC::dateParse):
(JSC::dateUTC):

  • runtime/DateConversion.cpp:

(JSC::parseDate):

  • runtime/DateConversion.h:
  • runtime/DateInstance.cpp:

(JSC::DateInstance::gregorianDateTime):

  • runtime/DateInstance.h:
  • runtime/DateInstanceCache.h:
  • runtime/DatePrototype.cpp:

(JSC::setNewValueFromTimeArgs):
(JSC::setNewValueFromDateArgs):
(JSC::dateProtoFuncSetYear):

  • runtime/InitializeThreading.cpp:

(JSC::initializeThreadingOnce):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::JSGlobalData):

  • runtime/JSGlobalData.h:
  • wtf/DateMath.cpp:

(WTF::getCurrentUTCTime):
(WTF::getCurrentUTCTimeWithMicroseconds):
(WTF::getLocalTime):
(JSC::getUTCOffset): Use the new cache. Also, see below.
(JSC::gregorianDateTimeToMS):
(JSC::msToGregorianDateTime):
(JSC::initializeDates):
(JSC::parseDateFromNullTerminatedCharacters): Simplified the way this function
accounts for the local timezone offset, to accomodate our new caching API,
and a (possibly misguided) caller in WebCore. Also, see below.

  • wtf/DateMath.h:

(JSC::GregorianDateTime::GregorianDateTime): Moved most of the code in
DateMath.* into the JSC namespace. The code needed to move so it could
naturally interact with ExecState and JSGlobalData to support caching.
Logically, it seemed right to move it, too, since this code is not really
as low-level as the WTF namespace might imply -- it implements a set of
date parsing and conversion quirks that are finely tuned to the JavaScript
language. Also removed the Mac OS X notify_* infrastructure.

WebCore: https://bugs.webkit.org/show_bug.cgi?id=31197
Implemented a timezone cache not based on Mac OS X's notify_check API.

Patch by Geoffrey Garen <[email protected]> on 2009-11-05
Updated for JavaScriptCore internal API change.

  • platform/network/HTTPParsers.cpp:

(WebCore::parseDate): Pass 0 for ExecState, since we don't have one.
(This function probably shouldn't be using a JavaScript date parser
to begin with, but oh well.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/DateConstructor.cpp

    r50183 r50590  
    8585            JSValue primitive = args.at(0).toPrimitive(exec);
    8686            if (primitive.isString())
    87                 value = parseDate(primitive.getString());
     87                value = parseDate(exec, primitive.getString());
    8888            else
    8989                value = primitive.toNumber(exec);
     
    109109            t.isDST = -1;
    110110            double ms = (numArgs >= 7) ? args.at(6).toNumber(exec) : 0;
    111             value = gregorianDateTimeToMS(t, ms, false);
     111            value = gregorianDateTimeToMS(exec, t, ms, false);
    112112        }
    113113    }
     
    133133    tm localTM;
    134134    getLocalTime(&localTime, &localTM);
    135     GregorianDateTime ts(localTM);
     135    GregorianDateTime ts(exec, localTM);
    136136    return jsNontrivialString(exec, formatDate(ts) + " " + formatTime(ts, false));
    137137}
     
    145145static JSValue JSC_HOST_CALL dateParse(ExecState* exec, JSObject*, JSValue, const ArgList& args)
    146146{
    147     return jsNumber(exec, parseDate(args.at(0).toString(exec)));
     147    return jsNumber(exec, parseDate(exec, args.at(0).toString(exec)));
    148148}
    149149
     
    174174    t.second = args.at(5).toInt32(exec);
    175175    double ms = (n >= 7) ? args.at(6).toNumber(exec) : 0;
    176     return jsNumber(exec, gregorianDateTimeToMS(t, ms, true));
     176    return jsNumber(exec, gregorianDateTimeToMS(exec, t, ms, true));
    177177}
    178178
Note: See TracChangeset for help on using the changeset viewer.