
The quick summary: - OOM crashes reduced significantly on Desktop (5-16%), - Cage exhaustion is almost fully gone on Windows/Linux and reduced by 77% on Mac, - PMF didn't change, as expected. Bug: 343959927 Change-Id: If990d54dd519f9474c88d1599a2b534c2bec7b0c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6012407 Commit-Queue: Anton Bikineev <bikineev@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#1382315}
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
// 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.
|
|
|
|
#include "gin/public/cppgc.h"
|
|
|
|
#include "base/check_op.h"
|
|
#include "base/feature_list.h"
|
|
#include "build/build_config.h"
|
|
#include "gin/gin_features.h"
|
|
#include "gin/public/v8_platform.h"
|
|
#include "v8/include/cppgc/platform.h"
|
|
|
|
namespace gin {
|
|
|
|
namespace {
|
|
|
|
int g_init_count = 0;
|
|
|
|
} // namespace
|
|
|
|
void InitializeCppgcFromV8Platform() {
|
|
#if BUILDFLAG(IS_ANDROID)
|
|
// Keep the cage size at 4GB on Android, since some vendors can configure the
|
|
// kernel to have address space limited to 2^39 or 2^36 bits, which is more
|
|
// prone to address space exhaustion.
|
|
static constexpr size_t kCageSize =
|
|
static_cast<size_t>(4) * 1024 * 1024 * 1024;
|
|
#else
|
|
static constexpr size_t kCageSize =
|
|
static_cast<size_t>(16) * 1024 * 1024 * 1024;
|
|
#endif
|
|
|
|
DCHECK_GE(g_init_count, 0);
|
|
if (g_init_count++ > 0) {
|
|
return;
|
|
}
|
|
|
|
cppgc::InitializeProcess(gin::V8Platform::Get()->GetPageAllocator(),
|
|
kCageSize);
|
|
}
|
|
|
|
void MaybeShutdownCppgc() {
|
|
DCHECK_GT(g_init_count, 0);
|
|
if (--g_init_count > 0)
|
|
return;
|
|
|
|
cppgc::ShutdownProcess();
|
|
}
|
|
|
|
} // namespace gin
|