Title: [252671] trunk/Source/_javascript_Core
Revision
252671
Author
hironori.fu...@sony.com
Date
2019-11-19 18:08:26 -0800 (Tue, 19 Nov 2019)

Log Message

[JSC] DisallowVMReentry and DeferGC should use WTF::ThreadSpecific instead of using WTF::threadSpecificKeyCreate directly
https://bugs.webkit.org/show_bug.cgi?id=204350

Reviewed by Yusuke Suzuki.

WTF provides two thread specific storages, ThreadSpecific and
threadSpecificKeyCreate. Only DisallowVMReentry and DeferGC were
using the latter. They should use WTF::ThreadSpecific because it
is a useful type-safe wrapper class.

* heap/DeferGC.cpp:
* heap/DeferGC.h:
(JSC::DisallowGC::initialize):
(JSC::DisallowGC::scopeReentryCount):
(JSC::DisallowGC::setScopeReentryCount):
* runtime/DisallowVMReentry.cpp:
* runtime/DisallowVMReentry.h:
(JSC::DisallowVMReentry::initialize):
(JSC::DisallowVMReentry::scopeReentryCount):
(JSC::DisallowVMReentry::setScopeReentryCount):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (252670 => 252671)


--- trunk/Source/_javascript_Core/ChangeLog	2019-11-20 01:53:06 UTC (rev 252670)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-11-20 02:08:26 UTC (rev 252671)
@@ -1,3 +1,26 @@
+2019-11-19  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [JSC] DisallowVMReentry and DeferGC should use WTF::ThreadSpecific instead of using WTF::threadSpecificKeyCreate directly
+        https://bugs.webkit.org/show_bug.cgi?id=204350
+
+        Reviewed by Yusuke Suzuki.
+
+        WTF provides two thread specific storages, ThreadSpecific and
+        threadSpecificKeyCreate. Only DisallowVMReentry and DeferGC were
+        using the latter. They should use WTF::ThreadSpecific because it
+        is a useful type-safe wrapper class.
+
+        * heap/DeferGC.cpp:
+        * heap/DeferGC.h:
+        (JSC::DisallowGC::initialize):
+        (JSC::DisallowGC::scopeReentryCount):
+        (JSC::DisallowGC::setScopeReentryCount):
+        * runtime/DisallowVMReentry.cpp:
+        * runtime/DisallowVMReentry.h:
+        (JSC::DisallowVMReentry::initialize):
+        (JSC::DisallowVMReentry::scopeReentryCount):
+        (JSC::DisallowVMReentry::setScopeReentryCount):
+
 2019-11-19  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Work-around Leaks' false-positive report about memory leaking

Modified: trunk/Source/_javascript_Core/heap/DeferGC.cpp (252670 => 252671)


--- trunk/Source/_javascript_Core/heap/DeferGC.cpp	2019-11-20 01:53:06 UTC (rev 252670)
+++ trunk/Source/_javascript_Core/heap/DeferGC.cpp	2019-11-20 02:08:26 UTC (rev 252671)
@@ -31,7 +31,7 @@
 namespace JSC {
 
 #ifndef NDEBUG
-WTF::ThreadSpecificKey DisallowGC::s_scopeReentryCount = 0;
+LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> DisallowGC::s_scopeReentryCount;
 #endif
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/heap/DeferGC.h (252670 => 252671)


--- trunk/Source/_javascript_Core/heap/DeferGC.h	2019-11-20 01:53:06 UTC (rev 252670)
+++ trunk/Source/_javascript_Core/heap/DeferGC.h	2019-11-20 02:08:26 UTC (rev 252671)
@@ -27,6 +27,7 @@
 
 #include "DisallowScope.h"
 #include "Heap.h"
+#include <wtf/NeverDestroyed.h>
 #include <wtf/ThreadSpecific.h>
 
 namespace JSC {
@@ -89,20 +90,20 @@
 
     static void initialize()
     {
-        WTF::threadSpecificKeyCreate(&s_scopeReentryCount, 0);
+        s_scopeReentryCount.construct();
     }
 
 private:
-    static uintptr_t scopeReentryCount()
+    static unsigned scopeReentryCount()
     {
-        return reinterpret_cast<uintptr_t>(WTF::threadSpecificGet(s_scopeReentryCount));
+        return *s_scopeReentryCount.get();
     }
-    static void setScopeReentryCount(uintptr_t value)
+    static void setScopeReentryCount(unsigned value)
     {
-        WTF::threadSpecificSet(s_scopeReentryCount, reinterpret_cast<void*>(value));
+        *s_scopeReentryCount.get() = value;
     }
     
-    JS_EXPORT_PRIVATE static WTF::ThreadSpecificKey s_scopeReentryCount;
+    JS_EXPORT_PRIVATE static LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> s_scopeReentryCount;
 
 #endif // NDEBUG
     

Modified: trunk/Source/_javascript_Core/runtime/DisallowVMReentry.cpp (252670 => 252671)


--- trunk/Source/_javascript_Core/runtime/DisallowVMReentry.cpp	2019-11-20 01:53:06 UTC (rev 252670)
+++ trunk/Source/_javascript_Core/runtime/DisallowVMReentry.cpp	2019-11-20 02:08:26 UTC (rev 252671)
@@ -31,7 +31,7 @@
 namespace JSC {
     
 #ifndef NDEBUG
-WTF::ThreadSpecificKey DisallowVMReentry::s_scopeReentryCount = 0;
+LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> DisallowVMReentry::s_scopeReentryCount;
 #endif
     
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/DisallowVMReentry.h (252670 => 252671)


--- trunk/Source/_javascript_Core/runtime/DisallowVMReentry.h	2019-11-20 01:53:06 UTC (rev 252670)
+++ trunk/Source/_javascript_Core/runtime/DisallowVMReentry.h	2019-11-20 02:08:26 UTC (rev 252671)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "DisallowScope.h"
+#include <wtf/NeverDestroyed.h>
 #include <wtf/ThreadSpecific.h>
 
 namespace JSC {
@@ -47,20 +48,20 @@
 
     static void initialize()
     {
-        WTF::threadSpecificKeyCreate(&s_scopeReentryCount, 0);
+        s_scopeReentryCount.construct();
     }
 
 private:
-    static uintptr_t scopeReentryCount()
+    static unsigned scopeReentryCount()
     {
-        return reinterpret_cast<uintptr_t>(WTF::threadSpecificGet(s_scopeReentryCount));
+        return *s_scopeReentryCount.get();
     }
-    static void setScopeReentryCount(uintptr_t value)
+    static void setScopeReentryCount(unsigned value)
     {
-        WTF::threadSpecificSet(s_scopeReentryCount, reinterpret_cast<void*>(value));
+        *s_scopeReentryCount.get() = value;
     }
 
-    JS_EXPORT_PRIVATE static WTF::ThreadSpecificKey s_scopeReentryCount;
+    JS_EXPORT_PRIVATE static LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> s_scopeReentryCount;
 
 #endif // NDEBUG
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to