Bug 1515999. Remove the unused JSContext argument from GetArrayIndexFromId. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 26 Dec 2018 13:45:15 -0800
changeset 509043 e283107433563720e22febcda4fa18f41c487f39
parent 509042 4afd271c2e75a009ca3884079eff7cbaf3b96884
child 509044 105d91988991ddb4cec5915d2090046227b6b819
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1515999
milestone66.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 1515999. Remove the unused JSContext argument from GetArrayIndexFromId. r=peterv
dom/base/nsGlobalWindowOuter.cpp
dom/bindings/Codegen.py
dom/bindings/DOMJSProxyHandler.h
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -520,17 +520,17 @@ bool nsOuterWindowProxy::getOwnPropertyD
   return true;
 }
 
 bool nsOuterWindowProxy::defineProperty(JSContext* cx,
                                         JS::Handle<JSObject*> proxy,
                                         JS::Handle<jsid> id,
                                         JS::Handle<JS::PropertyDescriptor> desc,
                                         JS::ObjectOpResult& result) const {
-  if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
+  if (IsArrayIndex(GetArrayIndexFromId(id))) {
     // Spec says to Reject whether this is a supported index or not,
     // since we have no indexed setter or indexed creator.  It is up
     // to the caller to decide whether to throw a TypeError.
     return result.failCantDefineWindowElement();
   }
 
   JS::ObjectOpResult ourResult;
   bool ok = js::Wrapper::defineProperty(cx, proxy, id, desc, ourResult);
@@ -614,17 +614,17 @@ bool nsOuterWindowProxy::ownPropertyKeys
 bool nsOuterWindowProxy::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
                                  JS::Handle<jsid> id,
                                  JS::ObjectOpResult& result) const {
   if (nsCOMPtr<nsPIDOMWindowOuter> frame = GetSubframeWindow(cx, proxy, id)) {
     // Fail (which means throw if strict, else return false).
     return result.failCantDeleteWindowElement();
   }
 
-  if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
+  if (IsArrayIndex(GetArrayIndexFromId(id))) {
     // Indexed, but not supported.  Spec says return true.
     return result.succeed();
   }
 
   return js::Wrapper::delete_(cx, proxy, id, result);
 }
 
 bool nsOuterWindowProxy::getPrototypeIfOrdinary(
@@ -704,17 +704,17 @@ bool nsOuterWindowProxy::get(JSContext* 
 
   return js::Wrapper::get(cx, proxy, receiver, id, vp);
 }
 
 bool nsOuterWindowProxy::set(JSContext* cx, JS::Handle<JSObject*> proxy,
                              JS::Handle<jsid> id, JS::Handle<JS::Value> v,
                              JS::Handle<JS::Value> receiver,
                              JS::ObjectOpResult& result) const {
-  if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
+  if (IsArrayIndex(GetArrayIndexFromId(id))) {
     // Reject the set.  It's up to the caller to decide whether to throw a
     // TypeError.  If the caller is strict mode JS code, it'll throw.
     return result.failReadOnly();
   }
 
   return js::Wrapper::set(cx, proxy, id, v, receiver, result);
 }
 
@@ -768,17 +768,17 @@ bool nsOuterWindowProxy::GetSubframeWind
   }
   JS::ExposeObjectToActiveJS(obj);
   vp.setObject(*obj);
   return JS_WrapValue(cx, vp);
 }
 
 already_AddRefed<nsPIDOMWindowOuter> nsOuterWindowProxy::GetSubframeWindow(
     JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id) const {
-  uint32_t index = GetArrayIndexFromId(cx, id);
+  uint32_t index = GetArrayIndexFromId(id);
   if (!IsArrayIndex(index)) {
     return nullptr;
   }
 
   nsGlobalWindowOuter* win = GetOuterWindow(proxy);
   return win->IndexedGetterOuter(index);
 }
 
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -11401,17 +11401,17 @@ class CGDOMJSProxyHandler_getOwnPropDesc
             templateValues = {
                 'jsvalRef': 'desc.value()',
                 'jsvalHandle': 'desc.value()',
                 'obj': 'proxy',
                 'successCode': fillDescriptor
             }
             getIndexed = fill(
                 """
-                uint32_t index = GetArrayIndexFromId(cx, id);
+                uint32_t index = GetArrayIndexFromId(id);
                 if (IsArrayIndex(index)) {
                   $*{callGetter}
                 }
 
                 """,
                 callGetter=CGProxyIndexedGetter(self.descriptor, templateValues).define())
         else:
             getIndexed = ""
