Skip to content

Commit 6cb718b

Browse files
Matt LoringMylesBorins
Matt Loring
authored andcommitted
deps: backport 5152d97 from upstream V8
Original commit message: Add API to create a platform with a tracing controller BUG=v8:6511 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Ie6b62df693d3b847837c071e1f985b7ce3b420c8 Reviewed-on: https://chromium-review.googlesource.com/548499 Reviewed-by: Fadi Meawad <[email protected]> Commit-Queue: Jochen Eisinger <[email protected]> Cr-Commit-Position: refs/heads/master@{#46227} PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent c6e2b8a commit 6cb718b

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

deps/v8/include/libplatform/libplatform.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ enum class MessageLoopBehavior : bool {
3030
* If |idle_task_support| is enabled then the platform will accept idle
3131
* tasks (IdleTasksEnabled will return true) and will rely on the embedder
3232
* calling v8::platform::RunIdleTasks to process the idle tasks.
33+
* If |tracing_controller| is nullptr, the default platform will create a
34+
* v8::platform::TracingController instance and use it.
3335
*/
3436
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
3537
int thread_pool_size = 0,
3638
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
3739
InProcessStackDumping in_process_stack_dumping =
38-
InProcessStackDumping::kEnabled);
40+
InProcessStackDumping::kEnabled,
41+
v8::TracingController* tracing_controller = nullptr);
3942

4043
/**
4144
* Pumps the message loop for the given isolate.

deps/v8/src/libplatform/default-platform.cc

+7-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ void PrintStackTrace() {
2929

3030
} // namespace
3131

32-
v8::Platform* CreateDefaultPlatform(
33-
int thread_pool_size, IdleTaskSupport idle_task_support,
34-
InProcessStackDumping in_process_stack_dumping) {
32+
v8::Platform* CreateDefaultPlatform(int thread_pool_size,
33+
IdleTaskSupport idle_task_support,
34+
InProcessStackDumping in_process_stack_dumping,
35+
v8::TracingController* tracing_controller) {
3536
if (in_process_stack_dumping == InProcessStackDumping::kEnabled) {
3637
v8::base::debug::EnableInProcessStackDumping();
3738
}
3839
DefaultPlatform* platform = new DefaultPlatform(idle_task_support);
3940
platform->SetThreadPoolSize(thread_pool_size);
4041
platform->EnsureInitialized();
42+
if (tracing_controller != nullptr)
43+
platform->SetTracingController(tracing_controller);
4144
return platform;
4245
}
4346

@@ -73,11 +76,6 @@ DefaultPlatform::DefaultPlatform(IdleTaskSupport idle_task_support)
7376
idle_task_support_(idle_task_support) {}
7477

7578
DefaultPlatform::~DefaultPlatform() {
76-
if (tracing_controller_) {
77-
tracing_controller_->StopTracing();
78-
tracing_controller_.reset();
79-
}
80-
8179
base::LockGuard<base::Mutex> guard(&lock_);
8280
queue_.Terminate();
8381
if (initialized_) {
@@ -316,7 +314,7 @@ const char* DefaultPlatform::GetCategoryGroupName(
316314
}
317315

318316
void DefaultPlatform::SetTracingController(
319-
tracing::TracingController* tracing_controller) {
317+
TracingController* tracing_controller) {
320318
tracing_controller_.reset(tracing_controller);
321319
}
322320

deps/v8/src/libplatform/default-platform.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class TaskQueue;
2727
class Thread;
2828
class WorkerThread;
2929

30-
namespace tracing {
31-
class TracingController;
32-
}
33-
3430
class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
3531
public:
3632
explicit DefaultPlatform(
@@ -72,7 +68,7 @@ class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
7268
unsigned int flags) override;
7369
void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
7470
const char* name, uint64_t handle) override;
75-
void SetTracingController(tracing::TracingController* tracing_controller);
71+
void SetTracingController(TracingController* tracing_controller);
7672

7773
void AddTraceStateObserver(TraceStateObserver* observer) override;
7874
void RemoveTraceStateObserver(TraceStateObserver* observer) override;
@@ -103,7 +99,7 @@ class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
10399
std::priority_queue<DelayedEntry, std::vector<DelayedEntry>,
104100
std::greater<DelayedEntry> > >
105101
main_thread_delayed_queue_;
106-
std::unique_ptr<tracing::TracingController> tracing_controller_;
102+
std::unique_ptr<TracingController> tracing_controller_;
107103

108104
DISALLOW_COPY_AND_ASSIGN(DefaultPlatform);
109105
};

0 commit comments

Comments
 (0)