Bug 893186, part 4 - Replace a use of JS_GetUCPropertyAttributes in JSD with a call to JS_GetOwnPropertyDescriptorById. r=luke.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 06 Sep 2013 12:05:30 -0500
changeset 146009 9515bf89bc4ad94bb67fa385f00fe9555c30f49c
parent 146008 5b8f4f23d53e570124ae0b80a5905ef0b6d273dc
child 146010 77e2eaaf2fbb93bbfe086703d5125eb9584668ec
push id25233
push userryanvm@gmail.com
push dateSat, 07 Sep 2013 00:57:08 +0000
treeherdermozilla-central@3697f962bb7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs893186
milestone26.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 893186, part 4 - Replace a use of JS_GetUCPropertyAttributes in JSD with a call to JS_GetOwnPropertyDescriptorById. r=luke.
js/jsd/jsd_val.cpp
--- a/js/jsd/jsd_val.cpp
+++ b/js/jsd/jsd_val.cpp
@@ -472,20 +472,17 @@ JSDProperty*
 jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* nameStr)
 {
     JS::RootedString name(jsdc->jsrt, nameStr);
     AutoSafeJSContext cx;
     JSAutoCompartment acBase(cx, jsdc->glob);
     JSDProperty* jsdprop;
     JSDProperty* iter = NULL;
     JS::RootedObject obj(cx);
-    unsigned  attrs = 0;
     bool found;
-    const jschar * nameChars;
-    size_t nameLen;
     JS::RootedValue val(cx), nameval(cx);
     JS::RootedId nameid(cx);
     JS::RootedValue propId(cx);
     JS::RootedValue propValue(cx);
     JS::RootedValue propAlias(cx);
     uint8_t propFlags;
 
     if(!jsd_IsValueObject(jsdc, jsdval))
@@ -499,34 +496,38 @@ jsd_GetValueProperty(JSDContext* jsdc, J
             int result;
             if (JS_CompareStrings(cx, propName, name, &result) && !result)
                 return jsdprop;
         }
         JSD_DropProperty(jsdc, jsdprop);
     }
     /* Not found in property list, look it up explicitly */
 
+    nameval = STRING_TO_JSVAL(name);
+    if(!JS_ValueToId(cx, nameval, nameid.address()))
+        return NULL;
+
     if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
         return NULL;
 
-    if (!(nameChars = JS_GetStringCharsZAndLength(cx, name, &nameLen)))
-        return NULL;
-
+    JS::Rooted<JSPropertyDescriptor> desc(cx);
     {
         JSAutoCompartment ac(cx, obj);
+        JS::RootedId id(cx, nameid);
 
-        JS_GetUCPropertyAttributes(cx, obj, nameChars, nameLen, &attrs, &found);
-        if (!found)
-        {
+        if(!JS_WrapId(cx, id.address()))
             return NULL;
-        }
+        if(!JS_GetOwnPropertyDescriptorById(cx, obj, id, 0, &desc))
+            return NULL;
+        if(!desc.object())
+            return NULL;
 
         JS_ClearPendingException(cx);
 
-        if(!JS_GetUCProperty(cx, obj, nameChars, nameLen, &val))
+        if(!JS_GetPropertyById(cx, obj, id, &val))
         {
             if (JS_IsExceptionPending(cx))
             {
                 if (!JS_GetPendingException(cx, propValue.address()))
                 {
                     return NULL;
                 }
                 propFlags = JSPD_EXCEPTION;
@@ -538,26 +539,23 @@ jsd_GetValueProperty(JSDContext* jsdc, J
             }
         }
         else
         {
             propValue = val;
         }
     }
 
-    nameval = STRING_TO_JSVAL(name);
-    if (!JS_ValueToId(cx, nameval, nameid.address()) ||
-        !JS_IdToValue(cx, nameid, propId.address())) {
+    if (!JS_IdToValue(cx, nameid, propId.address()))
         return NULL;
-    }
 
     propAlias = JSVAL_NULL;
-    propFlags |= (attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0
-        | (attrs & JSPROP_READONLY)  ? JSPD_READONLY  : 0
-        | (attrs & JSPROP_PERMANENT) ? JSPD_PERMANENT : 0;
+    propFlags |= desc.isEnumerable() ? JSPD_ENUMERATE : 0
+        | desc.isReadonly() ? JSPD_READONLY  : 0
+        | desc.isPermanent() ? JSPD_PERMANENT : 0;
 
     return _newProperty(jsdc, propId, propValue, propAlias, propFlags, JSDPD_HINTED);
 }
 
 /*
  * Retrieve a JSFunction* from a JSDValue*. This differs from
  * JS_ValueToFunction by fully unwrapping the object first.
  */