diff options
Diffstat (limited to 'Source/JavaScriptCore/runtime')
-rw-r--r-- | Source/JavaScriptCore/runtime/DateConstructor.cpp | 26 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/DateConversion.cpp | 32 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/DateConversion.h | 4 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/DateInstance.h | 4 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/DatePrototype.cpp | 80 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp | 1 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSDateMath.cpp | 37 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSDateMath.h | 86 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSObject.cpp | 20 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSObject.h | 6 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSValue.h | 2 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/PropertyOffset.h | 2 |
12 files changed, 108 insertions, 192 deletions
diff --git a/Source/JavaScriptCore/runtime/DateConstructor.cpp b/Source/JavaScriptCore/runtime/DateConstructor.cpp index 08b815035..0325080f6 100644 --- a/Source/JavaScriptCore/runtime/DateConstructor.cpp +++ b/Source/JavaScriptCore/runtime/DateConstructor.cpp @@ -136,13 +136,13 @@ JSObject* constructDate(ExecState* exec, JSGlobalObject* globalObject, const Arg else { GregorianDateTime t; int year = JSC::toInt32(doubleArguments[0]); - t.year = (year >= 0 && year <= 99) ? year : year - 1900; - t.month = JSC::toInt32(doubleArguments[1]); - t.monthDay = (numArgs >= 3) ? JSC::toInt32(doubleArguments[2]) : 1; - t.hour = JSC::toInt32(doubleArguments[3]); - t.minute = JSC::toInt32(doubleArguments[4]); - t.second = JSC::toInt32(doubleArguments[5]); - t.isDST = -1; + t.setYear((year >= 0 && year <= 99) ? year : year - 1900); + t.setMonth(JSC::toInt32(doubleArguments[1])); + t.setMonthDay((numArgs >= 3) ? JSC::toInt32(doubleArguments[2]) : 1); + t.setHour(JSC::toInt32(doubleArguments[3])); + t.setMinute(JSC::toInt32(doubleArguments[4])); + t.setSecond(JSC::toInt32(doubleArguments[5])); + t.setIsDST(-1); double ms = (numArgs >= 7) ? doubleArguments[6] : 0; value = gregorianDateTimeToMS(exec, t, ms, false); } @@ -214,12 +214,12 @@ static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec) GregorianDateTime t; int year = JSC::toInt32(doubleArguments[0]); - t.year = (year >= 0 && year <= 99) ? year : year - 1900; - t.month = JSC::toInt32(doubleArguments[1]); - t.monthDay = (n >= 3) ? JSC::toInt32(doubleArguments[2]) : 1; - t.hour = JSC::toInt32(doubleArguments[3]); - t.minute = JSC::toInt32(doubleArguments[4]); - t.second = JSC::toInt32(doubleArguments[5]); + t.setYear((year >= 0 && year <= 99) ? year : year - 1900); + t.setMonth(JSC::toInt32(doubleArguments[1])); + t.setMonthDay((n >= 3) ? JSC::toInt32(doubleArguments[2]) : 1); + t.setHour(JSC::toInt32(doubleArguments[3])); + t.setMinute(JSC::toInt32(doubleArguments[4])); + t.setSecond(JSC::toInt32(doubleArguments[5])); double ms = (n >= 7) ? doubleArguments[6] : 0; return JSValue::encode(jsNumber(timeClip(gregorianDateTimeToMS(exec, t, ms, true)))); } diff --git a/Source/JavaScriptCore/runtime/DateConversion.cpp b/Source/JavaScriptCore/runtime/DateConversion.cpp index 7bc0cbc0f..e8714c14c 100644 --- a/Source/JavaScriptCore/runtime/DateConversion.cpp +++ b/Source/JavaScriptCore/runtime/DateConversion.cpp @@ -55,53 +55,41 @@ using namespace WTF; namespace JSC { -double parseDate(ExecState* exec, const UString &date) -{ - if (date == exec->globalData().cachedDateString) - return exec->globalData().cachedDateStringValue; - double value = parseES5DateFromNullTerminatedCharacters(date.utf8().data()); - if (isnan(value)) - value = parseDateFromNullTerminatedCharacters(exec, date.utf8().data()); - exec->globalData().cachedDateString = date; - exec->globalData().cachedDateStringValue = value; - return value; -} - void formatDate(const GregorianDateTime &t, DateConversionBuffer& buffer) { snprintf(buffer, DateConversionBufferSize, "%s %s %02d %04d", - weekdayName[(t.weekDay + 6) % 7], - monthName[t.month], t.monthDay, t.year + 1900); + weekdayName[(t.weekDay() + 6) % 7], + monthName[t.month()], t.monthDay(), t.year() + 1900); } void formatDateUTCVariant(const GregorianDateTime &t, DateConversionBuffer& buffer) { snprintf(buffer, DateConversionBufferSize, "%s, %02d %s %04d", - weekdayName[(t.weekDay + 6) % 7], - t.monthDay, monthName[t.month], t.year + 1900); + weekdayName[(t.weekDay() + 6) % 7], + t.monthDay(), monthName[t.month()], t.year() + 1900); } void formatTime(const GregorianDateTime &t, DateConversionBuffer& buffer) { - int offset = abs(gmtoffset(t)); + int offset = abs(t.utcOffset()); char timeZoneName[70]; struct tm gtm = t; strftime(timeZoneName, sizeof(timeZoneName), "%Z", >m); if (timeZoneName[0]) { snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT%c%02d%02d (%s)", - t.hour, t.minute, t.second, - gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, timeZoneName); + t.hour(), t.minute(), t.second(), + t.utcOffset() < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, timeZoneName); } else { snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT%c%02d%02d", - t.hour, t.minute, t.second, - gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60); + t.hour(), t.minute(), t.second(), + t.utcOffset() < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60); } } void formatTimeUTC(const GregorianDateTime &t, DateConversionBuffer& buffer) { - snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT", t.hour, t.minute, t.second); + snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT", t.hour(), t.minute(), t.second()); } } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/DateConversion.h b/Source/JavaScriptCore/runtime/DateConversion.h index ff32b503d..0b078cd34 100644 --- a/Source/JavaScriptCore/runtime/DateConversion.h +++ b/Source/JavaScriptCore/runtime/DateConversion.h @@ -42,17 +42,15 @@ #ifndef DateConversion_h #define DateConversion_h -#include "UString.h" +#include <wtf/GregorianDateTime.h> namespace JSC { class ExecState; -struct GregorianDateTime; static const unsigned DateConversionBufferSize = 100; typedef char DateConversionBuffer[DateConversionBufferSize]; -double parseDate(ExecState* exec, const UString&); void formatDate(const GregorianDateTime&, DateConversionBuffer&); void formatDateUTCVariant(const GregorianDateTime&, DateConversionBuffer&); void formatTime(const GregorianDateTime&, DateConversionBuffer&); diff --git a/Source/JavaScriptCore/runtime/DateInstance.h b/Source/JavaScriptCore/runtime/DateInstance.h index 7c976a514..9742e6889 100644 --- a/Source/JavaScriptCore/runtime/DateInstance.h +++ b/Source/JavaScriptCore/runtime/DateInstance.h @@ -23,10 +23,6 @@ #include "JSWrapperObject.h" -namespace WTF { - struct GregorianDateTime; -} - namespace JSC { class DateInstance : public JSWrapperObject { diff --git a/Source/JavaScriptCore/runtime/DatePrototype.cpp b/Source/JavaScriptCore/runtime/DatePrototype.cpp index d3d0fe574..aa65acd05 100644 --- a/Source/JavaScriptCore/runtime/DatePrototype.cpp +++ b/Source/JavaScriptCore/runtime/DatePrototype.cpp @@ -222,13 +222,13 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L #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; + 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; @@ -265,7 +265,7 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L // Offset year if needed struct tm localTM = gdt; - int year = gdt.year + 1900; + int year = gdt.year() + 1900; bool yearNeedsOffset = year < 1900 || year > 2038; if (yearNeedsOffset) localTM.tm_year = equivalentYearForDST(year) - 1900; @@ -357,7 +357,7 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, int maxArgs, double* ms // hours if (maxArgs >= 4 && idx < numArgs) { - t->hour = 0; + t->setHour(0); double hours = exec->argument(idx++).toIntegerPreserveNaN(exec); ok = isfinite(hours); milliseconds += hours * msPerHour; @@ -365,7 +365,7 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, int maxArgs, double* ms // minutes if (maxArgs >= 3 && idx < numArgs && ok) { - t->minute = 0; + t->setMinute(0); double minutes = exec->argument(idx++).toIntegerPreserveNaN(exec); ok = isfinite(minutes); milliseconds += minutes * msPerMinute; @@ -373,7 +373,7 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, int maxArgs, double* ms // seconds if (maxArgs >= 2 && idx < numArgs && ok) { - t->second = 0; + t->setSecond(0); double seconds = exec->argument(idx++).toIntegerPreserveNaN(exec); ok = isfinite(seconds); milliseconds += seconds * msPerSecond; @@ -412,19 +412,19 @@ static bool fillStructuresUsingDateArgs(ExecState *exec, int maxArgs, double *ms if (maxArgs >= 3 && idx < numArgs) { double years = exec->argument(idx++).toIntegerPreserveNaN(exec); ok = isfinite(years); - t->year = toInt32(years - 1900); + t->setYear(toInt32(years - 1900)); } // months if (maxArgs >= 2 && idx < numArgs && ok) { double months = exec->argument(idx++).toIntegerPreserveNaN(exec); ok = isfinite(months); - t->month = toInt32(months); + t->setMonth(toInt32(months)); } // days if (idx < numArgs && ok) { double days = exec->argument(idx++).toIntegerPreserveNaN(exec); ok = isfinite(days); - t->monthDay = 0; + t->setMonthDay(0); *ms += days * msPerDay; } @@ -567,10 +567,10 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec) int ms = static_cast<int>(fmod(thisDateObj->internalNumber(), msPerSecond)); if (ms < 0) ms += msPerSecond; - if (gregorianDateTime->year > 8099 || gregorianDateTime->year < -1900) - snprintf(buffer, sizeof(buffer) - 1, "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year, gregorianDateTime->month + 1, gregorianDateTime->monthDay, gregorianDateTime->hour, gregorianDateTime->minute, gregorianDateTime->second, ms); + if (gregorianDateTime->year() > 8099 || gregorianDateTime->year() < -1900) + snprintf(buffer, sizeof(buffer) - 1, "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms); else - snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year, gregorianDateTime->month + 1, gregorianDateTime->monthDay, gregorianDateTime->hour, gregorianDateTime->minute, gregorianDateTime->second, ms); + snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms); buffer[sizeof(buffer) - 1] = 0; return JSValue::encode(jsNontrivialString(exec, buffer)); } @@ -657,7 +657,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(1900 + gregorianDateTime->year)); + return JSValue::encode(jsNumber(1900 + gregorianDateTime->year())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec) @@ -671,7 +671,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(1900 + gregorianDateTime->year)); + return JSValue::encode(jsNumber(1900 + gregorianDateTime->year())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec) @@ -703,7 +703,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->month)); + return JSValue::encode(jsNumber(gregorianDateTime->month())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec) @@ -717,7 +717,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->month)); + return JSValue::encode(jsNumber(gregorianDateTime->month())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec) @@ -731,7 +731,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->monthDay)); + return JSValue::encode(jsNumber(gregorianDateTime->monthDay())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec) @@ -745,7 +745,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->monthDay)); + return JSValue::encode(jsNumber(gregorianDateTime->monthDay())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec) @@ -759,7 +759,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->weekDay)); + return JSValue::encode(jsNumber(gregorianDateTime->weekDay())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec) @@ -773,7 +773,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->weekDay)); + return JSValue::encode(jsNumber(gregorianDateTime->weekDay())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec) @@ -787,7 +787,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->hour)); + return JSValue::encode(jsNumber(gregorianDateTime->hour())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec) @@ -801,7 +801,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->hour)); + return JSValue::encode(jsNumber(gregorianDateTime->hour())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec) @@ -815,7 +815,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->minute)); + return JSValue::encode(jsNumber(gregorianDateTime->minute())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec) @@ -829,7 +829,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->minute)); + return JSValue::encode(jsNumber(gregorianDateTime->minute())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec) @@ -843,7 +843,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->second)); + return JSValue::encode(jsNumber(gregorianDateTime->second())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec) @@ -857,7 +857,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(gregorianDateTime->second)); + return JSValue::encode(jsNumber(gregorianDateTime->second())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec) @@ -903,7 +903,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec) const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec); if (!gregorianDateTime) return JSValue::encode(jsNaN()); - return JSValue::encode(jsNumber(-gregorianDateTime->utcOffset / minutesPerHour)); + return JSValue::encode(jsNumber(-gregorianDateTime->utcOffset() / minutesPerHour)); } EncodedJSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec) @@ -1087,36 +1087,36 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec) if (!thisValue.inherits(&DateInstance::s_info)) return throwVMTypeError(exec); - DateInstance* thisDateObj = asDateInstance(thisValue); + DateInstance* thisDateObj = asDateInstance(thisValue); if (!exec->argumentCount()) { JSValue result = jsNaN(); thisDateObj->setInternalValue(exec->globalData(), result); return JSValue::encode(result); } - + double milli = thisDateObj->internalNumber(); double ms = 0; GregorianDateTime gregorianDateTime; if (isnan(milli)) // Based on ECMA 262 B.2.5 (setYear) - // the time must be reset to +0 if it is NaN. + // the time must be reset to +0 if it is NaN. msToGregorianDateTime(exec, 0, true, gregorianDateTime); - else { + else { double secs = floor(milli / msPerSecond); ms = milli - secs * msPerSecond; if (const GregorianDateTime* other = thisDateObj->gregorianDateTime(exec)) gregorianDateTime.copyFrom(*other); } - + double year = exec->argument(0).toIntegerPreserveNaN(exec); if (!isfinite(year)) { JSValue result = jsNaN(); thisDateObj->setInternalValue(exec->globalData(), result); return JSValue::encode(result); } - - gregorianDateTime.year = toInt32((year > 99 || year < 0) ? year - 1900 : year); + + gregorianDateTime.setYear(toInt32((year > 99 || year < 0) ? year - 1900 : year)); JSValue result = jsNumber(gregorianDateTimeToMS(exec, gregorianDateTime, ms, false)); thisDateObj->setInternalValue(exec->globalData(), result); return JSValue::encode(result); @@ -1135,7 +1135,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec) return JSValue::encode(jsNaN()); // NOTE: IE returns the full year even in getYear. - return JSValue::encode(jsNumber(gregorianDateTime->year)); + return JSValue::encode(jsNumber(gregorianDateTime->year())); } EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec) diff --git a/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp b/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp index d9f96fa1e..c052c61ba 100644 --- a/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp +++ b/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp @@ -34,6 +34,7 @@ DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap) void DefaultGCActivityCallback::doWork() { + JSLock lock(SilenceAssertionsOnly); m_globalData->heap.collect(Heap::DoNotSweep); } diff --git a/Source/JavaScriptCore/runtime/JSDateMath.cpp b/Source/JavaScriptCore/runtime/JSDateMath.cpp index dbe748835..a7840938c 100644 --- a/Source/JavaScriptCore/runtime/JSDateMath.cpp +++ b/Source/JavaScriptCore/runtime/JSDateMath.cpp @@ -203,8 +203,8 @@ double getUTCOffset(ExecState* exec) double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC) { - double day = dateToDaysFrom1970(t.year + 1900, t.month, t.monthDay); - double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds); + double day = dateToDaysFrom1970(t.year() + 1900, t.month(), t.monthDay()); + double ms = timeToMS(t.hour(), t.minute(), t.second(), milliSeconds); double result = (day * WTF::msPerDay) + ms; if (!inputIsUTC) { // convert to UTC @@ -228,17 +228,16 @@ void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, Gregori } const int year = msToYear(ms); - tm.second = msToSeconds(ms); - tm.minute = msToMinutes(ms); - tm.hour = msToHours(ms); - tm.weekDay = msToWeekDay(ms); - tm.yearDay = dayInYear(ms, year); - tm.monthDay = dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year)); - tm.month = monthFromDayInYear(tm.yearDay, isLeapYear(year)); - tm.year = year - 1900; - tm.isDST = dstOff != 0.0; - tm.utcOffset = static_cast<long>((dstOff + utcOff) / WTF::msPerSecond); - tm.timeZone = nullptr; + tm.setSecond(msToSeconds(ms)); + tm.setMinute(msToMinutes(ms)); + tm.setHour(msToHours(ms)); + tm.setWeekDay(msToWeekDay(ms)); + tm.setYearDay(dayInYear(ms, year)); + tm.setMonthDay(dayInMonthFromDayInYear(tm.yearDay(), isLeapYear(year))); + tm.setMonth(monthFromDayInYear(tm.yearDay(), isLeapYear(year))); + tm.setYear(year - 1900); + tm.setIsDST(dstOff != 0.0); + tm.setUtcOffset(static_cast<long>((dstOff + utcOff) / WTF::msPerSecond)); } double parseDateFromNullTerminatedCharacters(ExecState* exec, const char* dateString) @@ -259,4 +258,16 @@ double parseDateFromNullTerminatedCharacters(ExecState* exec, const char* dateSt return ms - (offset * WTF::msPerMinute); } +double parseDate(ExecState* exec, const UString& date) +{ + if (date == exec->globalData().cachedDateString) + return exec->globalData().cachedDateStringValue; + double value = parseES5DateFromNullTerminatedCharacters(date.utf8().data()); + if (isnan(value)) + value = parseDateFromNullTerminatedCharacters(exec, date.utf8().data()); + exec->globalData().cachedDateString = date; + exec->globalData().cachedDateStringValue = value; + return value; +} + } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/JSDateMath.h b/Source/JavaScriptCore/runtime/JSDateMath.h index f77cf1e75..c7fb5a975 100644 --- a/Source/JavaScriptCore/runtime/JSDateMath.h +++ b/Source/JavaScriptCore/runtime/JSDateMath.h @@ -44,98 +44,18 @@ #define JSDateMath_h #include <wtf/DateMath.h> +#include <wtf/GregorianDateTime.h> namespace JSC { class ExecState; -struct GregorianDateTime; +class UString; void msToGregorianDateTime(ExecState*, double, bool outputIsUTC, GregorianDateTime&); double gregorianDateTimeToMS(ExecState*, const GregorianDateTime&, double, bool inputIsUTC); double getUTCOffset(ExecState*); double parseDateFromNullTerminatedCharacters(ExecState*, const char* dateString); - -// Intentionally overridding the default tm of the system. -// The members of tm differ on various operating systems. -struct GregorianDateTime { - WTF_MAKE_NONCOPYABLE(GregorianDateTime); -public: - GregorianDateTime() - : second(0) - , minute(0) - , hour(0) - , weekDay(0) - , monthDay(0) - , yearDay(0) - , month(0) - , year(0) - , isDST(0) - , utcOffset(0) - { - } - - operator tm() const - { - tm ret; - memset(&ret, 0, sizeof(ret)); - - ret.tm_sec = second; - ret.tm_min = minute; - ret.tm_hour = hour; - ret.tm_wday = weekDay; - ret.tm_mday = monthDay; - ret.tm_yday = yearDay; - ret.tm_mon = month; - ret.tm_year = year; - ret.tm_isdst = isDST; - -#if HAVE(TM_GMTOFF) - ret.tm_gmtoff = static_cast<long>(utcOffset); -#endif -#if HAVE(TM_ZONE) - ret.tm_zone = timeZone.get(); -#endif - - return ret; - } - - void copyFrom(const GregorianDateTime& rhs) - { - second = rhs.second; - minute = rhs.minute; - hour = rhs.hour; - weekDay = rhs.weekDay; - monthDay = rhs.monthDay; - yearDay = rhs.yearDay; - month = rhs.month; - year = rhs.year; - isDST = rhs.isDST; - utcOffset = rhs.utcOffset; - if (rhs.timeZone) { - int inZoneSize = strlen(rhs.timeZone.get()) + 1; - timeZone = adoptArrayPtr(new char[inZoneSize]); - strncpy(timeZone.get(), rhs.timeZone.get(), inZoneSize); - } else - timeZone = nullptr; - } - - int second; - int minute; - int hour; - int weekDay; - int monthDay; - int yearDay; - int month; - int year; - int isDST; - int utcOffset; - OwnArrayPtr<char> timeZone; -}; - -static inline int gmtoffset(const GregorianDateTime& t) -{ - return t.utcOffset; -} +double parseDate(ExecState*, const UString&); } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/JSObject.cpp b/Source/JavaScriptCore/runtime/JSObject.cpp index 587929f66..a84597f8b 100644 --- a/Source/JavaScriptCore/runtime/JSObject.cpp +++ b/Source/JavaScriptCore/runtime/JSObject.cpp @@ -99,10 +99,11 @@ void JSObject::visitChildren(JSCell* cell, SlotVisitor& visitor) PropertyStorage storage = thisObject->outOfLineStorage(); if (storage) { size_t storageSize = thisObject->structure()->outOfLineSizeForKnownNonFinalObject(); + size_t capacity = thisObject->structure()->outOfLineCapacity(); // We have this extra temp here to slake GCC's thirst for the blood of those who dereference type-punned pointers. - void* temp = storage; - visitor.copyAndAppend(&temp, thisObject->structure()->outOfLineCapacity() * sizeof(WriteBarrierBase<Unknown>), storage->slot(), storageSize); - storage = static_cast<PropertyStorage>(temp); + void* temp = storage - capacity - 1; + visitor.copyAndAppend(&temp, capacity * sizeof(WriteBarrierBase<Unknown>), (storage - storageSize - 1)->slot(), storageSize); + storage = static_cast<PropertyStorage>(temp) + capacity + 1; thisObject->m_outOfLineStorage.set(storage, StorageBarrier::Unchecked); } @@ -128,10 +129,11 @@ void JSFinalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) PropertyStorage storage = thisObject->outOfLineStorage(); if (storage) { size_t storageSize = thisObject->structure()->outOfLineSizeForKnownFinalObject(); + size_t capacity = thisObject->structure()->outOfLineCapacity(); // We have this extra temp here to slake GCC's thirst for the blood of those who dereference type-punned pointers. - void* temp = storage; - visitor.copyAndAppend(&temp, thisObject->structure()->outOfLineCapacity() * sizeof(WriteBarrierBase<Unknown>), storage->slot(), storageSize); - storage = static_cast<PropertyStorage>(temp); + void* temp = storage - capacity - 1; + visitor.copyAndAppend(&temp, thisObject->structure()->outOfLineCapacity() * sizeof(WriteBarrierBase<Unknown>), (storage - storageSize - 1)->slot(), storageSize); + storage = static_cast<PropertyStorage>(temp) + capacity + 1; thisObject->m_outOfLineStorage.set(storage, StorageBarrier::Unchecked); } @@ -595,7 +597,7 @@ PropertyStorage JSObject::growOutOfLineStorage(JSGlobalData& globalData, size_t // It's important that this function not rely on structure(), since // we might be in the middle of a transition. - + PropertyStorage oldPropertyStorage = m_outOfLineStorage.get(); PropertyStorage newPropertyStorage = 0; @@ -603,9 +605,9 @@ PropertyStorage JSObject::growOutOfLineStorage(JSGlobalData& globalData, size_t void* temp = newPropertyStorage; if (!globalData.heap.tryAllocateStorage(sizeof(WriteBarrierBase<Unknown>) * newSize, &temp)) CRASH(); - newPropertyStorage = static_cast<PropertyStorage>(temp); + newPropertyStorage = static_cast<PropertyStorage>(temp) + newSize + 1; - memcpy(newPropertyStorage, oldPropertyStorage, sizeof(WriteBarrierBase<Unknown>) * oldSize); + memcpy(newPropertyStorage - oldSize - 1, oldPropertyStorage - oldSize - 1, sizeof(WriteBarrierBase<Unknown>) * oldSize); ASSERT(newPropertyStorage); return newPropertyStorage; diff --git a/Source/JavaScriptCore/runtime/JSObject.h b/Source/JavaScriptCore/runtime/JSObject.h index 9972d6077..cc43440ab 100644 --- a/Source/JavaScriptCore/runtime/JSObject.h +++ b/Source/JavaScriptCore/runtime/JSObject.h @@ -173,14 +173,14 @@ namespace JSC { { PropertyOffset offset = structure()->get(globalData, propertyName); checkOffset(offset, structure()->typeInfo().type()); - return offset != invalidOffset ? locationForOffset(offset) : 0; + return isValidOffset(offset) ? locationForOffset(offset) : 0; } WriteBarrierBase<Unknown>* getDirectLocation(JSGlobalData& globalData, PropertyName propertyName, unsigned& attributes) { JSCell* specificFunction; PropertyOffset offset = structure()->get(globalData, propertyName, attributes, specificFunction); - return offset != invalidOffset ? locationForOffset(offset) : 0; + return isValidOffset(offset) ? locationForOffset(offset) : 0; } bool hasInlineStorage() const { return structure()->hasInlineStorage(); } @@ -227,7 +227,7 @@ namespace JSC { if (offsetInInlineStorage < static_cast<size_t>(inlineStorageCapacity)) result = offsetInInlineStorage; else - result = location - outOfLineStorage() + firstOutOfLineOffset; + result = outOfLineStorage() - location + (inlineStorageCapacity - 2); validateOffset(result, structure()->typeInfo().type()); return result; } diff --git a/Source/JavaScriptCore/runtime/JSValue.h b/Source/JavaScriptCore/runtime/JSValue.h index 6f98bd6f7..19a8c4759 100644 --- a/Source/JavaScriptCore/runtime/JSValue.h +++ b/Source/JavaScriptCore/runtime/JSValue.h @@ -254,7 +254,7 @@ namespace JSC { JSValue structureOrUndefined() const; - char* description() const; + JS_EXPORT_PRIVATE char* description() const; JS_EXPORT_PRIVATE JSObject* synthesizePrototype(ExecState*) const; diff --git a/Source/JavaScriptCore/runtime/PropertyOffset.h b/Source/JavaScriptCore/runtime/PropertyOffset.h index c0d1316c4..3883d910f 100644 --- a/Source/JavaScriptCore/runtime/PropertyOffset.h +++ b/Source/JavaScriptCore/runtime/PropertyOffset.h @@ -118,7 +118,7 @@ inline size_t offsetInOutOfLineStorage(PropertyOffset offset) { validateOffset(offset); ASSERT(isOutOfLineOffset(offset)); - return offset - firstOutOfLineOffset; + return -static_cast<ptrdiff_t>(offset - firstOutOfLineOffset) - 2; } inline size_t offsetInRespectiveStorage(PropertyOffset offset) |