Commit 4d170e8b authored by rtenneti@chromium.org's avatar rtenneti@chromium.org

Revert 170800 - Speculatively reverting 166585 to see if it fixes issue...

Revert 170800 - Speculatively reverting  166585 to see if it fixes issue 160300 - 6% startup regression on Mac 10.6

Revert 166585 - Add a histogram enum to determine the cat's flavor and how many bits there are
in it.

BUG=159886, 160300
Review URL: https://codereview.chromium.org/11391002

TBR=mark@chromium.org
Review URL: https://codereview.chromium.org/11348360

TBR=mark@chromium.org
Review URL: https://codereview.chromium.org/11411343

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170850 0039d316-1c4b-4281-b951-d872f2087c98
parent 6c271d28
...@@ -140,9 +140,8 @@ BASE_EXPORT bool IsOSMountainLionOrLater(); ...@@ -140,9 +140,8 @@ BASE_EXPORT bool IsOSMountainLionOrLater();
// This should be infrequently used. It only makes sense to use this to avoid // 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, // codepaths that are very likely to break on future (unreleased, untested,
// unborn) OS releases. // unborn) OS releases, or to log when the OS is newer than any known version.
BASE_EXPORT BASE_EXPORT bool IsOSLaterThanMountainLion_DontCallThis();
bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement();
// When the deployment target is set, the code produced cannot run on earlier // 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 // OS releases. That enables some of the IsOS* family to be implemented as
...@@ -173,8 +172,7 @@ inline bool IsOSMountainLionOrLater() { return true; } ...@@ -173,8 +172,7 @@ inline bool IsOSMountainLionOrLater() { return true; }
MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8
#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8
inline bool IsOSMountainLion() { return false; } inline bool IsOSMountainLion() { return false; }
inline bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement() inline bool IsOSLaterThanMountainLion_DontCallThis() {
{
return true; return true;
} }
#endif #endif
......
...@@ -604,7 +604,7 @@ bool IsOSMountainLionOrLater() { ...@@ -604,7 +604,7 @@ bool IsOSMountainLionOrLater() {
#endif #endif
#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8)
bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement() { bool IsOSLaterThanMountainLion_DontCallThis() {
return MacOSXMinorVersion() > MOUNTAIN_LION_MINOR_VERSION; return MacOSXMinorVersion() > MOUNTAIN_LION_MINOR_VERSION;
} }
#endif #endif
......
...@@ -158,8 +158,7 @@ TEST_F(MacUtilTest, IsOSEllipsis) { ...@@ -158,8 +158,7 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOSLionOrLater()); EXPECT_FALSE(IsOSLionOrLater());
EXPECT_FALSE(IsOSMountainLion()); EXPECT_FALSE(IsOSMountainLion());
EXPECT_FALSE(IsOSMountainLionOrLater()); EXPECT_FALSE(IsOSMountainLionOrLater());
EXPECT_FALSE( EXPECT_FALSE(IsOSLaterThanMountainLion_DontCallThis());
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
} else if (minor == 7) { } else if (minor == 7) {
EXPECT_FALSE(IsOSSnowLeopard()); EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_TRUE(IsOSLion()); EXPECT_TRUE(IsOSLion());
...@@ -167,8 +166,7 @@ TEST_F(MacUtilTest, IsOSEllipsis) { ...@@ -167,8 +166,7 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOSLionOrLater()); EXPECT_TRUE(IsOSLionOrLater());
EXPECT_FALSE(IsOSMountainLion()); EXPECT_FALSE(IsOSMountainLion());
EXPECT_FALSE(IsOSMountainLionOrLater()); EXPECT_FALSE(IsOSMountainLionOrLater());
EXPECT_FALSE( EXPECT_FALSE(IsOSLaterThanMountainLion_DontCallThis());
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
} else if (minor == 8) { } else if (minor == 8) {
EXPECT_FALSE(IsOSSnowLeopard()); EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_FALSE(IsOSLion()); EXPECT_FALSE(IsOSLion());
...@@ -176,8 +174,7 @@ TEST_F(MacUtilTest, IsOSEllipsis) { ...@@ -176,8 +174,7 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOSLionOrLater()); EXPECT_TRUE(IsOSLionOrLater());
EXPECT_TRUE(IsOSMountainLion()); EXPECT_TRUE(IsOSMountainLion());
EXPECT_TRUE(IsOSMountainLionOrLater()); EXPECT_TRUE(IsOSMountainLionOrLater());
EXPECT_FALSE( EXPECT_FALSE(IsOSLaterThanMountainLion_DontCallThis());
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
} else { } else {
// Not five, six, seven, or eight. Ah, ah, ah. // Not five, six, seven, or eight. Ah, ah, ah.
EXPECT_TRUE(false); EXPECT_TRUE(false);
......
...@@ -819,8 +819,7 @@ void oom_killer_new() { ...@@ -819,8 +819,7 @@ void oom_killer_new() {
// === Core Foundation CFAllocators === // === Core Foundation CFAllocators ===
bool CanGetContextForCFAllocator() { bool CanGetContextForCFAllocator() {
return !base::mac:: return !base::mac::IsOSLaterThanMountainLion_DontCallThis();
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement();
} }
CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/chrome_browser_main_mac.h" #include "chrome/browser/chrome_browser_main_mac.h"
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <sys/sysctl.h>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/debugger.h" #include "base/debug/debugger.h"
...@@ -12,6 +13,7 @@ ...@@ -12,6 +13,7 @@
#include "base/mac/bundle_locations.h" #include "base/mac/bundle_locations.h"
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
#include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_nsobject.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "chrome/app/breakpad_mac.h" #include "chrome/app/breakpad_mac.h"
#import "chrome/browser/app_controller_mac.h" #import "chrome/browser/app_controller_mac.h"
...@@ -49,6 +51,103 @@ NSString* const kKeychainReauthorizeAtUpdatePref = ...@@ -49,6 +51,103 @@ NSString* const kKeychainReauthorizeAtUpdatePref =
@"KeychainReauthorizeAtUpdateMay2012"; @"KeychainReauthorizeAtUpdateMay2012";
const int kKeychainReauthorizeAtUpdateMaxTries = 3; const int kKeychainReauthorizeAtUpdateMaxTries = 3;
// This is one enum instead of two so that the values can be correlated in a
// histogram.
enum CatSixtyFour {
// Older than any expected cat.
SABER_TOOTHED_CAT_32 = 0,
SABER_TOOTHED_CAT_64,
// Known cats.
SNOW_LEOPARD_32,
SNOW_LEOPARD_64,
LION_32, // Unexpected, Lion requires a 64-bit CPU.
LION_64,
MOUNTAIN_LION_32, // Unexpected, Mountain Lion requires a 64-bit CPU.
MOUNTAIN_LION_64,
// DON'T add new constants here. It's important to keep the constant values,
// um, constant. Add new constants at the bottom.
// Newer than any known cat.
FUTURE_CAT_32, // Unexpected, it's unlikely Apple will un-obsolete old CPUs.
FUTURE_CAT_64,
// What if the bitsiness of the CPU can't be determined?
SABER_TOOTHED_CAT_DUNNO,
SNOW_LEOPARD_DUNNO,
LION_DUNNO,
MOUNTAIN_LION_DUNNO,
FUTURE_CAT_DUNNO,
// Add new constants here.
CAT_SIXTY_FOUR_MAX
};
CatSixtyFour CatSixtyFourValue() {
#if defined(ARCH_CPU_64_BITS)
// If 64-bit code is running, then it's established that this CPU can run
// 64-bit code, and no further inquiry is necessary.
int cpu64 = 1;
bool cpu64_known = true;
#else
// Check a sysctl conveniently provided by the kernel that identifies
// whether the CPU supports 64-bit operation. Note that this tests the
// actual hardware capabilities, not the bitsiness of the running process,
// and not the bitsiness of the running kernel. The value thus determines
// whether the CPU is capable of running 64-bit programs (in the presence of
// proper OS runtime support) without regard to whether the current program
// is 64-bit (it may not be) or whether the current kernel is (the kernel
// can launch cross-bitted user-space tasks).
int cpu64;
size_t len = sizeof(cpu64);
const char kSysctlName[] = "hw.cpu64bit_capable";
bool cpu64_known = sysctlbyname(kSysctlName, &cpu64, &len, NULL, 0) == 0;
if (!cpu64_known) {
PLOG(WARNING) << "sysctlbyname(\"" << kSysctlName << "\")";
}
#endif
if (base::mac::IsOSSnowLeopard()) {
return cpu64_known ? (cpu64 ? SNOW_LEOPARD_64 : SNOW_LEOPARD_32) :
SNOW_LEOPARD_DUNNO;
}
if (base::mac::IsOSLion()) {
return cpu64_known ? (cpu64 ? LION_64 : LION_32) :
LION_DUNNO;
}
if (base::mac::IsOSMountainLion()) {
return cpu64_known ? (cpu64 ? MOUNTAIN_LION_64 : MOUNTAIN_LION_32) :
MOUNTAIN_LION_DUNNO;
}
if (base::mac::IsOSLaterThanMountainLion_DontCallThis()) {
return cpu64_known ? (cpu64 ? FUTURE_CAT_64 : FUTURE_CAT_32) :
FUTURE_CAT_DUNNO;
}
// If it's not any of the expected OS versions or later than them, it must
// be prehistoric.
return cpu64_known ? (cpu64 ? SABER_TOOTHED_CAT_64 : SABER_TOOTHED_CAT_32) :
SABER_TOOTHED_CAT_DUNNO;
}
void RecordCatSixtyFour() {
CatSixtyFour cat_sixty_four = CatSixtyFourValue();
// Set this higher than the highest value in the CatSixtyFour enum to
// provide some headroom and then leave it alone. See HISTOGRAM_ENUMERATION
// in base/metrics/histogram.h.
const int kMaxCatsAndSixtyFours = 32;
COMPILE_ASSERT(kMaxCatsAndSixtyFours >= CAT_SIXTY_FOUR_MAX,
CatSixtyFour_enum_grew_too_large);
UMA_HISTOGRAM_ENUMERATION("OSX.CatSixtyFour",
cat_sixty_four,
kMaxCatsAndSixtyFours);
}
} // namespace } // namespace
void RecordBreakpadStatusUMA(MetricsService* metrics) { void RecordBreakpadStatusUMA(MetricsService* metrics) {
...@@ -102,6 +201,8 @@ void ChromeBrowserMainPartsMac::PreEarlyInitialization() { ...@@ -102,6 +201,8 @@ void ChromeBrowserMainPartsMac::PreEarlyInitialization() {
CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); CommandLine* singleton_command_line = CommandLine::ForCurrentProcess();
singleton_command_line->AppendSwitch(switches::kNoStartupWindow); singleton_command_line->AppendSwitch(switches::kNoStartupWindow);
} }
RecordCatSixtyFour();
} }
void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() {
......
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