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.
(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.)