Use asm volatile during benchmarks.
This commit is contained in:
@@ -3,44 +3,50 @@
|
||||
|
||||
static void
|
||||
malloc_free(void) {
|
||||
void* volatile p = malloc(1);
|
||||
void* p = malloc(1);
|
||||
expect_ptr_not_null((void *)p, "Unexpected malloc failure");
|
||||
p = no_opt_ptr(p);
|
||||
free((void *)p);
|
||||
}
|
||||
|
||||
static void
|
||||
new_delete(void) {
|
||||
void* volatile p = ::operator new(1);
|
||||
void* p = ::operator new(1);
|
||||
expect_ptr_not_null((void *)p, "Unexpected new failure");
|
||||
p = no_opt_ptr(p);
|
||||
::operator delete((void *)p);
|
||||
}
|
||||
|
||||
static void
|
||||
malloc_free_array(void) {
|
||||
void* volatile p = malloc(sizeof(int)*8);
|
||||
void* p = malloc(sizeof(int)*8);
|
||||
expect_ptr_not_null((void *)p, "Unexpected malloc failure");
|
||||
p = no_opt_ptr(p);
|
||||
free((void *)p);
|
||||
}
|
||||
|
||||
static void
|
||||
new_delete_array(void) {
|
||||
int* volatile p = new int[8];
|
||||
expect_ptr_not_null((int *)p, "Unexpected new[] failure");
|
||||
int* p = new int[8];
|
||||
expect_ptr_not_null((void *)p, "Unexpected new[] failure");
|
||||
p = (int *)no_opt_ptr((void *)p);
|
||||
delete[] (int *)p;
|
||||
}
|
||||
|
||||
#if __cpp_sized_deallocation >= 201309
|
||||
static void
|
||||
new_sized_delete(void) {
|
||||
void* volatile p = ::operator new(1);
|
||||
void* p = ::operator new(1);
|
||||
expect_ptr_not_null((void *)p, "Unexpected new failure");
|
||||
p = no_opt_ptr(p);
|
||||
::operator delete((void *)p, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
malloc_sdallocx(void) {
|
||||
void* volatile p = malloc(1);
|
||||
void* p = malloc(1);
|
||||
expect_ptr_not_null((void *)p, "Unexpected malloc failure");
|
||||
p = no_opt_ptr(p);
|
||||
sdallocx((void *)p, 1, 0);
|
||||
}
|
||||
#endif
|
||||
|
@@ -9,6 +9,7 @@ large_mallocx_free(void) {
|
||||
*/
|
||||
void *p = mallocx(SC_LARGE_MINCLASS, MALLOCX_TCACHE_NONE);
|
||||
assert_ptr_not_null(p, "mallocx shouldn't fail");
|
||||
p = no_opt_ptr(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
@@ -16,6 +17,7 @@ static void
|
||||
small_mallocx_free(void) {
|
||||
void *p = mallocx(16, 0);
|
||||
assert_ptr_not_null(p, "mallocx shouldn't fail");
|
||||
p = no_opt_ptr(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@ malloc_free(void) {
|
||||
test_fail("Unexpected malloc() failure");
|
||||
return;
|
||||
}
|
||||
p = no_opt_ptr(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
@@ -19,6 +20,7 @@ mallocx_free(void) {
|
||||
test_fail("Unexpected mallocx() failure");
|
||||
return;
|
||||
}
|
||||
p = no_opt_ptr(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
@@ -35,6 +37,7 @@ malloc_dallocx(void) {
|
||||
test_fail("Unexpected malloc() failure");
|
||||
return;
|
||||
}
|
||||
p = no_opt_ptr(p);
|
||||
dallocx(p, 0);
|
||||
}
|
||||
|
||||
@@ -45,6 +48,7 @@ malloc_sdallocx(void) {
|
||||
test_fail("Unexpected malloc() failure");
|
||||
return;
|
||||
}
|
||||
p = no_opt_ptr(p);
|
||||
sdallocx(p, 1, 0);
|
||||
}
|
||||
|
||||
@@ -82,6 +86,7 @@ malloc_sallocx_free(void) {
|
||||
test_fail("Unexpected malloc() failure");
|
||||
return;
|
||||
}
|
||||
p = no_opt_ptr(p);
|
||||
if (sallocx(p, 0) < 1) {
|
||||
test_fail("Unexpected sallocx() failure");
|
||||
}
|
||||
@@ -103,6 +108,7 @@ malloc_nallocx_free(void) {
|
||||
test_fail("Unexpected malloc() failure");
|
||||
return;
|
||||
}
|
||||
p = no_opt_ptr(p);
|
||||
if (nallocx(1, 0) < 1) {
|
||||
test_fail("Unexpected nallocx() failure");
|
||||
}
|
||||
|
Reference in New Issue
Block a user