[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.16-1409-g5afdf4d
ggaren at apple.com
ggaren at apple.com
Thu Dec 3 13:30:30 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit db4501acc1edd6c39ad6d9fd40b27b46c414cc3b
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Nov 10 03:14:26 2009 +0000
Added a tiny cache for Date parsing.
Reviewed by Sam "Home Wrecker" Weinig.
SunSpider says 1.2% faster.
* runtime/DateConversion.cpp:
(JSC::parseDate): Try to reuse the last parsed Date, if present.
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::resetDateCache):
* runtime/JSGlobalData.h: Added storage for last parsed Date. Refactored
this code to make resetting the date cache easier.
* runtime/JSGlobalObject.h:
(JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): Updated for
refactoring.
* wtf/DateMath.cpp:
(JSC::parseDateFromNullTerminatedCharacters):
* wtf/DateMath.h: Changed ExecState to be first parameter, as is the JSC custom.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50705 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 3b13490..e626ad9 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,27 @@
+2009-11-09 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by Sam "Home Wrecker" Weinig.
+
+ Added a tiny cache for Date parsing.
+
+ SunSpider says 1.2% faster.
+
+ * runtime/DateConversion.cpp:
+ (JSC::parseDate): Try to reuse the last parsed Date, if present.
+
+ * runtime/JSGlobalData.cpp:
+ (JSC::JSGlobalData::resetDateCache):
+ * runtime/JSGlobalData.h: Added storage for last parsed Date. Refactored
+ this code to make resetting the date cache easier.
+
+ * runtime/JSGlobalObject.h:
+ (JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): Updated for
+ refactoring.
+
+ * wtf/DateMath.cpp:
+ (JSC::parseDateFromNullTerminatedCharacters):
+ * wtf/DateMath.h: Changed ExecState to be first parameter, as is the JSC custom.
+
2009-11-09 Oliver Hunt <oliver at apple.com>
Reviewed by Gavin Barraclough.
diff --git a/JavaScriptCore/runtime/DateConversion.cpp b/JavaScriptCore/runtime/DateConversion.cpp
index 55eb6df..dba5551 100644
--- a/JavaScriptCore/runtime/DateConversion.cpp
+++ b/JavaScriptCore/runtime/DateConversion.cpp
@@ -43,6 +43,7 @@
#include "config.h"
#include "DateConversion.h"
+#include "CallFrame.h"
#include "UString.h"
#include <wtf/DateMath.h>
#include <wtf/StringExtras.h>
@@ -53,7 +54,12 @@ namespace JSC {
double parseDate(ExecState* exec, const UString &date)
{
- return parseDateFromNullTerminatedCharacters(date.UTF8String().c_str(), exec);
+ if (date == exec->globalData().cachedDateString)
+ return exec->globalData().cachedDateStringValue;
+ double value = parseDateFromNullTerminatedCharacters(exec, date.UTF8String().c_str());
+ exec->globalData().cachedDateString = date;
+ exec->globalData().cachedDateStringValue = value;
+ return value;
}
UString formatDate(const GregorianDateTime &t)
diff --git a/JavaScriptCore/runtime/JSGlobalData.cpp b/JavaScriptCore/runtime/JSGlobalData.cpp
index 769d395..97666aa 100644
--- a/JavaScriptCore/runtime/JSGlobalData.cpp
+++ b/JavaScriptCore/runtime/JSGlobalData.cpp
@@ -252,6 +252,12 @@ JSGlobalData::ClientData::~ClientData()
{
}
+void JSGlobalData::resetDateCache()
+{
+ cachedUTCOffset = NaN;
+ cachedDateString = UString();
+}
+
void JSGlobalData::startSampling()
{
interpreter->startSampling();
diff --git a/JavaScriptCore/runtime/JSGlobalData.h b/JavaScriptCore/runtime/JSGlobalData.h
index 476da5d..5aa8bd5 100644
--- a/JavaScriptCore/runtime/JSGlobalData.h
+++ b/JavaScriptCore/runtime/JSGlobalData.h
@@ -155,10 +155,15 @@ namespace JSC {
double cachedUTCOffset;
+ UString cachedDateString;
+ double cachedDateStringValue;
+
#ifndef NDEBUG
bool mainThreadOnly;
#endif
+ void resetDateCache();
+
void startSampling();
void stopSampling();
void dumpSampleData(ExecState* exec);
diff --git a/JavaScriptCore/runtime/JSGlobalObject.h b/JavaScriptCore/runtime/JSGlobalObject.h
index 7183d41..9e4ef49 100644
--- a/JavaScriptCore/runtime/JSGlobalObject.h
+++ b/JavaScriptCore/runtime/JSGlobalObject.h
@@ -445,9 +445,9 @@ namespace JSC {
if (!m_dynamicGlobalObjectSlot) {
m_dynamicGlobalObjectSlot = dynamicGlobalObject;
- // Reset the UTC cache between JS invocations to force the VM
+ // Reset the date cache between JS invocations to force the VM
// to observe time zone changes.
- callFrame->globalData().cachedUTCOffset = NaN;
+ callFrame->globalData().resetDateCache();
}
}
diff --git a/JavaScriptCore/wtf/DateMath.cpp b/JavaScriptCore/wtf/DateMath.cpp
index e797dde..f9cf9af 100644
--- a/JavaScriptCore/wtf/DateMath.cpp
+++ b/JavaScriptCore/wtf/DateMath.cpp
@@ -873,7 +873,7 @@ void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, Gregori
tm.timeZone = NULL;
}
-double parseDateFromNullTerminatedCharacters(const char* dateString, ExecState* exec)
+double parseDateFromNullTerminatedCharacters(ExecState* exec, const char* dateString)
{
ASSERT(exec);
bool haveTZ;
diff --git a/JavaScriptCore/wtf/DateMath.h b/JavaScriptCore/wtf/DateMath.h
index e1293db..8a0daea 100644
--- a/JavaScriptCore/wtf/DateMath.h
+++ b/JavaScriptCore/wtf/DateMath.h
@@ -85,7 +85,7 @@ struct GregorianDateTime;
void msToGregorianDateTime(ExecState*, double, bool outputIsUTC, GregorianDateTime&);
double gregorianDateTimeToMS(ExecState*, const GregorianDateTime&, double, bool inputIsUTC);
double getUTCOffset(ExecState*);
-double parseDateFromNullTerminatedCharacters(const char* dateString, ExecState*);
+double parseDateFromNullTerminatedCharacters(ExecState*, const char* dateString);
// Intentionally overridding the default tm of the system.
// The members of tm differ on various operating systems.
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list