13
13
#include " src/base/platform/platform.h"
14
14
#include " src/base/platform/time.h"
15
15
#include " src/base/sys-info.h"
16
+ #include " src/libplatform/tracing/trace-buffer.h"
17
+ #include " src/libplatform/tracing/trace-writer.h"
16
18
#include " src/libplatform/worker-thread.h"
17
19
18
20
namespace v8 {
@@ -36,11 +38,10 @@ v8::Platform* CreateDefaultPlatform(int thread_pool_size,
36
38
if (in_process_stack_dumping == InProcessStackDumping::kEnabled ) {
37
39
v8::base::debug::EnableInProcessStackDumping ();
38
40
}
39
- DefaultPlatform* platform = new DefaultPlatform (idle_task_support);
41
+ DefaultPlatform* platform =
42
+ new DefaultPlatform (idle_task_support, tracing_controller);
40
43
platform->SetThreadPoolSize (thread_pool_size);
41
44
platform->EnsureInitialized ();
42
- if (tracing_controller != nullptr )
43
- platform->SetTracingController (tracing_controller);
44
45
return platform;
45
46
}
46
47
@@ -70,10 +71,22 @@ void SetTracingController(
70
71
71
72
const int DefaultPlatform::kMaxThreadPoolSize = 8 ;
72
73
73
- DefaultPlatform::DefaultPlatform (IdleTaskSupport idle_task_support)
74
+ DefaultPlatform::DefaultPlatform (IdleTaskSupport idle_task_support,
75
+ v8::TracingController* tracing_controller)
74
76
: initialized_(false ),
75
77
thread_pool_size_ (0 ),
76
- idle_task_support_(idle_task_support) {}
78
+ idle_task_support_(idle_task_support) {
79
+ if (tracing_controller) {
80
+ tracing_controller_.reset (tracing_controller);
81
+ } else {
82
+ tracing::TraceWriter* writer = new tracing::NullTraceWriter ();
83
+ tracing::TraceBuffer* ring_buffer =
84
+ new tracing::TraceBufferRingBuffer (1 , writer);
85
+ tracing::TracingController* controller = new tracing::TracingController ();
86
+ controller->Initialize (ring_buffer);
87
+ tracing_controller_.reset (controller);
88
+ }
89
+ }
77
90
78
91
DefaultPlatform::~DefaultPlatform () {
79
92
base::LockGuard<base::Mutex> guard (&lock_);
@@ -274,64 +287,16 @@ TracingController* DefaultPlatform::GetTracingController() {
274
287
return tracing_controller_.get ();
275
288
}
276
289
277
- uint64_t DefaultPlatform::AddTraceEvent (
278
- char phase, const uint8_t * category_enabled_flag, const char * name,
279
- const char * scope, uint64_t id, uint64_t bind_id, int num_args,
280
- const char ** arg_names, const uint8_t * arg_types,
281
- const uint64_t * arg_values,
282
- std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
283
- unsigned int flags) {
284
- if (tracing_controller_) {
285
- return tracing_controller_->AddTraceEvent (
286
- phase, category_enabled_flag, name, scope, id, bind_id, num_args,
287
- arg_names, arg_types, arg_values, arg_convertables, flags);
288
- }
289
-
290
- return 0 ;
291
- }
292
-
293
- void DefaultPlatform::UpdateTraceEventDuration (
294
- const uint8_t * category_enabled_flag, const char * name, uint64_t handle) {
295
- if (tracing_controller_) {
296
- tracing_controller_->UpdateTraceEventDuration (category_enabled_flag, name,
297
- handle);
298
- }
299
- }
300
-
301
- const uint8_t * DefaultPlatform::GetCategoryGroupEnabled (const char * name) {
302
- if (tracing_controller_) {
303
- return tracing_controller_->GetCategoryGroupEnabled (name);
304
- }
305
- static uint8_t no = 0 ;
306
- return &no;
307
- }
308
-
309
-
310
- const char * DefaultPlatform::GetCategoryGroupName (
311
- const uint8_t * category_enabled_flag) {
312
- static const char dummy[] = " dummy" ;
313
- return dummy;
314
- }
315
-
316
290
void DefaultPlatform::SetTracingController (
317
- TracingController* tracing_controller) {
291
+ v8::TracingController* tracing_controller) {
292
+ DCHECK_NOT_NULL (tracing_controller);
318
293
tracing_controller_.reset (tracing_controller);
319
294
}
320
295
321
296
size_t DefaultPlatform::NumberOfAvailableBackgroundThreads () {
322
297
return static_cast <size_t >(thread_pool_size_);
323
298
}
324
299
325
- void DefaultPlatform::AddTraceStateObserver (TraceStateObserver* observer) {
326
- if (!tracing_controller_) return ;
327
- tracing_controller_->AddTraceStateObserver (observer);
328
- }
329
-
330
- void DefaultPlatform::RemoveTraceStateObserver (TraceStateObserver* observer) {
331
- if (!tracing_controller_) return ;
332
- tracing_controller_->RemoveTraceStateObserver (observer);
333
- }
334
-
335
300
Platform::StackTracePrinter DefaultPlatform::GetStackTracePrinter () {
336
301
return PrintStackTrace;
337
302
}
0 commit comments