@@ -11506,17 +11506,17 @@ class CGDOMJSProxyHandler_defineProperty
 
     def getBody(self):
         set = ""
 
         indexedSetter = self.descriptor.operations['IndexedSetter']
         if indexedSetter:
             set += fill(
                 """
-                uint32_t index = GetArrayIndexFromId(cx, id);
+                uint32_t index = GetArrayIndexFromId(id);
                 if (IsArrayIndex(index)) {
                   *defined = true;
                   // https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty
                   // Step 1.1.  The no-indexed-setter case is handled by step 1.2.
                   if (!desc.isDataDescriptor()) {
                     return opresult.failNotDataDescriptor();
                   }
 
@@ -11528,17 +11528,17 @@ class CGDOMJSProxyHandler_defineProperty
         elif self.descriptor.supportsIndexedProperties():
             # We allow untrusted content to prevent Xrays from setting a
             # property if that property is an indexed property and we have no
             # indexed setter.  That's how the object would normally behave if
             # you tried to set the property on it.  That means we don't need to
             # do anything special for Xrays here.
             set += dedent(
                 """
-                if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
+                if (IsArrayIndex(GetArrayIndexFromId(id))) {
                   *defined = true;
                   return opresult.failNoIndexedSetter();
                 }
                 """)
 
         namedSetter = self.descriptor.operations['NamedSetter']
         if namedSetter:
             if self.descriptor.hasUnforgeableMembers:
@@ -11683,17 +11683,17 @@ class CGDOMJSProxyHandler_delete(ClassMe
                       "Should not have a XrayWrapper here");
 
             """)
 
         indexedBody = getDeleterBody(self.descriptor, "Indexed")
         if indexedBody is not None:
             delete += fill(
                 """
-                uint32_t index = GetArrayIndexFromId(cx, id);
+                uint32_t index = GetArrayIndexFromId(id);
                 if (IsArrayIndex(index)) {
                   bool deleteSucceeded;
                   $*{indexedBody}
                   return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
                 }
                 """,
                 indexedBody=indexedBody)
 
