Bug 903519 - Strings in the nursery: allow any thread to access zone of permanent atoms, r=jonco
☠☠ backed out by 65e92478e09d ☠ ☠
authorSteve Fink <sfink@mozilla.com>
Sun, 30 Jul 2017 13:21:53 -0700
changeset 453158 7854bfe5d68346a38b25d93ea8870f47bce4f901
parent 453157 f5f72c93adf94f4ae670c38941f68c75d19f8072
child 453159 c62e5867d763dea5a05117e8ab7c02a9b5994dd8
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs903519
milestone59.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 903519 - Strings in the nursery: allow any thread to access zone of permanent atoms, r=jonco
js/public/HeapAPI.h
js/src/jsapi.cpp
js/src/vm/String.h
--- a/js/public/HeapAPI.h
+++ b/js/public/HeapAPI.h
@@ -456,17 +456,25 @@ namespace JS {
 static MOZ_ALWAYS_INLINE Zone*
 GetTenuredGCThingZone(GCCellPtr thing)
 {
     MOZ_ASSERT(!js::gc::IsInsideNursery(thing.asCell()));
     return js::gc::detail::GetGCThingZone(thing.unsafeAsUIntPtr());
 }
 
 extern JS_PUBLIC_API(Zone*)
-GetStringZone(JSString* str);
+GetNurseryStringZone(JSString* str);
+
+static MOZ_ALWAYS_INLINE Zone*
+GetStringZone(JSString* str)
+{
+    if (!js::gc::IsInsideNursery(reinterpret_cast<js::gc::Cell*>(str)))
+        return js::gc::detail::GetGCThingZone(reinterpret_cast<uintptr_t>(str));
+    return GetNurseryStringZone(str);
+}
 
 extern JS_PUBLIC_API(Zone*)
 GetObjectZone(JSObject* obj);
 
 extern JS_PUBLIC_API(Zone*)
 GetValueZone(const Value& value);
 
 static MOZ_ALWAYS_INLINE bool
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -7709,18 +7709,19 @@ JS::CopyAsyncStack(JSContext* cx, JS::Ha
 
 JS_PUBLIC_API(Zone*)
 JS::GetObjectZone(JSObject* obj)
 {
     return obj->zone();
 }
 
 JS_PUBLIC_API(Zone*)
-JS::GetStringZone(JSString* str)
-{
+JS::GetNurseryStringZone(JSString* str)
+{
+    MOZ_ASSERT(!str->isTenured());
     return str->zone();
 }
 
 JS_PUBLIC_API(JS::TraceKind)
 JS::GCThingTraceKind(void* thing)
 {
     MOZ_ASSERT(thing);
     return static_cast<js::gc::Cell*>(thing)->getTraceKind();
--- a/js/src/vm/String.h
+++ b/js/src/vm/String.h
@@ -541,18 +541,22 @@ class JSString : public js::gc::Cell
                       offsetof(JSString, d.s.u2.nonInlineCharsLatin1),
                       "nonInlineCharsTwoByte and nonInlineCharsLatin1 must have same offset");
         return offsetof(JSString, d.s.u2.nonInlineCharsTwoByte);
     }
 
     static const JS::TraceKind TraceKind = JS::TraceKind::String;
 
     JS::Zone* zone() const {
-        if (isTenured())
+        if (isTenured()) {
+            // Allow permanent atoms to be accessed across zones and runtimes.
+            if (isPermanentAtom())
+                return zoneFromAnyThread();
             return asTenured().zone();
+        }
         return js::Nursery::getStringZone(this);
     }
 
     // Implement TenuredZone members needed for template instantiations.
 
     JS::Zone* zoneFromAnyThread() const {
         if (isTenured())
             return asTenured().zoneFromAnyThread();