v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
default-platform.h
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
6#define INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
7
8#include <memory>
9
10#include "cppgc/platform.h"
12#include "v8config.h" // NOLINT(build/include_directory)
13
14namespace cppgc {
15
21 public:
24 int thread_pool_size = 0,
25 IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
26 std::unique_ptr<TracingController> tracing_controller = {})
27 : v8_platform_(v8::platform::NewDefaultPlatform(
28 thread_pool_size, idle_task_support,
29 v8::platform::InProcessStackDumping::kDisabled,
30 std::move(tracing_controller))) {}
31
33 return v8_platform_->GetPageAllocator();
34 }
35
36 double MonotonicallyIncreasingTime() override {
37 return v8_platform_->MonotonicallyIncreasingTime();
38 }
39
40 std::shared_ptr<cppgc::TaskRunner> GetForegroundTaskRunner(
41 TaskPriority priority) override {
42 // V8's default platform creates a new task runner when passed the
43 // `v8::Isolate` pointer the first time. For non-default platforms this will
44 // require getting the appropriate task runner.
45 return v8_platform_->GetForegroundTaskRunner(kNoIsolate, priority);
46 }
47
48 std::unique_ptr<cppgc::JobHandle> PostJob(
50 std::unique_ptr<cppgc::JobTask> job_task) override {
51 return v8_platform_->PostJob(priority, std::move(job_task));
52 }
53
55 return v8_platform_->GetTracingController();
56 }
57
58 v8::Platform* GetV8Platform() const { return v8_platform_.get(); }
59
60 protected:
61 static constexpr v8::Isolate* kNoIsolate = nullptr;
62
63 std::unique_ptr<v8::Platform> v8_platform_;
64};
65
66} // namespace cppgc
67
68#endif // INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
TracingController * GetTracingController() override
DefaultPlatform(int thread_pool_size=0, IdleTaskSupport idle_task_support=IdleTaskSupport::kDisabled, std::unique_ptr< TracingController > tracing_controller={})
v8::Platform * GetV8Platform() const
cppgc::PageAllocator * GetPageAllocator() override
std::unique_ptr< cppgc::JobHandle > PostJob(cppgc::TaskPriority priority, std::unique_ptr< cppgc::JobTask > job_task) override
std::unique_ptr< v8::Platform > v8_platform_
std::shared_ptr< cppgc::TaskRunner > GetForegroundTaskRunner(TaskPriority priority) override
double MonotonicallyIncreasingTime() override
size_t priority
STL namespace.
TaskPriority
Definition v8-platform.h:24
#define V8_EXPORT
Definition v8config.h:800