electron/patches/chromium/export_gin_v8platform_pagea...

38 lines
1.7 KiB
Diff

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
In order for memory allocation in the main process node environment to be
correctly tagged with MAP_JIT we need to use gins page allocator instead
of the default V8 allocator. This probably can't be usptreamed.
diff --git a/gin/public/v8_platform.h b/gin/public/v8_platform.h
index cec5e3b283343586ba846a4ce58fee34e8542164..09ec66b75113d6a934d51ee5aad684281be61e8f 100644
--- a/gin/public/v8_platform.h
+++ b/gin/public/v8_platform.h
@@ -32,6 +32,7 @@ class GIN_EXPORT V8Platform : public v8::Platform {
// enabling Arm's Branch Target Instructions for executable pages. This is
// verified in the tests for gin::PageAllocator.
PageAllocator* GetPageAllocator() override;
+ static PageAllocator* GetCurrentPageAllocator();
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
ThreadIsolatedAllocator* GetThreadIsolatedAllocator() override;
#endif
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index 0a445ec921d6a81e8d5972215a5928e368a555eb..339554921d00f79cc92f3a40443f8f5d3cee1829 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -336,6 +336,10 @@ ThreadIsolatedAllocator* V8Platform::GetThreadIsolatedAllocator() {
}
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
+PageAllocator* V8Platform::GetCurrentPageAllocator() {
+ 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.