fix: use the gin PageAllocator instead of V8::PageAllocator (#26331)

* fix: use the gin PageAllocator instead of V8::PageAllocator

This makes browser-process JS allocate pages using the base/gin allocator thus ensuring flags such as MAP_JIT are appropriately applied.

* chore: add gin patch

* update patches

Co-authored-by: Electron Bot <electron@github.com>
This commit is contained in:
Samuel Attard 2020-11-09 13:57:24 -08:00 committed by GitHub
parent 02a8c0a640
commit 40ebdb5c42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 159 additions and 1 deletions

View file

@ -101,3 +101,4 @@ fix_properly_honor_printing_page_ranges.patch
fix_use_electron_generated_resources.patch
chore_expose_v8_initialization_isolate_callbacks.patch
rename_the_v8_context_snapshot_on_arm64_macos_builds.patch
export_gin_v8platform_pageallocator_for_usage_outside_of_the_gin.patch

View file

@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <samuel.r.attard@gmail.com>
Date: Tue, 3 Nov 2020 16:49:32 -0800
Subject: export gin::V8Platform::PageAllocator for usage outside of the gin
platform
diff --git a/gin/public/v8_platform.h b/gin/public/v8_platform.h
index da2aeb2f2da84fe47d5cc7d721f8d3dade0c0972..4ddad9065782fad5927bc0481ad772014af0d689 100644
--- a/gin/public/v8_platform.h
+++ b/gin/public/v8_platform.h
@@ -23,6 +23,7 @@ class GIN_EXPORT V8Platform : public v8::Platform {
// Some configurations do not use page_allocator.
#if BUILDFLAG(USE_PARTITION_ALLOC)
v8::PageAllocator* GetPageAllocator() override;
+ static v8::PageAllocator* PageAllocator();
void OnCriticalMemoryPressure() override;
#endif
std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index 9cec7468189af7f290ff32c184f0a7baa636be62..e4f20e56680e652ca99b416d352e4a2ec1b79509 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -439,6 +439,10 @@ v8::PageAllocator* V8Platform::GetPageAllocator() {
return g_page_allocator.Pointer();
}
+v8::PageAllocator* V8Platform::PageAllocator() {
+ return g_page_allocator.Pointer();
+}
+
void V8Platform::OnCriticalMemoryPressure() {
// We only have a reservation on 32-bit Windows systems.
// TODO(bbudge) Make the #if's in BlinkInitializer match.