summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-09-28 12:05:30 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-09-28 10:40:04 +0000
commit64e83cb70ad814bab86c440e67268bf2e6d76a56 (patch)
tree964b11887726d457300b2e9e47c8a957aca7774a
parent789694067acc605664b76bd17a200f583a972226 (diff)
[Backport] mac: Update knowledge of CFAllocator internals for 10.12
For each new major OS version, we need to poke at the internals of CFAllocator to enable the out-of-memory killer for the default CFAllocator implementations. This update is for macOS 10.12 ("Sierra"), whose CFAllocator internals are unchanged from 10.11 (and from 10.9, and in fact from 10.7). It also updates the base::mac::IsOS*() family of functions for this new OS version. BUG=626536,45650 TEST=base_unittests OutOfMemoryDeathTest.CFAllocator*,MacUtilTest.IsOSEllipsis Review-Url: https://codereview.chromium.org/2129273002 Cr-Commit-Position: refs/heads/master@{#404471} (cherry picked from commit fd1cb64d5070bd041e86434e91a8cca796414367) Review URL: https://codereview.chromium.org/2136813002 . Change-Id: I3690b016585db5aec14fd8b710e4af6658cf9c62 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--chromium/base/mac/mac_util.h21
-rw-r--r--chromium/base/mac/mac_util.mm19
-rw-r--r--chromium/base/mac/mac_util_unittest.mm29
-rw-r--r--chromium/base/process/memory_mac.mm5
4 files changed, 63 insertions, 11 deletions
diff --git a/chromium/base/mac/mac_util.h b/chromium/base/mac/mac_util.h
index 7772e883fad..371220629cd 100644
--- a/chromium/base/mac/mac_util.h
+++ b/chromium/base/mac/mac_util.h
@@ -153,10 +153,14 @@ BASE_EXPORT bool IsOSYosemiteOrLater();
BASE_EXPORT bool IsOSElCapitan();
BASE_EXPORT bool IsOSElCapitanOrLater();
+// Sierra is macOS 10.12, Darwin 16.
+BASE_EXPORT bool IsOSSierra();
+BASE_EXPORT bool IsOSSierraOrLater();
+
// This should be infrequently used. It only makes sense to use this to avoid
// codepaths that are very likely to break on future (unreleased, untested,
// unborn) OS releases, or to log when the OS is newer than any known version.
-BASE_EXPORT bool IsOSLaterThanElCapitan_DontCallThis();
+BASE_EXPORT bool IsOSLaterThanSierra_DontCallThis();
// Inline functions that are redundant due to version ranges being mutually-
// exclusive.
@@ -164,6 +168,7 @@ inline bool IsOSLionOrEarlier() { return !IsOSMountainLionOrLater(); }
inline bool IsOSMountainLionOrEarlier() { return !IsOSMavericksOrLater(); }
inline bool IsOSMavericksOrEarlier() { return !IsOSYosemiteOrLater(); }
inline bool IsOSYosemiteOrEarlier() { return !IsOSElCapitanOrLater(); }
+inline bool IsOSElCapitanOrEarlier() { return !IsOSSierraOrLater(); }
// When the deployment target is set, the code produced cannot run on earlier
// OS releases. That enables some of the IsOS* family to be implemented as
@@ -229,7 +234,19 @@ inline bool IsOSElCapitanOrLater() { return true; }
MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_11
#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11
inline bool IsOSElCapitan() { return false; }
-inline bool IsOSLaterThanElCapitan_DontCallThis() { return true; }
+#endif
+
+#if defined(MAC_OS_X_VERSION_10_12) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
+#define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_12
+inline bool IsOSSierraOrLater() { return true; }
+#endif
+
+#if defined(MAC_OS_X_VERSION_10_12) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_12
+#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12
+inline bool IsOSSierra() { return false; }
+inline bool IsOSLaterThanSierra_DontCallThis() { return true; }
#endif
// Retrieve the system's model identifier string from the IOKit registry:
diff --git a/chromium/base/mac/mac_util.mm b/chromium/base/mac/mac_util.mm
index 75d53c90961..46030e0809d 100644
--- a/chromium/base/mac/mac_util.mm
+++ b/chromium/base/mac/mac_util.mm
@@ -484,6 +484,7 @@ enum {
MAVERICKS_MINOR_VERSION = 9,
YOSEMITE_MINOR_VERSION = 10,
EL_CAPITAN_MINOR_VERSION = 11,
+ SIERRA_MINOR_VERSION = 12,
};
} // namespace
@@ -554,9 +555,21 @@ bool IsOSElCapitanOrLater() {
}
#endif
-#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11)
-bool IsOSLaterThanElCapitan_DontCallThis() {
- return MacOSXMinorVersion() > EL_CAPITAN_MINOR_VERSION;
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12)
+bool IsOSSierra() {
+ return MacOSXMinorVersion() == SIERRA_MINOR_VERSION;
+}
+#endif
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_12)
+bool IsOSSierraOrLater() {
+ return MacOSXMinorVersion() >= SIERRA_MINOR_VERSION;
+}
+#endif
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12)
+bool IsOSLaterThanSierra_DontCallThis() {
+ return MacOSXMinorVersion() > SIERRA_MINOR_VERSION;
}
#endif
diff --git a/chromium/base/mac/mac_util_unittest.mm b/chromium/base/mac/mac_util_unittest.mm
index c5042a05f0b..009d9f59fcc 100644
--- a/chromium/base/mac/mac_util_unittest.mm
+++ b/chromium/base/mac/mac_util_unittest.mm
@@ -211,8 +211,11 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOSYosemiteOrEarlier());
EXPECT_FALSE(IsOSYosemiteOrLater());
EXPECT_FALSE(IsOSElCapitan());
+ EXPECT_TRUE(IsOSElCapitanOrEarlier());
EXPECT_FALSE(IsOSElCapitanOrLater());
- EXPECT_FALSE(IsOSLaterThanElCapitan_DontCallThis());
+ EXPECT_FALSE(IsOSSierra());
+ EXPECT_FALSE(IsOSSierraOrLater());
+ EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis());
} else if (minor == 10) {
EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_FALSE(IsOSLion());
@@ -228,8 +231,11 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOSYosemiteOrEarlier());
EXPECT_TRUE(IsOSYosemiteOrLater());
EXPECT_FALSE(IsOSElCapitan());
+ EXPECT_TRUE(IsOSElCapitanOrEarlier());
EXPECT_FALSE(IsOSElCapitanOrLater());
- EXPECT_FALSE(IsOSLaterThanElCapitan_DontCallThis());
+ EXPECT_FALSE(IsOSSierra());
+ EXPECT_FALSE(IsOSSierraOrLater());
+ EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis());
} else if (minor == 11) {
EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_FALSE(IsOSLion());
@@ -245,10 +251,25 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOSYosemiteOrEarlier());
EXPECT_TRUE(IsOSYosemiteOrLater());
EXPECT_TRUE(IsOSElCapitan());
+ EXPECT_TRUE(IsOSElCapitanOrEarlier());
EXPECT_TRUE(IsOSElCapitanOrLater());
- EXPECT_FALSE(IsOSLaterThanElCapitan_DontCallThis());
+ EXPECT_FALSE(IsOSSierra());
+ EXPECT_FALSE(IsOSSierraOrLater());
+ EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis());
+ } else if (minor == 12) {
+ EXPECT_FALSE(IsOSMavericks());
+ EXPECT_TRUE(IsOSMavericksOrLater());
+ EXPECT_FALSE(IsOSYosemite());
+ EXPECT_FALSE(IsOSYosemiteOrEarlier());
+ EXPECT_TRUE(IsOSYosemiteOrLater());
+ EXPECT_FALSE(IsOSElCapitan());
+ EXPECT_FALSE(IsOSElCapitanOrEarlier());
+ EXPECT_TRUE(IsOSElCapitanOrLater());
+ EXPECT_TRUE(IsOSSierra());
+ EXPECT_TRUE(IsOSSierraOrLater());
+ EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis());
} else {
- // Not six, seven, eight, nine, ten, or eleven. Ah, ah, ah.
+ // Not nine, ten, eleven, or twelve. Ah, ah, ah.
EXPECT_TRUE(false);
}
} else {
diff --git a/chromium/base/process/memory_mac.mm b/chromium/base/process/memory_mac.mm
index 1e1a1ba536f..f59cdf8bf43 100644
--- a/chromium/base/process/memory_mac.mm
+++ b/chromium/base/process/memory_mac.mm
@@ -248,7 +248,7 @@ void oom_killer_new() {
// === Core Foundation CFAllocators ===
bool CanGetContextForCFAllocator() {
- return !base::mac::IsOSLaterThanElCapitan_DontCallThis();
+ return !base::mac::IsOSLaterThanSierra_DontCallThis();
}
CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) {
@@ -261,7 +261,8 @@ CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) {
base::mac::IsOSMountainLion() ||
base::mac::IsOSMavericks() ||
base::mac::IsOSYosemite() ||
- base::mac::IsOSElCapitan()) {
+ base::mac::IsOSElCapitan() ||
+ base::mac::IsOSSierra()) {
ChromeCFAllocatorLions* our_allocator =
const_cast<ChromeCFAllocatorLions*>(
reinterpret_cast<const ChromeCFAllocatorLions*>(allocator));