Ignore:
Timestamp:
Apr 19, 2010, 1:05:53 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=37745
Move string uniquing tables to (new) WTFThreadData class.

Reviewed by Sam Weinig.

Remove AtomicString's dependency on ThreadGlobalData so that we can move
WebCore's string classes up to WTF.

JavaScriptCore:

WTFThreadData.cpp/.h are based on ThreadGlobalData from WebCore.
Moved JSC & WebCore's string uniquing tables to this class.

This patch introduces a temporary layering violation in providing forward
declarations of classes from JSC and WTF; this will be resolved as we move
more string code up to WTF.

  • API/APIShims.h:

(JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock):
(JSC::APIEntryShimWithoutLock::~APIEntryShimWithoutLock):
(JSC::APICallbackShim::APICallbackShim):
(JSC::APICallbackShim::~APICallbackShim):

(JSC::checkSyntax):
(JSC::evaluate):

  • runtime/Identifier.cpp:

(JSC::Identifier::remove):
(JSC::Identifier::checkCurrentIdentifierTable):

  • runtime/Identifier.h:
  • runtime/InitializeThreading.cpp:

(JSC::initializeThreadingOnce):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::create):

  • wtf/WTFThreadData.cpp: Copied from WebCore/platform/ThreadGlobalData.cpp.

(WTF::WTFThreadData::WTFThreadData):
(WTF::WTFThreadData::~WTFThreadData):

  • wtf/WTFThreadData.h: Copied from WebCore/platform/ThreadGlobalData.h.

(WTF::WTFThreadData::atomicStringTable):
(WTF::WTFThreadData::initializeIdentifierTable):
(WTF::WTFThreadData::currentIdentifierTable):
(WTF::WTFThreadData::setCurrentIdentifierTable):
(WTF::WTFThreadData::resetCurrentIdentifierTable):
(WTF::wtfThreadData):

JavaScriptGlue:

  • ForwardingHeaders/wtf/WTFThreadData.h: Added.
  • JSUtils.cpp: Update

(JSGlueAPIEntry::JSGlueAPIEntry):
(JSGlueAPIEntry::~JSGlueAPIEntry):
(JSGlueAPICallback::JSGlueAPICallback):
(JSGlueAPICallback::~JSGlueAPICallback):

WebCore:

  • ForwardingHeaders/wtf/WTFThreadData.h: Added.
  • platform/ThreadGlobalData.cpp: Remove m_atomicStringTable, all wtfThreadData() to ensure threadsafely initialized.

(WebCore::ThreadGlobalData::ThreadGlobalData):
(WebCore::ThreadGlobalData::~ThreadGlobalData):

  • platform/ThreadGlobalData.h: Remove m_atomicStringTable.

(WebCore::ThreadGlobalData::eventNames):

  • platform/text/AtomicString.cpp:

(WebCore::AtomicStringTable::create):
(WebCore::AtomicStringTable::table):
(WebCore::AtomicStringTable::destroy):
(WebCore::stringTable): Access the AtomicStringTable on wtfThreadData() rather then threadGlobalData().

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/WTFThreadData.cpp

    r57765 r57829  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626
    2727#include "config.h"
    28 #include "ThreadGlobalData.h"
     28#include "WTFThreadData.h"
    2929
    30 #include "EventNames.h"
    31 #include "StringImpl.h"
    32 #include "ThreadTimers.h"
    33 #include <wtf/UnusedParam.h>
     30namespace WTF {
    3431
    35 #if USE(ICU_UNICODE)
    36 #include "TextCodecICU.h"
     32#if WTFTHREADDATA_MULTITHREADED
     33ThreadSpecific<WTFThreadData>* WTFThreadData::staticData;
     34#else
     35WTFThreadData* WTFThreadData::staticData;
    3736#endif
    3837
    39 #if PLATFORM(MAC)
    40 #include "TextCodecMac.h"
    41 #endif
    42 
    43 #if ENABLE(WORKERS)
    44 #include <wtf/Threading.h>
    45 #include <wtf/ThreadSpecific.h>
    46 using namespace WTF;
    47 #endif
    48 
    49 namespace WebCore {
    50 
    51 #if ENABLE(WORKERS)
    52 ThreadSpecific<ThreadGlobalData>* ThreadGlobalData::staticData;
    53 #else
    54 ThreadGlobalData* ThreadGlobalData::staticData;
    55 #endif
    56 
    57 ThreadGlobalData::ThreadGlobalData()
    58     : m_atomicStringTable(new HashSet<StringImpl*>)
    59     , m_eventNames(new EventNames)
    60     , m_threadTimers(new ThreadTimers)
    61 #ifndef NDEBUG
    62     , m_isMainThread(isMainThread())
    63 #endif
    64 #if USE(ICU_UNICODE)
    65     , m_cachedConverterICU(new ICUConverterWrapper)
    66 #endif
    67 #if PLATFORM(MAC)
    68     , m_cachedConverterTEC(new TECConverterWrapper)
     38WTFThreadData::WTFThreadData()
     39    : m_atomicStringTable(0)
     40    , m_atomicStringTableDestructor(0)
     41#if USE(JSC)
     42    , m_defaultIdentifierTable(0)
     43    , m_currentIdentifierTable(0)
    6944#endif
    7045{
    71     // StringImpl::empty() does not construct its static string in a threadsafe fashion,
    72     // so ensure it has been initialized from here.
    73     //
    74     // This constructor will have been called on the main thread before being called on
    75     // any other thread, and is only called once per thread.
    76     StringImpl::empty();
    7746}
    7847
    79 ThreadGlobalData::~ThreadGlobalData()
     48WTFThreadData::~WTFThreadData()
    8049{
    81 #if PLATFORM(MAC)
    82     delete m_cachedConverterTEC;
    83 #endif
    84 #if USE(ICU_UNICODE)
    85     delete m_cachedConverterICU;
    86 #endif
    87     delete m_eventNames;
    88     delete m_atomicStringTable;
    89     delete m_threadTimers;
     50    if (m_atomicStringTableDestructor)
     51        m_atomicStringTableDestructor(m_atomicStringTable);
    9052}
    9153
Note: See TracChangeset for help on using the changeset viewer.