chromium/base/allocator/partition_allocator/src/partition_alloc/partition_bucket_lookup.h

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PARTITION_ALLOC_PARTITION_BUCKET_LOOKUP_H_
#define PARTITION_ALLOC_PARTITION_BUCKET_LOOKUP_H_

#include <array>
#include <cstdint>
#include <utility>

#include "partition_alloc/buildflags.h"
#include "partition_alloc/partition_alloc_base/bits.h"
#include "partition_alloc/partition_alloc_base/compiler_specific.h"
#include "partition_alloc/partition_alloc_check.h"
#include "partition_alloc/partition_alloc_constants.h"

namespace partition_alloc::internal {

// Don't use an anonymous namespace for the constants because it can inhibit
// collapsing them together, even when they are tagged as inline.

// Precalculate some shift and mask constants used in the hot path.
// Example: malloc(41) == 101001 binary.
// Order is 6 (1 << 6-1) == 32 is highest bit set.
// order_index is the next three MSB == 010 == 2.
// sub_order_index_mask is a mask for the remaining bits == 11 (masking to 01
// for the sub_order_index).
constexpr uint8_t OrderIndexShift(uint8_t order) {}

constexpr size_t OrderSubIndexMask(uint8_t order) {}

#if PA_BUILDFLAG(HAS_64_BIT_POINTERS)
static_assert;
#else
static_assert(kBitsPerSizeT == 32, "");
#endif  // PA_BUILDFLAG(HAS_64_BIT_POINTERS)

// Orders range from 0 to `kBitsPerSizeT`, inclusive.
inline constexpr uint8_t kNumOrders =;

template <typename SizeClass, SizeClass... Index>
constexpr auto MakeOrderArray(SizeClass (*order_function)(uint8_t),
                              std::integer_sequence<SizeClass, Index...> seq) {}

inline constexpr auto kOrderIndexShift =;

inline constexpr auto kOrderSubIndexMask =;

// The class used to generate the bucket lookup table at compile-time.
class BucketIndexLookup final {};

PA_ALWAYS_INLINE constexpr size_t RoundUpToPowerOfTwo(size_t size) {}

PA_ALWAYS_INLINE constexpr size_t RoundUpSize(size_t size) {}

PA_ALWAYS_INLINE constexpr uint16_t RoundUpToOdd(uint16_t size) {}

// static
PA_ALWAYS_INLINE constexpr uint16_t BucketIndexLookup::GetIndexForDenserBuckets(
    size_t size) {}

// static
PA_ALWAYS_INLINE constexpr uint16_t
BucketIndexLookup::GetIndexForNeutralBuckets(size_t size) {}

// static
PA_ALWAYS_INLINE constexpr uint16_t BucketIndexLookup::GetIndex(size_t size) {}

}  // namespace partition_alloc::internal

#endif  // PARTITION_ALLOC_PARTITION_BUCKET_LOOKUP_H_