@@ -11839,17 +11839,17 @@ class CGDOMJSProxyHandler_hasOwn(ClassMe
         ClassMethod.__init__(self, "hasOwn", "bool", args,
                              virtual=True, override=True, const=True)
         self.descriptor = descriptor
 
     def getBody(self):
         if self.descriptor.supportsIndexedProperties():
             indexed = fill(
                 """
-                uint32_t index = GetArrayIndexFromId(cx, id);
+                uint32_t index = GetArrayIndexFromId(id);
                 if (IsArrayIndex(index)) {
                   bool found = false;
                   $*{presenceChecker}
 
                   *bp = found;
                   return true;
                 }
 
@@ -11942,17 +11942,17 @@ class CGDOMJSProxyHandler_get(ClassMetho
             }
             """)
 
         templateValues = {'jsvalRef': 'vp', 'jsvalHandle': 'vp', 'obj': 'proxy'}
 
         if self.descriptor.supportsIndexedProperties():
             getIndexedOrExpando = fill(
                 """
-                uint32_t index = GetArrayIndexFromId(cx, id);
+                uint32_t index = GetArrayIndexFromId(id);
                 if (IsArrayIndex(index)) {
                   $*{callGetter}
                   // Even if we don't have this index, we don't forward the
                   // get on to our expando object.
                 } else {
                   $*{getUnforgeableOrExpando}
                 }
                 """,
@@ -12034,17 +12034,17 @@ class CGDOMJSProxyHandler_setCustom(Clas
                     "return true;\n")
 
         # As an optimization, if we are going to call an IndexedSetter, go
         # ahead and call it and have done.
         indexedSetter = self.descriptor.operations['IndexedSetter']
         if indexedSetter is not None:
             setIndexed = fill(
                 """
-                uint32_t index = GetArrayIndexFromId(cx, id);
+                uint32_t index = GetArrayIndexFromId(id);
                 if (IsArrayIndex(index)) {
                   $*{callSetter}
                   *done = true;
                   return true;
                 }
 
                 """,
                 callSetter=CGProxyIndexedSetter(self.descriptor,
--- a/dom/bindings/DOMJSProxyHandler.h
+++ b/dom/bindings/DOMJSProxyHandler.h
@@ -160,17 +160,17 @@ inline const DOMProxyHandler* GetDOMProx
   MOZ_ASSERT(IsDOMProxy(obj));
   return static_cast<const DOMProxyHandler*>(js::GetProxyHandler(obj));
 }
 
 extern jsid s_length_id;
 
 // A return value of UINT32_MAX indicates "not an array index".  Note, in
 // particular, that UINT32_MAX itself is not a valid array index in general.
-inline uint32_t GetArrayIndexFromId(JSContext* cx, JS::Handle<jsid> id) {
+inline uint32_t GetArrayIndexFromId(JS::Handle<jsid> id) {
   // Much like js::IdIsIndex, except with a fast path for "length" and another
   // fast path for starting with a lowercase ascii char.  Is that second one
   // really needed?  I guess it is because StringIsArrayIndex is out of line...
   // as of now, use id.get() instead of id otherwise operands mismatch error
   // occurs.
   if (MOZ_LIKELY(JSID_IS_INT(id))) {
     return JSID_TO_INT(id);
   }
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -530,17 +530,17 @@ bool JSXrayTraits::resolveOwnProperty(JS
     // serves as a non-tight upper bound on |own| indexed properties. So while
     // it's tempting to try to impose some sort of structure on what Arrays
     // "should" look like over Xrays, the underlying object is squishy enough
     // that it makes sense to just treat them like Objects for Xray purposes.
     if (key == JSProto_Object || key == JSProto_Array) {
       return getOwnPropertyFromWrapperIfSafe(cx, wrapper, id, desc);
     }
     if (IsTypedArrayKey(key)) {
-      if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
+      if (IsArrayIndex(GetArrayIndexFromId(id))) {
         // WebExtensions can't use cloneInto(), so we just let them do
         // the slow thing to maximize compatibility.
         if (CompartmentPrivate::Get(CurrentGlobalOrNull(cx))
                 ->isWebExtensionContentScript) {
           Rooted<PropertyDescriptor> innerDesc(cx);
           {
             JSAutoRealm ar(cx, target);
             JS_MarkCrossZoneId(cx, id);
@@ -809,17 +809,17 @@ bool JSXrayTraits::defineProperty(JSCont
   // For WebExtensions content scripts, we forward the definition of indexed
   // properties. By validating that the key and value are both numbers, we can
   // avoid doing any wrapping.
   if (isInstance && IsTypedArrayKey(key) &&
       CompartmentPrivate::Get(JS::CurrentGlobalOrNull(cx))
           ->isWebExtensionContentScript &&
       desc.isDataDescriptor() &&
       (desc.value().isNumber() || desc.value().isUndefined()) &&
-      IsArrayIndex(GetArrayIndexFromId(cx, id))) {
+      IsArrayIndex(GetArrayIndexFromId(id))) {
     RootedObject target(cx, getTargetObject(wrapper));
     JSAutoRealm ar(cx, target);
     JS_MarkCrossZoneId(cx, id);
     if (!JS_DefinePropertyById(cx, target, id, desc, result)) {
       return false;
     }
     *defined = true;
     return true;
@@ -1628,17 +1628,17 @@ bool DOMXrayTraits::resolveOwnProperty(J
   // Call the common code.
   bool ok =
       XrayTraits::resolveOwnProperty(cx, wrapper, target, holder, id, desc);
   if (!ok || desc.object()) {
     return ok;
   }
 
   // Check for indexed access on a window.
-  uint32_t index = GetArrayIndexFromId(cx, id);
+  uint32_t index = GetArrayIndexFromId(id);
   if (IsArrayIndex(index)) {
     nsGlobalWindowInner* win = AsWindow(cx, wrapper);
     // Note: As() unwraps outer windows to get to the inner window.
     if (win) {
       nsCOMPtr<nsPIDOMWindowOuter> subframe = win->IndexedGetter(index);
       if (subframe) {
         subframe->EnsureInnerWindow();
         nsGlobalWindowOuter* global = nsGlobalWindowOuter::Cast(subframe);
@@ -1687,17 +1687,17 @@ bool DOMXrayTraits::delete_(JSContext* c
 
 bool DOMXrayTraits::defineProperty(JSContext* cx, HandleObject wrapper,
                                    HandleId id, Handle<PropertyDescriptor> desc,
                                    Handle<PropertyDescriptor> existingDesc,
                                    JS::ObjectOpResult& result, bool* defined) {
   // Check for an indexed property on a Window.  If that's happening, do
   // nothing but claim we defined it so it won't get added as an expando.
   if (IsWindow(cx, wrapper)) {
-    if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
+    if (IsArrayIndex(GetArrayIndexFromId(id))) {
       *defined = true;
       return result.succeed();
     }
   }
 
   JS::Rooted<JSObject*> obj(cx, getTargetObject(wrapper));
   return XrayDefineProperty(cx, wrapper, obj, id, desc, result, defined);
 }