[llvm-commits] [compiler-rt] r158072 - in /compiler-rt/trunk/lib/asan: asan_allocator.cc asan_internal.h asan_posix.cc asan_win.cc
Kostya Serebryany
kcc at google.com
Wed Jun 6 07:46:38 PDT 2012
Author: kcc
Date: Wed Jun 6 09:46:38 2012
New Revision: 158072
URL: http://llvm.org/viewvc/llvm-project?rev=158072&view=rev
Log:
[asan] start compacting the allocator header, the goal is to make it 16 bytes w/o losing any information
Modified:
compiler-rt/trunk/lib/asan/asan_allocator.cc
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_posix.cc
compiler-rt/trunk/lib/asan/asan_win.cc
Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=158072&r1=158071&r2=158072&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Wed Jun 6 09:46:38 2012
@@ -150,19 +150,19 @@
//
// The magic numbers for the enum values are taken randomly.
enum {
- CHUNK_AVAILABLE = 0x573B,
- CHUNK_ALLOCATED = 0x3204,
- CHUNK_QUARANTINE = 0x1978,
- CHUNK_MEMALIGN = 0xDC68,
+ CHUNK_AVAILABLE = 0x57,
+ CHUNK_ALLOCATED = 0x32,
+ CHUNK_QUARANTINE = 0x19,
+ CHUNK_MEMALIGN = 0xDC,
};
struct ChunkBase {
- u16 chunk_state;
- u8 size_class;
- u32 offset; // User-visible memory starts at this+offset (beg()).
- s32 alloc_tid;
- s32 free_tid;
- uptr used_size; // Size requested by the user.
+ u8 chunk_state;
+ u8 size_class;
+ u32 offset; // User-visible memory starts at this+offset (beg()).
+ s32 alloc_tid;
+ s32 free_tid;
+ uptr used_size; // Size requested by the user.
AsanChunk *next;
uptr beg() { return (uptr)this + offset; }
@@ -708,7 +708,7 @@
AsanChunk *m = PtrToChunk((uptr)ptr);
// Flip the state atomically to avoid race on double-free.
- u16 old_chunk_state = AtomicExchange(&m->chunk_state, CHUNK_QUARANTINE);
+ u8 old_chunk_state = AtomicExchange(&m->chunk_state, CHUNK_QUARANTINE);
if (old_chunk_state == CHUNK_QUARANTINE) {
AsanReport("ERROR: AddressSanitizer attempting double-free on %p:\n", ptr);
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=158072&r1=158071&r2=158072&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Jun 6 09:46:38 2012
@@ -144,6 +144,7 @@
uptr GetThreadSelf();
int AtomicInc(int *a);
u16 AtomicExchange(u16 *a, u16 new_val);
+u8 AtomicExchange(u8 *a, u8 new_val);
// Wrapper for TLS/TSD.
void AsanTSDInit(void (*destructor)(void *tsd));
Modified: compiler-rt/trunk/lib/asan/asan_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=158072&r1=158071&r2=158072&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Wed Jun 6 09:46:38 2012
@@ -186,6 +186,10 @@
return __sync_lock_test_and_set(a, new_val);
}
+u8 AtomicExchange(u8 *a, u8 new_val) {
+ return __sync_lock_test_and_set(a, new_val);
+}
+
void SortArray(uptr *array, uptr size) {
std::sort(array, array + size);
}
Modified: compiler-rt/trunk/lib/asan/asan_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=158072&r1=158071&r2=158072&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Wed Jun 6 09:46:38 2012
@@ -219,6 +219,13 @@
return new_val;
}
+u16 AtomicExchange(u16 *a, u16 new_val) {
+ // FIXME: can we do this with a proper xchg intrinsic?
+ u8 t = *a;
+ *a = new_val;
+ return t;
+}
+
const char* AsanGetEnv(const char* name) {
static char env_buffer[32767] = {};
More information about the llvm-commits
mailing list