Skip to content

Commit

Permalink
deps: backport 5152d97 from upstream V8
Browse files Browse the repository at this point in the history
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 <fmeawad@chromium.org>
  Commit-Queue: Jochen Eisinger <jochen@chromium.org>
  Cr-Commit-Position: refs/heads/master@{#46227}

PR-URL: #14001
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
Matt Loring authored and addaleax committed Aug 17, 2017
1 parent 4f21834 commit 832a87f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
5 changes: 4 additions & 1 deletion deps/v8/include/libplatform/libplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 7 additions & 9 deletions deps/v8/src/libplatform/default-platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ void PrintStackTrace() {

} // namespace

v8::Platform* CreateDefaultPlatform(
int thread_pool_size, IdleTaskSupport idle_task_support,
InProcessStackDumping in_process_stack_dumping) {
v8::Platform* CreateDefaultPlatform(int thread_pool_size,
IdleTaskSupport idle_task_support,
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;
}

Expand Down Expand Up @@ -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_) {
Expand Down Expand Up @@ -316,7 +314,7 @@ const char* DefaultPlatform::GetCategoryGroupName(
}

void DefaultPlatform::SetTracingController(
tracing::TracingController* tracing_controller) {
TracingController* tracing_controller) {
tracing_controller_.reset(tracing_controller);
}

Expand Down
8 changes: 2 additions & 6 deletions deps/v8/src/libplatform/default-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit 832a87f

Please sign in to comment.