Loading hal/HalTypes.h +3 −1 Original line number Diff line number Diff line Loading @@ -94,9 +94,11 @@ class PerformanceHintSession { * information. */ struct HeterogeneousCpuInfo { // We use a max of 32 because currently this is only implemented for Android // We use a max of 32 because this was initially implemented only for Android // where we are unlikely to need more CPUs than that, and it simplifies // dealing with cpu_set_t as CPU_SETSIZE is 32 on 32-bit Android. // If there are more than 32 CPU cores, the implementation should try to fill // first mBigCpus before adding anything to mMediumCpus or mLittleCpus. static const size_t MAX_CPUS = 32; size_t mTotalNumCpus; mozilla::BitSet<MAX_CPUS> mLittleCpus; Loading hal/cocoa/CocoaHeterogeneousCpuInfo.cpp 0 → 100644 +58 −0 Original line number Diff line number Diff line /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include <sys/types.h> #include <sys/sysctl.h> #include "mozilla/BitSet.h" #include "nsSystemInfo.h" namespace mozilla::hal_impl { mozilla::Maybe<HeterogeneousCpuInfo> CreateHeterogeneousCpuInfo() { #ifdef __aarch64__ // As of now on Apple Silicon the number of *.logicalcpu_max is the same as // *.physicalcpu_max. size_t len = sizeof(uint32_t); uint32_t pCores = 0; if (sysctlbyname("hw.perflevel0.logicalcpu_max", &pCores, &len, nullptr, 0)) { return Nothing(); } len = sizeof(uint32_t); uint32_t eCores = 0; if (sysctlbyname("hw.perflevel1.logicalcpu_max", &eCores, &len, nullptr, 0)) { return Nothing(); } HeterogeneousCpuInfo info; info.mTotalNumCpus = pCores + eCores; // The API has currently a limit how many cpu cores it can tell about. for (uint32_t i = 0; i < HeterogeneousCpuInfo::MAX_CPUS; ++i) { if (pCores) { --pCores; info.mBigCpus[i] = true; } else if (eCores) { --eCores; info.mLittleCpus[i] = true; } else { break; } } return Some(info); #else return Nothing(); #endif } const Maybe<HeterogeneousCpuInfo>& GetHeterogeneousCpuInfo() { static const Maybe<HeterogeneousCpuInfo> cpuInfo = CreateHeterogeneousCpuInfo(); return cpuInfo; } } // namespace mozilla::hal_impl hal/moz.build +5 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": ] elif CONFIG["OS_TARGET"] == "Linux": UNIFIED_SOURCES += [ "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackScreenConfiguration.cpp", "fallback/FallbackSensor.cpp", "fallback/FallbackVibration.cpp", Loading @@ -63,6 +64,7 @@ elif CONFIG["OS_TARGET"] == "Linux": ] elif CONFIG["OS_TARGET"] == "WINNT": UNIFIED_SOURCES += [ "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackVibration.cpp", "windows/WindowsProcessPriority.cpp", "windows/WindowsScreenConfiguration.cpp", Loading @@ -75,12 +77,14 @@ elif CONFIG["OS_TARGET"] == "WINNT": elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": UNIFIED_SOURCES += [ "cocoa/CocoaBattery.cpp", "cocoa/CocoaHeterogeneousCpuInfo.cpp", "fallback/FallbackProcessPriority.cpp", "fallback/FallbackScreenConfiguration.cpp", "fallback/FallbackVibration.cpp", ] elif CONFIG["OS_TARGET"] in ("OpenBSD", "NetBSD", "FreeBSD", "DragonFly"): UNIFIED_SOURCES += [ "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackProcessPriority.cpp", "fallback/FallbackScreenConfiguration.cpp", "fallback/FallbackSensor.cpp", Loading @@ -97,6 +101,7 @@ elif CONFIG["OS_TARGET"] in ("OpenBSD", "NetBSD", "FreeBSD", "DragonFly"): else: UNIFIED_SOURCES += [ "fallback/FallbackBattery.cpp", "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackProcessPriority.cpp", "fallback/FallbackScreenConfiguration.cpp", "fallback/FallbackSensor.cpp", Loading @@ -106,7 +111,6 @@ else: # Fallbacks for backends implemented on Android only. if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android": UNIFIED_SOURCES += [ "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackNetwork.cpp", "fallback/FallbackPerformanceHintManager.cpp", ] Loading security/sandbox/mac/SandboxPolicyContent.h +2 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,8 @@ static const char SandboxPolicyContent[] = R"SANDBOX_LITERAL( (sysctl-name "hw.pagesize_compat") (sysctl-name "hw.logicalcpu") (sysctl-name "hw.logicalcpu_max") (sysctl-name "hw.perflevel0.logicalcpu_max") (sysctl-name "hw.perflevel1.logicalcpu_max") (sysctl-name "hw.physicalcpu_max") (sysctl-name "hw.busfrequency_compat") (sysctl-name "hw.busfrequency_max") Loading Loading
hal/HalTypes.h +3 −1 Original line number Diff line number Diff line Loading @@ -94,9 +94,11 @@ class PerformanceHintSession { * information. */ struct HeterogeneousCpuInfo { // We use a max of 32 because currently this is only implemented for Android // We use a max of 32 because this was initially implemented only for Android // where we are unlikely to need more CPUs than that, and it simplifies // dealing with cpu_set_t as CPU_SETSIZE is 32 on 32-bit Android. // If there are more than 32 CPU cores, the implementation should try to fill // first mBigCpus before adding anything to mMediumCpus or mLittleCpus. static const size_t MAX_CPUS = 32; size_t mTotalNumCpus; mozilla::BitSet<MAX_CPUS> mLittleCpus; Loading
hal/cocoa/CocoaHeterogeneousCpuInfo.cpp 0 → 100644 +58 −0 Original line number Diff line number Diff line /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include <sys/types.h> #include <sys/sysctl.h> #include "mozilla/BitSet.h" #include "nsSystemInfo.h" namespace mozilla::hal_impl { mozilla::Maybe<HeterogeneousCpuInfo> CreateHeterogeneousCpuInfo() { #ifdef __aarch64__ // As of now on Apple Silicon the number of *.logicalcpu_max is the same as // *.physicalcpu_max. size_t len = sizeof(uint32_t); uint32_t pCores = 0; if (sysctlbyname("hw.perflevel0.logicalcpu_max", &pCores, &len, nullptr, 0)) { return Nothing(); } len = sizeof(uint32_t); uint32_t eCores = 0; if (sysctlbyname("hw.perflevel1.logicalcpu_max", &eCores, &len, nullptr, 0)) { return Nothing(); } HeterogeneousCpuInfo info; info.mTotalNumCpus = pCores + eCores; // The API has currently a limit how many cpu cores it can tell about. for (uint32_t i = 0; i < HeterogeneousCpuInfo::MAX_CPUS; ++i) { if (pCores) { --pCores; info.mBigCpus[i] = true; } else if (eCores) { --eCores; info.mLittleCpus[i] = true; } else { break; } } return Some(info); #else return Nothing(); #endif } const Maybe<HeterogeneousCpuInfo>& GetHeterogeneousCpuInfo() { static const Maybe<HeterogeneousCpuInfo> cpuInfo = CreateHeterogeneousCpuInfo(); return cpuInfo; } } // namespace mozilla::hal_impl
hal/moz.build +5 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": ] elif CONFIG["OS_TARGET"] == "Linux": UNIFIED_SOURCES += [ "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackScreenConfiguration.cpp", "fallback/FallbackSensor.cpp", "fallback/FallbackVibration.cpp", Loading @@ -63,6 +64,7 @@ elif CONFIG["OS_TARGET"] == "Linux": ] elif CONFIG["OS_TARGET"] == "WINNT": UNIFIED_SOURCES += [ "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackVibration.cpp", "windows/WindowsProcessPriority.cpp", "windows/WindowsScreenConfiguration.cpp", Loading @@ -75,12 +77,14 @@ elif CONFIG["OS_TARGET"] == "WINNT": elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": UNIFIED_SOURCES += [ "cocoa/CocoaBattery.cpp", "cocoa/CocoaHeterogeneousCpuInfo.cpp", "fallback/FallbackProcessPriority.cpp", "fallback/FallbackScreenConfiguration.cpp", "fallback/FallbackVibration.cpp", ] elif CONFIG["OS_TARGET"] in ("OpenBSD", "NetBSD", "FreeBSD", "DragonFly"): UNIFIED_SOURCES += [ "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackProcessPriority.cpp", "fallback/FallbackScreenConfiguration.cpp", "fallback/FallbackSensor.cpp", Loading @@ -97,6 +101,7 @@ elif CONFIG["OS_TARGET"] in ("OpenBSD", "NetBSD", "FreeBSD", "DragonFly"): else: UNIFIED_SOURCES += [ "fallback/FallbackBattery.cpp", "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackProcessPriority.cpp", "fallback/FallbackScreenConfiguration.cpp", "fallback/FallbackSensor.cpp", Loading @@ -106,7 +111,6 @@ else: # Fallbacks for backends implemented on Android only. if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android": UNIFIED_SOURCES += [ "fallback/FallbackHeterogeneousCpuInfo.cpp", "fallback/FallbackNetwork.cpp", "fallback/FallbackPerformanceHintManager.cpp", ] Loading
security/sandbox/mac/SandboxPolicyContent.h +2 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,8 @@ static const char SandboxPolicyContent[] = R"SANDBOX_LITERAL( (sysctl-name "hw.pagesize_compat") (sysctl-name "hw.logicalcpu") (sysctl-name "hw.logicalcpu_max") (sysctl-name "hw.perflevel0.logicalcpu_max") (sysctl-name "hw.perflevel1.logicalcpu_max") (sysctl-name "hw.physicalcpu_max") (sysctl-name "hw.busfrequency_compat") (sysctl-name "hw.busfrequency_max") Loading