Bug 1437842: [Part 5] Convert IsCollator to GuardToCollator r=jandem
authorMatthew Gaudet <mgaudet@mozilla.com>
Mon, 23 Apr 2018 10:51:06 -0400
changeset 471912 0993cb0d74e6e4466a4c19b8fe917714cce6546d
parent 471911 c568e772c710ff169873fd90695126b8765b3196
child 471913 83ea97f7f8d3aca75d44c6818780cb3d42301d44
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [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 5] Convert IsCollator to GuardToCollator r=jandem
js/src/builtin/intl/Collator.js
js/src/builtin/intl/CommonFunctions.js
js/src/jit/InlinableNatives.h
js/src/jit/MCallOptimize.cpp
js/src/vm/SelfHosting.cpp
--- a/js/src/builtin/intl/Collator.js
+++ b/js/src/builtin/intl/Collator.js
@@ -75,17 +75,17 @@ function resolveCollatorInternals(lazyCo
     return internalProps;
 }
 
 /**
  * Returns an object containing the Collator internal properties of |obj|.
  */
 function getCollatorInternals(obj) {
     assert(IsObject(obj), "getCollatorInternals called with non-object");
-    assert(IsCollator(obj), "getCollatorInternals called with non-Collator");
+    assert(GuardToCollator(obj) !== null, "getCollatorInternals called with non-Collator");
 
     var internals = getIntlObjectInternals(obj);
     assert(internals.type === "Collator", "bad type escaped getIntlObjectInternals");
 
     // If internal properties have already been computed, use them.
     var internalProps = maybeInternalProperties(internals);
     if (internalProps)
         return internalProps;
@@ -104,17 +104,17 @@ function getCollatorInternals(obj) {
  * all the work we can until the object is actually used as a Collator.  This
  * later work occurs in |resolveCollatorInternals|; steps not noted here occur
  * there.
  *
  * Spec: ECMAScript Internationalization API Specification, 10.1.1.
  */
 function InitializeCollator(collator, locales, options) {
     assert(IsObject(collator), "InitializeCollator called with non-object");
-    assert(IsCollator(collator), "InitializeCollator called with non-Collator");
+    assert(GuardToCollator(collator) != null, "InitializeCollator called with non-Collator");
 
     // Lazy Collator data has the following structure:
     //
     //   {
     //     requestedLocales: List of locales,
     //     usage: "sort" / "search",
     //     opt: // opt object computed in InitializeCollator
     //       {
@@ -324,17 +324,17 @@ function collatorSearchLocaleData() {
  * Spec: ECMAScript Internationalization API Specification, 10.3.3.1.
  */
 function collatorCompareToBind(x, y) {
     // Step 1.
     var collator = this;
 
     // Step 2.
     assert(IsObject(collator), "collatorCompareToBind called with non-object");
-    assert(IsCollator(collator), "collatorCompareToBind called with non-Collator");
+    assert(GuardToCollator(collator) !== null, "collatorCompareToBind called with non-Collator");
 
     // Steps 3-6
     var X = ToString(x);
     var Y = ToString(y);
 
     // Step 7.
     return intl_CompareStrings(collator, X, Y);
 }
@@ -348,17 +348,17 @@ function collatorCompareToBind(x, y) {
  *
  * Spec: ECMAScript Internationalization API Specification, 10.3.3.
  */
 function Intl_Collator_compare_get() {
     // Step 1.
     var collator = this;
 
     // Steps 2-3.
-    if (!IsObject(collator) || !IsCollator(collator))
+    if (!IsObject(collator) || (collator = GuardToCollator(collator)) === null)
         ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "Collator", "compare", "Collator");
 
     var internals = getCollatorInternals(collator);
 
     // Step 4.
     if (internals.boundCompare === undefined) {
         // Steps 4.a-b.
         var F = callFunction(FunctionBind, collatorCompareToBind, collator);
@@ -377,17 +377,17 @@ function Intl_Collator_compare_get() {
  *
  * Spec: ECMAScript Internationalization API Specification, 10.3.4.
  */
 function Intl_Collator_resolvedOptions() {
     // Step 1.
     var collator = this;
 
     // Steps 2-3.
-    if (!IsObject(collator) || !IsCollator(collator))
+    if (!IsObject(collator) || (collator = GuardToCollator(collator)) === null)
         ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "Collator", "resolvedOptions", "Collator");
 
     var internals = getCollatorInternals(collator);
 
     // Steps 4-5.
     var result = {
         locale: internals.locale,
         usage: internals.usage,
--- a/js/src/builtin/intl/CommonFunctions.js
+++ b/js/src/builtin/intl/CommonFunctions.js
@@ -1439,17 +1439,17 @@ function intlFallbackSymbol() {
     return fallbackSymbol;
 }
 
 /**
  * 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" && IsCollator(obj)) ||
+    assert((type === "Collator" && GuardToCollator(obj) !== null) ||
            (type === "DateTimeFormat" && IsDateTimeFormat(obj)) ||
            (type === "NumberFormat" && IsNumberFormat(obj)) ||
            (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,26 +1507,26 @@ 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(IsCollator(obj) || IsDateTimeFormat(obj) ||
+    assert(GuardToCollator(obj) !== null || IsDateTimeFormat(obj) ||
            IsNumberFormat(obj) || 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" && IsCollator(obj)) ||
+    assert((internals.type === "Collator" && GuardToCollator(obj) !== null) ||
            (internals.type === "DateTimeFormat" && IsDateTimeFormat(obj)) ||
            (internals.type === "NumberFormat" && IsNumberFormat(obj)) ||
            (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");
 
--- a/js/src/jit/InlinableNatives.h
+++ b/js/src/jit/InlinableNatives.h
@@ -24,17 +24,17 @@
     _(AtomicsSub)                   \
     _(AtomicsAnd)                   \
     _(AtomicsOr)                    \
     _(AtomicsXor)                   \
     _(AtomicsIsLockFree)            \
                                     \
     _(Boolean)                      \
                                     \
-    _(IntlIsCollator)               \
+    _(IntlGuardToCollator)          \
     _(IntlIsDateTimeFormat)         \
     _(IntlIsNumberFormat)           \
     _(IntlIsPluralRules)            \
     _(IntlIsRelativeTimeFormat)     \
                                     \
     _(MathAbs)                      \
     _(MathFloor)                    \
     _(MathCeil)                     \
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -114,18 +114,18 @@ IonBuilder::inlineNativeCall(CallInfo& c
       case InlinableNative::AtomicsIsLockFree:
         return inlineAtomicsIsLockFree(callInfo);
 
       // Boolean natives.
       case InlinableNative::Boolean:
         return inlineBoolean(callInfo);
 
       // Intl natives.
-      case InlinableNative::IntlIsCollator:
-        return inlineHasClass(callInfo, &CollatorObject::class_);
+      case InlinableNative::IntlGuardToCollator:
+        return inlineGuardToClass(callInfo, &CollatorObject::class_);
       case InlinableNative::IntlIsDateTimeFormat:
         return inlineHasClass(callInfo, &DateTimeFormatObject::class_);
       case InlinableNative::IntlIsNumberFormat:
         return inlineHasClass(callInfo, &NumberFormatObject::class_);
       case InlinableNative::IntlIsPluralRules:
         return inlineHasClass(callInfo, &PluralRulesObject::class_);
       case InlinableNative::IntlIsRelativeTimeFormat:
         return inlineHasClass(callInfo, &RelativeTimeFormatObject::class_);
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -2558,19 +2558,19 @@ static const JSFunctionSpec intrinsic_fu
     JS_FN("intl_PluralRules_availableLocales", intl_PluralRules_availableLocales, 0,0),
     JS_FN("intl_GetPluralCategories", intl_GetPluralCategories, 1, 0),
     JS_FN("intl_SelectPluralRule", intl_SelectPluralRule, 2,0),
     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("IsCollator",
-                    intrinsic_IsInstanceOfBuiltin<CollatorObject>, 1,0,
-                    IntlIsCollator),
+    JS_INLINABLE_FN("GuardToCollator",
+                    intrinsic_GuardToBuiltin<CollatorObject>, 1,0,
+                    IntlGuardToCollator),
     JS_INLINABLE_FN("IsDateTimeFormat",
                     intrinsic_IsInstanceOfBuiltin<DateTimeFormatObject>, 1,0,
                     IntlIsDateTimeFormat),
     JS_INLINABLE_FN("IsNumberFormat",
                     intrinsic_IsInstanceOfBuiltin<NumberFormatObject>, 1,0,
                     IntlIsNumberFormat),
     JS_INLINABLE_FN("IsPluralRules",
                     intrinsic_IsInstanceOfBuiltin<PluralRulesObject>, 1,0,