Bug 1034627 part 5 - Make quick stubs work with Latin1 strings and nursery strings. r=bz
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 11 Jul 2014 16:22:35 +0200
changeset 193616 4dfa43eb6862a1d795cdbb7a9e7ffb2ce1dbed51
parent 193615 48b4e65d344d71e132ee97c79ab542b939d058b9
child 193617 52291e750b098ebacd926875e5d4977e9ce948b1
push id27123
push userryanvm@gmail.com
push dateFri, 11 Jul 2014 20:35:05 +0000
treeherdermozilla-central@84bd8d9f4256 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1034627
milestone33.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 1034627 part 5 - Make quick stubs work with Latin1 strings and nursery strings. r=bz
js/xpconnect/src/XPCQuickStubs.cpp
js/xpconnect/src/XPCQuickStubs.h
--- a/js/xpconnect/src/XPCQuickStubs.cpp
+++ b/js/xpconnect/src/XPCQuickStubs.cpp
@@ -417,25 +417,19 @@ xpc_qsDOMString::xpc_qsDOMString(JSConte
     // From the T_DOMSTRING case in XPCConvert::JSData2Native.
     JSString *s = InitOrStringify<traits>(cx, v,
                                           pval, notpassed,
                                           nullBehavior,
                                           undefinedBehavior);
     if (!s)
         return;
 
-    size_t len;
-    const jschar *chars = JS_GetStringCharsZAndLength(cx, s, &len);
-    if (!chars) {
-        mValid = false;
-        return;
-    }
+    nsAutoString *str = new(mBuf) implementation_type();
 
-    new(mBuf) implementation_type(chars, len);
-    mValid = true;
+    mValid = AssignJSString(cx, *str, s);
 }
 
 xpc_qsACString::xpc_qsACString(JSContext *cx, HandleValue v,
                                MutableHandleValue pval, bool notpassed,
                                StringificationBehavior nullBehavior,
                                StringificationBehavior undefinedBehavior)
 {
     typedef implementation_type::char_traits traits;
@@ -466,24 +460,23 @@ xpc_qsACString::xpc_qsACString(JSContext
 xpc_qsAUTF8String::xpc_qsAUTF8String(JSContext *cx, HandleValue v, MutableHandleValue pval, bool notpassed)
 {
     typedef nsCharTraits<char16_t> traits;
     // From the T_UTF8STRING  case in XPCConvert::JSData2Native.
     JSString *s = InitOrStringify<traits>(cx, v, pval, notpassed, eNull, eNull);
     if (!s)
         return;
 
-    size_t len;
-    const char16_t *chars = JS_GetStringCharsZAndLength(cx, s, &len);
-    if (!chars) {
+    nsAutoJSString str;
+    if (!str.init(cx, s)) {
         mValid = false;
         return;
     }
 
-    new(mBuf) implementation_type(chars, len);
+    new(mBuf) implementation_type(str);
     mValid = true;
 }
 
 static nsresult
 getNative(nsISupports *idobj,
           HandleObject obj,
           const nsIID &iid,
           void **ppThis,
--- a/js/xpconnect/src/XPCQuickStubs.h
+++ b/js/xpconnect/src/XPCQuickStubs.h
@@ -276,17 +276,17 @@ protected:
  *
  * The second argument to the constructor is an in-out parameter. It must
  * point to a rooted jsval, such as a JSNative argument or return value slot.
  * The value in the jsval on entry is converted to a string. The constructor
  * may overwrite that jsval with a string value, to protect the characters of
  * the string from garbage collection. The caller must leave the jsval alone
  * for the lifetime of the xpc_qsDOMString.
  */
-class xpc_qsDOMString : public xpc_qsBasicString<nsAString, nsDependentString>
+class xpc_qsDOMString : public xpc_qsBasicString<nsAString, nsAutoString>
 {
 public:
     xpc_qsDOMString(JSContext *cx, JS::HandleValue v,
                     JS::MutableHandleValue pval, bool notpassed,
                     StringificationBehavior nullBehavior,
                     StringificationBehavior undefinedBehavior);
 };