Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Unified Diff: base/process/memory_linux.cc

Issue 1675143004: Allocator shim skeleton + Linux impl behind a build flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shim_exp_flag
Patch Set: Make self the 1st arg Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gyp ('k') | build/common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/memory_linux.cc
diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc
index b5c964084870a927d8adb60e8692f4b6fa5819d7..9fb630b4750bff97a952850c655b8159fe9c075d 100644
--- a/base/process/memory_linux.cc
+++ b/base/process/memory_linux.cc
@@ -8,6 +8,8 @@
#include <new>
+#include "base/allocator/allocator_shim.h"
+#include "base/allocator/features.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
@@ -41,8 +43,12 @@ void OnNoMemory() {
} // namespace
+// TODO(primiano): Once the unified shim is on by default (crbug.com/550886)
+// get rid of the code in this entire #if section. The whole termination-on-OOM
+// logic is implemented in the shim.
#if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) && \
- !defined(THREAD_SANITIZER) && !defined(LEAK_SANITIZER)
+ !defined(THREAD_SANITIZER) && !defined(LEAK_SANITIZER) && \
+ !BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
#if defined(LIBC_GLIBC) && !defined(USE_TCMALLOC)
@@ -150,7 +156,10 @@ void EnableTerminationOnOutOfMemory() {
// If we're using glibc's allocator, the above functions will override
// malloc and friends and make them die on out of memory.
#endif
-#if defined(USE_TCMALLOC)
+
+#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
+ allocator::SetCallNewHandlerOnMallocFailure(true);
+#elif defined(USE_TCMALLOC)
// For tcmalloc, we need to tell it to behave like new.
tc_set_new_mode(1);
#endif
@@ -194,7 +203,9 @@ bool AdjustOOMScore(ProcessId process, int score) {
}
bool UncheckedMalloc(size_t size, void** result) {
-#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || \
+#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
+ *result = allocator::UncheckedAlloc(size);
+#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || \
(!defined(LIBC_GLIBC) && !defined(USE_TCMALLOC))
*result = malloc(size);
#elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC)
« no previous file with comments | « base/base.gyp ('k') | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698