Ignore:
Timestamp:
Jun 1, 2020, 5:51:53 PM (5 years ago)
Author:
[email protected]
Message:

Correct misunderstandings on how ThreadSpecific work
https://bugs.webkit.org/show_bug.cgi?id=212616

Reviewed by Michael Saboff.

There were two misunderstandings I had when writing code using ThreadSpecific
when doing LLInt bytecode buffer caching in Wasm.

  1. For ThreadSpecific<Vector>, I was calling Vector's constructor twice

unnecessarily, and incorrectly, since we ended up constructing over an
already constructed Vector for the second call. When doing operator* or
operator-> on a ThreadSpecific<T>, T() is called if it has not been
initialized yet. So there is no need to do manually call the constructor
the second time.

  1. There is no need to try to destroy entries for ThreadSpecific manually

since we already run destructors when the thread goes away.

This patch removes code for (1) and (2) both from the Wasm bytecode
buffer and from AssemblerData.

  • assembler/AssemblerBuffer.cpp:

(JSC::clearAssembleDataThreadSpecificCache): Deleted.

  • assembler/AssemblerBuffer.h:

(JSC::AssemblerBuffer::AssemblerBuffer):
(JSC::AssemblerBuffer::~AssemblerBuffer):
(JSC::AssemblerBuffer::getThreadSpecificAssemblerData): Deleted.

  • dfg/DFGWorklist.cpp:
  • jit/JITWorklist.cpp:
  • wasm/WasmLLIntGenerator.cpp:

(JSC::Wasm::LLIntGenerator::LLIntGenerator):
(JSC::Wasm::clearLLIntThreadSpecificCache): Deleted.

  • wasm/WasmLLIntGenerator.h:
  • wasm/WasmWorklist.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h

    r262362 r262402  
    4747
    4848    JS_EXPORT_PRIVATE ThreadSpecificAssemblerData& threadSpecificAssemblerData();
    49     void clearAssembleDataThreadSpecificCache();
    5049
    5150    class LinkBuffer;
     
    211210            , m_index(0)
    212211        {
    213             auto& threadSpecific = getThreadSpecificAssemblerData();
     212            auto& threadSpecific = threadSpecificAssemblerData();
    214213            m_storage.takeBufferIfLarger(WTFMove(*threadSpecific));
    215214        }
     
    217216        ~AssemblerBuffer()
    218217        {
    219             auto& threadSpecific = getThreadSpecificAssemblerData();
     218            auto& threadSpecific = threadSpecificAssemblerData();
    220219            threadSpecific->takeBufferIfLarger(WTFMove(m_storage));
    221220        }
     
    335334
    336335    protected:
    337         ThreadSpecificAssemblerData& getThreadSpecificAssemblerData()
    338         {
    339             auto& threadSpecific = threadSpecificAssemblerData();
    340 
    341             if (!threadSpecific.isSet()) {
    342                 void* ptr = static_cast<AssemblerData*>(threadSpecific);
    343                 new (ptr) AssemblerData();
    344             }
    345 
    346             return threadSpecific;
    347         }
    348        
    349336        template<typename IntegralType>
    350337        void putIntegral(IntegralType value)
Note: See TracChangeset for help on using the changeset viewer.