Bug 785524 - Remove JS_MakeStringImmutable; it is no longer necessary; r=luke
authorTerrence Cole <terrence@mozilla.com>
Fri, 24 Aug 2012 15:00:38 -0700
changeset 105624 2954b2a61cfa971bda27ebf2cbdc1c3dd3715558
parent 105623 72bb1083fbab13792b9434efe92a49403cb71433
child 105625 c7e0c849fcdc8acb4a15687fabc17bd3033addf8
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersluke
bugs785524
milestone17.0a1
Bug 785524 - Remove JS_MakeStringImmutable; it is no longer necessary; r=luke
js/src/jsapi.cpp
js/src/jsapi.h
js/xpconnect/src/XPCVariant.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -6221,24 +6221,16 @@ JS_PUBLIC_API(const jschar *)
 JS_UndependString(JSContext *cx, JSString *str)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
     return str->getCharsZ(cx);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_MakeStringImmutable(JSContext *cx, JSString *str)
-{
-    AssertHeapIsIdle(cx);
-    CHECK_REQUEST(cx);
-    return !!str->ensureFixed(cx);
-}
-
-JS_PUBLIC_API(JSBool)
 JS_EncodeCharacters(JSContext *cx, const jschar *src, size_t srclen, char *dst, size_t *dstlenp)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
 
     size_t n;
     if (!dst) {
         n = GetDeflatedStringLength(cx, src, srclen);
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -5553,37 +5553,16 @@ JS_PutEscapedFlatString(char *buffer, si
 /*
  * This function is now obsolete and behaves the same as JS_NewUCString.  Use
  * JS_NewUCString instead.
  */
 extern JS_PUBLIC_API(JSString *)
 JS_NewGrowableString(JSContext *cx, jschar *chars, size_t length);
 
 /*
- * Mutable string support.  A string's characters are never mutable in this JS
- * implementation, but a dependent string is a substring of another dependent
- * or immutable string, and a rope is a lazily concatenated string that creates
- * its underlying buffer the first time it is accessed.  Even after a rope
- * creates its underlying buffer, it still considered mutable.  The direct data
- * members of the (opaque to API clients) JSString struct may be changed in a
- * single-threaded way for dependent strings and ropes.
- *
- * Therefore mutable strings (ropes and dependent strings) cannot be used by
- * more than one thread at a time.  You may call JS_MakeStringImmutable to
- * convert the string from a mutable string to an immutable (and therefore
- * thread-safe) string.  The engine takes care of converting ropes and dependent
- * strings to immutable for you if you store strings in multi-threaded objects
- * using JS_SetProperty or kindred API entry points.
- *
- * If you store a JSString pointer in a native data structure that is (safely)
- * accessible to multiple threads, you must call JS_MakeStringImmutable before
- * retiring the store.
- */
-
-/*
  * Create a dependent string, i.e., a string that owns no character storage,
  * but that refers to a slice of another string's chars.  Dependent strings
  * are mutable by definition, so the thread safety comments above apply.
  */
 extern JS_PUBLIC_API(JSString *)
 JS_NewDependentString(JSContext *cx, JSString *str, size_t start,
                       size_t length);
 
@@ -5597,23 +5576,16 @@ JS_ConcatStrings(JSContext *cx, JSString
 /*
  * Convert a dependent string into an independent one.  This function does not
  * change the string's mutability, so the thread safety comments above apply.
  */
 extern JS_PUBLIC_API(const jschar *)
 JS_UndependString(JSContext *cx, JSString *str);
 
 /*
- * Convert a mutable string (either rope or dependent) into an immutable,
- * thread-safe one.
- */
-extern JS_PUBLIC_API(JSBool)
-JS_MakeStringImmutable(JSContext *cx, JSString *str);
-
-/*
  * Return JS_TRUE if C (char []) strings passed via the API and internally
  * are UTF-8.
  */
 JS_PUBLIC_API(JSBool)
 JS_CStringsAreUTF8(void);
 
 /*
  * Update the value to be returned by JS_CStringsAreUTF8(). Once set, it
--- a/js/xpconnect/src/XPCVariant.cpp
+++ b/js/xpconnect/src/XPCVariant.cpp
@@ -278,20 +278,18 @@ JSBool XPCVariant::InitializeData(XPCCal
         return NS_SUCCEEDED(nsVariant::SetFromDouble(&mData, val.toDouble()));
     if (val.isBoolean())
         return NS_SUCCEEDED(nsVariant::SetFromBool(&mData, val.toBoolean()));
     if (val.isUndefined())
         return NS_SUCCEEDED(nsVariant::SetToVoid(&mData));
     if (val.isNull())
         return NS_SUCCEEDED(nsVariant::SetToEmpty(&mData));
     if (val.isString()) {
-        // Make our string immutable.  This will also ensure null-termination,
-        // which nsVariant assumes for its PRUnichar* stuff.
         JSString* str = val.toString();
-        if (!JS_MakeStringImmutable(ccx, str))
+        if (!str)
             return false;
 
         // Don't use nsVariant::SetFromWStringWithSize, because that will copy
         // the data.  Just handle this ourselves.  Note that it's ok to not
         // copy because we added mJSVal as a GC root.
         NS_ASSERTION(mData.mType == nsIDataType::VTYPE_EMPTY,
                      "Why do we already have data?");