Adds an iterator to the AddrHashMap class used by sanitizer runtime
libraries. Adds a test of the new iterator.
Details
- Reviewers
vitalybuka dvyukov aizatsky
Diff Detail
Event Timeline
lib/sanitizer_common/sanitizer_addrhashmap.h | ||
---|---|---|
113 | I think logic could be simpler if Iterator contained temp copy of HashValue<T*> E.g.: const HashValue<T*>& operator*() { return curr_item_; } Iterator& operator++() { // all logic here, curr_item_ = something. } HashValue<T*> curr_item_; } | |
121 | add == nullptr should not be possible according line 139 | |
130 | This will hide bugs. We should crash here if someone increments end(). | |
136 | Iterating concurrent hash map looks scary in general, and not very efficient. |
lib/sanitizer_common/sanitizer_addrhashmap.h | ||
---|---|---|
91 | remove the template, and just use T* | |
92 | s/HashValue/Value/ It's already in the scope of Addr_Hash_Map. | |
101 | please move all the code out of the class declaration to the bottom of the file you can see that it is done for all member functions here, I wanted the declaration to remain at least minimally readable (to the point it is possible with C++) | |
105 | this won't work: iterator can hold mutex lock if you copy the iterator, you will double unlock the mutex and corrupt its state do you plan to use them? if not, = delete | |
124 | this must be acquire to pair with release in the release function but unfortunately that's not enough: elements can be concurrently removed and overwritten I think the simplest fix would be to read lock the cell whenever you access it (both embed and add elements). | |
136 | unless I am missing something, this can double-lock the mutex if a cell contains more than 1 add element need more tests to catch it | |
lib/sanitizer_common/tests/sanitizer_addrhashmap_test.cc | ||
1 | s/bitvector/addrhashmap/ | |
11 | s/bitvector/addrhashmap/ |
AddrHashMap has significant limitations that make it unsuitable for most of our use cases for hashtables and we're going to need to add a separate, more general-purpose table: the data being read-only after creation, and most importantly, the fixed-size table that cannot resize and adapt to the size of the app, are blockers for us. Abandoning this CL.
remove the template, and just use T*
simpler and less typing