Changeset 252671 in webkit


Ignore:
Timestamp:
Nov 19, 2019 6:08:26 PM (5 years ago)
Author:
Fujii Hironori
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):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r252661 r252671  
     12019-11-19  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [JSC] DisallowVMReentry and DeferGC should use WTF::ThreadSpecific instead of using WTF::threadSpecificKeyCreate directly
     4        https://bugs.webkit.org/show_bug.cgi?id=204350
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        WTF provides two thread specific storages, ThreadSpecific and
     9        threadSpecificKeyCreate. Only DisallowVMReentry and DeferGC were
     10        using the latter. They should use WTF::ThreadSpecific because it
     11        is a useful type-safe wrapper class.
     12
     13        * heap/DeferGC.cpp:
     14        * heap/DeferGC.h:
     15        (JSC::DisallowGC::initialize):
     16        (JSC::DisallowGC::scopeReentryCount):
     17        (JSC::DisallowGC::setScopeReentryCount):
     18        * runtime/DisallowVMReentry.cpp:
     19        * runtime/DisallowVMReentry.h:
     20        (JSC::DisallowVMReentry::initialize):
     21        (JSC::DisallowVMReentry::scopeReentryCount):
     22        (JSC::DisallowVMReentry::setScopeReentryCount):
     23
    1242019-11-19  Yusuke Suzuki  <ysuzuki@apple.com>
    225
  • trunk/Source/JavaScriptCore/heap/DeferGC.cpp

    r215885 r252671  
    3232
    3333#ifndef NDEBUG
    34 WTF::ThreadSpecificKey DisallowGC::s_scopeReentryCount = 0;
     34LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> DisallowGC::s_scopeReentryCount;
    3535#endif
    3636
  • trunk/Source/JavaScriptCore/heap/DeferGC.h

    r241927 r252671  
    2828#include "DisallowScope.h"
    2929#include "Heap.h"
     30#include <wtf/NeverDestroyed.h>
    3031#include <wtf/ThreadSpecific.h>
    3132
     
    9091    static void initialize()
    9192    {
    92         WTF::threadSpecificKeyCreate(&s_scopeReentryCount, 0);
     93        s_scopeReentryCount.construct();
    9394    }
    9495
    9596private:
    96     static uintptr_t scopeReentryCount()
     97    static unsigned scopeReentryCount()
    9798    {
    98         return reinterpret_cast<uintptr_t>(WTF::threadSpecificGet(s_scopeReentryCount));
     99        return *s_scopeReentryCount.get();
    99100    }
    100     static void setScopeReentryCount(uintptr_t value)
     101    static void setScopeReentryCount(unsigned value)
    101102    {
    102         WTF::threadSpecificSet(s_scopeReentryCount, reinterpret_cast<void*>(value));
     103        *s_scopeReentryCount.get() = value;
    103104    }
    104105   
    105     JS_EXPORT_PRIVATE static WTF::ThreadSpecificKey s_scopeReentryCount;
     106    JS_EXPORT_PRIVATE static LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> s_scopeReentryCount;
    106107
    107108#endif // NDEBUG
  • trunk/Source/JavaScriptCore/runtime/DisallowVMReentry.cpp

    r215885 r252671  
    3232   
    3333#ifndef NDEBUG
    34 WTF::ThreadSpecificKey DisallowVMReentry::s_scopeReentryCount = 0;
     34LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> DisallowVMReentry::s_scopeReentryCount;
    3535#endif
    3636   
  • trunk/Source/JavaScriptCore/runtime/DisallowVMReentry.h

    r215885 r252671  
    2727
    2828#include "DisallowScope.h"
     29#include <wtf/NeverDestroyed.h>
    2930#include <wtf/ThreadSpecific.h>
    3031
     
    4849    static void initialize()
    4950    {
    50         WTF::threadSpecificKeyCreate(&s_scopeReentryCount, 0);
     51        s_scopeReentryCount.construct();
    5152    }
    5253
    5354private:
    54     static uintptr_t scopeReentryCount()
     55    static unsigned scopeReentryCount()
    5556    {
    56         return reinterpret_cast<uintptr_t>(WTF::threadSpecificGet(s_scopeReentryCount));
     57        return *s_scopeReentryCount.get();
    5758    }
    58     static void setScopeReentryCount(uintptr_t value)
     59    static void setScopeReentryCount(unsigned value)
    5960    {
    60         WTF::threadSpecificSet(s_scopeReentryCount, reinterpret_cast<void*>(value));
     61        *s_scopeReentryCount.get() = value;
    6162    }
    6263
    63     JS_EXPORT_PRIVATE static WTF::ThreadSpecificKey s_scopeReentryCount;
     64    JS_EXPORT_PRIVATE static LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> s_scopeReentryCount;
    6465
    6566#endif // NDEBUG
Note: See TracChangeset for help on using the changeset viewer.