forked from OSchip/llvm-project
[sanitizer] Remove SpinMutexLock from stat function
Mapped size is more appropriate for most users. Depends on D111605. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D111607
This commit is contained in:
parent
b4b9f9b4b3
commit
884d290427
|
@ -24,11 +24,7 @@ template <typename T>
|
|||
class PersistentAllocator {
|
||||
public:
|
||||
T *alloc(uptr count = 1);
|
||||
uptr allocated() const {
|
||||
SpinMutexLock l(&mtx);
|
||||
return atomic_load_relaxed(&mapped_size) +
|
||||
atomic_load_relaxed(®ion_pos) - atomic_load_relaxed(®ion_end);
|
||||
}
|
||||
uptr allocated() const { return atomic_load_relaxed(&mapped_size); }
|
||||
|
||||
private:
|
||||
T *tryAlloc(uptr count);
|
||||
|
|
|
@ -81,10 +81,12 @@ TEST(SanitizerCommon, ChainedOriginDepotStats) {
|
|||
EXPECT_EQ(stats2.n_uniq_ids, stats1.n_uniq_ids);
|
||||
EXPECT_EQ(stats2.allocated, stats1.allocated);
|
||||
|
||||
EXPECT_TRUE(chainedOriginDepot.Put(35, 36, &new_id));
|
||||
StackDepotStats stats3 = chainedOriginDepot.GetStats();
|
||||
EXPECT_EQ(stats3.n_uniq_ids, stats2.n_uniq_ids + 1);
|
||||
EXPECT_GT(stats3.allocated, stats2.allocated);
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
ASSERT_TRUE(chainedOriginDepot.Put(35, i, &new_id));
|
||||
StackDepotStats stats3 = chainedOriginDepot.GetStats();
|
||||
ASSERT_EQ(stats3.n_uniq_ids, stats2.n_uniq_ids + 1 + i);
|
||||
}
|
||||
EXPECT_GT(chainedOriginDepot.GetStats().allocated, stats2.allocated);
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
|
Loading…
Reference in New Issue