Changeset 262362 in webkit for trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h
- Timestamp:
- May 31, 2020, 7:56:06 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h
r254087 r262362 38 38 #endif 39 39 #include <wtf/StdLibExtras.h> 40 #include <wtf/ThreadSpecific.h> 40 41 #include <wtf/UnalignedAccess.h> 41 42 42 43 namespace JSC { 44 class AssemblerData; 45 46 typedef ThreadSpecific<AssemblerData, WTF::CanBeGCThread::True> ThreadSpecificAssemblerData; 47 48 JS_EXPORT_PRIVATE ThreadSpecificAssemblerData& threadSpecificAssemblerData(); 49 void clearAssembleDataThreadSpecificCache(); 43 50 44 51 class LinkBuffer; … … 100 107 m_capacity = other.m_capacity; 101 108 102 other.m_buffer = nullptr;103 other.m_capacity = 0;109 other.m_buffer = other.m_inlineBuffer; 110 other.m_capacity = InlineCapacity; 104 111 } 105 112 … … 117 124 m_capacity = other.m_capacity; 118 125 119 other.m_buffer = nullptr;120 other.m_capacity = 0;126 other.m_buffer = other.m_inlineBuffer; 127 other.m_capacity = InlineCapacity; 121 128 return *this; 122 129 } 123 130 124 ~AssemblerData() 125 { 131 void takeBufferIfLarger(AssemblerData&& other) 132 { 133 if (other.isInlineBuffer()) 134 return; 135 136 if (m_capacity >= other.m_capacity) 137 return; 138 126 139 if (m_buffer && !isInlineBuffer()) 127 140 AssemblerDataMalloc::free(m_buffer); 141 142 m_buffer = other.m_buffer; 143 m_capacity = other.m_capacity; 144 145 other.m_buffer = other.m_inlineBuffer; 146 other.m_capacity = InlineCapacity; 147 } 148 149 ~AssemblerData() 150 { 151 clear(); 152 } 153 154 void clear() 155 { 156 if (m_buffer && !isInlineBuffer()) { 157 AssemblerDataMalloc::free(m_buffer); 158 m_capacity = InlineCapacity; 159 m_buffer = m_inlineBuffer; 160 } 128 161 } 129 162 … … 178 211 , m_index(0) 179 212 { 213 auto& threadSpecific = getThreadSpecificAssemblerData(); 214 m_storage.takeBufferIfLarger(WTFMove(*threadSpecific)); 215 } 216 217 ~AssemblerBuffer() 218 { 219 auto& threadSpecific = getThreadSpecificAssemblerData(); 220 threadSpecific->takeBufferIfLarger(WTFMove(m_storage)); 180 221 } 181 222 … … 294 335 295 336 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 296 349 template<typename IntegralType> 297 350 void putIntegral(IntegralType value)
Note:
See TracChangeset
for help on using the changeset viewer.