Bug 1469217 part 4 - Simplify DefineAccessorPropertyById a bit more. r=anba
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 21 Jun 2018 11:05:42 +0200
changeset 477486 dce07077e253644c1186d8620485ff155c45e02b
parent 477485 72a1c5b1acb9e723325b71515c1017659ba7d4ac
child 477487 4db8094fadc1b5577ab3668e1f49875af9f758f6
push id9385
push userdluca@mozilla.com
push dateFri, 22 Jun 2018 15:47:18 +0000
treeherdermozilla-beta@82a9a1027e2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanba
bugs1469217
milestone62.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 1469217 part 4 - Simplify DefineAccessorPropertyById a bit more. r=anba
js/src/jsapi.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -2120,39 +2120,37 @@ DefineAccessorPropertyById(JSContext* cx
     return js::DefineAccessorProperty(cx, obj, id, getterOp, setterOp, attrs);
 }
 
 static bool
 DefineAccessorPropertyById(JSContext* cx, HandleObject obj, HandleId id,
                            const JSNativeWrapper& get, const JSNativeWrapper& set,
                            unsigned attrs)
 {
-    // When we use DefineProperty, we need full scriptable Function objects rather
-    // than JSNatives. However, we might be pulling this property descriptor off
-    // of something with JSNative property descriptors. If we are, wrap them in
-    // JS Function objects.
-
-    // Getter/setter are both possibly-null JSNatives (or possibly-null
-    // JSFunction* if JSPROP_GETTER or JSPROP_SETTER is appropriately set).
+    // Getter/setter are both possibly-null JSNatives. Wrap them in JSFunctions.
+
+    MOZ_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
+
     RootedFunction getter(cx);
-    RootedFunction setter(cx);
-    if (get.op && !(attrs & JSPROP_GETTER)) {
+    if (get.op) {
         RootedAtom atom(cx, IdToFunctionName(cx, id, FunctionPrefixKind::Get));
         if (!atom)
             return false;
         getter = NewNativeFunction(cx, get.op, 0, atom);
         if (!getter)
             return false;
 
         if (get.info)
             getter->setJitInfo(get.info);
 
         attrs |= JSPROP_GETTER;
     }
-    if (set.op && !(attrs & JSPROP_SETTER)) {
+
+    RootedFunction setter(cx);
+    if (set.op) {
         RootedAtom atom(cx, IdToFunctionName(cx, id, FunctionPrefixKind::Set));
         if (!atom)
             return false;
         setter = NewNativeFunction(cx, set.op, 1, atom);
         if (!setter)
             return false;
 
         if (set.info)