diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-05-14 10:50:01 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-05-14 10:50:01 +0200 |
commit | e9dd029f5d00590e1a53e63b0ab805110a10b54c (patch) | |
tree | 1126ca5dda925a62be3dc12c99c90e953d08afcf /js | |
parent | 9d6a7ae25d7f5da855a8f8df884de483b4e2a538 (diff) | |
parent | 36b8fd734f590eb726ca2e50f8d1ff9cc968b8e1 (diff) | |
download | UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.gz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.lz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.xz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.zip |
Merge branch 'master' into Basilisk-release
Diffstat (limited to 'js')
41 files changed, 250 insertions, 1166 deletions
diff --git a/js/public/Value.h b/js/public/Value.h index a40e65c83..01666ed4e 100644 --- a/js/public/Value.h +++ b/js/public/Value.h @@ -140,12 +140,16 @@ static_assert(sizeof(JSValueShiftedTag) == sizeof(uint64_t), #define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_CLEAR | (type))) +#define JSVAL_RAW64_UNDEFINED (uint64_t(JSVAL_TAG_UNDEFINED) << 32) + #define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT #define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 #define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING #elif defined(JS_PUNBOX64) +#define JSVAL_RAW64_UNDEFINED (uint64_t(JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT) + #define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL #define JSVAL_TAG_MASK 0xFFFF800000000000LL #define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type))) @@ -817,7 +821,7 @@ class MOZ_NON_PARAM alignas(8) Value double asDouble; void* asPtr; - layout() = default; + layout() : asBits(JSVAL_RAW64_UNDEFINED) {} explicit constexpr layout(uint64_t bits) : asBits(bits) {} explicit constexpr layout(double d) : asDouble(d) {} } data; @@ -843,7 +847,7 @@ class MOZ_NON_PARAM alignas(8) Value size_t asWord; uintptr_t asUIntPtr; - layout() = default; + layout() : asBits(JSVAL_RAW64_UNDEFINED) {} explicit constexpr layout(uint64_t bits) : asBits(bits) {} explicit constexpr layout(double d) : asDouble(d) {} } data; @@ -871,7 +875,7 @@ class MOZ_NON_PARAM alignas(8) Value double asDouble; void* asPtr; - layout() = default; + layout() : asBits(JSVAL_RAW64_UNDEFINED) {} explicit constexpr layout(uint64_t bits) : asBits(bits) {} explicit constexpr layout(double d) : asDouble(d) {} } data; @@ -895,7 +899,7 @@ class MOZ_NON_PARAM alignas(8) Value size_t asWord; uintptr_t asUIntPtr; - layout() = default; + layout() : asBits(JSVAL_RAW64_UNDEFINED) {} explicit constexpr layout(uint64_t bits) : asBits(bits) {} explicit constexpr layout(double d) : asDouble(d) {} } data; @@ -948,8 +952,51 @@ class MOZ_NON_PARAM alignas(8) Value } } JS_HAZ_GC_POINTER; +/** + * This is a null-constructible structure that can convert to and from + * a Value, allowing UninitializedValue to be stored in unions. + */ +struct MOZ_NON_PARAM alignas(8) UninitializedValue +{ + private: + uint64_t bits; + + public: + UninitializedValue() = default; + UninitializedValue(const UninitializedValue&) = default; + MOZ_IMPLICIT UninitializedValue(const Value& val) : bits(val.asRawBits()) {} + + inline uint64_t asRawBits() const { + return bits; + } + + inline Value& asValueRef() { + return *reinterpret_cast<Value*>(this); + } + inline const Value& asValueRef() const { + return *reinterpret_cast<const Value*>(this); + } + + inline operator Value&() { + return asValueRef(); + } + inline operator Value const&() const { + return asValueRef(); + } + inline operator Value() const { + return asValueRef(); + } + + inline void operator=(Value const& other) { + asValueRef() = other; + } +}; + static_assert(sizeof(Value) == 8, "Value size must leave three tag bits, be a binary power, and is ubiquitously depended upon everywhere"); +static_assert(sizeof(UninitializedValue) == sizeof(Value), "Value and UninitializedValue must be the same size"); +static_assert(alignof(UninitializedValue) == alignof(Value), "Value and UninitializedValue must have same alignment"); + inline bool IsOptimizedPlaceholderMagicValue(const Value& v) { diff --git a/js/src/aclocal.m4 b/js/src/aclocal.m4 index 627837a41..abbbd4873 100644 --- a/js/src/aclocal.m4 +++ b/js/src/aclocal.m4 @@ -25,7 +25,6 @@ builtin(include, ../../build/autoconf/zlib.m4)dnl builtin(include, ../../build/autoconf/icu.m4)dnl builtin(include, ../../build/autoconf/clang-plugin.m4)dnl builtin(include, ../../build/autoconf/alloc.m4)dnl -builtin(include, ../../build/autoconf/jemalloc.m4)dnl builtin(include, ../../build/autoconf/sanitize.m4)dnl builtin(include, ../../build/autoconf/ios.m4)dnl diff --git a/js/src/builtin/Array.js b/js/src/builtin/Array.js index 45f90a7b8..360dd2af1 100644 --- a/js/src/builtin/Array.js +++ b/js/src/builtin/Array.js @@ -900,11 +900,7 @@ function ArrayToLocaleString(locales, options) { if (firstElement === undefined || firstElement === null) { R = ""; } else { -#if EXPOSE_INTL_API R = ToString(callContentFunction(firstElement.toLocaleString, firstElement, locales, options)); -#else - R = ToString(callContentFunction(firstElement.toLocaleString, firstElement)); -#endif } // Step 3 (reordered). @@ -919,11 +915,7 @@ function ArrayToLocaleString(locales, options) { // Steps 9.a, 9.c-e. R += separator; if (!(nextElement === undefined || nextElement === null)) { -#if EXPOSE_INTL_API R += ToString(callContentFunction(nextElement.toLocaleString, nextElement, locales, options)); -#else - R += ToString(callContentFunction(nextElement.toLocaleString, nextElement)); -#endif } } diff --git a/js/src/builtin/Intl.cpp b/js/src/builtin/Intl.cpp index cd808cb10..71f7b58d4 100644 --- a/js/src/builtin/Intl.cpp +++ b/js/src/builtin/Intl.cpp @@ -23,7 +23,6 @@ #include "jsobj.h" #include "builtin/IntlTimeZoneData.h" -#if ENABLE_INTL_API #include "unicode/ucal.h" #include "unicode/ucol.h" #include "unicode/udat.h" @@ -32,7 +31,6 @@ #include "unicode/unum.h" #include "unicode/unumsys.h" #include "unicode/ustring.h" -#endif #include "vm/DateTime.h" #include "vm/GlobalObject.h" #include "vm/Interpreter.h" @@ -60,603 +58,6 @@ using mozilla::PodCopy; * http://userguide.icu-project.org/design#TOC-Error-Handling */ - -/******************** ICU stubs ********************/ - -#if !ENABLE_INTL_API - -/* - * When the Internationalization API isn't enabled, we also shouldn't link - * against ICU. However, we still want to compile this code in order to prevent - * bit rot. The following stub implementations for ICU functions make this - * possible. The functions using them should never be called, so they assert - * and return error codes. Signatures adapted from ICU header files locid.h, - * numsys.h, ucal.h, ucol.h, udat.h, udatpg.h, uenum.h, unum.h; see the ICU - * directory for license. - */ - -typedef bool UBool; -typedef char16_t UChar; -typedef double UDate; - -enum UErrorCode { - U_ZERO_ERROR, - U_BUFFER_OVERFLOW_ERROR, -}; - -static inline UBool -U_FAILURE(UErrorCode code) -{ - MOZ_CRASH("U_FAILURE: Intl API disabled"); -} - -inline const UChar* -Char16ToUChar(const char16_t* chars) -{ - MOZ_CRASH("Char16ToUChar: Intl API disabled"); -} - -inline UChar* -Char16ToUChar(char16_t* chars) -{ - MOZ_CRASH("Char16ToUChar: Intl API disabled"); -} - -inline char16_t* -UCharToChar16(UChar* chars) -{ - MOZ_CRASH("UCharToChar16: Intl API disabled"); -} - -inline const char16_t* -UCharToChar16(const UChar* chars) -{ - MOZ_CRASH("UCharToChar16: Intl API disabled"); -} - -static int32_t -u_strlen(const UChar* s) -{ - MOZ_CRASH("u_strlen: Intl API disabled"); -} - -struct UEnumeration; - -static int32_t -uenum_count(UEnumeration* en, UErrorCode* status) -{ - MOZ_CRASH("uenum_count: Intl API disabled"); -} - -static const char* -uenum_next(UEnumeration* en, int32_t* resultLength, UErrorCode* status) -{ - MOZ_CRASH("uenum_next: Intl API disabled"); -} - -static void -uenum_close(UEnumeration* en) -{ - MOZ_CRASH("uenum_close: Intl API disabled"); -} - -struct UCollator; - -enum UColAttribute { - UCOL_ALTERNATE_HANDLING, - UCOL_CASE_FIRST, - UCOL_CASE_LEVEL, - UCOL_NORMALIZATION_MODE, - UCOL_STRENGTH, - UCOL_NUMERIC_COLLATION, -}; - -enum UColAttributeValue { - UCOL_DEFAULT = -1, - UCOL_PRIMARY = 0, - UCOL_SECONDARY = 1, - UCOL_TERTIARY = 2, - UCOL_OFF = 16, - UCOL_ON = 17, - UCOL_SHIFTED = 20, - UCOL_LOWER_FIRST = 24, - UCOL_UPPER_FIRST = 25, -}; - -enum UCollationResult { - UCOL_EQUAL = 0, - UCOL_GREATER = 1, - UCOL_LESS = -1 -}; - -static int32_t -ucol_countAvailable() -{ - MOZ_CRASH("ucol_countAvailable: Intl API disabled"); -} - -static const char* -ucol_getAvailable(int32_t localeIndex) -{ - MOZ_CRASH("ucol_getAvailable: Intl API disabled"); -} - -static UCollator* -ucol_open(const char* loc, UErrorCode* status) -{ - MOZ_CRASH("ucol_open: Intl API disabled"); -} - -static void -ucol_setAttribute(UCollator* coll, UColAttribute attr, UColAttributeValue value, UErrorCode* status) -{ - MOZ_CRASH("ucol_setAttribute: Intl API disabled"); -} - -static UCollationResult -ucol_strcoll(const UCollator* coll, const UChar* source, int32_t sourceLength, - const UChar* target, int32_t targetLength) -{ - MOZ_CRASH("ucol_strcoll: Intl API disabled"); -} - -static void -ucol_close(UCollator* coll) -{ - MOZ_CRASH("ucol_close: Intl API disabled"); -} - -static UEnumeration* -ucol_getKeywordValuesForLocale(const char* key, const char* locale, UBool commonlyUsed, - UErrorCode* status) -{ - MOZ_CRASH("ucol_getKeywordValuesForLocale: Intl API disabled"); -} - -struct UParseError; -struct UFieldPosition; -struct UFieldPositionIterator; -typedef void* UNumberFormat; - -enum UNumberFormatStyle { - UNUM_DECIMAL = 1, - UNUM_CURRENCY, - UNUM_PERCENT, - UNUM_CURRENCY_ISO, - UNUM_CURRENCY_PLURAL, -}; - -enum UNumberFormatRoundingMode { - UNUM_ROUND_HALFUP, -}; - -enum UNumberFormatAttribute { - UNUM_GROUPING_USED, - UNUM_MIN_INTEGER_DIGITS, - UNUM_MAX_FRACTION_DIGITS, - UNUM_MIN_FRACTION_DIGITS, - UNUM_ROUNDING_MODE, - UNUM_SIGNIFICANT_DIGITS_USED, - UNUM_MIN_SIGNIFICANT_DIGITS, - UNUM_MAX_SIGNIFICANT_DIGITS, -}; - -enum UNumberFormatTextAttribute { - UNUM_CURRENCY_CODE, -}; - -static int32_t -unum_countAvailable() -{ - MOZ_CRASH("unum_countAvailable: Intl API disabled"); -} - -static const char* -unum_getAvailable(int32_t localeIndex) -{ - MOZ_CRASH("unum_getAvailable: Intl API disabled"); -} - -static UNumberFormat* -unum_open(UNumberFormatStyle style, const UChar* pattern, int32_t patternLength, - const char* locale, UParseError* parseErr, UErrorCode* status) -{ - MOZ_CRASH("unum_open: Intl API disabled"); -} - -static void -unum_setAttribute(UNumberFormat* fmt, UNumberFormatAttribute attr, int32_t newValue) -{ - MOZ_CRASH("unum_setAttribute: Intl API disabled"); -} - -static int32_t -unum_formatDouble(const UNumberFormat* fmt, double number, UChar* result, - int32_t resultLength, UFieldPosition* pos, UErrorCode* status) -{ - MOZ_CRASH("unum_formatDouble: Intl API disabled"); -} - -static void -unum_close(UNumberFormat* fmt) -{ - MOZ_CRASH("unum_close: Intl API disabled"); -} - -static void -unum_setTextAttribute(UNumberFormat* fmt, UNumberFormatTextAttribute tag, const UChar* newValue, - int32_t newValueLength, UErrorCode* status) -{ - MOZ_CRASH("unum_setTextAttribute: Intl API disabled"); -} - -typedef void* UNumberingSystem; - -static UNumberingSystem* -unumsys_open(const char* locale, UErrorCode* status) -{ - MOZ_CRASH("unumsys_open: Intl API disabled"); -} - -static const char* -unumsys_getName(const UNumberingSystem* unumsys) -{ - MOZ_CRASH("unumsys_getName: Intl API disabled"); -} - -static void -unumsys_close(UNumberingSystem* unumsys) -{ - MOZ_CRASH("unumsys_close: Intl API disabled"); -} - -typedef void* UCalendar; - -enum UCalendarType { - UCAL_TRADITIONAL, - UCAL_DEFAULT = UCAL_TRADITIONAL, - UCAL_GREGORIAN -}; - -enum UCalendarAttribute { - UCAL_FIRST_DAY_OF_WEEK, - UCAL_MINIMAL_DAYS_IN_FIRST_WEEK -}; - -enum UCalendarDaysOfWeek { - UCAL_SUNDAY, - UCAL_MONDAY, - UCAL_TUESDAY, - UCAL_WEDNESDAY, - UCAL_THURSDAY, - UCAL_FRIDAY, - UCAL_SATURDAY -}; - -enum UCalendarWeekdayType { - UCAL_WEEKDAY, - UCAL_WEEKEND, - UCAL_WEEKEND_ONSET, - UCAL_WEEKEND_CEASE -}; - -enum UCalendarDateFields { - UCAL_ERA, - UCAL_YEAR, - UCAL_MONTH, - UCAL_WEEK_OF_YEAR, - UCAL_WEEK_OF_MONTH, - UCAL_DATE, - UCAL_DAY_OF_YEAR, - UCAL_DAY_OF_WEEK, - UCAL_DAY_OF_WEEK_IN_MONTH, - UCAL_AM_PM, - UCAL_HOUR, - UCAL_HOUR_OF_DAY, - UCAL_MINUTE, - UCAL_SECOND, - UCAL_MILLISECOND, - UCAL_ZONE_OFFSET, - UCAL_DST_OFFSET, - UCAL_YEAR_WOY, - UCAL_DOW_LOCAL, - UCAL_EXTENDED_YEAR, - UCAL_JULIAN_DAY, - UCAL_MILLISECONDS_IN_DAY, - UCAL_IS_LEAP_MONTH, - UCAL_FIELD_COUNT, - UCAL_DAY_OF_MONTH = UCAL_DATE -}; - -enum UCalendarMonths { - UCAL_JANUARY, - UCAL_FEBRUARY, - UCAL_MARCH, - UCAL_APRIL, - UCAL_MAY, - UCAL_JUNE, - UCAL_JULY, - UCAL_AUGUST, - UCAL_SEPTEMBER, - UCAL_OCTOBER, - UCAL_NOVEMBER, - UCAL_DECEMBER, - UCAL_UNDECIMBER -}; - -enum UCalendarAMPMs { - UCAL_AM, - UCAL_PM -}; - -static UCalendar* -ucal_open(const UChar* zoneID, int32_t len, const char* locale, - UCalendarType type, UErrorCode* status) -{ - MOZ_CRASH("ucal_open: Intl API disabled"); -} - -static const char* -ucal_getType(const UCalendar* cal, UErrorCode* status) -{ - MOZ_CRASH("ucal_getType: Intl API disabled"); -} - -static UEnumeration* -ucal_getKeywordValuesForLocale(const char* key, const char* locale, - UBool commonlyUsed, UErrorCode* status) -{ - MOZ_CRASH("ucal_getKeywordValuesForLocale: Intl API disabled"); -} - -static void -ucal_close(UCalendar* cal) -{ - MOZ_CRASH("ucal_close: Intl API disabled"); -} - -static UCalendarWeekdayType -ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status) -{ - MOZ_CRASH("ucal_getDayOfWeekType: Intl API disabled"); -} - -static int32_t -ucal_getAttribute(const UCalendar* cal, - UCalendarAttribute attr) -{ - MOZ_CRASH("ucal_getAttribute: Intl API disabled"); -} - -static int32_t -ucal_get(const UCalendar *cal, UCalendarDateFields field, UErrorCode *status) -{ - MOZ_CRASH("ucal_get: Intl API disabled"); -} - -static UEnumeration* -ucal_openTimeZones(UErrorCode* status) -{ - MOZ_CRASH("ucal_openTimeZones: Intl API disabled"); -} - -static int32_t -ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len, UChar* result, int32_t resultCapacity, - UBool* isSystemID, UErrorCode* status) -{ - MOZ_CRASH("ucal_getCanonicalTimeZoneID: Intl API disabled"); -} - -static int32_t -ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* status) -{ - MOZ_CRASH("ucal_getDefaultTimeZone: Intl API disabled"); -} - -enum UDateTimePatternField { - UDATPG_YEAR_FIELD, - UDATPG_MONTH_FIELD, - UDATPG_WEEK_OF_YEAR_FIELD, - UDATPG_DAY_FIELD, -}; - -typedef void* UDateTimePatternGenerator; - -static UDateTimePatternGenerator* -udatpg_open(const char* locale, UErrorCode* pErrorCode) -{ - MOZ_CRASH("udatpg_open: Intl API disabled"); -} - -static int32_t -udatpg_getBestPattern(UDateTimePatternGenerator* dtpg, const UChar* skeleton, - int32_t length, UChar* bestPattern, int32_t capacity, - UErrorCode* pErrorCode) -{ - MOZ_CRASH("udatpg_getBestPattern: Intl API disabled"); -} - -static const UChar * -udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg, - UDateTimePatternField field, - int32_t *pLength) -{ - MOZ_CRASH("udatpg_getAppendItemName: Intl API disabled"); -} - -static void -udatpg_close(UDateTimePatternGenerator* dtpg) -{ - MOZ_CRASH("udatpg_close: Intl API disabled"); -} - -typedef void* UCalendar; -typedef void* UDateFormat; - -enum UDateFormatField { - UDAT_ERA_FIELD = 0, - UDAT_YEAR_FIELD = 1, - UDAT_MONTH_FIELD = 2, - UDAT_DATE_FIELD = 3, - UDAT_HOUR_OF_DAY1_FIELD = 4, - UDAT_HOUR_OF_DAY0_FIELD = 5, - UDAT_MINUTE_FIELD = 6, - UDAT_SECOND_FIELD = 7, - UDAT_FRACTIONAL_SECOND_FIELD = 8, - UDAT_DAY_OF_WEEK_FIELD = 9, - UDAT_DAY_OF_YEAR_FIELD = 10, - UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11, - UDAT_WEEK_OF_YEAR_FIELD = 12, - UDAT_WEEK_OF_MONTH_FIELD = 13, - UDAT_AM_PM_FIELD = 14, - UDAT_HOUR1_FIELD = 15, - UDAT_HOUR0_FIELD = 16, - UDAT_TIMEZONE_FIELD = 17, - UDAT_YEAR_WOY_FIELD = 18, - UDAT_DOW_LOCAL_FIELD = 19, - UDAT_EXTENDED_YEAR_FIELD = 20, - UDAT_JULIAN_DAY_FIELD = 21, - UDAT_MILLISECONDS_IN_DAY_FIELD = 22, - UDAT_TIMEZONE_RFC_FIELD = 23, - UDAT_TIMEZONE_GENERIC_FIELD = 24, - UDAT_STANDALONE_DAY_FIELD = 25, - UDAT_STANDALONE_MONTH_FIELD = 26, - UDAT_QUARTER_FIELD = 27, - UDAT_STANDALONE_QUARTER_FIELD = 28, - UDAT_TIMEZONE_SPECIAL_FIELD = 29, - UDAT_YEAR_NAME_FIELD = 30, - UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31, - UDAT_TIMEZONE_ISO_FIELD = 32, - UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33, - UDAT_RELATED_YEAR_FIELD = 34, - UDAT_AM_PM_MIDNIGHT_NOON_FIELD = 35, - UDAT_FLEXIBLE_DAY_PERIOD_FIELD = 36, - UDAT_TIME_SEPARATOR_FIELD = 37, - UDAT_FIELD_COUNT = 38 -}; - -enum UDateFormatStyle { - UDAT_FULL, - UDAT_LONG, - UDAT_MEDIUM, - UDAT_SHORT, - UDAT_DEFAULT = UDAT_MEDIUM, - UDAT_PATTERN = -2, - UDAT_IGNORE = UDAT_PATTERN -}; - -enum UDateFormatSymbolType { - UDAT_ERAS, - UDAT_MONTHS, - UDAT_SHORT_MONTHS, - UDAT_WEEKDAYS, - UDAT_SHORT_WEEKDAYS, - UDAT_AM_PMS, - UDAT_LOCALIZED_CHARS, - UDAT_ERA_NAMES, - UDAT_NARROW_MONTHS, - UDAT_NARROW_WEEKDAYS, - UDAT_STANDALONE_MONTHS, - UDAT_STANDALONE_SHORT_MONTHS, - UDAT_STANDALONE_NARROW_MONTHS, - UDAT_STANDALONE_WEEKDAYS, - UDAT_STANDALONE_SHORT_WEEKDAYS, - UDAT_STANDALONE_NARROW_WEEKDAYS, - UDAT_QUARTERS, - UDAT_SHORT_QUARTERS, - UDAT_STANDALONE_QUARTERS, - UDAT_STANDALONE_SHORT_QUARTERS, - UDAT_SHORTER_WEEKDAYS, - UDAT_STANDALONE_SHORTER_WEEKDAYS, - UDAT_CYCLIC_YEARS_WIDE, - UDAT_CYCLIC_YEARS_ABBREVIATED, - UDAT_CYCLIC_YEARS_NARROW, - UDAT_ZODIAC_NAMES_WIDE, - UDAT_ZODIAC_NAMES_ABBREVIATED, - UDAT_ZODIAC_NAMES_NARROW -}; - -static int32_t -udat_countAvailable() -{ - MOZ_CRASH("udat_countAvailable: Intl API disabled"); -} - -static const char* -udat_getAvailable(int32_t localeIndex) -{ - MOZ_CRASH("udat_getAvailable: Intl API disabled"); -} - -static UDateFormat* -udat_open(UDateFormatStyle timeStyle, UDateFormatStyle dateStyle, const char* locale, - const UChar* tzID, int32_t tzIDLength, const UChar* pattern, - int32_t patternLength, UErrorCode* status) -{ - MOZ_CRASH("udat_open: Intl API disabled"); -} - -static const UCalendar* -udat_getCalendar(const UDateFormat* fmt) -{ - MOZ_CRASH("udat_getCalendar: Intl API disabled"); -} - -static void -ucal_setGregorianChange(UCalendar* cal, UDate date, UErrorCode* pErrorCode) -{ - MOZ_CRASH("ucal_setGregorianChange: Intl API disabled"); -} - -static int32_t -udat_format(const UDateFormat* format, UDate dateToFormat, UChar* result, - int32_t resultLength, UFieldPosition* position, UErrorCode* status) -{ - MOZ_CRASH("udat_format: Intl API disabled"); -} - -static int32_t -udat_formatForFields(const UDateFormat* format, UDate dateToFormat, - UChar* result, int32_t resultLength, UFieldPositionIterator* fpositer, - UErrorCode* status) -{ - MOZ_CRASH("udat_formatForFields: Intl API disabled"); -} - -static UFieldPositionIterator* -ufieldpositer_open(UErrorCode* status) -{ - MOZ_CRASH("ufieldpositer_open: Intl API disabled"); -} - -static void -ufieldpositer_close(UFieldPositionIterator* fpositer) -{ - MOZ_CRASH("ufieldpositer_close: Intl API disabled"); -} - -static int32_t -ufieldpositer_next(UFieldPositionIterator* fpositer, int32_t* beginIndex, int32_t* endIndex) -{ - MOZ_CRASH("ufieldpositer_next: Intl API disabled"); -} - -static void -udat_close(UDateFormat* format) -{ - MOZ_CRASH("udat_close: Intl API disabled"); -} - -static int32_t -udat_getSymbols(const UDateFormat *fmt, UDateFormatSymbolType type, int32_t symbolIndex, - UChar *result, int32_t resultLength, UErrorCode *status) -{ - MOZ_CRASH("udat_getSymbols: Intl API disabled"); -} - -#endif - - /******************** Common to Intl constructors ********************/ static bool @@ -706,7 +107,6 @@ intl_availableLocales(JSContext* cx, CountAvailable countAvailable, if (!locales) return false; -#if ENABLE_INTL_API uint32_t count = countAvailable(); RootedValue t(cx, BooleanValue(true)); for (uint32_t i = 0; i < count; i++) { @@ -726,7 +126,7 @@ intl_availableLocales(JSContext* cx, CountAvailable countAvailable, return false; } } -#endif + result.setObject(*locales); return true; } diff --git a/js/src/builtin/Intl.h b/js/src/builtin/Intl.h index b2197060d..9a1e44913 100644 --- a/js/src/builtin/Intl.h +++ b/js/src/builtin/Intl.h @@ -16,9 +16,7 @@ #include "js/GCAPI.h" #include "js/GCHashTable.h" -#if ENABLE_INTL_API #include "unicode/utypes.h" -#endif /* * The Intl module specified by standard ECMA-402, @@ -429,7 +427,6 @@ intl_GetCalendarInfo(JSContext* cx, unsigned argc, Value* vp); extern MOZ_MUST_USE bool intl_ComputeDisplayNames(JSContext* cx, unsigned argc, Value* vp); -#if ENABLE_INTL_API /** * Cast char16_t* strings to UChar* strings used by ICU. */ @@ -456,7 +453,6 @@ UCharToChar16(const UChar* chars) { return reinterpret_cast<const char16_t*>(chars); } -#endif // ENABLE_INTL_API } // namespace js diff --git a/js/src/builtin/Intl.js b/js/src/builtin/Intl.js index 509168d7a..6391c3e70 100644 --- a/js/src/builtin/Intl.js +++ b/js/src/builtin/Intl.js @@ -9,7 +9,8 @@ JSMSG_INVALID_OPTION_VALUE: false, JSMSG_INVALID_DIGITS_VALUE: false, JSMSG_INTL_OBJECT_REINITED: false, JSMSG_INVALID_CURRENCY_CODE: false, JSMSG_UNDEFINED_CURRENCY: false, JSMSG_INVALID_TIME_ZONE: false, - JSMSG_DATE_NOT_FINITE: false, + JSMSG_DATE_NOT_FINITE: false, JSMSG_INVALID_KEYS_TYPE: false, + JSMSG_INVALID_KEY: false, intl_Collator_availableLocales: false, intl_availableCollations: false, intl_CompareStrings: false, @@ -3024,3 +3025,126 @@ function Intl_getCalendarInfo(locales) { return result; } + +/** + * This function is a custom method designed after Intl API, but currently + * not part of the spec or spec proposal. + * We want to use it internally to retrieve translated values from CLDR in + * order to ensure they're aligned with what Intl API returns. + * + * This API may one day be a foundation for an ECMA402 API spec proposal. + * + * The function takes two arguments - locales which is a list of locale strings + * and options which is an object with two optional properties: + * + * keys: + * an Array of string values that are paths to individual terms + * + * style: + * a String with a value "long", "short" or "narrow" + * + * It returns an object with properties: + * + * locale: + * a negotiated locale string + * + * style: + * negotiated style + * + * values: + * A key-value pair list of requested keys and corresponding + * translated values + * + */ +function Intl_getDisplayNames(locales, options) { + // 1. Let requestLocales be ? CanonicalizeLocaleList(locales). + const requestedLocales = CanonicalizeLocaleList(locales); + + // 2. If options is undefined, then + if (options === undefined) + // a. Let options be ObjectCreate(%ObjectPrototype%). + options = {}; + // 3. Else, + else + // a. Let options be ? ToObject(options). + options = ToObject(options); + + const DateTimeFormat = dateTimeFormatInternalProperties; + + // 4. Let localeData be %DateTimeFormat%.[[localeData]]. + const localeData = DateTimeFormat.localeData; + + // 5. Let opt be a new Record. + const localeOpt = new Record(); + // 6. Set localeOpt.[[localeMatcher]] to "best fit". + localeOpt.localeMatcher = "best fit"; + + // 7. Let r be ResolveLocale(%DateTimeFormat%.[[availableLocales]], requestedLocales, localeOpt, + // %DateTimeFormat%.[[relevantExtensionKeys]], localeData). + const r = ResolveLocale(callFunction(DateTimeFormat.availableLocales, DateTimeFormat), + requestedLocales, + localeOpt, + DateTimeFormat.relevantExtensionKeys, + localeData); + + // 8. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow" », "long"). + const style = GetOption(options, "style", "string", ["long", "short", "narrow"], "long"); + // 9. Let keys be ? Get(options, "keys"). + let keys = options.keys; + + // 10. If keys is undefined, + if (keys === undefined) { + // a. Let keys be ArrayCreate(0). + keys = []; + } else if (!IsObject(keys)) { + // 11. Else, + // a. If Type(keys) is not Object, throw a TypeError exception. + ThrowTypeError(JSMSG_INVALID_KEYS_TYPE); + } + + // 12. Let processedKeys be ArrayCreate(0). + // (This really should be a List, but we use an Array here in order that + // |intl_ComputeDisplayNames| may infallibly access the list's length via + // |ArrayObject::length|.) + let processedKeys = []; + // 13. Let len be ? ToLength(? Get(keys, "length")). + let len = ToLength(keys.length); + // 14. Let i be 0. + // 15. Repeat, while i < len + for (let i = 0; i < len; i++) { + // a. Let processedKey be ? ToString(? Get(keys, i)). + // b. Perform ? CreateDataPropertyOrThrow(processedKeys, i, processedKey). + callFunction(std_Array_push, processedKeys, ToString(keys[i])); + } + + // 16. Let names be ? ComputeDisplayNames(r.[[locale]], style, processedKeys). + const names = intl_ComputeDisplayNames(r.locale, style, processedKeys); + + // 17. Let values be ObjectCreate(%ObjectPrototype%). + const values = {}; + + // 18. Set i to 0. + // 19. Repeat, while i < len + for (let i = 0; i < len; i++) { + // a. Let key be ? Get(processedKeys, i). + const key = processedKeys[i]; + // b. Let name be ? Get(names, i). + const name = names[i]; + // c. Assert: Type(name) is string. + assert(typeof name === "string", "unexpected non-string value"); + // d. Assert: the length of name is greater than zero. + assert(name.length > 0, "empty string value"); + // e. Perform ? DefinePropertyOrThrow(values, key, name). + _DefineDataProperty(values, key, name); + } + + // 20. Let options be ObjectCreate(%ObjectPrototype%). + // 21. Perform ! DefinePropertyOrThrow(result, "locale", r.[[locale]]). + // 22. Perform ! DefinePropertyOrThrow(result, "style", style). + // 23. Perform ! DefinePropertyOrThrow(result, "values", values). + const result = { locale: r.locale, style, values }; + + // 24. Return result. + return result; + +} diff --git a/js/src/builtin/String.js b/js/src/builtin/String.js index 4202d0de6..6d1d335a0 100644 --- a/js/src/builtin/String.js +++ b/js/src/builtin/String.js @@ -659,11 +659,7 @@ function String_static_localeCompare(str1, str2) { ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "String.localeCompare"); var locales = arguments.length > 2 ? arguments[2] : undefined; var options = arguments.length > 3 ? arguments[3] : undefined; -#if EXPOSE_INTL_API return callFunction(String_localeCompare, str1, str2, locales, options); -#else - return callFunction(std_String_localeCompare, str1, str2, locales, options); -#endif } // ES6 draft 2014-04-27 B.2.3.3 @@ -855,14 +851,12 @@ function String_static_toLocaleUpperCase(string) { return callFunction(std_String_toLocaleUpperCase, string); } -#if EXPOSE_INTL_API function String_static_normalize(string) { if (arguments.length < 1) ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, 'String.normalize'); var form = arguments.length > 1 ? arguments[1] : undefined; return callFunction(std_String_normalize, string, form); } -#endif function String_static_concat(string, arg1) { if (arguments.length < 1) diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index a14f9ba69..00637a7a5 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -236,11 +236,7 @@ GetBuildConfiguration(JSContext* cx, unsigned argc, Value* vp) if (!JS_SetProperty(cx, info, "binary-data", value)) return false; -#ifdef EXPOSE_INTL_API value = BooleanValue(true); -#else - value = BooleanValue(false); -#endif if (!JS_SetProperty(cx, info, "intl-api", value)) return false; diff --git a/js/src/builtin/TypedArray.js b/js/src/builtin/TypedArray.js index a2205dc92..a1934051d 100644 --- a/js/src/builtin/TypedArray.js +++ b/js/src/builtin/TypedArray.js @@ -1232,11 +1232,7 @@ function TypedArrayToLocaleString(locales = undefined, options = undefined) { // Steps 6-7. // Omit the 'if' clause in step 6, since typed arrays can't have undefined // or null elements. -#if EXPOSE_INTL_API var R = ToString(callContentFunction(firstElement.toLocaleString, firstElement, locales, options)); -#else - var R = ToString(callContentFunction(firstElement.toLocaleString, firstElement)); -#endif // Step 3 (reordered). // We don't (yet?) implement locale-dependent separators. @@ -1258,11 +1254,7 @@ function TypedArrayToLocaleString(locales = undefined, options = undefined) { // the error message. So despite bug 1079853, we can skip step 9.c. // Step 9.d. -#if EXPOSE_INTL_API R = ToString(callContentFunction(nextElement.toLocaleString, nextElement, locales, options)); -#else - R = ToString(callContentFunction(nextElement.toLocaleString, nextElement)); -#endif // Step 9.e. R = S + R; diff --git a/js/src/gdb/moz.build b/js/src/gdb/moz.build index 681f9807c..faa69eb7b 100644 --- a/js/src/gdb/moz.build +++ b/js/src/gdb/moz.build @@ -34,7 +34,7 @@ USE_LIBS += [ 'static:js', ] -if CONFIG['ENABLE_INTL_API'] and CONFIG['MOZ_ICU_DATA_ARCHIVE']: +if CONFIG['MOZ_ICU_DATA_ARCHIVE']: # The ICU libraries linked into libmozjs will not include the ICU data, # so link it directly. USE_LIBS += ['icudata'] diff --git a/js/src/jit/BaselineFrameInfo.h b/js/src/jit/BaselineFrameInfo.h index 13bf0358d..1691270ac 100644 --- a/js/src/jit/BaselineFrameInfo.h +++ b/js/src/jit/BaselineFrameInfo.h @@ -67,7 +67,7 @@ class StackValue union { struct { - Value v; + JS::UninitializedValue v; } constant; struct { mozilla::AlignedStorage2<ValueOperand> reg; @@ -112,7 +112,7 @@ class StackValue } Value constant() const { MOZ_ASSERT(kind_ == Constant); - return data.constant.v; + return data.constant.v.asValueRef(); } ValueOperand reg() const { MOZ_ASSERT(kind_ == Register); diff --git a/js/src/jit/RegisterSets.h b/js/src/jit/RegisterSets.h index 0a4045dd7..08ae53f16 100644 --- a/js/src/jit/RegisterSets.h +++ b/js/src/jit/RegisterSets.h @@ -226,13 +226,13 @@ class ConstantOrRegister // Space to hold either a Value or a TypedOrValueRegister. union U { - Value constant; + JS::UninitializedValue constant; TypedOrValueRegister reg; } data; - const Value& dataValue() const { + Value dataValue() const { MOZ_ASSERT(constant()); - return data.constant; + return data.constant.asValueRef(); } void setDataValue(const Value& value) { MOZ_ASSERT(constant()); @@ -268,7 +268,7 @@ class ConstantOrRegister return constant_; } - const Value& value() const { + Value value() const { return dataValue(); } diff --git a/js/src/jit/RematerializedFrame.cpp b/js/src/jit/RematerializedFrame.cpp index cb324220c..32fad1267 100644 --- a/js/src/jit/RematerializedFrame.cpp +++ b/js/src/jit/RematerializedFrame.cpp @@ -61,9 +61,17 @@ RematerializedFrame::New(JSContext* cx, uint8_t* top, InlineFrameIterator& iter, { unsigned numFormals = iter.isFunctionFrame() ? iter.calleeTemplate()->nargs() : 0; unsigned argSlots = Max(numFormals, iter.numActualArgs()); - size_t numBytes = sizeof(RematerializedFrame) + - (argSlots + iter.script()->nfixed()) * sizeof(Value) - - sizeof(Value); // 1 Value included in sizeof(RematerializedFrame) + unsigned extraSlots = argSlots + iter.script()->nfixed(); + + // One Value slot is included in sizeof(RematerializedFrame), so we can + // reduce the extra slot count by one. However, if there are zero slot + // allocations total, then reducing the slots by one will lead to + // the memory allocation being smaller than sizeof(RematerializedFrame). + if (extraSlots > 0) + extraSlots -= 1; + + size_t numBytes = sizeof(RematerializedFrame) + (extraSlots * sizeof(Value)); + MOZ_ASSERT(numBytes >= sizeof(RematerializedFrame)); void* buf = cx->pod_calloc<uint8_t>(numBytes); if (!buf) diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build index f7a6080aa..277a145b0 100644 --- a/js/src/jsapi-tests/moz.build +++ b/js/src/jsapi-tests/moz.build @@ -135,7 +135,7 @@ LOCAL_INCLUDES += [ '..', ] -if CONFIG['ENABLE_INTL_API'] and CONFIG['MOZ_ICU_DATA_ARCHIVE']: +if CONFIG['MOZ_ICU_DATA_ARCHIVE']: # The ICU libraries linked into libmozjs will not include the ICU data, # so link it directly. USE_LIBS += ['icudata'] diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 989abe47c..c1195cc00 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -5222,7 +5222,7 @@ JS_ResetDefaultLocale(JSContext* cx); struct JSLocaleCallbacks { JSLocaleToUpperCase localeToUpperCase; JSLocaleToLowerCase localeToLowerCase; - JSLocaleCompare localeCompare; // not used #if EXPOSE_INTL_API + JSLocaleCompare localeCompare; // not used JSLocaleToUnicode localeToUnicode; }; diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index 00a8abf84..52294a5df 100755 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -2743,77 +2743,6 @@ ToLocaleFormatHelper(JSContext* cx, HandleObject obj, const char* format, Mutabl return true; } -#if !EXPOSE_INTL_API -/* ES5 15.9.5.5. */ -MOZ_ALWAYS_INLINE bool -date_toLocaleString_impl(JSContext* cx, const CallArgs& args) -{ - /* - * Use '%#c' for windows, because '%c' is backward-compatible and non-y2k - * with msvc; '%#c' requests that a full year be used in the result string. - */ - static const char format[] = -#if defined(_WIN32) && !defined(__MWERKS__) - "%#c" -#else - "%c" -#endif - ; - - Rooted<DateObject*> dateObj(cx, &args.thisv().toObject().as<DateObject>()); - return ToLocaleFormatHelper(cx, dateObj, format, args.rval()); -} - -static bool -date_toLocaleString(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - return CallNonGenericMethod<IsDate, date_toLocaleString_impl>(cx, args); -} - -/* ES5 15.9.5.6. */ -MOZ_ALWAYS_INLINE bool -date_toLocaleDateString_impl(JSContext* cx, const CallArgs& args) -{ - /* - * Use '%#x' for windows, because '%x' is backward-compatible and non-y2k - * with msvc; '%#x' requests that a full year be used in the result string. - */ - static const char format[] = -#if defined(_WIN32) && !defined(__MWERKS__) - "%#x" -#else - "%x" -#endif - ; - - Rooted<DateObject*> dateObj(cx, &args.thisv().toObject().as<DateObject>()); - return ToLocaleFormatHelper(cx, dateObj, format, args.rval()); -} - -static bool -date_toLocaleDateString(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - return CallNonGenericMethod<IsDate, date_toLocaleDateString_impl>(cx, args); -} - -/* ES5 15.9.5.7. */ -MOZ_ALWAYS_INLINE bool -date_toLocaleTimeString_impl(JSContext* cx, const CallArgs& args) -{ - Rooted<DateObject*> dateObj(cx, &args.thisv().toObject().as<DateObject>()); - return ToLocaleFormatHelper(cx, dateObj, "%X", args.rval()); -} - -static bool -date_toLocaleTimeString(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - return CallNonGenericMethod<IsDate, date_toLocaleTimeString_impl>(cx, args); -} -#endif /* !EXPOSE_INTL_API */ - MOZ_ALWAYS_INLINE bool date_toLocaleFormat_impl(JSContext* cx, const CallArgs& args) { @@ -3037,15 +2966,9 @@ static const JSFunctionSpec date_methods[] = { JS_FN("setUTCMilliseconds", date_setUTCMilliseconds, 1,0), JS_FN("toUTCString", date_toGMTString, 0,0), JS_FN("toLocaleFormat", date_toLocaleFormat, 0,0), -#if EXPOSE_INTL_API JS_SELF_HOSTED_FN(js_toLocaleString_str, "Date_toLocaleString", 0,0), JS_SELF_HOSTED_FN("toLocaleDateString", "Date_toLocaleDateString", 0,0), JS_SELF_HOSTED_FN("toLocaleTimeString", "Date_toLocaleTimeString", 0,0), -#else - JS_FN(js_toLocaleString_str, date_toLocaleString, 0,0), - JS_FN("toLocaleDateString", date_toLocaleDateString, 0,0), - JS_FN("toLocaleTimeString", date_toLocaleTimeString, 0,0), -#endif JS_FN("toDateString", date_toDateString, 0,0), JS_FN("toTimeString", date_toTimeString, 0,0), JS_FN("toISOString", date_toISOString, 0,0), diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index 8885737f7..28ed15159 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -724,141 +724,6 @@ js::num_toString(JSContext* cx, unsigned argc, Value* vp) return CallNonGenericMethod<IsNumber, num_toString_impl>(cx, args); } -#if !EXPOSE_INTL_API -MOZ_ALWAYS_INLINE bool -num_toLocaleString_impl(JSContext* cx, const CallArgs& args) -{ - MOZ_ASSERT(IsNumber(args.thisv())); - - double d = Extract(args.thisv()); - - RootedString str(cx, NumberToStringWithBase<CanGC>(cx, d, 10)); - if (!str) { - JS_ReportOutOfMemory(cx); - return false; - } - - /* - * Create the string, move back to bytes to make string twiddling - * a bit easier and so we can insert platform charset seperators. - */ - JSAutoByteString numBytes(cx, str); - if (!numBytes) - return false; - const char* num = numBytes.ptr(); - if (!num) - return false; - - /* - * Find the first non-integer value, whether it be a letter as in - * 'Infinity', a decimal point, or an 'e' from exponential notation. - */ - const char* nint = num; - if (*nint == '-') - nint++; - while (*nint >= '0' && *nint <= '9') - nint++; - int digits = nint - num; - const char* end = num + digits; - if (!digits) { - args.rval().setString(str); - return true; - } - - JSRuntime* rt = cx->runtime(); - size_t thousandsLength = strlen(rt->thousandsSeparator); - size_t decimalLength = strlen(rt->decimalSeparator); - - /* Figure out how long resulting string will be. */ - int buflen = strlen(num); - if (*nint == '.') - buflen += decimalLength - 1; /* -1 to account for existing '.' */ - - const char* numGrouping; - const char* tmpGroup; - numGrouping = tmpGroup = rt->numGrouping; - int remainder = digits; - if (*num == '-') - remainder--; - - while (*tmpGroup != CHAR_MAX && *tmpGroup != '\0') { - if (*tmpGroup >= remainder) - break; - buflen += thousandsLength; - remainder -= *tmpGroup; - tmpGroup++; - } - - int nrepeat; - if (*tmpGroup == '\0' && *numGrouping != '\0') { - nrepeat = (remainder - 1) / tmpGroup[-1]; - buflen += thousandsLength * nrepeat; - remainder -= nrepeat * tmpGroup[-1]; - } else { - nrepeat = 0; - } - tmpGroup--; - - char* buf = cx->pod_malloc<char>(buflen + 1); - if (!buf) - return false; - - char* tmpDest = buf; - const char* tmpSrc = num; - - while (*tmpSrc == '-' || remainder--) { - MOZ_ASSERT(tmpDest - buf < buflen); - *tmpDest++ = *tmpSrc++; - } - while (tmpSrc < end) { - MOZ_ASSERT(tmpDest - buf + ptrdiff_t(thousandsLength) <= buflen); - strcpy(tmpDest, rt->thousandsSeparator); - tmpDest += thousandsLength; - MOZ_ASSERT(tmpDest - buf + *tmpGroup <= buflen); - js_memcpy(tmpDest, tmpSrc, *tmpGroup); - tmpDest += *tmpGroup; - tmpSrc += *tmpGroup; - if (--nrepeat < 0) - tmpGroup--; - } - - if (*nint == '.') { - MOZ_ASSERT(tmpDest - buf + ptrdiff_t(decimalLength) <= buflen); - strcpy(tmpDest, rt->decimalSeparator); - tmpDest += decimalLength; - MOZ_ASSERT(tmpDest - buf + ptrdiff_t(strlen(nint + 1)) <= buflen); - strcpy(tmpDest, nint + 1); - } else { - MOZ_ASSERT(tmpDest - buf + ptrdiff_t(strlen(nint)) <= buflen); - strcpy(tmpDest, nint); - } - - if (cx->runtime()->localeCallbacks && cx->runtime()->localeCallbacks->localeToUnicode) { - Rooted<Value> v(cx, StringValue(str)); - bool ok = !!cx->runtime()->localeCallbacks->localeToUnicode(cx, buf, &v); - if (ok) - args.rval().set(v); - js_free(buf); - return ok; - } - - str = NewStringCopyN<CanGC>(cx, buf, buflen); - js_free(buf); - if (!str) - return false; - - args.rval().setString(str); - return true; -} - -static bool -num_toLocaleString(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - return CallNonGenericMethod<IsNumber, num_toLocaleString_impl>(cx, args); -} -#endif /* !EXPOSE_INTL_API */ - MOZ_ALWAYS_INLINE bool num_valueOf_impl(JSContext* cx, const CallArgs& args) { @@ -1075,11 +940,7 @@ static const JSFunctionSpec number_methods[] = { JS_FN(js_toSource_str, num_toSource, 0, 0), #endif JS_FN(js_toString_str, num_toString, 1, 0), -#if EXPOSE_INTL_API JS_SELF_HOSTED_FN(js_toLocaleString_str, "Number_toLocaleString", 0,0), -#else - JS_FN(js_toLocaleString_str, num_toLocaleString, 0,0), -#endif JS_FN(js_valueOf_str, num_valueOf, 0, 0), JS_FN("toFixed", num_toFixed, 1, 0), JS_FN("toExponential", num_toExponential, 1, 0), @@ -1130,76 +991,11 @@ js::FIX_FPU() #endif } -bool +void js::InitRuntimeNumberState(JSRuntime* rt) { FIX_FPU(); - - // XXX If EXPOSE_INTL_API becomes true all the time at some point, - // js::InitRuntimeNumberState is no longer fallible, and we should - // change its return type. -#if !EXPOSE_INTL_API - /* Copy locale-specific separators into the runtime strings. */ - const char* thousandsSeparator; - const char* decimalPoint; - const char* grouping; -#ifdef HAVE_LOCALECONV - struct lconv* locale = localeconv(); - thousandsSeparator = locale->thousands_sep; - decimalPoint = locale->decimal_point; - grouping = locale->grouping; -#else - thousandsSeparator = getenv("LOCALE_THOUSANDS_SEP"); - decimalPoint = getenv("LOCALE_DECIMAL_POINT"); - grouping = getenv("LOCALE_GROUPING"); -#endif - if (!thousandsSeparator) - thousandsSeparator = "'"; - if (!decimalPoint) - decimalPoint = "."; - if (!grouping) - grouping = "\3\0"; - - /* - * We use single malloc to get the memory for all separator and grouping - * strings. - */ - size_t thousandsSeparatorSize = strlen(thousandsSeparator) + 1; - size_t decimalPointSize = strlen(decimalPoint) + 1; - size_t groupingSize = strlen(grouping) + 1; - - char* storage = js_pod_malloc<char>(thousandsSeparatorSize + - decimalPointSize + - groupingSize); - if (!storage) - return false; - - js_memcpy(storage, thousandsSeparator, thousandsSeparatorSize); - rt->thousandsSeparator = storage; - storage += thousandsSeparatorSize; - - js_memcpy(storage, decimalPoint, decimalPointSize); - rt->decimalSeparator = storage; - storage += decimalPointSize; - - js_memcpy(storage, grouping, groupingSize); - rt->numGrouping = grouping; -#endif /* !EXPOSE_INTL_API */ - return true; -} - -#if !EXPOSE_INTL_API -void -js::FinishRuntimeNumberState(JSRuntime* rt) -{ - /* - * The free also releases the memory for decimalSeparator and numGrouping - * strings. - */ - char* storage = const_cast<char*>(rt->thousandsSeparator); - js_free(storage); } -#endif JSObject* js::InitNumberClass(JSContext* cx, HandleObject obj) diff --git a/js/src/jsnum.h b/js/src/jsnum.h index 62b3d617f..8dff45f69 100644 --- a/js/src/jsnum.h +++ b/js/src/jsnum.h @@ -34,13 +34,7 @@ namespace js { class StringBuffer; -extern MOZ_MUST_USE bool -InitRuntimeNumberState(JSRuntime* rt); - -#if !EXPOSE_INTL_API -extern void -FinishRuntimeNumberState(JSRuntime* rt); -#endif +void InitRuntimeNumberState(JSRuntime* rt); /* Initialize the Number class, returning its prototype object. */ extern JSObject* diff --git a/js/src/jsprototypes.h b/js/src/jsprototypes.h index f409dce95..dc7cdb85a 100644 --- a/js/src/jsprototypes.h +++ b/js/src/jsprototypes.h @@ -37,11 +37,7 @@ #define TYPED_ARRAY_CLASP(type) (&TypedArrayObject::classes[Scalar::type]) #define ERROR_CLASP(type) (&ErrorObject::classes[type]) -#ifdef EXPOSE_INTL_API #define IF_INTL(real,imaginary) real -#else -#define IF_INTL(real,imaginary) imaginary -#endif #ifdef ENABLE_BINARYDATA #define IF_BDATA(real,imaginary) real diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 7adeed620..01b407626 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -36,9 +36,7 @@ #include "jit/InlinableNatives.h" #include "js/Conversions.h" #include "js/UniquePtr.h" -#if ENABLE_INTL_API #include "unicode/unorm.h" -#endif #include "vm/GlobalObject.h" #include "vm/Interpreter.h" #include "vm/Opcodes.h" @@ -899,38 +897,6 @@ js::str_toLocaleUpperCase(JSContext* cx, unsigned argc, Value* vp) return ToUpperCaseHelper(cx, args); } -#if !EXPOSE_INTL_API -bool -js::str_localeCompare(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - RootedString str(cx, ToStringForStringFunction(cx, args.thisv())); - if (!str) - return false; - - RootedString thatStr(cx, ToString<CanGC>(cx, args.get(0))); - if (!thatStr) - return false; - - if (cx->runtime()->localeCallbacks && cx->runtime()->localeCallbacks->localeCompare) { - RootedValue result(cx); - if (!cx->runtime()->localeCallbacks->localeCompare(cx, str, thatStr, &result)) - return false; - - args.rval().set(result); - return true; - } - - int32_t result; - if (!CompareStrings(cx, str, thatStr, &result)) - return false; - - args.rval().setInt32(result); - return true; -} -#endif - -#if EXPOSE_INTL_API /* ES6 20140210 draft 21.1.3.12. */ bool js::str_normalize(JSContext* cx, unsigned argc, Value* vp) @@ -1007,7 +973,6 @@ js::str_normalize(JSContext* cx, unsigned argc, Value* vp) args.rval().setString(ns); return true; } -#endif bool js::str_charAt(JSContext* cx, unsigned argc, Value* vp) @@ -2599,15 +2564,9 @@ static const JSFunctionSpec string_methods[] = { JS_FN("trimRight", str_trimRight, 0,0), JS_FN("toLocaleLowerCase", str_toLocaleLowerCase, 0,0), JS_FN("toLocaleUpperCase", str_toLocaleUpperCase, 0,0), -#if EXPOSE_INTL_API JS_SELF_HOSTED_FN("localeCompare", "String_localeCompare", 1,0), -#else - JS_FN("localeCompare", str_localeCompare, 1,0), -#endif JS_SELF_HOSTED_FN("repeat", "String_repeat", 1,0), -#if EXPOSE_INTL_API JS_FN("normalize", str_normalize, 0,0), -#endif /* Perl-ish methods (search is actually Python-esque). */ JS_SELF_HOSTED_FN("match", "String_match", 1,0), @@ -2918,9 +2877,7 @@ static const JSFunctionSpec string_static_methods[] = { JS_SELF_HOSTED_FN("trimRight", "String_static_trimRight", 1,0), JS_SELF_HOSTED_FN("toLocaleLowerCase","String_static_toLocaleLowerCase",1,0), JS_SELF_HOSTED_FN("toLocaleUpperCase","String_static_toLocaleUpperCase",1,0), -#if EXPOSE_INTL_API JS_SELF_HOSTED_FN("normalize", "String_static_normalize", 1,0), -#endif JS_SELF_HOSTED_FN("concat", "String_static_concat", 2,0), JS_SELF_HOSTED_FN("localeCompare", "String_static_localeCompare", 2,0), diff --git a/js/src/jsstr.h b/js/src/jsstr.h index 3b92aa21b..118118839 100644 --- a/js/src/jsstr.h +++ b/js/src/jsstr.h @@ -9,6 +9,7 @@ #include "mozilla/HashFunctions.h" #include "mozilla/PodOperations.h" +#include "mozilla/TextUtils.h" #include <stdio.h> @@ -95,7 +96,7 @@ struct JSSubString { #define JS7_UNOCT(c) (JS7_UNDEC(c)) #define JS7_ISHEX(c) ((c) < 128 && isxdigit(c)) #define JS7_UNHEX(c) (unsigned)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a') -#define JS7_ISLET(c) ((c) < 128 && isalpha(c)) +#define JS7_ISLET(c) (mozilla::IsAsciiAlpha(c)) extern size_t js_strlen(const char16_t* s); @@ -377,13 +378,8 @@ str_toLocaleLowerCase(JSContext* cx, unsigned argc, Value* vp); extern bool str_toLocaleUpperCase(JSContext* cx, unsigned argc, Value* vp); -#if !EXPOSE_INTL_API -extern bool -str_localeCompare(JSContext* cx, unsigned argc, Value* vp); -#else extern bool str_normalize(JSContext* cx, unsigned argc, Value* vp); -#endif extern bool str_concat(JSContext* cx, unsigned argc, Value* vp); diff --git a/js/src/make-source-package.sh b/js/src/make-source-package.sh index 6e44dd977..e6d3f6df5 100755 --- a/js/src/make-source-package.sh +++ b/js/src/make-source-package.sh @@ -151,7 +151,6 @@ case $cmd in ${TOPSRCDIR}/memory/moz.build \ ${TOPSRCDIR}/memory/build \ ${TOPSRCDIR}/memory/fallible \ - ${TOPSRCDIR}/memory/jemalloc \ ${TOPSRCDIR}/memory/mozalloc \ ${TOPSRCDIR}/memory/mozjemalloc \ ${tgtpath}/memory diff --git a/js/src/moz.build b/js/src/moz.build index 2d4e83db3..a3283b5d6 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -645,18 +645,17 @@ else: FORCE_STATIC_LIB = True STATIC_LIBRARY_NAME = 'js_static' -if CONFIG['ENABLE_INTL_API']: - if not CONFIG['MOZ_ICU_DATA_ARCHIVE']: - USE_LIBS += [ - 'icu', - ] - else: - # Linking 'icu' will pull in the stubdata library, - # which the shell doesn't want, so link the other bits. - USE_LIBS += [ - 'icui18n', - 'icuuc', - ] +if not CONFIG['MOZ_ICU_DATA_ARCHIVE']: + USE_LIBS += [ + 'icu', + ] +else: + # Linking 'icu' will pull in the stubdata library, + # which the shell doesn't want, so link the other bits. + USE_LIBS += [ + 'icui18n', + 'icuuc', + ] USE_LIBS += [ 'nspr', diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 1736cc5d4..8abea5956 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -734,12 +734,14 @@ case "$target" in dnl VS2012+ defaults to -arch:SSE2. We want to target nothing dnl more recent, so set that explicitly here unless another dnl target arch has already been set. + changequote(,) if test -z `echo $CFLAGS | grep -i [-/]arch:` ; then CFLAGS="$CFLAGS -arch:SSE2" - fi + fi if test -z `echo $CXXFLAGS | grep -i [-/]arch:` ; then CXXFLAGS="$CXXFLAGS -arch:SSE2" fi + changequote([,]) fi dnl VS2013+ requires -FS when parallel building by make -jN. dnl If nothing, compiler sometimes causes C1041 error. @@ -1534,6 +1536,14 @@ MOZ_ARG_ENABLE_STRING(ui-locale, AC_SUBST(MOZ_UI_LOCALE) dnl ======================================================== +dnl Build the tests? +dnl ======================================================== +MOZ_ARG_ENABLE_BOOL(tests, +[ --enable-tests Build test libraries & programs], + ENABLE_TESTS=1, + ENABLE_TESTS= ) + +dnl ======================================================== dnl = dnl = Module specific options dnl = @@ -2091,6 +2101,8 @@ AC_SUBST(MOZ_DEBUG_LDFLAGS) AC_SUBST(WARNINGS_AS_ERRORS) AC_SUBST(LIBICONV) +AC_SUBST(ENABLE_TESTS) + AC_SUBST(ENABLE_STRIP) AC_SUBST(PKG_SKIP_STRIP) AC_SUBST(INCREMENTAL_LINKER) @@ -2244,8 +2256,6 @@ AC_SUBST(JS_LIBRARY_NAME) AC_SUBST(JS_CONFIG_MOZ_JS_LIBS) AC_SUBST(JS_CONFIG_LIBS) -MOZ_SUBCONFIGURE_JEMALLOC() - # Avoid using obsolete NSPR features AC_DEFINE(NO_NSPR_10_SUPPORT) diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 8d69ca942..8d144417a 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -893,7 +893,6 @@ SetPromiseRejectionTrackerCallback(JSContext* cx, unsigned argc, Value* vp) return true; } -#ifdef ENABLE_INTL_API static bool AddIntlExtras(JSContext* cx, unsigned argc, Value* vp) { @@ -916,7 +915,6 @@ AddIntlExtras(JSContext* cx, unsigned argc, Value* vp) args.rval().setUndefined(); return true; } -#endif // ENABLE_INTL_API static bool EvalAndPrint(JSContext* cx, const char* bytes, size_t length, @@ -6140,7 +6138,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = { "Sets the callback to be invoked whenever a Promise rejection is unhandled\n" "or a previously-unhandled rejection becomes handled."), -#ifdef ENABLE_INTL_API JS_FN_HELP("addIntlExtras", AddIntlExtras, 1, 0, "addIntlExtras(obj)", "Adds various not-yet-standardized Intl functions as properties on the\n" @@ -6148,7 +6145,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = { "functions and their behavior are experimental: don't depend upon them\n" "unless you're willing to update your code if these experimental APIs change\n" "underneath you."), -#endif // ENABLE_INTL_API JS_FS_HELP_END }; diff --git a/js/src/shell/moz.build b/js/src/shell/moz.build index 72ea8145c..e18bad238 100644 --- a/js/src/shell/moz.build +++ b/js/src/shell/moz.build @@ -36,7 +36,7 @@ LOCAL_INCLUDES += [ OS_LIBS += CONFIG['EDITLINE_LIBS'] OS_LIBS += CONFIG['MOZ_ZLIB_LIBS'] -if CONFIG['ENABLE_INTL_API'] and CONFIG['MOZ_ICU_DATA_ARCHIVE']: +if CONFIG['MOZ_ICU_DATA_ARCHIVE']: # The ICU libraries linked into libmozjs will not include the ICU data, # so link it directly. USE_LIBS += ['icudata'] diff --git a/js/src/threading/windows/ConditionVariable.cpp b/js/src/threading/windows/ConditionVariable.cpp index 3c75a0f27..92e0249b7 100644 --- a/js/src/threading/windows/ConditionVariable.cpp +++ b/js/src/threading/windows/ConditionVariable.cpp @@ -54,8 +54,8 @@ js::ConditionVariable::notify_all() void js::ConditionVariable::wait(UniqueLock<Mutex>& lock) { - CRITICAL_SECTION* cs = &lock.lock.platformData()->criticalSection; - bool r = SleepConditionVariableCS(&platformData()->cv_, cs, INFINITE); + SRWLOCK* srwlock = &lock.lock.platformData()->lock; + bool r = SleepConditionVariableSRW(&platformData()->cv_, srwlock, INFINITE, 0); MOZ_RELEASE_ASSERT(r); } @@ -70,7 +70,7 @@ js::CVStatus js::ConditionVariable::wait_for(UniqueLock<Mutex>& lock, const mozilla::TimeDuration& rel_time) { - CRITICAL_SECTION* cs = &lock.lock.platformData()->criticalSection; + SRWLOCK* srwlock = &lock.lock.platformData()->lock; // Note that DWORD is unsigned, so we have to be careful to clamp at 0. // If rel_time is Forever, then ToMilliseconds is +inf, which evaluates as @@ -82,7 +82,7 @@ js::ConditionVariable::wait_for(UniqueLock<Mutex>& lock, ? INFINITE : static_cast<DWORD>(msecd); - BOOL r = SleepConditionVariableCS(&platformData()->cv_, cs, msec); + BOOL r = SleepConditionVariableSRW(&platformData()->cv_, srwlock, msec, 0); if (r) return CVStatus::NoTimeout; MOZ_RELEASE_ASSERT(GetLastError() == ERROR_TIMEOUT); diff --git a/js/src/threading/windows/MutexImpl.cpp b/js/src/threading/windows/MutexImpl.cpp index 385d1c8de..e838459b5 100644 --- a/js/src/threading/windows/MutexImpl.cpp +++ b/js/src/threading/windows/MutexImpl.cpp @@ -13,35 +13,6 @@ #include "threading/Mutex.h" #include "threading/windows/MutexPlatformData.h" -namespace { - -// We build with a toolkit that supports WinXP, so we have to probe -// for modern features at runtime. This is necessary because Vista and -// later automatically allocate and subsequently leak a debug info -// object for each critical section that we allocate unless we tell it -// not to. In order to tell it not to, we need the extra flags field -// provided by the Ex version of InitializeCriticalSection. -struct MutexNativeImports -{ - using InitializeCriticalSectionExT = BOOL (WINAPI*)(CRITICAL_SECTION*, DWORD, DWORD); - InitializeCriticalSectionExT InitializeCriticalSectionEx; - - MutexNativeImports() { - HMODULE kernel32_dll = GetModuleHandle("kernel32.dll"); - MOZ_RELEASE_ASSERT(kernel32_dll != NULL); - InitializeCriticalSectionEx = reinterpret_cast<InitializeCriticalSectionExT>( - GetProcAddress(kernel32_dll, "InitializeCriticalSectionEx")); - } - - bool hasInitializeCriticalSectionEx() const { - return InitializeCriticalSectionEx; - } -}; - -static MutexNativeImports NativeImports; - -} // (anonymous namespace) - js::detail::MutexImpl::MutexImpl() { AutoEnterOOMUnsafeRegion oom; @@ -49,18 +20,7 @@ js::detail::MutexImpl::MutexImpl() if (!platformData_) oom.crash("js::Mutex::Mutex"); - // This number was adopted from NSPR. - const static DWORD LockSpinCount = 1500; - BOOL r; - if (NativeImports.hasInitializeCriticalSectionEx()) { - r = NativeImports.InitializeCriticalSectionEx(&platformData()->criticalSection, - LockSpinCount, - CRITICAL_SECTION_NO_DEBUG_INFO); - } else { - r = InitializeCriticalSectionAndSpinCount(&platformData()->criticalSection, - LockSpinCount); - } - MOZ_RELEASE_ASSERT(r); + InitializeSRWLock(&platformData()->lock); } js::detail::MutexImpl::~MutexImpl() @@ -68,18 +28,17 @@ js::detail::MutexImpl::~MutexImpl() if (!platformData_) return; - DeleteCriticalSection(&platformData()->criticalSection); js_delete(platformData()); } void js::detail::MutexImpl::lock() { - EnterCriticalSection(&platformData()->criticalSection); + AcquireSRWLockExclusive(&platformData()->lock); } void js::detail::MutexImpl::unlock() { - LeaveCriticalSection(&platformData()->criticalSection); + ReleaseSRWLockExclusive(&platformData()->lock); } diff --git a/js/src/threading/windows/MutexPlatformData.h b/js/src/threading/windows/MutexPlatformData.h index fbe7fc80d..1d741c5d0 100644 --- a/js/src/threading/windows/MutexPlatformData.h +++ b/js/src/threading/windows/MutexPlatformData.h @@ -13,7 +13,7 @@ struct js::detail::MutexImpl::PlatformData { - CRITICAL_SECTION criticalSection; + SRWLOCK lock; }; #endif // platform_win_MutexPlatformData_h diff --git a/js/src/vm/DateTime.cpp b/js/src/vm/DateTime.cpp index e35ad4285..ba3145af2 100644 --- a/js/src/vm/DateTime.cpp +++ b/js/src/vm/DateTime.cpp @@ -13,9 +13,7 @@ #include "jsutil.h" #include "js/Date.h" -#if ENABLE_INTL_API #include "unicode/timezone.h" -#endif using mozilla::Atomic; using mozilla::ReleaseAcquire; @@ -333,7 +331,7 @@ JS::ResetTimeZone() { js::DateTimeInfo::updateTimeZoneAdjustment(); -#if ENABLE_INTL_API && defined(ICU_TZ_HAS_RECREATE_DEFAULT) +#if defined(ICU_TZ_HAS_RECREATE_DEFAULT) TZInfo.acquire(); TZInfo.status = IcuTimeZoneInfo::NeedsUpdate; TZInfo.release(); @@ -343,7 +341,7 @@ JS::ResetTimeZone() void js::ResyncICUDefaultTimeZone() { -#if ENABLE_INTL_API && defined(ICU_TZ_HAS_RECREATE_DEFAULT) +#if defined(ICU_TZ_HAS_RECREATE_DEFAULT) TZInfo.acquire(); if (TZInfo.status == IcuTimeZoneInfo::NeedsUpdate) { icu::TimeZone::recreateDefault(); diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 280548cd6..c90b6b85f 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -17,9 +17,7 @@ #include "builtin/AtomicsObject.h" #include "builtin/Eval.h" -#if EXPOSE_INTL_API -# include "builtin/Intl.h" -#endif +#include "builtin/Intl.h" #include "builtin/MapObject.h" #include "builtin/ModuleObject.h" #include "builtin/Object.h" diff --git a/js/src/vm/Initialization.cpp b/js/src/vm/Initialization.cpp index 05cc087cc..39acdf9a8 100644 --- a/js/src/vm/Initialization.cpp +++ b/js/src/vm/Initialization.cpp @@ -20,10 +20,8 @@ #include "jit/ExecutableAllocator.h" #include "jit/Ion.h" #include "js/Utility.h" -#if ENABLE_INTL_API #include "unicode/uclean.h" #include "unicode/utypes.h" -#endif // ENABLE_INTL_API #include "vm/DateTime.h" #include "vm/HelperThreads.h" #include "vm/Runtime.h" @@ -113,12 +111,10 @@ JS::detail::InitWithFailureDiagnostic(bool isDebugBuild) js::DateTimeInfo::init(); -#if EXPOSE_INTL_API UErrorCode err = U_ZERO_ERROR; u_init(&err); if (U_FAILURE(err)) return "u_init() failed"; -#endif // EXPOSE_INTL_API RETURN_IF_FAIL(js::CreateHelperThreadsState()); RETURN_IF_FAIL(FutexRuntime::initialize()); @@ -171,9 +167,7 @@ JS_ShutDown(void) // to do it only when PRMJ_Now is eventually called. PRMJ_NowShutdown(); -#if EXPOSE_INTL_API u_cleanup(); -#endif // EXPOSE_INTL_API if (!JSRuntime::hasLiveRuntimes()) js::jit::ReleaseProcessExecutableMemory(); @@ -188,11 +182,7 @@ JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn, JS_ICUReallocFn reallocFn, JS_IC "must call JS_SetICUMemoryFunctions before any other JSAPI " "operation (including JS_Init)"); -#if EXPOSE_INTL_API UErrorCode status = U_ZERO_ERROR; u_setMemoryFunctions(/* context = */ nullptr, allocFn, reallocFn, freeFn, &status); return U_SUCCESS(status); -#else - return true; -#endif } diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 0d6a3922c..174e23594 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -213,11 +213,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime) warningReporter(nullptr), buildIdOp(nullptr), propertyRemovals(0), -#if !EXPOSE_INTL_API - thousandsSeparator(0), - decimalSeparator(0), - numGrouping(0), -#endif keepAtoms_(0), trustedPrincipals_(nullptr), beingDestroyed_(false), @@ -330,8 +325,7 @@ JSRuntime::init(uint32_t maxbytes, uint32_t maxNurseryBytes) /* The garbage collector depends on everything before this point being initialized. */ gcInitialized = true; - if (!InitRuntimeNumberState(this)) - return false; + InitRuntimeNumberState(this); JS::ResetTimeZone(); @@ -425,10 +419,6 @@ JSRuntime::destroyRuntime() */ FreeScriptData(this, lock); -#if !EXPOSE_INTL_API - FinishRuntimeNumberState(this); -#endif - gc.finish(); atomsCompartment_ = nullptr; diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index 734543c4e..735adadf2 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -978,13 +978,6 @@ struct JSRuntime : public JS::shadow::Runtime, */ uint32_t propertyRemovals; -#if !EXPOSE_INTL_API - /* Number localization, used by jsnum.cpp. */ - const char* thousandsSeparator; - const char* decimalSeparator; - const char* numGrouping; -#endif - private: mozilla::Maybe<js::SharedImmutableStringsCache> sharedImmutableStrings_; diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 9a8ec7679..653807ce8 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -2205,11 +2205,7 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("std_String_trimRight", str_trimRight, 0,0), JS_FN("std_String_toLocaleLowerCase", str_toLocaleLowerCase, 0,0), JS_FN("std_String_toLocaleUpperCase", str_toLocaleUpperCase, 0,0), -#if !EXPOSE_INTL_API - JS_FN("std_String_localeCompare", str_localeCompare, 1,0), -#else JS_FN("std_String_normalize", str_normalize, 0,0), -#endif JS_FN("std_String_concat", str_concat, 1,0), JS_FN("std_TypedArray_buffer", js::TypedArray_bufferGetter, 1,0), diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp index b4f41c3d5..7fade24fb 100644 --- a/js/src/wasm/AsmJS.cpp +++ b/js/src/wasm/AsmJS.cpp @@ -857,7 +857,7 @@ class NumLit private: Which which_; union { - Value scalar_; + JS::UninitializedValue scalar_; SimdConstant simd_; } u; @@ -880,7 +880,7 @@ class NumLit int32_t toInt32() const { MOZ_ASSERT(which_ == Fixnum || which_ == NegativeInt || which_ == BigUnsigned); - return u.scalar_.toInt32(); + return u.scalar_.asValueRef().toInt32(); } uint32_t toUint32() const { @@ -889,17 +889,17 @@ class NumLit RawF64 toDouble() const { MOZ_ASSERT(which_ == Double); - return RawF64(u.scalar_.toDouble()); + return RawF64(u.scalar_.asValueRef().toDouble()); } RawF32 toFloat() const { MOZ_ASSERT(which_ == Float); - return RawF32(float(u.scalar_.toDouble())); + return RawF32(float(u.scalar_.asValueRef().toDouble())); } Value scalarValue() const { MOZ_ASSERT(which_ != OutOfRangeInt); - return u.scalar_; + return u.scalar_.asValueRef(); } bool isSimd() const diff --git a/js/xpconnect/shell/moz.build b/js/xpconnect/shell/moz.build index ecc796f7f..d4f5d55af 100644 --- a/js/xpconnect/shell/moz.build +++ b/js/xpconnect/shell/moz.build @@ -35,22 +35,6 @@ if CONFIG['_MSC_VER']: if CONFIG['OS_ARCH'] == 'WINNT': RCINCLUDE = 'xpcshell.rc' - if CONFIG['MOZ_SANDBOX']: - # For sandbox includes and the include dependencies those have - LOCAL_INCLUDES += [ - '/security/sandbox/chromium', - '/security/sandbox/chromium-shim', - ] - - USE_LIBS += [ - 'sandbox_s', - ] - - DELAYLOAD_DLLS += [ - 'winmm.dll', - 'user32.dll', - ] - DELAYLOAD_DLLS += [ 'xul.dll', ] diff --git a/js/xpconnect/shell/xpcshell.cpp b/js/xpconnect/shell/xpcshell.cpp index ba979bc69..4eef3f6bf 100644 --- a/js/xpconnect/shell/xpcshell.cpp +++ b/js/xpconnect/shell/xpcshell.cpp @@ -22,9 +22,6 @@ #define XRE_DONT_PROTECT_DLL_LOAD #define XRE_WANT_ENVIRON #include "nsWindowsWMain.cpp" -#ifdef MOZ_SANDBOX -#include "mozilla/sandboxing/SandboxInitialization.h" -#endif #endif #ifdef MOZ_WIDGET_GTK @@ -53,13 +50,7 @@ main(int argc, char** argv, char** envp) DllBlocklist_Initialize(); #endif - XREShellData shellData; -#if defined(XP_WIN) && defined(MOZ_SANDBOX) - shellData.sandboxBrokerServices = - mozilla::sandboxing::GetInitializedBrokerServices(); -#endif - - int result = XRE_XPCShellMain(argc, argv, envp, &shellData); + int result = XRE_XPCShellMain(argc, argv, envp); #ifdef XP_MACOSX FinishAutoreleasePool(); diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index f5f6a11bb..8862bca32 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -59,10 +59,6 @@ #include "nsIXULRuntime.h" #include "nsJSPrincipals.h" -#if defined(MOZ_JEMALLOC4) -#include "mozmemory.h" -#endif - #ifdef XP_WIN #include <windows.h> #endif @@ -147,18 +143,6 @@ public: mActive = false; } } else { -#if defined(MOZ_JEMALLOC4) - if (mPurge) { - /* Jemalloc purges dirty pages regularly during free() when the - * ratio of dirty pages compared to active pages is higher than - * 1 << lg_dirty_mult. A high ratio can have an impact on - * performance, so we use the default ratio of 8, but force a - * regular purge of all remaining dirty pages, after cycle - * collection. */ - Telemetry::AutoTimer<Telemetry::MEMORY_FREE_PURGED_PAGES_MS> timer; - jemalloc_free_dirty_pages(); - } -#endif mActive = false; } return NS_OK; diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 45d00d390..a6432856d 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -44,9 +44,6 @@ #ifdef XP_WIN #include "mozilla/widget/AudioSession.h" #include <windows.h> -#if defined(MOZ_SANDBOX) -#include "SandboxBroker.h" -#endif #endif // all this crap is needed to do the interactive shell stuff @@ -1235,11 +1232,8 @@ GetCurrentWorkingDirectory(nsAString& workingDirectory) static JSSecurityCallbacks shellSecurityCallbacks; int -XRE_XPCShellMain(int argc, char** argv, char** envp, - const XREShellData* aShellData) +XRE_XPCShellMain(int argc, char** argv, char** envp) { - MOZ_ASSERT(aShellData); - JSContext* cx; int result = 0; nsresult rv; @@ -1484,16 +1478,6 @@ XRE_XPCShellMain(int argc, char** argv, char** envp, // Plugin may require audio session if installed plugin can initialize // asynchronized. AutoAudioSession audioSession; - -#if defined(MOZ_SANDBOX) - // Required for sandboxed child processes. - if (aShellData->sandboxBrokerServices) { - SandboxBroker::Initialize(aShellData->sandboxBrokerServices); - } else { - NS_WARNING("Failed to initialize broker services, sandboxed " - "processes will fail to start."); - } -#endif #endif { diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index acf92f3c3..a12e36baa 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -1785,9 +1785,12 @@ CallMethodHelper::ConvertIndependentParam(uint8_t i) // indirectly, regardless of in/out-ness. if (type_tag == nsXPTType::T_JSVAL) { // Root the value. - dp->val.j.setUndefined(); - if (!js::AddRawValueRoot(mCallContext, &dp->val.j, "XPCWrappedNative::CallMethod param")) + dp->val.j.asValueRef().setUndefined(); + if (!js::AddRawValueRoot(mCallContext, &dp->val.j.asValueRef(), + "XPCWrappedNative::CallMethod param")) + { return false; + } } // Flag cleanup for anything that isn't self-contained. |