summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime')
-rw-r--r--Source/JavaScriptCore/runtime/DatePrototype.cpp58
-rw-r--r--Source/JavaScriptCore/runtime/JSGlobalData.h7
-rw-r--r--Source/JavaScriptCore/runtime/JSObject.cpp20
-rw-r--r--Source/JavaScriptCore/runtime/Structure.cpp4
-rw-r--r--Source/JavaScriptCore/runtime/Structure.h9
5 files changed, 70 insertions, 28 deletions
diff --git a/Source/JavaScriptCore/runtime/DatePrototype.cpp b/Source/JavaScriptCore/runtime/DatePrototype.cpp
index f81ae10f3..d3d0fe574 100644
--- a/Source/JavaScriptCore/runtime/DatePrototype.cpp
+++ b/Source/JavaScriptCore/runtime/DatePrototype.cpp
@@ -66,10 +66,6 @@
#include <unicode/udat.h>
#endif
-#if OS(WINCE) && !PLATFORM(QT)
-extern "C" size_t strftime(char * const s, const size_t maxsize, const char * const format, const struct tm * const t); //provided by libce
-#endif
-
using namespace WTF;
namespace JSC {
@@ -223,22 +219,57 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, doubl
static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, LocaleDateTimeFormat format)
{
+#if OS(WINDOWS)
+ SYSTEMTIME systemTime;
+ memset(&systemTime, 0, sizeof(systemTime));
+ systemTime.wYear = gdt.year + 1900;
+ systemTime.wMonth = gdt.month + 1;
+ systemTime.wDay = gdt.monthDay;
+ systemTime.wDayOfWeek = gdt.weekDay;
+ systemTime.wHour = gdt.hour;
+ systemTime.wMinute = gdt.minute;
+ systemTime.wSecond = gdt.second;
+
+ Vector<UChar, 128> buffer;
+ size_t length = 0;
+
+ if (format == LocaleDate) {
+ buffer.resize(GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &systemTime, 0, 0, 0));
+ length = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &systemTime, 0, buffer.data(), buffer.size());
+ } else if (format == LocaleTime) {
+ buffer.resize(GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &systemTime, 0, 0, 0));
+ length = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &systemTime, 0, buffer.data(), buffer.size());
+ } else if (format == LocaleDateAndTime) {
+ buffer.resize(GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &systemTime, 0, 0, 0) + GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &systemTime, 0, 0, 0));
+ length = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &systemTime, 0, buffer.data(), buffer.size());
+ if (length) {
+ buffer[length - 1] = ' ';
+ length += GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &systemTime, 0, buffer.data() + length, buffer.size() - length);
+ }
+ } else
+ ASSERT_NOT_REACHED();
+
+ // Remove terminating null character.
+ if (length)
+ length--;
+
+ return jsNontrivialString(exec, UString(buffer.data(), length));
+
+#else // OS(WINDOWS)
+
#if HAVE(LANGINFO_H)
static const nl_item formats[] = { D_T_FMT, D_FMT, T_FMT };
-#elif (OS(WINCE) && !PLATFORM(QT))
- // strftime() does not support '#' on WinCE
- static const char* const formatStrings[] = { "%c", "%x", "%X" };
#else
static const char* const formatStrings[] = { "%#c", "%#x", "%X" };
#endif
-
+
// Offset year if needed
struct tm localTM = gdt;
int year = gdt.year + 1900;
bool yearNeedsOffset = year < 1900 || year > 2038;
if (yearNeedsOffset)
localTM.tm_year = equivalentYearForDST(year) - 1900;
-
+
#if HAVE(LANGINFO_H)
// We do not allow strftime to generate dates with 2-digits years,
// both to avoid ambiguity, and a crash in strncpy, for years that
@@ -259,19 +290,19 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L
#else
size_t ret = strftime(timebuffer, bufsize, formatStrings[format], &localTM);
#endif
-
+
if (ret == 0)
return jsEmptyString(exec);
-
+
// Copy original into the buffer
if (yearNeedsOffset && format != LocaleTime) {
static const int yearLen = 5; // FIXME will be a problem in the year 10,000
char yearString[yearLen];
-
+
snprintf(yearString, yearLen, "%d", localTM.tm_year + 1900);
char* yearLocation = strstr(timebuffer, yearString);
snprintf(yearString, yearLen, "%d", year);
-
+
strncpy(yearLocation, yearString, yearLen - 1);
}
@@ -296,6 +327,7 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L
#endif
return jsNontrivialString(exec, timebuffer);
+#endif // OS(WINDOWS)
}
static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double, LocaleDateTimeFormat format)
diff --git a/Source/JavaScriptCore/runtime/JSGlobalData.h b/Source/JavaScriptCore/runtime/JSGlobalData.h
index 90925778b..59a672f67 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalData.h
+++ b/Source/JavaScriptCore/runtime/JSGlobalData.h
@@ -129,6 +129,10 @@ namespace JSC {
#if ENABLE(DFG_JIT)
class ConservativeRoots;
+#if COMPILER(MSVC)
+#pragma warning(push)
+#pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning
+#endif
struct ScratchBuffer {
ScratchBuffer()
: m_activeLength(0)
@@ -151,6 +155,9 @@ namespace JSC {
size_t m_activeLength;
void* m_buffer[0];
};
+#if COMPILER(MSVC)
+#pragma warning(pop)
+#endif
#endif
class JSGlobalData : public ThreadSafeRefCounted<JSGlobalData> {
diff --git a/Source/JavaScriptCore/runtime/JSObject.cpp b/Source/JavaScriptCore/runtime/JSObject.cpp
index ccc49fd5c..587929f66 100644
--- a/Source/JavaScriptCore/runtime/JSObject.cpp
+++ b/Source/JavaScriptCore/runtime/JSObject.cpp
@@ -599,19 +599,13 @@ PropertyStorage JSObject::growOutOfLineStorage(JSGlobalData& globalData, size_t
PropertyStorage oldPropertyStorage = m_outOfLineStorage.get();
PropertyStorage newPropertyStorage = 0;
- if (!oldPropertyStorage) {
- // We have this extra temp here to slake GCC's thirst for the blood of those who dereference type-punned pointers.
- void* temp = newPropertyStorage;
- if (!globalData.heap.tryAllocateStorage(sizeof(WriteBarrierBase<Unknown>) * newSize, &temp))
- CRASH();
- newPropertyStorage = static_cast<PropertyStorage>(temp);
- } else {
- // We have this extra temp here to slake GCC's thirst for the blood of those who dereference type-punned pointers.
- void* temp = oldPropertyStorage;
- if (!globalData.heap.tryReallocateStorage(&temp, sizeof(WriteBarrierBase<Unknown>) * oldSize, sizeof(WriteBarrierBase<Unknown>) * newSize))
- CRASH();
- newPropertyStorage = static_cast<PropertyStorage>(temp);
- }
+ // We have this extra temp here to slake GCC's thirst for the blood of those who dereference type-punned pointers.
+ void* temp = newPropertyStorage;
+ if (!globalData.heap.tryAllocateStorage(sizeof(WriteBarrierBase<Unknown>) * newSize, &temp))
+ CRASH();
+ newPropertyStorage = static_cast<PropertyStorage>(temp);
+
+ memcpy(newPropertyStorage, oldPropertyStorage, sizeof(WriteBarrierBase<Unknown>) * oldSize);
ASSERT(newPropertyStorage);
return newPropertyStorage;
diff --git a/Source/JavaScriptCore/runtime/Structure.cpp b/Source/JavaScriptCore/runtime/Structure.cpp
index 509ff3d45..e02105826 100644
--- a/Source/JavaScriptCore/runtime/Structure.cpp
+++ b/Source/JavaScriptCore/runtime/Structure.cpp
@@ -259,8 +259,8 @@ void Structure::materializePropertyMap(JSGlobalData& globalData)
inline size_t nextOutOfLineStorageCapacity(size_t currentCapacity)
{
if (!currentCapacity)
- return 4;
- return currentCapacity * 2;
+ return initialOutOfLineCapacity;
+ return currentCapacity * outOfLineGrowthFactor;
}
void Structure::growOutOfLineCapacity()
diff --git a/Source/JavaScriptCore/runtime/Structure.h b/Source/JavaScriptCore/runtime/Structure.h
index d2d025b98..712ea6bb5 100644
--- a/Source/JavaScriptCore/runtime/Structure.h
+++ b/Source/JavaScriptCore/runtime/Structure.h
@@ -53,6 +53,15 @@ namespace JSC {
class SlotVisitor;
class JSString;
+ // The out-of-line property storage capacity to use when first allocating out-of-line
+ // storage. Note that all objects start out without having any out-of-line storage;
+ // this comes into play only on the first property store that exhausts inline storage.
+ static const unsigned initialOutOfLineCapacity = 4;
+
+ // The factor by which to grow out-of-line storage when it is exhausted, after the
+ // initial allocation.
+ static const unsigned outOfLineGrowthFactor = 2;
+
class Structure : public JSCell {
public:
friend class StructureTransitionTable;