зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1735715 - Handle gMaxSubPageClass == 0 properly r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D128448
This commit is contained in:
Родитель
1af62d829d
Коммит
1b721fc414
|
@ -20,20 +20,6 @@ struct Log2 : mozilla::tl::CeilingLog2<N> {
|
|||
};
|
||||
#define LOG2(N) Log2<N>::value
|
||||
|
||||
// Like Log2, but ignores 0.
|
||||
template <size_t N>
|
||||
struct Log2Or0 : mozilla::tl::CeilingLog2<N> {
|
||||
using mozilla::tl::CeilingLog2<N>::value;
|
||||
static_assert(1ULL << value == N, "Number is not a power of 2");
|
||||
};
|
||||
template <>
|
||||
struct Log2Or0<0> {
|
||||
// This makes no sense but neither does any other value. It's just enough
|
||||
// that this can be used on the unused side of a conditional expression.
|
||||
static const size_t value = 0;
|
||||
};
|
||||
#define LOG2_OR_0(N) Log2Or0<N>::value
|
||||
|
||||
enum class Order {
|
||||
eLess = -1,
|
||||
eEqual = 0,
|
||||
|
|
|
@ -483,21 +483,21 @@ static size_t gPageSize;
|
|||
# define END_GLOBALS
|
||||
# define DEFINE_GLOBAL(type) static const type
|
||||
# define GLOBAL_LOG2 LOG2
|
||||
# define GLOBAL_LOG2_OR_0 LOG2_OR_0
|
||||
# define GLOBAL_ASSERT_HELPER1(x) static_assert(x, # x)
|
||||
# define GLOBAL_ASSERT_HELPER2(x, y) static_assert(x, y)
|
||||
# define GLOBAL_ASSERT(...) \
|
||||
MACRO_CALL( \
|
||||
MOZ_PASTE_PREFIX_AND_ARG_COUNT(GLOBAL_ASSERT_HELPER, __VA_ARGS__), \
|
||||
(__VA_ARGS__))
|
||||
# define GLOBAL_CONSTEXPR constexpr
|
||||
#else
|
||||
# define DECLARE_GLOBAL(type, name) static type name;
|
||||
# define DEFINE_GLOBALS static void DefineGlobals() {
|
||||
# define END_GLOBALS }
|
||||
# define DEFINE_GLOBAL(type)
|
||||
# define GLOBAL_LOG2 FloorLog2
|
||||
# define GLOBAL_LOG2_OR_0 FloorLog2
|
||||
# define GLOBAL_ASSERT MOZ_RELEASE_ASSERT
|
||||
# define GLOBAL_CONSTEXPR
|
||||
#endif
|
||||
|
||||
DECLARE_GLOBAL(size_t, gMaxSubPageClass)
|
||||
|
@ -520,10 +520,12 @@ gMaxSubPageClass = gPageSize / 2 >= kMinSubPageClass ? gPageSize / 2 : 0;
|
|||
|
||||
// Number of sub-page bins.
|
||||
DEFINE_GLOBAL(uint8_t)
|
||||
gNumSubPageClasses =
|
||||
static_cast<uint8_t>(gMaxSubPageClass ? GLOBAL_LOG2_OR_0(gMaxSubPageClass) -
|
||||
LOG2(kMinSubPageClass) + 1
|
||||
: 0);
|
||||
gNumSubPageClasses = []() GLOBAL_CONSTEXPR -> uint8_t {
|
||||
if GLOBAL_CONSTEXPR (gMaxSubPageClass != 0) {
|
||||
return FloorLog2(gMaxSubPageClass) - LOG2(kMinSubPageClass) + 1;
|
||||
}
|
||||
return 0;
|
||||
}();
|
||||
|
||||
DEFINE_GLOBAL(uint8_t) gPageSize2Pow = GLOBAL_LOG2(gPageSize);
|
||||
DEFINE_GLOBAL(size_t) gPageSizeMask = gPageSize - 1;
|
||||
|
|
|
@ -375,7 +375,7 @@ class FloorLog2<T, 8> {
|
|||
* FloorLog2(8..15) is 3; and so on.
|
||||
*/
|
||||
template <typename T>
|
||||
inline uint_fast8_t FloorLog2(const T aValue) {
|
||||
inline constexpr uint_fast8_t FloorLog2(const T aValue) {
|
||||
return detail::FloorLog2<T>::compute(aValue);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче