Bug 1560553 part 1. Simplify the TryToOuterize callers a bit. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 27 Jun 2019 15:03:20 +0000
changeset 480408 1bf78850148bd7dd06e451ae9a60c627c7066b88
parent 480407 92eb304ccb520255d2dee36dfdc7fe9f5515a6e3
child 480409 0b533d8d086e4828cb712061ff95e5ee1527bbd5
push id88672
push userbzbarsky@mozilla.com
push dateThu, 27 Jun 2019 17:45:30 +0000
treeherderautoland@0b533d8d086e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1560553
milestone69.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 1560553 part 1. Simplify the TryToOuterize callers a bit. r=peterv TryToOuterize fast-path bails out if a bit-check on the JSClass fails. Trying to avoid that bit-check by checking for a DOM class, which is also a bit-check on the JSClass doesn't really make sense. Differential Revision: https://phabricator.services.mozilla.com/D35533
dom/bindings/BindingUtils.h
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -882,44 +882,32 @@ bool MaybeWrapObjectValue(JSContext* cx,
   MOZ_ASSERT(rval.isObject());
 
   // Cross-compartment always requires wrapping.
   JSObject* obj = &rval.toObject();
   if (js::GetObjectCompartment(obj) != js::GetContextCompartment(cx)) {
     return JS_WrapValue(cx, rval);
   }
 
-  // We're same-compartment, but even then we might need to wrap
-  // objects specially.  Check for that.
-  if (IsDOMObject(obj)) {
-    return TryToOuterize(rval);
-  }
-
-  // It's not a WebIDL object, so it's OK to just leave it as-is: only WebIDL
-  // objects (specifically only windows) require outerization.
-  return true;
+  // We're same-compartment, but we might still need to outerize if we
+  // have a Window.
+  return TryToOuterize(rval);
 }
 
 // Like MaybeWrapObjectValue, but working with a
 // JS::MutableHandle<JSObject*> which must be non-null.
 MOZ_ALWAYS_INLINE
 bool MaybeWrapObject(JSContext* cx, JS::MutableHandle<JSObject*> obj) {
   if (js::GetObjectCompartment(obj) != js::GetContextCompartment(cx)) {
     return JS_WrapObject(cx, obj);
   }
 
-  // We're same-compartment, but even then we might need to wrap
-  // objects specially.  Check for that.
-  if (IsDOMObject(obj)) {
-    return TryToOuterize(obj);
-  }
-
-  // It's not a WebIDL object, so it's OK to just leave it as-is: only WebIDL
-  // objects (specifically only windows) require outerization.
-  return true;
+  // We're same-compartment, but we might still need to outerize if we
+  // have a Window.
+  return TryToOuterize(obj);
 }
 
 // Like MaybeWrapObjectValue, but also allows null
 MOZ_ALWAYS_INLINE
 bool MaybeWrapObjectOrNullValue(JSContext* cx,
                                 JS::MutableHandle<JS::Value> rval) {
   MOZ_ASSERT(rval.isObjectOrNull());
   if (rval.isNull()) {