summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-10-17 13:32:47 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-10-20 11:06:34 +0000
commitdb205d71b2ac4cf5cedc762b1431decaca3c0321 (patch)
tree1a3abbabb57ad6be216ce48bcda87ffed9314ed6
parent3d02dd98fb1928c0c92d3ca4d67c2baeca4aece1 (diff)
downloadqtwebengine-chromium-60-based.tar.gz
[Backport] mac: Update knowledge of CFAllocator internals for 10.1360-based
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.13 ("High Sierra"), whose CFAllocator internals are unchanged from 10.12 (and in fact from 10.7). It also updates the base::mac::IsOS*() family of functions for this new OS version. BUG=45650 TEST=base_unittests OutOfMemoryDeathTest.CFAllocator*,MacUtilTest.IsOSEllipsis Change-Id: I2cab74c57cb75e4aebc2cb13d6844f0c77dbd54f Reviewed-on: https://chromium-review.googlesource.com/565467 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--chromium/base/allocator/allocator_interception_mac.mm2
-rw-r--r--chromium/base/mac/mac_util.h10
-rw-r--r--chromium/base/mac/mac_util_unittest.mm39
3 files changed, 43 insertions, 8 deletions
diff --git a/chromium/base/allocator/allocator_interception_mac.mm b/chromium/base/allocator/allocator_interception_mac.mm
index 4980051aff8..68fa5468b59 100644
--- a/chromium/base/allocator/allocator_interception_mac.mm
+++ b/chromium/base/allocator/allocator_interception_mac.mm
@@ -211,7 +211,7 @@ void* oom_killer_memalign_purgeable(struct _malloc_zone_t* zone,
// === Core Foundation CFAllocators ===
bool CanGetContextForCFAllocator() {
- return !base::mac::IsOSLaterThan10_12_DontCallThis();
+ return !base::mac::IsOSLaterThan10_13_DontCallThis();
}
CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) {
diff --git a/chromium/base/mac/mac_util.h b/chromium/base/mac/mac_util.h
index 67d1880849e..37e5b670cee 100644
--- a/chromium/base/mac/mac_util.h
+++ b/chromium/base/mac/mac_util.h
@@ -147,6 +147,12 @@ DEFINE_IS_OS_FUNCS(12, TEST_DEPLOYMENT_TARGET)
DEFINE_IS_OS_FUNCS(12, IGNORE_DEPLOYMENT_TARGET)
#endif
+#ifdef MAC_OS_X_VERSION_10_13
+DEFINE_IS_OS_FUNCS(13, TEST_DEPLOYMENT_TARGET)
+#else
+DEFINE_IS_OS_FUNCS(13, IGNORE_DEPLOYMENT_TARGET)
+#endif
+
#undef IGNORE_DEPLOYMENT_TARGET
#undef TEST_DEPLOYMENT_TARGET
#undef DEFINE_IS_OS_FUNCS
@@ -154,8 +160,8 @@ DEFINE_IS_OS_FUNCS(12, IGNORE_DEPLOYMENT_TARGET)
// 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.
-inline bool IsOSLaterThan10_12_DontCallThis() {
- return !IsAtMostOS10_12();
+inline bool IsOSLaterThan10_13_DontCallThis() {
+ return !IsAtMostOS10_13();
}
// Retrieve the system's model identifier string from the IOKit registry:
diff --git a/chromium/base/mac/mac_util_unittest.mm b/chromium/base/mac/mac_util_unittest.mm
index ff508f3336b..266d1c42947 100644
--- a/chromium/base/mac/mac_util_unittest.mm
+++ b/chromium/base/mac/mac_util_unittest.mm
@@ -150,7 +150,10 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOS10_12());
EXPECT_FALSE(IsAtLeastOS10_12());
EXPECT_TRUE(IsAtMostOS10_12());
- EXPECT_FALSE(IsOSLaterThan10_12_DontCallThis());
+ EXPECT_FALSE(IsOS10_13());
+ EXPECT_FALSE(IsAtLeastOS10_13());
+ EXPECT_TRUE(IsAtMostOS10_13());
+ EXPECT_FALSE(IsOSLaterThan10_13_DontCallThis());
} else if (minor == 10) {
EXPECT_FALSE(IsOS10_9());
EXPECT_FALSE(IsAtMostOS10_9());
@@ -164,7 +167,10 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOS10_12());
EXPECT_FALSE(IsAtLeastOS10_12());
EXPECT_TRUE(IsAtMostOS10_12());
- EXPECT_FALSE(IsOSLaterThan10_12_DontCallThis());
+ EXPECT_FALSE(IsOS10_13());
+ EXPECT_FALSE(IsAtLeastOS10_13());
+ EXPECT_TRUE(IsAtMostOS10_13());
+ EXPECT_FALSE(IsOSLaterThan10_13_DontCallThis());
} else if (minor == 11) {
EXPECT_FALSE(IsOS10_9());
EXPECT_FALSE(IsAtMostOS10_9());
@@ -178,7 +184,10 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOS10_12());
EXPECT_FALSE(IsAtLeastOS10_12());
EXPECT_TRUE(IsAtMostOS10_12());
- EXPECT_FALSE(IsOSLaterThan10_12_DontCallThis());
+ EXPECT_FALSE(IsOS10_13());
+ EXPECT_FALSE(IsAtLeastOS10_13());
+ EXPECT_TRUE(IsAtMostOS10_13());
+ EXPECT_FALSE(IsOSLaterThan10_13_DontCallThis());
} else if (minor == 12) {
EXPECT_FALSE(IsOS10_9());
EXPECT_FALSE(IsAtMostOS10_9());
@@ -192,9 +201,29 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOS10_12());
EXPECT_TRUE(IsAtMostOS10_12());
EXPECT_TRUE(IsAtLeastOS10_12());
- EXPECT_FALSE(IsOSLaterThan10_12_DontCallThis());
+ EXPECT_FALSE(IsOS10_13());
+ EXPECT_FALSE(IsAtLeastOS10_13());
+ EXPECT_TRUE(IsAtMostOS10_13());
+ EXPECT_FALSE(IsOSLaterThan10_13_DontCallThis());
+ } else if (minor == 13) {
+ EXPECT_FALSE(IsOS10_9());
+ EXPECT_FALSE(IsAtMostOS10_9());
+ EXPECT_TRUE(IsAtLeastOS10_9());
+ EXPECT_FALSE(IsOS10_10());
+ EXPECT_FALSE(IsAtMostOS10_10());
+ EXPECT_TRUE(IsAtLeastOS10_10());
+ EXPECT_FALSE(IsOS10_11());
+ EXPECT_FALSE(IsAtMostOS10_11());
+ EXPECT_TRUE(IsAtLeastOS10_11());
+ EXPECT_FALSE(IsOS10_12());
+ EXPECT_FALSE(IsAtMostOS10_12());
+ EXPECT_TRUE(IsAtLeastOS10_12());
+ EXPECT_TRUE(IsOS10_13());
+ EXPECT_TRUE(IsAtLeastOS10_13());
+ EXPECT_TRUE(IsAtMostOS10_13());
+ EXPECT_FALSE(IsOSLaterThan10_13_DontCallThis());
} else {
- // Not nine, ten, eleven, or twelve. Ah, ah, ah.
+ // Not nine, ten, eleven, twelve, or thirteen. Ah, ah, ah.
EXPECT_TRUE(false);
}
} else {