Bug 1306756 - Remove the JS_strdup() overload accepting a JSRuntime*; r=sfink
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 30 Sep 2016 17:50:43 -0400
changeset 316263 f7555646ebedb56d95ec5b037a7766f7f06266d9
parent 316262 53291cfac404af036ad542a7a5a0e30c9d044df1
child 316264 1adfbab318a6de4b40e1e88751c06f5b354bb1b0
push id20649
push userphilringnalda@gmail.com
push dateTue, 04 Oct 2016 03:52:28 +0000
treeherderfx-team@96c39d552134 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1306756
milestone52.0a1
Bug 1306756 - Remove the JS_strdup() overload accepting a JSRuntime*; r=sfink There's no way to get a JSRuntime* in the JS API any more.
js/src/jsapi.cpp
js/src/jsapi.h
js/src/vm/Runtime.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1296,27 +1296,16 @@ JS_updateMallocCounter(JSContext* cx, si
 
 JS_PUBLIC_API(char*)
 JS_strdup(JSContext* cx, const char* s)
 {
     AssertHeapIsIdle(cx);
     return DuplicateString(cx, s).release();
 }
 
-JS_PUBLIC_API(char*)
-JS_strdup(JSRuntime* rt, const char* s)
-{
-    AssertHeapIsIdle(rt);
-    size_t n = strlen(s) + 1;
-    char* p = rt->pod_malloc<char>(n);
-    if (!p)
-        return nullptr;
-    return static_cast<char*>(js_memcpy(p, s, n));
-}
-
 #undef JS_AddRoot
 
 JS_PUBLIC_API(bool)
 JS_AddExtraGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data)
 {
     return cx->gc.addBlackRootsTracer(traceOp, data);
 }
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1587,20 +1587,16 @@ extern JS_PUBLIC_API(void)
 JS_freeop(JSFreeOp* fop, void* p);
 
 extern JS_PUBLIC_API(void)
 JS_updateMallocCounter(JSContext* cx, size_t nbytes);
 
 extern JS_PUBLIC_API(char*)
 JS_strdup(JSContext* cx, const char* s);
 
-/** Duplicate a string.  Does not report an error on failure. */
-extern JS_PUBLIC_API(char*)
-JS_strdup(JSRuntime* rt, const char* s);
-
 /**
  * Register externally maintained GC roots.
  *
  * traceOp: the trace operation. For each root the implementation should call
  *          JS::TraceEdge whenever the root contains a traceable thing.
  * data:    the data argument to pass to each invocation of traceOp.
  */
 extern JS_PUBLIC_API(bool)
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -618,17 +618,17 @@ JSRuntime::handleInterrupt(JSContext* cx
 }
 
 bool
 JSRuntime::setDefaultLocale(const char* locale)
 {
     if (!locale)
         return false;
     resetDefaultLocale();
-    defaultLocale = JS_strdup(this, locale);
+    defaultLocale = JS_strdup(contextFromMainThread(), locale);
     return defaultLocale != nullptr;
 }
 
 void
 JSRuntime::resetDefaultLocale()
 {
     js_free(defaultLocale);
     defaultLocale = nullptr;
@@ -645,17 +645,17 @@ JSRuntime::getDefaultLocale()
     locale = setlocale(LC_ALL, nullptr);
 #else
     locale = getenv("LANG");
 #endif
     // convert to a well-formed BCP 47 language tag
     if (!locale || !strcmp(locale, "C"))
         locale = "und";
 
-    char* lang = JS_strdup(this, locale);
+    char* lang = JS_strdup(contextFromMainThread(), locale);
     if (!lang)
         return nullptr;
 
     char* p;
     if ((p = strchr(lang, '.')))
         *p = '\0';
     while ((p = strchr(lang, '_')))
         *p = '-';