Bug 925534 - Convert toVariant to use handles, r=terrence
authorSteve Fink <sfink@mozilla.com>
Fri, 11 Oct 2013 22:02:24 -0700
changeset 164380 f6b879837822bac2c4f5988a0d5d04b88625d657
parent 164379 cfebceef31082cb2466a13a55da004c1ceffb2ff
child 164381 09b4e50f4b2f4a97d917785257059c4b7797f699
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs925534
milestone27.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 925534 - Convert toVariant to use handles, r=terrence
js/ipc/JavaScriptChild.cpp
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptShared.h
--- a/js/ipc/JavaScriptChild.cpp
+++ b/js/ipc/JavaScriptChild.cpp
@@ -127,19 +127,19 @@ JavaScriptChild::fail(JSContext *cx, Ret
     // that would crash.
     JS_ClearPendingException(cx);
 
     if (JS_IsStopIteration(exn)) {
         *rs = ReturnStatus(ReturnStopIteration());
         return true;
     }
 
-    if (!toVariant(cx, exn, &rs->get_ReturnException().exn()))
-        return true;
-
+    // If this fails, we still don't want to exit. Just return an invalid
+    // exception.
+    (void) toVariant(cx, exn, &rs->get_ReturnException().exn());
     return true;
 }
 
 bool
 JavaScriptChild::ok(ReturnStatus *rs)
 {
     *rs = ReturnStatus(ReturnSuccess());
     return true;
@@ -372,17 +372,17 @@ JavaScriptChild::AnswerGet(const ObjectI
         return false;
 
     JSAutoCompartment comp(cx, obj);
 
     RootedId internedId(cx);
     if (!convertGeckoStringToId(cx, id, &internedId))
         return fail(cx, rs);
 
-    JS::Rooted<JS::Value> val(cx);
+    JS::RootedValue val(cx);
     if (!JS_ForwardGetPropertyTo(cx, obj, internedId, receiver, &val))
         return fail(cx, rs);
 
     if (!toVariant(cx, val, result))
         return fail(cx, rs);
 
     return ok(rs);
 }
@@ -532,17 +532,17 @@ JavaScriptChild::AnswerCall(const Object
         if (!vals.append(v))
             return fail(cx, rs);
     }
 
     // Copy the outparams. If any outparam is already set to a void_t, we
     // treat this as the outparam never having been set.
     for (size_t i = 0; i < vals.length(); i++) {
         JSVariant variant;
-        if (!toVariant(cx, vals[i], &variant))
+        if (!toVariant(cx, vals.handleAt(i), &variant))
             return fail(cx, rs);
         outparams->ReplaceElementAt(i, JSParam(variant));
     }
 
     return ok(rs);
 }
 
 bool
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -147,17 +147,17 @@ JavaScriptShared::convertGeckoStringToId
     RootedString str(cx, JS_NewUCStringCopyN(cx, from.BeginReading(), from.Length()));
     if (!str)
         return false;
 
     return JS_ValueToId(cx, StringValue(str), to.address());
 }
 
 bool
-JavaScriptShared::toVariant(JSContext *cx, jsval from, JSVariant *to)
+JavaScriptShared::toVariant(JSContext *cx, JS::HandleValue from, JSVariant *to)
 {
     switch (JS_TypeOfValue(cx, from)) {
       case JSTYPE_VOID:
         *to = void_t();
         return true;
 
       case JSTYPE_NULL:
       {
--- a/js/ipc/JavaScriptShared.h
+++ b/js/ipc/JavaScriptShared.h
@@ -86,17 +86,17 @@ class JavaScriptShared
 
     static const uint32_t OBJECT_EXTRA_BITS  = 1;
     static const uint32_t OBJECT_IS_CALLABLE = (1 << 0);
 
     bool Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpows, JSObject **objp);
     bool Wrap(JSContext *cx, JS::HandleObject aObj, InfallibleTArray<CpowEntry> *outCpows);
 
   protected:
-    bool toVariant(JSContext *cx, jsval from, JSVariant *to);
+    bool toVariant(JSContext *cx, JS::HandleValue from, JSVariant *to);
     bool toValue(JSContext *cx, const JSVariant &from, JS::MutableHandleValue to);
     bool fromDescriptor(JSContext *cx, JS::Handle<JSPropertyDescriptor> desc, PPropertyDescriptor *out);
     bool toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
                       JS::MutableHandle<JSPropertyDescriptor> out);
     bool convertIdToGeckoString(JSContext *cx, JS::HandleId id, nsString *to);
     bool convertGeckoStringToId(JSContext *cx, const nsString &from, JS::MutableHandleId id);
 
     bool toValue(JSContext *cx, const JSVariant &from, jsval *to) {