Changeset 219281 in webkit
- Timestamp:
- Jul 9, 2017, 5:22:58 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r219276 r219281 1 2017-07-09 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [JSC] Use fastMalloc / fastFree for STL containers 4 https://bugs.webkit.org/show_bug.cgi?id=174297 5 6 Reviewed by Sam Weinig. 7 8 In some places, we intentionally use STL containers over WTF containers. 9 For example, we sometimes use std::unordered_{set,map} instead of WTF::Hash{Set,Map} 10 because we do not have effective empty / deleted representations in the space of key's value. 11 But just using STL container means using libc's malloc instead of our fast malloc (bmalloc if it is enabled). 12 13 We introduce WTF::FastAllocator. This is C++ allocator implementation using fastMalloc and fastFree. 14 We specify this allocator to STL containers' template parameter to allocate memory from fastMalloc. 15 16 This WTF::FastAllocator gives us a chance to use STL containers if it is necessary 17 without compromising memory allocation throughput. 18 19 * dfg/DFGGraph.h: 20 * dfg/DFGIntegerCheckCombiningPhase.cpp: 21 * ftl/FTLLowerDFGToB3.cpp: 22 (JSC::FTL::DFG::LowerDFGToB3::switchStringSlow): 23 * runtime/FunctionHasExecutedCache.h: 24 * runtime/TypeLocationCache.h: 25 1 26 2017-07-08 Yusuke Suzuki <utatane.tea@gmail.com> 2 27 -
trunk/Source/JavaScriptCore/dfg/DFGGraph.h
r219046 r219281 998 998 999 999 #if USE(JSVALUE32_64) 1000 std::unordered_map<int64_t, double* > m_doubleConstantsMap;1000 std::unordered_map<int64_t, double*, std::hash<int64_t>, std::equal_to<int64_t>, FastAllocator<std::pair<const int64_t, double*>>> m_doubleConstantsMap; 1001 1001 std::unique_ptr<Bag<double>> m_doubleConstants; 1002 1002 #endif -
trunk/Source/JavaScriptCore/dfg/DFGIntegerCheckCombiningPhase.cpp
r214240 r219281 397 397 } 398 398 399 typedef std::unordered_map<RangeKey, Range, HashMethod<RangeKey>> RangeMap;399 using RangeMap = std::unordered_map<RangeKey, Range, HashMethod<RangeKey>, std::equal_to<RangeKey>, FastAllocator<std::pair<const RangeKey, Range>>>; 400 400 RangeMap m_map; 401 401 -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r219187 r219281 11850 11850 11851 11851 Vector<SwitchCase> cases; 11852 std::unordered_set<int32_t> alreadyHandled; // These may be negative, or zero, or probably other stuff, too. We don't want to mess with HashSet's corner cases and we don't really care about throughput here. 11852 // These may be negative, or zero, or probably other stuff, too. We don't want to mess with HashSet's corner cases and we don't really care about throughput here. 11853 std::unordered_set<int32_t, std::hash<int32_t>, std::equal_to<int32_t>, FastAllocator<int32_t>> alreadyHandled; 11853 11854 for (unsigned i = 0; i < data->cases.size(); ++i) { 11854 11855 // FIXME: The fact that we're using the bytecode's switch table means that the -
trunk/Source/JavaScriptCore/runtime/FunctionHasExecutedCache.h
r206525 r219281 54 54 Vector<std::tuple<bool, unsigned, unsigned>> getFunctionRanges(intptr_t id); 55 55 56 private: 57 typedef std::unordered_map<FunctionRange, bool, HashMethod<FunctionRange>> RangeMap;58 typedef std::unordered_map<intptr_t, RangeMap> SourceIDToRangeMap;56 private: 57 using RangeMap = std::unordered_map<FunctionRange, bool, HashMethod<FunctionRange>, std::equal_to<FunctionRange>, FastAllocator<std::pair<const FunctionRange, bool>>>; 58 using SourceIDToRangeMap = std::unordered_map<intptr_t, RangeMap, std::hash<intptr_t>, std::equal_to<intptr_t>, FastAllocator<std::pair<const intptr_t, RangeMap>>>; 59 59 SourceIDToRangeMap m_rangeMap; 60 60 }; -
trunk/Source/JavaScriptCore/runtime/TypeLocationCache.h
r212365 r219281 28 28 #include "TypeLocation.h" 29 29 #include <unordered_map> 30 #include <wtf/FastMalloc.h> 30 31 #include <wtf/HashMethod.h> 31 32 … … 58 59 59 60 std::pair<TypeLocation*, bool> getTypeLocation(GlobalVariableID, intptr_t, unsigned start, unsigned end, RefPtr<TypeSet>&&, VM*); 60 private: 61 typedef std::unordered_map<LocationKey, TypeLocation*, HashMethod<LocationKey>> LocationMap;61 private: 62 using LocationMap = std::unordered_map<LocationKey, TypeLocation*, HashMethod<LocationKey>, std::equal_to<LocationKey>, FastAllocator<std::pair<const LocationKey, TypeLocation*>>>; 62 63 LocationMap m_locationMap; 63 64 }; -
trunk/Source/WTF/ChangeLog
r219274 r219281 1 2017-07-09 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [JSC] Use fastMalloc / fastFree for STL containers 4 https://bugs.webkit.org/show_bug.cgi?id=174297 5 6 Reviewed by Sam Weinig. 7 8 * wtf/FastMalloc.h: 9 (WTF::FastAllocator::FastAllocator): 10 (WTF::FastAllocator::allocate): 11 (WTF::FastAllocator::deallocate): 12 (WTF::FastAllocator::operator==): 13 (WTF::FastAllocator::operator!=): 14 1 15 2017-07-07 Brent Fulgham <bfulgham@apple.com> 2 16 -
trunk/Source/WTF/wtf/FastMalloc.h
r210840 r219281 105 105 } 106 106 107 // C++ STL allocator implementation. You can integrate fastMalloc into STL containers. 108 // e.g. std::unordered_map<Key, Value, std::hash<Key>, std::equal_to<Key>, FastAllocator<std::pair<const Key, Value>>>. 109 template<typename T> 110 class FastAllocator { 111 public: 112 using value_type = T; 113 114 FastAllocator() = default; 115 116 template<typename U> FastAllocator(const FastAllocator<U>&) { } 117 118 T* allocate(size_t count) 119 { 120 return reinterpret_cast<T*>(fastMalloc(sizeof(T) * count)); 121 } 122 123 void deallocate(T* pointer, size_t) 124 { 125 fastFree(pointer); 126 } 127 128 template<typename U> bool operator==(const FastAllocator<U>&) { return true; } 129 130 template<typename U> bool operator!=(const FastAllocator<U>&) { return false; } 131 }; 132 107 133 } // namespace WTF 108 134 … … 126 152 using WTF::fastAlignedMalloc; 127 153 using WTF::fastAlignedFree; 154 using WTF::FastAllocator; 128 155 129 156 #if COMPILER(GCC_OR_CLANG) && OS(DARWIN)
Note:
See TracChangeset
for help on using the changeset viewer.