diff --git a/common.gypi b/common.gypi index 346a199b4c9ba4..733d668e8830ca 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.1', + 'v8_embedder_string': '-node.2', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h index 74630b6f19d475..932a36ae7daa62 100644 --- a/deps/v8/include/v8-platform.h +++ b/deps/v8/include/v8-platform.h @@ -36,6 +36,51 @@ class IdleTask { virtual void Run(double deadline_in_seconds) = 0; }; +/** + * A TaskRunner allows scheduling of tasks. The TaskRunner may still be used to + * post tasks after the isolate gets destructed, but these tasks may not get + * executed anymore. All tasks posted to a given TaskRunner will be invoked in + * sequence. Tasks can be posted from any thread. + */ +class TaskRunner { + public: + /** + * Schedules a task to be invoked by this TaskRunner. The TaskRunner + * implementation takes ownership of |task|. + */ + virtual void PostTask(std::unique_ptr task) = 0; + + /** + * Schedules a task to be invoked by this TaskRunner. The task is scheduled + * after the given number of seconds |delay_in_seconds|. The TaskRunner + * implementation takes ownership of |task|. + */ + virtual void PostDelayedTask(std::unique_ptr task, + double delay_in_seconds) = 0; + + /** + * Schedules an idle task to be invoked by this TaskRunner. The task is + * scheduled when the embedder is idle. Requires that + * TaskRunner::SupportsIdleTasks(isolate) is true. Idle tasks may be reordered + * relative to other task types and may be starved for an arbitrarily long + * time if no idle time is available. The TaskRunner implementation takes + * ownership of |task|. + */ + virtual void PostIdleTask(std::unique_ptr task) = 0; + + /** + * Returns true if idle tasks are enabled for this TaskRunner. + */ + virtual bool IdleTasksEnabled() = 0; + + TaskRunner() = default; + virtual ~TaskRunner() = default; + + private: + TaskRunner(const TaskRunner&) = delete; + TaskRunner& operator=(const TaskRunner&) = delete; +}; + /** * The interface represents complex arguments to trace events. */ @@ -150,6 +195,28 @@ class Platform { */ virtual size_t NumberOfAvailableBackgroundThreads() { return 0; } + /** + * Returns a TaskRunner which can be used to post a task on the foreground. + * This function should only be called from a foreground thread. + */ + virtual std::unique_ptr GetForegroundTaskRunner( + Isolate* isolate) { + // TODO(ahaas): Make this function abstract after it got implemented on all + // platforms. + return {}; + } + + /** + * 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::unique_ptr GetBackgroundTaskRunner( + Isolate* isolate) { + // TODO(ahaas): Make this function abstract after it got implemented on all + // platforms. + return {}; + } + /** * Schedules a task to be invoked on a background thread. |expected_runtime| * indicates that the task will run a long time. The Platform implementation