chromium/third_party/blink/renderer/platform/wtf/allocator/partitions.cc

/*
 * Copyright (C) 2013 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "third_party/blink/renderer/platform/wtf/allocator/partitions.h"

#include "base/allocator/partition_alloc_features.h"
#include "base/allocator/partition_alloc_support.h"
#include "base/debug/alias.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/strings/safe_sprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/thread_annotations.h"
#include "build/build_config.h"
#include "components/crash/core/common/crash_key.h"
#include "partition_alloc/buildflags.h"
#include "partition_alloc/oom.h"
#include "partition_alloc/page_allocator.h"
#include "partition_alloc/partition_alloc.h"
#include "partition_alloc/partition_alloc_constants.h"
#include "partition_alloc/partition_root.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"

namespace WTF {

const char* const Partitions::kAllocatedObjectPoolName =;

BASE_FEATURE();
#endif

bool Partitions::initialized_ =;

// These statics are inlined, so cannot be LazyInstances. We create the values,
// and then set the pointers correctly in Initialize().
partition_alloc::PartitionRoot* Partitions::fast_malloc_root_ =;
partition_alloc::PartitionRoot* Partitions::array_buffer_root_ =;
partition_alloc::PartitionRoot* Partitions::buffer_root_ =;

namespace {

// Reads feature configuration and returns a suitable
// `PartitionOptions`.
partition_alloc::PartitionOptions PartitionOptionsFromFeatures() {}

}  // namespace

// static
void Partitions::Initialize() {}

// static
bool Partitions::InitializeOnce() {}

// static
void Partitions::InitializeArrayBufferPartition() {}

// static
void Partitions::StartMemoryReclaimer(
    scoped_refptr<base::SequencedTaskRunner> task_runner) {}

// static
void Partitions::DumpMemoryStats(
    bool is_light_dump,
    partition_alloc::PartitionStatsDumper* partition_stats_dumper) {}

namespace {

class LightPartitionStatsDumperImpl
    : public partition_alloc::PartitionStatsDumper {};

}  // namespace

// static
size_t Partitions::TotalSizeOfCommittedPages() {}

// static
size_t Partitions::TotalActiveBytes() {}

NOINLINE static void PartitionsOutOfMemoryUsing2G(size_t size) {}

NOINLINE static void PartitionsOutOfMemoryUsing1G(size_t size) {}

NOINLINE static void PartitionsOutOfMemoryUsing512M(size_t size) {}

NOINLINE static void PartitionsOutOfMemoryUsing256M(size_t size) {}

NOINLINE static void PartitionsOutOfMemoryUsing128M(size_t size) {}

NOINLINE static void PartitionsOutOfMemoryUsing64M(size_t size) {}

NOINLINE static void PartitionsOutOfMemoryUsing32M(size_t size) {}

NOINLINE static void PartitionsOutOfMemoryUsing16M(size_t size) {}

NOINLINE static void PartitionsOutOfMemoryUsingLessThan16M(size_t size) {}

// static
void* Partitions::BufferMalloc(size_t n, const char* type_name) {}

// static
void* Partitions::BufferTryRealloc(void* p, size_t n, const char* type_name) {}

// static
void Partitions::BufferFree(void* p) {}

// static
size_t Partitions::BufferPotentialCapacity(size_t n) {}

// Ideally this would be removed when PartitionAlloc is malloc(), but there are
// quite a few callers. Just forward to the C functions instead.  Most of the
// usual callers will never reach here though, as USING_FAST_MALLOC() becomes a
// no-op.
// static
void* Partitions::FastMalloc(size_t n, const char* type_name) {}

// static
void* Partitions::FastZeroedMalloc(size_t n, const char* type_name) {}

// static
void Partitions::FastFree(void* p) {}

// static
void Partitions::HandleOutOfMemory(size_t size) {}

// static
void Partitions::AdjustPartitionsForForeground() {}

// static
void Partitions::AdjustPartitionsForBackground() {}

}  // namespace WTF