Commit 1388ccff authored by avi@chromium.org's avatar avi@chromium.org

Add preliminary OOM support for Mountain Lion.

BUG=117476
TEST=run base_unittests on Mountain Lion


Review URL: http://codereview.chromium.org/9701031

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126773 0039d316-1c4b-4281-b951-d872f2087c98
parent 73159d6d
......@@ -150,8 +150,6 @@ BASE_EXPORT bool IsOSMountainLionOrLater();
// unborn) OS releases.
BASE_EXPORT
bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement();
// TODO(rsesek|avi): Remove when allocators gonna allocate.
BASE_EXPORT bool IsOSLaterThanLion();
// 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
......@@ -179,7 +177,6 @@ inline bool IsOSLionOrLater() { return true; }
#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7
inline bool IsOSLion() { return false; }
inline bool IsOSLionOrEarlier() { return false; }
inline bool IsOSLaterThanLion() { return true; }
#endif
#if defined(MAC_OS_X_VERSION_10_8) && \
......
......@@ -625,12 +625,6 @@ bool IsOSLionOrLater() {
}
#endif
#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7)
bool IsOSLaterThanLion() {
return MacOSXMinorVersion() > LION_MINOR_VERSION;
}
#endif
#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8)
bool IsOSMountainLion() {
return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION;
......
......@@ -164,7 +164,6 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOSMountainLionOrLater());
EXPECT_FALSE(
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
EXPECT_FALSE(IsOSLaterThanLion());
} else if (minor == 6) {
EXPECT_FALSE(IsOSLeopard());
EXPECT_FALSE(IsOSLeopardOrEarlier());
......@@ -178,7 +177,6 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOSMountainLionOrLater());
EXPECT_FALSE(
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
EXPECT_FALSE(IsOSLaterThanLion());
} else if (minor == 7) {
EXPECT_FALSE(IsOSLeopard());
EXPECT_FALSE(IsOSLeopardOrEarlier());
......@@ -205,7 +203,6 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOSMountainLionOrLater());
EXPECT_FALSE(
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
EXPECT_TRUE(IsOSLaterThanLion());
} else {
// Not five, six, seven, or eight. Ah, ah, ah.
EXPECT_TRUE(false);
......
......@@ -718,8 +718,16 @@ void oom_killer_new() {
// === Core Foundation CFAllocators ===
bool CanGetContextForCFAllocator() {
// TODO(rsesek|avi): See mac_util.h:153 for removing/updating this.
return !base::mac::IsOSLaterThanLion();
// TODO(avi): remove at final release; http://crbug.com/117476
if (base::mac::IsOSMountainLion()) {
NSLog(@"Unsure about the internals of CFAllocator but going to patch them "
"anyway. If there is a crash inside of CFAllocatorAllocate, please "
"report it at http://crbug.com/117476 . If there is a crash and it "
"is NOT inside of CFAllocatorAllocate, it is NOT RELATED. DO NOT "
"REPORT IT THERE but rather FILE A NEW BUG.");
}
return !base::mac::
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement();
}
CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) {
......@@ -728,10 +736,10 @@ CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) {
const_cast<ChromeCFAllocatorLeopards*>(
reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator));
return &our_allocator->_context;
} else if (base::mac::IsOSLion()) {
ChromeCFAllocatorLion* our_allocator =
const_cast<ChromeCFAllocatorLion*>(
reinterpret_cast<const ChromeCFAllocatorLion*>(allocator));
} else if (base::mac::IsOSLion() || base::mac::IsOSMountainLion()) {
ChromeCFAllocatorLions* our_allocator =
const_cast<ChromeCFAllocatorLions*>(
reinterpret_cast<const ChromeCFAllocatorLions*>(allocator));
return &our_allocator->_context;
} else {
return NULL;
......
......@@ -1118,7 +1118,7 @@ TEST_F(OutOfMemoryDeathTest, PosixMemalignPurgeable) {
// Since these allocation functions take a signed size, it's possible that
// calling them just once won't be enough to exhaust memory. In the 32-bit
// environment, it's likely that these allocation attempts will fail because
// not enough contiguous address space is availble. In the 64-bit environment,
// not enough contiguous address space is available. In the 64-bit environment,
// it's likely that they'll fail because they would require a preposterous
// amount of (virtual) memory.
......
......@@ -50,7 +50,8 @@ struct ChromeCFAllocatorLeopards {
CFAllocatorContext _context;
};
struct ChromeCFAllocatorLion {
// TODO(avi): verify that this is accurate for 10.8 upon source release; http://crbug.com/117476
struct ChromeCFAllocatorLions {
ChromeCFRuntimeBase _base;
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
size_t (*size)(struct _malloc_zone_t *zone, const void *ptr); /* returns the size of a block or 0 if not in this zone; must be fast, especially for negative answers */
......
......@@ -32,7 +32,7 @@ Modifications:
- Removed everything but the definition of __CFAllocator.
- Modified the reference of CFRuntimeBase to ChromeCFRuntimeBase.
- Renamed __CFAllocator to ChromeCFAllocatorLeopards (from CF-550) and to
ChromeCFAllocatorLion (from CF-635) to avoid possible name conflicts.
ChromeCFAllocatorLions (from CF-635) to avoid possible name conflicts.
cssmapplePriv.h from:
http://www.opensource.apple.com/source/libsecurity_cssm/libsecurity_cssm-31536/lib/cssmapplePriv.h
......
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