fix: correct redefinition which is invalid C++ (#36096)

* fix: correct redefinition which is invalid C++

See https://stackoverflow.com/a/15538759 for an explanation of class scope.
GCC gives an error when compiling this code: https://godbolt.org/z/sYhc3cMjE

* Update export_gin_v8platform_pageallocator_for_usage_outside_of_the_gin.patch

---------

Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
Co-authored-by: Cheng Zhao <github@zcbenz.com>
This commit is contained in:
Bruno Pitrus 2023-02-08 08:03:47 +01:00 коммит произвёл GitHub
Родитель 00a542358d
Коммит df6f99aa72
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -9,26 +9,26 @@ 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 c4f2df96133012faebec25ac3a738c34cd6b4cf8..1b0333b2efe05a659e161f28ce6c01e572fddcef 100644
index c4f2df96133012faebec25ac3a738c34cd6b4cf8..54bc2625686b9344c2c793c74589ed85de8227ba 100644
--- a/gin/public/v8_platform.h
+++ b/gin/public/v8_platform.h
@@ -30,6 +30,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* PageAllocator();
+ static PageAllocator* GetCurrentPageAllocator();
void OnCriticalMemoryPressure() override;
v8::ZoneBackingAllocator* GetZoneBackingAllocator() override;
#endif
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index bbb16efbf5208989fa88c7f6d83d36aa5e54a0d1..1ead276abf4327d48a816d8b520ebe958b5aa17b 100644
index bbb16efbf5208989fa88c7f6d83d36aa5e54a0d1..ef562c9a9abed85198282728287637d178a0af0f 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -370,6 +370,10 @@ PageAllocator* V8Platform::GetPageAllocator() {
return g_page_allocator.Pointer();
}
+PageAllocator* V8Platform::PageAllocator() {
+PageAllocator* V8Platform::GetCurrentPageAllocator() {
+ return g_page_allocator.Pointer();
+}
+

Просмотреть файл

@ -267,7 +267,7 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop,
node::tracing::TraceEventHelper::SetAgent(tracing_agent);
platform_ = node::MultiIsolatePlatform::Create(
base::RecommendedMaxNumberOfThreadsInThreadGroup(3, 8, 0.1, 0),
tracing_controller, gin::V8Platform::PageAllocator());
tracing_controller, gin::V8Platform::GetCurrentPageAllocator());
v8::V8::InitializePlatform(platform_.get());
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,