Commit 3211a499 authored by Chris Palmer's avatar Chris Palmer Committed by Commit Bot

[PartitionAlloc] Revert "poison on free" behavior.

Performance regressions, alas.

Bug: 1005070, 1013329, 1013326, 1013324
Change-Id: I15c0a539d5adde6f86de98ceec301863708307f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880145Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Chris Palmer <palmer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709322}
parent 89cde7b0
...@@ -14,24 +14,6 @@ ...@@ -14,24 +14,6 @@
#include "base/allocator/partition_allocator/random.h" #include "base/allocator/partition_allocator/random.h"
#include "base/logging.h" #include "base/logging.h"
namespace {
// Returns true if we've hit the end of a random-length period. We don't want to
// invoke `RandomValue` too often, because we call this function in a hot spot
// (`Free`), and `RandomValue` incurs the cost of atomics.
#if !DCHECK_IS_ON()
bool RandomPeriod() {
static thread_local uint8_t counter = 0;
if (UNLIKELY(counter == 0)) {
counter = base::RandomValue();
}
counter--;
return counter == 0;
}
#endif
} // namespace
namespace base { namespace base {
namespace internal { namespace internal {
...@@ -220,24 +202,19 @@ ALWAYS_INLINE size_t PartitionPage::get_raw_size() const { ...@@ -220,24 +202,19 @@ ALWAYS_INLINE size_t PartitionPage::get_raw_size() const {
} }
ALWAYS_INLINE void PartitionPage::Free(void* ptr) { ALWAYS_INLINE void PartitionPage::Free(void* ptr) {
#if DCHECK_IS_ON()
size_t slot_size = this->bucket->slot_size; size_t slot_size = this->bucket->slot_size;
const size_t raw_size = get_raw_size(); const size_t raw_size = get_raw_size();
if (raw_size) { if (raw_size) {
slot_size = raw_size; slot_size = raw_size;
} }
#if DCHECK_IS_ON()
// If these asserts fire, you probably corrupted memory. // If these asserts fire, you probably corrupted memory.
PartitionCookieCheckValue(ptr); PartitionCookieCheckValue(ptr);
PartitionCookieCheckValue(reinterpret_cast<char*>(ptr) + slot_size - PartitionCookieCheckValue(reinterpret_cast<char*>(ptr) + slot_size -
kCookieSize); kCookieSize);
memset(ptr, kFreedByte, slot_size); memset(ptr, kFreedByte, slot_size);
#else
// `memset` only once in a while.
if (UNLIKELY(RandomPeriod())) {
memset(ptr, kFreedByte, slot_size);
}
#endif #endif
DCHECK(this->num_allocated_slots); DCHECK(this->num_allocated_slots);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment