From 2a3f8c3a83e3820d3c601bdf02eda8db462027aa Mon Sep 17 00:00:00 2001
From: Peter Marshall
Date: Thu, 12 Apr 2018 16:42:10 +0200
Subject: [PATCH] deps: patch the V8 API to be forward compatible with 6.7
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PR-URL: https://github.com/nodejs/node/pull/19999
Reviewed-By: Anna Henningsen
Reviewed-By: James M Snell
Reviewed-By: Yang Guo
Reviewed-By: Michaƫl Zasso
---
common.gypi | 2 +-
deps/v8/include/libplatform/libplatform.h | 4 +-
deps/v8/include/v8-platform.h | 63 ++++++++++++++++--
deps/v8/include/v8.h | 79 +++++++++--------------
deps/v8/src/api.cc | 54 ++++++----------
deps/v8/src/d8.cc | 14 ----
deps/v8/test/mkgrokdump/mkgrokdump.cc | 4 --
src/node_version.h | 3 +-
8 files changed, 114 insertions(+), 109 deletions(-)
diff --git a/common.gypi b/common.gypi
index 4ca1aaf88ecb6d..d1304a14478d2c 100644
--- a/common.gypi
+++ b/common.gypi
@@ -27,7 +27,7 @@
# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
- 'v8_embedder_string': '-node.4',
+ 'v8_embedder_string': '-node.5',
# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
diff --git a/deps/v8/include/libplatform/libplatform.h b/deps/v8/include/libplatform/libplatform.h
index 04b47b8d2e154a..b5f2b77711166f 100644
--- a/deps/v8/include/libplatform/libplatform.h
+++ b/deps/v8/include/libplatform/libplatform.h
@@ -38,7 +38,7 @@ V8_PLATFORM_EXPORT std::unique_ptr NewDefaultPlatform(
int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
InProcessStackDumping in_process_stack_dumping =
- InProcessStackDumping::kEnabled,
+ InProcessStackDumping::kDisabled,
std::unique_ptr tracing_controller = {});
V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
@@ -47,7 +47,7 @@ V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
InProcessStackDumping in_process_stack_dumping =
- InProcessStackDumping::kEnabled,
+ InProcessStackDumping::kDisabled,
v8::TracingController* tracing_controller = nullptr));
/**
diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h
index 2bb14df93e9bad..62b3af84a0f717 100644
--- a/deps/v8/include/v8-platform.h
+++ b/deps/v8/include/v8-platform.h
@@ -5,11 +5,14 @@
#ifndef V8_V8_PLATFORM_H_
#define V8_V8_PLATFORM_H_
+#include
#include
#include
#include
#include
+#include "v8config.h" // NOLINT(build/include)
+
namespace v8 {
class Isolate;
@@ -285,6 +288,10 @@ class Platform {
*/
virtual bool OnCriticalMemoryPressure(size_t length) { return false; }
+ virtual int NumberOfWorkerThreads() {
+ return static_cast(NumberOfAvailableBackgroundThreads());
+ }
+
/**
* Gets the number of threads that are used to execute background tasks. Is
* used to estimate the number of tasks a work package should be split into.
@@ -292,7 +299,12 @@ class Platform {
* Note that a value of 0 won't prohibit V8 from posting tasks using
* |CallOnBackgroundThread|.
*/
- virtual size_t NumberOfAvailableBackgroundThreads() { return 0; }
+ V8_DEPRECATE_SOON(
+ "NumberOfAvailableBackgroundThreads() is deprecated, use "
+ "NumberOfAvailableBackgroundThreads() instead.",
+ virtual size_t NumberOfAvailableBackgroundThreads()) {
+ return 0;
+ }
/**
* Returns a TaskRunner which can be used to post a task on the foreground.
@@ -309,11 +321,28 @@ class Platform {
* Returns a TaskRunner which can be used to post a task on a background.
* This function should only be called from a foreground thread.
*/
- virtual std::shared_ptr GetBackgroundTaskRunner(
+ V8_DEPRECATE_SOON(
+ "GetBackgroundTaskRunner() is deprecated, use "
+ "GetWorkerThreadsTaskRunner() "
+ "instead.",
+ virtual std::shared_ptr GetBackgroundTaskRunner(
+ Isolate* isolate)) {
+ // TODO(gab): Remove this method when all embedders have moved to
+ // GetWorkerThreadsTaskRunner().
+
+ // An implementation needs to be provided here because this is called by the
+ // default GetWorkerThreadsTaskRunner() implementation below. In practice
+ // however, all code either:
+ // - Overrides GetWorkerThreadsTaskRunner() (thus not making this call) --
+ // i.e. all v8 code.
+ // - Overrides this method (thus not making this call) -- i.e. all
+ // unadapted embedders.
+ abort();
+ }
+
+ virtual std::shared_ptr GetWorkerThreadsTaskRunner(
Isolate* isolate) {
- // TODO(ahaas): Make this function abstract after it got implemented on all
- // platforms.
- return {};
+ return GetBackgroundTaskRunner(isolate);
}
/**
@@ -323,8 +352,28 @@ class Platform {
* of tasks wrt order of scheduling, nor is there a guarantee about the
* thread the task will be run on.
*/
- virtual void CallOnBackgroundThread(Task* task,
- ExpectedRuntime expected_runtime) = 0;
+ V8_DEPRECATE_SOON(
+ "ExpectedRuntime is deprecated, use CallOnWorkerThread() instead.",
+ virtual void CallOnBackgroundThread(Task* task,
+ ExpectedRuntime expected_runtime)) {
+ // An implementation needs to be provided here because this is called by the
+ // default implementation below. In practice however, all code either:
+ // - Overrides the new method (thus not making this call) -- i.e. all v8
+ // code.
+ // - Overrides this method (thus not making this call) -- i.e. all
+ // unadapted embedders.
+ abort();
+ }
+
+ virtual void CallOnWorkerThread(std::unique_ptr task) {
+ CallOnBackgroundThread(task.release(), kShortRunningTask);
+ }
+
+ virtual void CallBlockingTaskOnWorkerThread(std::unique_ptr task) {
+ // Embedders may optionally override this to process these tasks in a high
+ // priority pool.
+ CallOnWorkerThread(std::move(task));
+ }
/**
* Schedules a task to be invoked on a foreground thread wrt a specific
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h
index 0149ed3ca2406e..201c2cc05ca6bd 100644
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -1567,7 +1567,9 @@ class V8_EXPORT ScriptCompiler {
static V8_WARN_UNUSED_RESULT MaybeLocal CompileFunctionInContext(
Local context, Source* source, size_t arguments_count,
Local arguments[], size_t context_extension_count,
- Local