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 <fmeawad@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46227}
This commit is contained in:
Jochen Eisinger 2017-06-26 17:49:09 +02:00 committed by Commit Bot
parent 3c9ee8f3f8
commit 5152d97870
3 changed files with 11 additions and 14 deletions

View File

@ -30,12 +30,15 @@ enum class MessageLoopBehavior : bool {
* If |idle_task_support| is enabled then the platform will accept idle
* tasks (IdleTasksEnabled will return true) and will rely on the embedder
* calling v8::platform::RunIdleTasks to process the idle tasks.
* If |tracing_controller| is nullptr, the default platform will create a
* v8::platform::TracingController instance and use it.
*/
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
InProcessStackDumping in_process_stack_dumping =
InProcessStackDumping::kEnabled);
InProcessStackDumping::kEnabled,
v8::TracingController* tracing_controller = nullptr);
/**
* Pumps the message loop for the given isolate.

View File

@ -31,13 +31,16 @@ void PrintStackTrace() {
v8::Platform* CreateDefaultPlatform(
int thread_pool_size, IdleTaskSupport idle_task_support,
InProcessStackDumping in_process_stack_dumping) {
InProcessStackDumping in_process_stack_dumping,
v8::TracingController* tracing_controller) {
if (in_process_stack_dumping == InProcessStackDumping::kEnabled) {
v8::base::debug::EnableInProcessStackDumping();
}
DefaultPlatform* platform = new DefaultPlatform(idle_task_support);
platform->SetThreadPoolSize(thread_pool_size);
platform->EnsureInitialized();
if (tracing_controller != nullptr)
platform->SetTracingController(tracing_controller);
return platform;
}
@ -73,11 +76,6 @@ DefaultPlatform::DefaultPlatform(IdleTaskSupport idle_task_support)
idle_task_support_(idle_task_support) {}
DefaultPlatform::~DefaultPlatform() {
if (tracing_controller_) {
tracing_controller_->StopTracing();
tracing_controller_.reset();
}
base::LockGuard<base::Mutex> guard(&lock_);
queue_.Terminate();
if (initialized_) {
@ -316,7 +314,7 @@ const char* DefaultPlatform::GetCategoryGroupName(
}
void DefaultPlatform::SetTracingController(
tracing::TracingController* tracing_controller) {
TracingController* tracing_controller) {
tracing_controller_.reset(tracing_controller);
}

View File

@ -27,10 +27,6 @@ class TaskQueue;
class Thread;
class WorkerThread;
namespace tracing {
class TracingController;
}
class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
public:
explicit DefaultPlatform(
@ -72,7 +68,7 @@ class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
unsigned int flags) override;
void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
const char* name, uint64_t handle) override;
void SetTracingController(tracing::TracingController* tracing_controller);
void SetTracingController(TracingController* tracing_controller);
void AddTraceStateObserver(TraceStateObserver* observer) override;
void RemoveTraceStateObserver(TraceStateObserver* observer) override;
@ -103,7 +99,7 @@ class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
std::priority_queue<DelayedEntry, std::vector<DelayedEntry>,
std::greater<DelayedEntry> > >
main_thread_delayed_queue_;
std::unique_ptr<tracing::TracingController> tracing_controller_;
std::unique_ptr<TracingController> tracing_controller_;
DISALLOW_COPY_AND_ASSIGN(DefaultPlatform);
};