Bug 1090749. Reverse the isSelfHosted test in XrayWrapper and jsapi.cpp. r=waldo
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 29 Oct 2014 17:00:48 -0400
changeset 212989 2a12da881f9250ee446d699eb9d6405bdc133284
parent 212988 8335aff95389012158d3525d9810bfc0247c994f
child 212990 51aa419a7b82409bce864bddecacff4717ae27e7
push id51108
push userbzbarsky@mozilla.com
push dateWed, 29 Oct 2014 21:01:48 +0000
treeherdermozilla-inbound@51aa419a7b82 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs1090749
milestone36.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 1090749. Reverse the isSelfHosted test in XrayWrapper and jsapi.cpp. r=waldo
js/src/jsapi.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3312,27 +3312,27 @@ JS_PUBLIC_API(bool)
 JS_DefineProperties(JSContext *cx, HandleObject obj, const JSPropertySpec *ps)
 {
     RootedId id(cx);
 
     for (; ps->name; ps++) {
         if (!PropertySpecNameToId(cx, ps->name, &id))
             return false;
 
-        if (!ps->isSelfHosted()) {
-            if (!DefinePropertyById(cx, obj, id, JS::UndefinedHandleValue,
-                                    ps->getter.native, ps->setter.native, ps->flags, 0))
+        if (ps->isSelfHosted()) {
+            if (!DefineSelfHostedProperty(cx, obj, id,
+                                          ps->getter.selfHosted.funname,
+                                          ps->setter.selfHosted.funname,
+                                          ps->flags, 0))
             {
                 return false;
             }
         } else {
-            if (!DefineSelfHostedProperty(cx, obj, id,
-                                          ps->getter.selfHosted.funname,
-                                          ps->setter.selfHosted.funname,
-                                          ps->flags, 0))
+            if (!DefinePropertyById(cx, obj, id, JS::UndefinedHandleValue,
+                                    ps->getter.native, ps->setter.native, ps->flags, 0))
             {
                 return false;
             }
         }
     }
     return true;
 }
 
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -499,33 +499,33 @@ JSXrayTraits::resolveOwnProperty(JSConte
             break;
         }
     }
     if (psMatch) {
         desc.value().setUndefined();
         RootedFunction getterObj(cx);
         RootedFunction setterObj(cx);
         unsigned flags = psMatch->flags;
-        if (!psMatch->isSelfHosted()) {
-            desc.setGetter(JS_CAST_NATIVE_TO(psMatch->getter.native.op,
-                                             JSPropertyOp));
-            desc.setSetter(JS_CAST_NATIVE_TO(psMatch->setter.native.op,
-                                             JSStrictPropertyOp));
-        } else {
+        if (psMatch->isSelfHosted()) {
             getterObj = JS::GetSelfHostedFunction(cx, psMatch->getter.selfHosted.funname, id, 0);
             if (!getterObj)
                 return false;
             desc.setGetterObject(JS_GetFunctionObject(getterObj));
             if (psMatch->setter.selfHosted.funname) {
                 MOZ_ASSERT(flags & JSPROP_SETTER);
                 setterObj = JS::GetSelfHostedFunction(cx, psMatch->setter.selfHosted.funname, id, 0);
                 if (!setterObj)
                     return false;
                 desc.setSetterObject(JS_GetFunctionObject(setterObj));
             }
+        } else {
+            desc.setGetter(JS_CAST_NATIVE_TO(psMatch->getter.native.op,
+                                             JSPropertyOp));
+            desc.setSetter(JS_CAST_NATIVE_TO(psMatch->setter.native.op,
+                                             JSStrictPropertyOp));
         }
         desc.setAttributes(flags);
 
         // The generic Xray machinery only defines non-own properties on the holder.
         // This is broken, and will be fixed at some point, but for now we need to
         // cache the value explicitly. See the corresponding call to
         // JS_GetPropertyById at the top of this function.
         //