Blob Blame History Raw
--- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h
+++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h
@@ -176,7 +176,11 @@ SystemPageBaseMask() {
   return ~SystemPageOffsetMask();
 }
 
+#if defined(ARCH_CPU_PPC64)
+constexpr size_t kPageMetadataShift = 6;  // 64 bytes per partition page.
+#else
 constexpr size_t kPageMetadataShift = 5;  // 32 bytes per partition page.
+#endif
 constexpr size_t kPageMetadataSize = 1 << kPageMetadataShift;
 
 }  // namespace internal
--- a/base/allocator/partition_allocator/src/partition_alloc/partition_page.h
+++ b/base/allocator/partition_allocator/src/partition_alloc/partition_page.h
@@ -86,7 +86,11 @@ struct SlotSpanMetadata {
 
   // CHECK()ed in AllocNewSlotSpan().
   // The maximum number of bits needed to cover all currently supported OSes.
+#if defined(ARCH_CPU_PPC64)
+  static constexpr size_t kMaxSlotsPerSlotSpanBits = 15;
+#else
   static constexpr size_t kMaxSlotsPerSlotSpanBits = 13;
+#endif
   static_assert(kMaxSlotsPerSlotSpan < (1 << kMaxSlotsPerSlotSpanBits), "");
 
   // |marked_full| isn't equivalent to being full. Slot span is marked as full
@@ -100,7 +104,11 @@ struct SlotSpanMetadata {
  private:
   const uint32_t can_store_raw_size_ : 1;
   uint32_t freelist_is_sorted_ : 1;
+#if defined(ARCH_CPU_PPC64)
+  uint32_t unused1_ : (64 - 1 - 2 * kMaxSlotsPerSlotSpanBits - 1 - 1);
+#else
   uint32_t unused1_ : (32 - 1 - 2 * kMaxSlotsPerSlotSpanBits - 1 - 1);
+#endif
   // If |in_empty_cache_|==1, |empty_cache_index| is undefined and mustn't be
   // used.
   uint16_t in_empty_cache_ : 1;
--- a/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h
+++ b/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h
@@ -21,6 +21,11 @@ static constexpr size_t kMaxSlotsPerSlot
 // currently (kMaxSlotsPerSlotSpanBits == 13) not supported by the code,
 // so we use the 16 kiB maximum (64 kiB will crash).
 static constexpr size_t kMaxSlotsPerSlotSpan = 4 * (1 << 14) / kSmallestBucket;
+#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_PPC64)
+// System page size is not a constant on OpenPOWER systems, but is either 4kiB
+// or 64kiB (1 << 12 or 1 << 16)
+// And PartitionPageSize() is 4 times the OS page size.
+static constexpr size_t kMaxSlotsPerSlotSpan = 4 * (1 << 16) / kSmallestBucket;
 #else
 // A slot span can "span" multiple PartitionPages, but then its slot size is
 // larger, so it doesn't have as many slots.