Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: src/libplatform/default-platform.cc

Issue 2183943002: Revert of [Tracing] V8 Tracing Controller (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/libplatform/default-platform.h ('k') | src/libplatform/tracing/trace-buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/libplatform/default-platform.h" 5 #include "src/libplatform/default-platform.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 9
10 #include "src/base/logging.h" 10 #include "src/base/logging.h"
(...skipping 11 matching lines...) Expand all
22 platform->SetThreadPoolSize(thread_pool_size); 22 platform->SetThreadPoolSize(thread_pool_size);
23 platform->EnsureInitialized(); 23 platform->EnsureInitialized();
24 return platform; 24 return platform;
25 } 25 }
26 26
27 27
28 bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate) { 28 bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate) {
29 return reinterpret_cast<DefaultPlatform*>(platform)->PumpMessageLoop(isolate); 29 return reinterpret_cast<DefaultPlatform*>(platform)->PumpMessageLoop(isolate);
30 } 30 }
31 31
32 void SetTracingController(
33 v8::Platform* platform,
34 v8::platform::tracing::TracingController* tracing_controller) {
35 return reinterpret_cast<DefaultPlatform*>(platform)->SetTracingController(
36 tracing_controller);
37 }
38
39 const int DefaultPlatform::kMaxThreadPoolSize = 8; 32 const int DefaultPlatform::kMaxThreadPoolSize = 8;
40 33
41 DefaultPlatform::DefaultPlatform() 34 DefaultPlatform::DefaultPlatform()
42 : initialized_(false), thread_pool_size_(0), tracing_controller_(NULL) {} 35 : initialized_(false), thread_pool_size_(0) {}
36
43 37
44 DefaultPlatform::~DefaultPlatform() { 38 DefaultPlatform::~DefaultPlatform() {
45 base::LockGuard<base::Mutex> guard(&lock_); 39 base::LockGuard<base::Mutex> guard(&lock_);
46 queue_.Terminate(); 40 queue_.Terminate();
47 if (initialized_) { 41 if (initialized_) {
48 for (auto i = thread_pool_.begin(); i != thread_pool_.end(); ++i) { 42 for (auto i = thread_pool_.begin(); i != thread_pool_.end(); ++i) {
49 delete *i; 43 delete *i;
50 } 44 }
51 } 45 }
52 for (auto i = main_thread_queue_.begin(); i != main_thread_queue_.end(); 46 for (auto i = main_thread_queue_.begin(); i != main_thread_queue_.end();
53 ++i) { 47 ++i) {
54 while (!i->second.empty()) { 48 while (!i->second.empty()) {
55 delete i->second.front(); 49 delete i->second.front();
56 i->second.pop(); 50 i->second.pop();
57 } 51 }
58 } 52 }
59 for (auto i = main_thread_delayed_queue_.begin(); 53 for (auto i = main_thread_delayed_queue_.begin();
60 i != main_thread_delayed_queue_.end(); ++i) { 54 i != main_thread_delayed_queue_.end(); ++i) {
61 while (!i->second.empty()) { 55 while (!i->second.empty()) {
62 delete i->second.top().second; 56 delete i->second.top().second;
63 i->second.pop(); 57 i->second.pop();
64 } 58 }
65 } 59 }
66
67 if (tracing_controller_) {
68 tracing_controller_->StopTracing();
69 delete tracing_controller_;
70 }
71 } 60 }
72 61
73 62
74 void DefaultPlatform::SetThreadPoolSize(int thread_pool_size) { 63 void DefaultPlatform::SetThreadPoolSize(int thread_pool_size) {
75 base::LockGuard<base::Mutex> guard(&lock_); 64 base::LockGuard<base::Mutex> guard(&lock_);
76 DCHECK(thread_pool_size >= 0); 65 DCHECK(thread_pool_size >= 0);
77 if (thread_pool_size < 1) { 66 if (thread_pool_size < 1) {
78 thread_pool_size = base::SysInfo::NumberOfProcessors() - 1; 67 thread_pool_size = base::SysInfo::NumberOfProcessors() - 1;
79 } 68 }
80 thread_pool_size_ = 69 thread_pool_size_ =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return base::TimeTicks::HighResolutionNow().ToInternalValue() / 166 return base::TimeTicks::HighResolutionNow().ToInternalValue() /
178 static_cast<double>(base::Time::kMicrosecondsPerSecond); 167 static_cast<double>(base::Time::kMicrosecondsPerSecond);
179 } 168 }
180 169
181 170
182 uint64_t DefaultPlatform::AddTraceEvent( 171 uint64_t DefaultPlatform::AddTraceEvent(
183 char phase, const uint8_t* category_enabled_flag, const char* name, 172 char phase, const uint8_t* category_enabled_flag, const char* name,
184 const char* scope, uint64_t id, uint64_t bind_id, int num_args, 173 const char* scope, uint64_t id, uint64_t bind_id, int num_args,
185 const char** arg_names, const uint8_t* arg_types, 174 const char** arg_names, const uint8_t* arg_types,
186 const uint64_t* arg_values, unsigned int flags) { 175 const uint64_t* arg_values, unsigned int flags) {
187 if (tracing_controller_) {
188 return tracing_controller_->AddTraceEvent(
189 phase, category_enabled_flag, name, scope, id, bind_id, num_args,
190 arg_names, arg_types, arg_values, flags);
191 }
192
193 return 0; 176 return 0;
194 } 177 }
195 178
179
196 void DefaultPlatform::UpdateTraceEventDuration( 180 void DefaultPlatform::UpdateTraceEventDuration(
197 const uint8_t* category_enabled_flag, const char* name, uint64_t handle) { 181 const uint8_t* category_enabled_flag, const char* name, uint64_t handle) {}
198 if (tracing_controller_) { 182
199 tracing_controller_->UpdateTraceEventDuration(category_enabled_flag, name,
200 handle);
201 }
202 }
203 183
204 const uint8_t* DefaultPlatform::GetCategoryGroupEnabled(const char* name) { 184 const uint8_t* DefaultPlatform::GetCategoryGroupEnabled(const char* name) {
205 if (tracing_controller_) {
206 return tracing_controller_->GetCategoryGroupEnabled(name);
207 }
208 static uint8_t no = 0; 185 static uint8_t no = 0;
209 return &no; 186 return &no;
210 } 187 }
211 188
212 189
213 const char* DefaultPlatform::GetCategoryGroupName( 190 const char* DefaultPlatform::GetCategoryGroupName(
214 const uint8_t* category_enabled_flag) { 191 const uint8_t* category_enabled_flag) {
215 static const char dummy[] = "dummy"; 192 static const char dummy[] = "dummy";
216 return dummy; 193 return dummy;
217 } 194 }
218 195
219 void DefaultPlatform::SetTracingController(
220 tracing::TracingController* tracing_controller) {
221 tracing_controller_ = tracing_controller;
222 }
223 196
224 size_t DefaultPlatform::NumberOfAvailableBackgroundThreads() { 197 size_t DefaultPlatform::NumberOfAvailableBackgroundThreads() {
225 return static_cast<size_t>(thread_pool_size_); 198 return static_cast<size_t>(thread_pool_size_);
226 } 199 }
227 200
228 } // namespace platform 201 } // namespace platform
229 } // namespace v8 202 } // namespace v8
OLDNEW
« no previous file with comments | « src/libplatform/default-platform.h ('k') | src/libplatform/tracing/trace-buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698