Bug 1437842: [Part 7] Convert IsDateTimeFormat to GuardToDateTimeFormat r=jandem
authorMatthew Gaudet <mgaudet@mozilla.com>
Mon, 23 Apr 2018 11:12:38 -0400
changeset 415825 bcbac9c78599b1e48b2e868ccb15c6b2d9bdd151
parent 415824 83ea97f7f8d3aca75d44c6818780cb3d42301d44
child 415826 8206293b20c04d052b270d38d2586270dbfddce4
push id33910
push usershindli@mozilla.com
push dateThu, 26 Apr 2018 21:39:52 +0000
treeherdermozilla-central@63a0e2f626fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1437842
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1437842: [Part 7] Convert IsDateTimeFormat to GuardToDateTimeFormat r=jandem
js/src/builtin/intl/CommonFunctions.js
js/src/builtin/intl/DateTimeFormat.js
js/src/jit/InlinableNatives.h
js/src/jit/MCallOptimize.cpp
js/src/vm/SelfHosting.cpp
--- a/js/src/builtin/intl/CommonFunctions.js
+++ b/js/src/builtin/intl/CommonFunctions.js
@@ -1440,17 +1440,17 @@ function intlFallbackSymbol() {
 }
 
 /**
  * Initializes the INTL_INTERNALS_OBJECT_SLOT of the given object.
  */
 function initializeIntlObject(obj, type, lazyData) {
     assert(IsObject(obj), "Non-object passed to initializeIntlObject");
     assert((type === "Collator" && GuardToCollator(obj) !== null) ||
-           (type === "DateTimeFormat" && IsDateTimeFormat(obj)) ||
+           (type === "DateTimeFormat" && GuardToDateTimeFormat(obj) !== null) ||
            (type === "NumberFormat" && GuardToNumberFormat(obj) !== null) ||
            (type === "PluralRules" && IsPluralRules(obj)) ||
            (type === "RelativeTimeFormat" && IsRelativeTimeFormat(obj)),
            "type must match the object's class");
     assert(IsObject(lazyData), "non-object lazy data");
 
     // The meaning of an internals object for an object |obj| is as follows.
     //
@@ -1507,27 +1507,27 @@ function maybeInternalProperties(interna
  * properties!), with structure specified above.
  *
  * Spec: ECMAScript Internationalization API Specification, 10.3.
  * Spec: ECMAScript Internationalization API Specification, 11.3.
  * Spec: ECMAScript Internationalization API Specification, 12.3.
  */
 function getIntlObjectInternals(obj) {
     assert(IsObject(obj), "getIntlObjectInternals called with non-Object");
-    assert(GuardToCollator(obj) !== null || IsDateTimeFormat(obj) ||
+    assert(GuardToCollator(obj) !== null || GuardToDateTimeFormat(obj) !== null ||
            GuardToNumberFormat(obj) !== null || IsPluralRules(obj) ||
            IsRelativeTimeFormat(obj),
            "getIntlObjectInternals called with non-Intl object");
 
     var internals = UnsafeGetReservedSlot(obj, INTL_INTERNALS_OBJECT_SLOT);
 
     assert(IsObject(internals), "internals not an object");
     assert(hasOwn("type", internals), "missing type");
     assert((internals.type === "Collator" && GuardToCollator(obj) !== null) ||
-           (internals.type === "DateTimeFormat" && IsDateTimeFormat(obj)) ||
+           (internals.type === "DateTimeFormat" && GuardToDateTimeFormat(obj) !== null) ||
            (internals.type === "NumberFormat" && GuardToNumberFormat(obj) !== null) ||
            (internals.type === "PluralRules" && IsPluralRules(obj)) ||
            (internals.type === "RelativeTimeFormat" && IsRelativeTimeFormat(obj)),
            "type must match the object's class");
     assert(hasOwn("lazyData", internals), "missing lazyData");
     assert(hasOwn("internalProps", internals), "missing internalProps");
 
     return internals;
--- a/js/src/builtin/intl/DateTimeFormat.js
+++ b/js/src/builtin/intl/DateTimeFormat.js
@@ -164,17 +164,17 @@ function replaceHourRepresentation(patte
     return resultPattern;
 }
 
 /**
  * Returns an object containing the DateTimeFormat internal properties of |obj|.
  */
 function getDateTimeFormatInternals(obj) {
     assert(IsObject(obj), "getDateTimeFormatInternals called with non-object");
-    assert(IsDateTimeFormat(obj), "getDateTimeFormatInternals called with non-DateTimeFormat");
+    assert(GuardToDateTimeFormat(obj) !== null, "getDateTimeFormatInternals called with non-DateTimeFormat");
 
     var internals = getIntlObjectInternals(obj);
     assert(internals.type === "DateTimeFormat", "bad type escaped getIntlObjectInternals");
 
     // If internal properties have already been computed, use them.
     var internalProps = maybeInternalProperties(internals);
     if (internalProps)
         return internalProps;
@@ -187,21 +187,21 @@ function getDateTimeFormatInternals(obj)
 
 /**
  * 12.1.10 UnwrapDateTimeFormat( dtf )
  */
 function UnwrapDateTimeFormat(dtf, methodName) {
     // Step 1 (not applicable in our implementation).
 
     // Step 2.
-    if (IsObject(dtf) && !IsDateTimeFormat(dtf) && dtf instanceof GetDateTimeFormatConstructor())
+    if (IsObject(dtf) && (GuardToDateTimeFormat(dtf)) === null && dtf instanceof GetDateTimeFormatConstructor())
         dtf = dtf[intlFallbackSymbol()];
 
     // Step 3.
-    if (!IsObject(dtf) || !IsDateTimeFormat(dtf)) {
+    if (!IsObject(dtf) || (dtf = GuardToDateTimeFormat(dtf)) === null) {
         ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "DateTimeFormat", methodName,
                        "DateTimeFormat");
     }
 
     // Step 4.
     return dtf;
 }
 
@@ -297,17 +297,17 @@ function DefaultTimeZone() {
  * all the work we can until the object is actually used as a DateTimeFormat.
  * This later work occurs in |resolveDateTimeFormatInternals|; steps not noted
  * here occur there.
  *
  * Spec: ECMAScript Internationalization API Specification, 12.1.1.
  */
 function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, mozExtensions) {
     assert(IsObject(dateTimeFormat), "InitializeDateTimeFormat called with non-Object");
-    assert(IsDateTimeFormat(dateTimeFormat),
+    assert(GuardToDateTimeFormat(dateTimeFormat) !== null,
            "InitializeDateTimeFormat called with non-DateTimeFormat");
 
     // Lazy DateTimeFormat data has the following structure:
     //
     //   {
     //     requestedLocales: List of locales,
     //
     //     localeOpt: // *first* opt computed in InitializeDateTimeFormat
@@ -780,17 +780,17 @@ function dateTimeFormatLocaleData() {
  * Spec: ECMAScript Internationalization API Specification, 12.1.5.
  */
 function dateTimeFormatFormatToBind(date) {
     // Step 1.
     var dtf = this;
 
     // Step 2.
     assert(IsObject(dtf), "dateTimeFormatFormatToBind called with non-Object");
-    assert(IsDateTimeFormat(dtf), "dateTimeFormatFormatToBind called with non-DateTimeFormat");
+    assert(GuardToDateTimeFormat(dtf) !== null, "dateTimeFormatFormatToBind called with non-DateTimeFormat");
 
     // Steps 3-4.
     var x = (date === undefined) ? std_Date_now() : ToNumber(date);
 
     // Step 5.
     return intl_FormatDateTime(dtf, x, /* formatToParts = */ false);
 }
 
@@ -826,17 +826,17 @@ function Intl_DateTimeFormat_format_get(
  *
  * Spec: ECMAScript Internationalization API Specification, 12.4.4.
  */
 function Intl_DateTimeFormat_formatToParts(date) {
     // Step 1.
     var dtf = this;
 
     // Steps 2-3.
-    if (!IsObject(dtf) || !IsDateTimeFormat(dtf)) {
+    if (!IsObject(dtf) || (dtf = GuardToDateTimeFormat(dtf)) == null) {
         ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "DateTimeFormat", "formatToParts",
                        "DateTimeFormat");
     }
 
     // Ensure the DateTimeFormat internals are resolved.
     getDateTimeFormatInternals(dtf);
 
     // Steps 4-5.
--- a/js/src/jit/InlinableNatives.h
+++ b/js/src/jit/InlinableNatives.h
@@ -25,17 +25,17 @@
     _(AtomicsAnd)                   \
     _(AtomicsOr)                    \
     _(AtomicsXor)                   \
     _(AtomicsIsLockFree)            \
                                     \
     _(Boolean)                      \
                                     \
     _(IntlGuardToCollator)          \
-    _(IntlIsDateTimeFormat)         \
+    _(IntlGuardToDateTimeFormat)    \
     _(IntlGuardToNumberFormat)      \
     _(IntlIsPluralRules)            \
     _(IntlIsRelativeTimeFormat)     \
                                     \
     _(MathAbs)                      \
     _(MathFloor)                    \
     _(MathCeil)                     \
     _(MathRound)                    \
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -116,18 +116,18 @@ IonBuilder::inlineNativeCall(CallInfo& c
 
       // Boolean natives.
       case InlinableNative::Boolean:
         return inlineBoolean(callInfo);
 
       // Intl natives.
       case InlinableNative::IntlGuardToCollator:
         return inlineGuardToClass(callInfo, &CollatorObject::class_);
-      case InlinableNative::IntlIsDateTimeFormat:
-        return inlineHasClass(callInfo, &DateTimeFormatObject::class_);
+      case InlinableNative::IntlGuardToDateTimeFormat:
+        return inlineGuardToClass(callInfo, &DateTimeFormatObject::class_);
       case InlinableNative::IntlGuardToNumberFormat:
         return inlineGuardToClass(callInfo, &NumberFormatObject::class_);
       case InlinableNative::IntlIsPluralRules:
         return inlineHasClass(callInfo, &PluralRulesObject::class_);
       case InlinableNative::IntlIsRelativeTimeFormat:
         return inlineHasClass(callInfo, &RelativeTimeFormatObject::class_);
 
       // Math natives.
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -2561,19 +2561,19 @@ static const JSFunctionSpec intrinsic_fu
     JS_FN("intl_RelativeTimeFormat_availableLocales", intl_RelativeTimeFormat_availableLocales, 0,0),
     JS_FN("intl_FormatRelativeTime", intl_FormatRelativeTime, 4,0),
     JS_FN("intl_toLocaleLowerCase", intl_toLocaleLowerCase, 2,0),
     JS_FN("intl_toLocaleUpperCase", intl_toLocaleUpperCase, 2,0),
 
     JS_INLINABLE_FN("GuardToCollator",
                     intrinsic_GuardToBuiltin<CollatorObject>, 1,0,
                     IntlGuardToCollator),
-    JS_INLINABLE_FN("IsDateTimeFormat",
-                    intrinsic_IsInstanceOfBuiltin<DateTimeFormatObject>, 1,0,
-                    IntlIsDateTimeFormat),
+    JS_INLINABLE_FN("GuardToDateTimeFormat",
+                    intrinsic_GuardToBuiltin<DateTimeFormatObject>, 1,0,
+                    IntlGuardToDateTimeFormat),
     JS_INLINABLE_FN("GuardToNumberFormat",
                     intrinsic_GuardToBuiltin<NumberFormatObject>, 1,0,
                     IntlGuardToNumberFormat),
     JS_INLINABLE_FN("IsPluralRules",
                     intrinsic_IsInstanceOfBuiltin<PluralRulesObject>, 1,0,
                     IntlIsPluralRules),
     JS_INLINABLE_FN("IsRelativeTimeFormat",
                     intrinsic_IsInstanceOfBuiltin<RelativeTimeFormatObject>, 1,0,