Changeset 225362 in webkit
- Timestamp:
- Nov 30, 2017, 3:44:24 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r225360 r225362 1 2017-11-30 Yusuke Suzuki <[email protected]> 2 3 [JSC] Remove easy toRemove & map.remove() use 4 https://bugs.webkit.org/show_bug.cgi?id=180208 5 6 Reviewed by Mark Lam. 7 8 In this patch, we replace Vector<> toRemove & map.remove loop with removeIf, 9 to optimize this common pattern. This patch only modifies apparent ones. 10 But we can apply this refactoring further to OAS phase in the future. 11 12 * b3/B3MoveConstants.cpp: 13 * dfg/DFGArgumentsEliminationPhase.cpp: 14 * dfg/DFGObjectAllocationSinkingPhase.cpp: 15 * wasm/WasmSignature.cpp: 16 (JSC::Wasm::SignatureInformation::tryCleanup): 17 1 18 2017-11-29 Yusuke Suzuki <[email protected]> 2 19 -
trunk/Source/JavaScriptCore/b3/B3MoveConstants.cpp
r219027 r225362 343 343 344 344 Procedure& m_proc; 345 Vector<Value*> m_toRemove;346 345 HashMap<ValueKey, unsigned> m_constTable; 347 346 int64_t* m_dataSection; 348 HashMap<ValueKey, Value*> m_constants;349 347 InsertionSet m_insertionSet; 350 348 }; -
trunk/Source/JavaScriptCore/dfg/DFGArgumentsEliminationPhase.cpp
r225307 r225362 193 193 bool changed; 194 194 do { 195 changed = false; 196 Vector<Node*, 1> toRemove; 197 198 for (Node* candidate : m_candidates) { 199 if (!isStillValidCandidate(candidate)) 200 toRemove.append(candidate); 201 } 202 203 if (toRemove.size()) { 204 changed = true; 205 for (Node* node : toRemove) 206 m_candidates.remove(node); 207 } 208 195 changed = m_candidates.removeIf( 196 [&] (Node* candidate) { 197 return !isStillValidCandidate(candidate); 198 }); 209 199 } while (changed); 210 200 } -
trunk/Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp
r221954 r225362 508 508 void pruneByLiveness(const NodeSet& live) 509 509 { 510 Vector<Node*> toRemove; 511 for (const auto& entry : m_pointers) { 512 if (!live.contains(entry.key)) 513 toRemove.append(entry.key); 514 } 515 for (Node* node : toRemove) 516 m_pointers.remove(node); 517 510 m_pointers.removeIf( 511 [&] (const auto& entry) { 512 return !live.contains(entry.key); 513 }); 518 514 prune(); 519 515 } … … 683 679 684 680 // Remove unreachable allocations 685 { 686 Vector<Node*> toRemove; 687 for (const auto& entry : m_allocations) { 688 if (!reachable.contains(entry.key)) 689 toRemove.append(entry.key); 690 } 691 for (Node* identifier : toRemove) 692 m_allocations.remove(identifier); 693 } 681 m_allocations.removeIf( 682 [&] (const auto& entry) { 683 return !reachable.contains(entry.key); 684 }); 694 685 } 695 686 … … 1250 1241 // We don't create materializations if the escapee is not a 1251 1242 // sink candidate 1252 Vector<Node*> toRemove; 1253 for (const auto& entry : escapees) { 1254 if (!m_sinkCandidates.contains(entry.key)) 1255 toRemove.append(entry.key); 1256 } 1257 for (Node* identifier : toRemove) 1258 escapees.remove(identifier); 1259 1243 escapees.removeIf( 1244 [&] (const auto& entry) { 1245 return !m_sinkCandidates.contains(entry.key); 1246 }); 1260 1247 if (escapees.isEmpty()) 1261 1248 return; -
trunk/Source/JavaScriptCore/wasm/WasmSignature.cpp
r223738 r225362 145 145 LockHolder lock(info.m_lock); 146 146 147 Vector<std::pair<SignatureIndex, Signature*>> toRemove; 148 for (const auto& pair : info.m_indexMap) { 149 const Ref<Signature>& signature = pair.value; 150 if (signature->refCount() == 1) { 151 // We're the only owner. 152 toRemove.append(std::make_pair(pair.key, signature.ptr())); 153 } 154 } 155 for (const auto& pair : toRemove) { 156 bool removed = info.m_signatureMap.remove(SignatureHash { pair.second }); 157 ASSERT_UNUSED(removed, removed); 158 removed = info.m_indexMap.remove(pair.first); 159 ASSERT_UNUSED(removed, removed); 160 } 147 info.m_indexMap.removeIf( 148 [&] (const auto& pair) { 149 const Ref<Signature>& signature = pair.value; 150 if (signature->refCount() == 1) { 151 // We're the only owner. 152 bool removed = info.m_signatureMap.remove(SignatureHash { signature.ptr() }); 153 ASSERT_UNUSED(removed, removed); 154 return true; 155 } 156 return false; 157 }); 158 161 159 if (info.m_signatureMap.isEmpty()) { 162 160 ASSERT(info.m_indexMap.isEmpty()); -
trunk/Source/WTF/ChangeLog
r225341 r225362 1 2017-11-30 Yusuke Suzuki <[email protected]> 2 3 [JSC] Remove easy toRemove & map.remove() use 4 https://bugs.webkit.org/show_bug.cgi?id=180208 5 6 Reviewed by Mark Lam. 7 8 Return bool from removeIf. It is true if removeIf removes at least one entry. 9 This interface is similar to existing HashSet::remove, which returns true 10 if it actually removes entry. 11 12 * wtf/HashMap.h: 13 (WTF::X>::removeIf): 14 * wtf/HashSet.h: 15 (WTF::V>::removeIf): 16 * wtf/HashTable.h: 17 (WTF::KeyTraits>::removeIf): 18 1 19 2017-11-30 Chris Dumez <[email protected]> 2 20 -
trunk/Source/WTF/wtf/HashMap.h
r223617 r225362 136 136 bool remove(iterator); 137 137 template<typename Functor> 138 voidremoveIf(Functor&&);138 bool removeIf(Functor&&); 139 139 void clear(); 140 140 … … 444 444 template<typename T, typename U, typename V, typename W, typename X> 445 445 template<typename Functor> 446 inline voidHashMap<T, U, V, W, X>::removeIf(Functor&& functor)447 { 448 m_impl.removeIf(std::forward<Functor>(functor));446 inline bool HashMap<T, U, V, W, X>::removeIf(Functor&& functor) 447 { 448 return m_impl.removeIf(std::forward<Functor>(functor)); 449 449 } 450 450 -
trunk/Source/WTF/wtf/HashSet.h
r223617 r225362 106 106 bool remove(iterator); 107 107 template<typename Functor> 108 voidremoveIf(const Functor&);108 bool removeIf(const Functor&); 109 109 void clear(); 110 110 … … 276 276 template<typename T, typename U, typename V> 277 277 template<typename Functor> 278 inline voidHashSet<T, U, V>::removeIf(const Functor& functor)279 { 280 m_impl.removeIf(functor);278 inline bool HashSet<T, U, V>::removeIf(const Functor& functor) 279 { 280 return m_impl.removeIf(functor); 281 281 } 282 282 -
trunk/Source/WTF/wtf/HashTable.h
r223617 r225362 406 406 void removeWithoutEntryConsistencyCheck(const_iterator); 407 407 template<typename Functor> 408 voidremoveIf(const Functor&);408 bool removeIf(const Functor&); 409 409 void clear(); 410 410 … … 1109 1109 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 1110 1110 template<typename Functor> 1111 inline voidHashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::removeIf(const Functor& functor)1111 inline bool HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::removeIf(const Functor& functor) 1112 1112 { 1113 1113 // We must use local copies in case "functor" or "deleteBucket" … … 1135 1135 1136 1136 internalCheckTableConsistency(); 1137 return removedBucketCount; 1137 1138 } 1138 1139
Note:
See TracChangeset
for help on using the changeset viewer.