Add valgrind annotations
All checks were successful
Tests / Release [gcc] total: 583, passed: 583
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Reference build: <a href="https://jenkins.weaselab.dev/job/weaselab/job/conflict-set/job/main/30//gcc">weaselab » conflict-set » main #30</a>
Tests / Coverage total: 581, passed: 581
weaselab/conflict-set/pipeline/head This commit looks good
All checks were successful
Tests / Release [gcc] total: 583, passed: 583
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Reference build: <a href="https://jenkins.weaselab.dev/job/weaselab/job/conflict-set/job/main/30//gcc">weaselab » conflict-set » main #30</a>
Tests / Coverage total: 581, passed: 581
weaselab/conflict-set/pipeline/head This commit looks good
This appears to affect the binary (how else could it possibly work??), but the microbenchmarks don't show a difference
This commit is contained in:
@@ -36,6 +36,11 @@ limitations under the License.
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#if __has_include(<valgrind/memcheck.h>)
|
||||
#define MEMCHECK
|
||||
#include <valgrind/memcheck.h>
|
||||
#endif
|
||||
|
||||
// ==================== BEGIN IMPLEMENTATION ====================
|
||||
|
||||
struct Entry {
|
||||
@@ -53,10 +58,16 @@ struct BoundedFreeListAllocator {
|
||||
return new (safe_malloc(sizeof(T))) T;
|
||||
}
|
||||
assert(freeList != nullptr);
|
||||
void *result = freeList;
|
||||
void *buffer = freeList;
|
||||
#ifdef MEMCHECK
|
||||
VALGRIND_MAKE_MEM_DEFINED(freeList, sizeof(freeList));
|
||||
#endif
|
||||
memcpy(&freeList, freeList, sizeof(freeList));
|
||||
--freeListSize;
|
||||
return new (result) T;
|
||||
#ifdef MEMCHECK
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(buffer, sizeof(T));
|
||||
#endif
|
||||
return new (buffer) T;
|
||||
}
|
||||
|
||||
void release(T *p) {
|
||||
@@ -67,10 +78,16 @@ struct BoundedFreeListAllocator {
|
||||
memcpy((void *)p, &freeList, sizeof(freeList));
|
||||
freeList = p;
|
||||
++freeListSize;
|
||||
#ifdef MEMCHECK
|
||||
VALGRIND_MAKE_MEM_NOACCESS(p, sizeof(T));
|
||||
#endif
|
||||
}
|
||||
|
||||
~BoundedFreeListAllocator() {
|
||||
for (void *iter = freeList; iter != nullptr;) {
|
||||
#ifdef MEMCHECK
|
||||
VALGRIND_MAKE_MEM_DEFINED(iter, sizeof(iter));
|
||||
#endif
|
||||
auto *tmp = iter;
|
||||
memcpy(&iter, iter, sizeof(void *));
|
||||
free(tmp);
|
||||
|
Reference in New Issue
Block a user