Changeset 242054 in webkit
- Timestamp:
- Feb 25, 2019 12:15:53 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r242053 r242054 1 2019-02-25 Tadeu Zagallo <tzagallo@apple.com> 2 3 Avoid hashing CompactVariableEnvironment when decoding CompactVariableMap::Handle 4 https://bugs.webkit.org/show_bug.cgi?id=194937 5 6 Reviewed by Saam Barati. 7 8 Hashing the CompactVariableEnvironment is expensive and we could avoid it 9 when decoding multiple handles to the same environment. This is sound because 10 a pointer to the same CompactVariableEnvironment will hash the same. 11 12 * runtime/CachedTypes.cpp: 13 (JSC::Decoder::handleForEnvironment const): 14 (JSC::Decoder::setHandleForEnvironment): 15 (JSC::CachedCompactVariableMapHandle::decode const): 16 1 17 2019-02-25 Tadeu Zagallo <tzagallo@apple.com> 2 18 -
trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp
r242053 r242054 260 260 } 261 261 262 CompactVariableMap::Handle handleForEnvironment(CompactVariableEnvironment* environment) const 263 { 264 auto it = m_environmentToHandleMap.find(environment); 265 ASSERT(it != m_environmentToHandleMap.end()); 266 return it->value; 267 } 268 269 void setHandleForEnvironment(CompactVariableEnvironment* environment, const CompactVariableMap::Handle& handle) 270 { 271 auto addResult = m_environmentToHandleMap.add(environment, handle); 272 ASSERT_UNUSED(addResult, addResult.isNewEntry); 273 } 274 262 275 private: 263 276 VM& m_vm; … … 268 281 HashMap<ptrdiff_t, void*> m_offsetToPtrMap; 269 282 Vector<std::function<void()>> m_finalizers; 283 HashMap<CompactVariableEnvironment*, CompactVariableMap::Handle> m_environmentToHandleMap; 270 284 }; 271 285 … … 939 953 bool isNewAllocation; 940 954 CompactVariableEnvironment* environment = m_environment.decode(decoder, isNewAllocation); 955 if (!isNewAllocation) 956 return decoder.handleForEnvironment(environment); 941 957 bool isNewEntry; 942 958 CompactVariableMap::Handle handle = decoder.vm().m_compactVariableMap->get(environment, isNewEntry); 943 if (!isNewAllocation) 944 ASSERT(!isNewEntry); 945 else if (!isNewEntry) { 959 if (!isNewEntry) { 946 960 decoder.addFinalizer([=] { 947 961 delete environment; 948 962 }); 949 963 } 964 decoder.setHandleForEnvironment(environment, handle); 950 965 return handle; 951 966 }
Note: See TracChangeset
for help on using the changeset viewer.