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

Side by Side Diff: src/log.cc

Issue 6723014: Avoid TLS access for counters. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix lint Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/jump-target-heavy.cc ('k') | src/objects.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 #ifdef ENABLE_LOGGING_AND_PROFILING 46 #ifdef ENABLE_LOGGING_AND_PROFILING
47 47
48 // 48 //
49 // Sliding state window. Updates counters to keep track of the last 49 // Sliding state window. Updates counters to keep track of the last
50 // window of kBufferSize states. This is useful to track where we 50 // window of kBufferSize states. This is useful to track where we
51 // spent our time. 51 // spent our time.
52 // 52 //
53 class SlidingStateWindow { 53 class SlidingStateWindow {
54 public: 54 public:
55 SlidingStateWindow(); 55 explicit SlidingStateWindow(Isolate* isolate);
56 ~SlidingStateWindow(); 56 ~SlidingStateWindow();
57 void AddState(StateTag state); 57 void AddState(StateTag state);
58 58
59 private: 59 private:
60 static const int kBufferSize = 256; 60 static const int kBufferSize = 256;
61 Counters* counters_;
61 int current_index_; 62 int current_index_;
62 bool is_full_; 63 bool is_full_;
63 byte buffer_[kBufferSize]; 64 byte buffer_[kBufferSize];
64 65
65 66
66 void IncrementStateCounter(StateTag state) { 67 void IncrementStateCounter(StateTag state) {
67 COUNTERS->state_counters(state)->Increment(); 68 counters_->state_counters(state)->Increment();
68 } 69 }
69 70
70 71
71 void DecrementStateCounter(StateTag state) { 72 void DecrementStateCounter(StateTag state) {
72 COUNTERS->state_counters(state)->Decrement(); 73 counters_->state_counters(state)->Decrement();
73 } 74 }
74 }; 75 };
75 76
76 77
77 // 78 //
78 // The Profiler samples pc and sp values for the main thread. 79 // The Profiler samples pc and sp values for the main thread.
79 // Each sample is appended to a circular buffer. 80 // Each sample is appended to a circular buffer.
80 // An independent thread removes data and writes it to the log. 81 // An independent thread removes data and writes it to the log.
81 // This design minimizes the time spent in the sampler. 82 // This design minimizes the time spent in the sampler.
82 // 83 //
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 232
232 private: 233 private:
233 SlidingStateWindow* window_; 234 SlidingStateWindow* window_;
234 Profiler* profiler_; 235 Profiler* profiler_;
235 }; 236 };
236 237
237 238
238 // 239 //
239 // SlidingStateWindow implementation. 240 // SlidingStateWindow implementation.
240 // 241 //
241 SlidingStateWindow::SlidingStateWindow(): current_index_(0), is_full_(false) { 242 SlidingStateWindow::SlidingStateWindow(Isolate* isolate)
243 : counters_(isolate->counters()), current_index_(0), is_full_(false) {
242 for (int i = 0; i < kBufferSize; i++) { 244 for (int i = 0; i < kBufferSize; i++) {
243 buffer_[i] = static_cast<byte>(OTHER); 245 buffer_[i] = static_cast<byte>(OTHER);
244 } 246 }
245 LOGGER->ticker_->SetWindow(this); 247 isolate->logger()->ticker_->SetWindow(this);
246 } 248 }
247 249
248 250
249 SlidingStateWindow::~SlidingStateWindow() { 251 SlidingStateWindow::~SlidingStateWindow() {
250 LOGGER->ticker_->ClearWindow(); 252 LOGGER->ticker_->ClearWindow();
251 } 253 }
252 254
253 255
254 void SlidingStateWindow::AddState(StateTag state) { 256 void SlidingStateWindow::AddState(StateTag state) {
255 if (is_full_) { 257 if (is_full_) {
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 // TODO(isolates): this assert introduces cyclic dependency (logger 1510 // TODO(isolates): this assert introduces cyclic dependency (logger
1509 // -> thread local top -> heap -> logger). 1511 // -> thread local top -> heap -> logger).
1510 // ASSERT(VMState::is_outermost_external()); 1512 // ASSERT(VMState::is_outermost_external());
1511 1513
1512 log_->Initialize(); 1514 log_->Initialize();
1513 1515
1514 if (FLAG_ll_prof) LogCodeInfo(); 1516 if (FLAG_ll_prof) LogCodeInfo();
1515 1517
1516 ticker_ = new Ticker(Isolate::Current(), kSamplingIntervalMs); 1518 ticker_ = new Ticker(Isolate::Current(), kSamplingIntervalMs);
1517 1519
1520 Isolate* isolate = Isolate::Current();
1518 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { 1521 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) {
1519 sliding_state_window_ = new SlidingStateWindow(); 1522 sliding_state_window_ = new SlidingStateWindow(isolate);
1520 } 1523 }
1521 1524
1522 bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api 1525 bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api
1523 || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect 1526 || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect
1524 || FLAG_log_regexp || FLAG_log_state_changes; 1527 || FLAG_log_regexp || FLAG_log_state_changes;
1525 1528
1526 if (start_logging) { 1529 if (start_logging) {
1527 logging_nesting_ = 1; 1530 logging_nesting_ = 1;
1528 } 1531 }
1529 1532
1530 if (FLAG_prof) { 1533 if (FLAG_prof) {
1531 profiler_ = new Profiler(Isolate::Current()); 1534 profiler_ = new Profiler(isolate);
1532 if (!FLAG_prof_auto) { 1535 if (!FLAG_prof_auto) {
1533 profiler_->pause(); 1536 profiler_->pause();
1534 } else { 1537 } else {
1535 logging_nesting_ = 1; 1538 logging_nesting_ = 1;
1536 } 1539 }
1537 if (!FLAG_prof_lazy) { 1540 if (!FLAG_prof_lazy) {
1538 profiler_->Engage(); 1541 profiler_->Engage();
1539 } 1542 }
1540 } 1543 }
1541 1544
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 // that case, we set the sliding_state_window flag so that the 1599 // that case, we set the sliding_state_window flag so that the
1597 // sliding window computation will be started when Logger::Setup is 1600 // sliding window computation will be started when Logger::Setup is
1598 // called. 1601 // called.
1599 if (ticker_ == NULL) { 1602 if (ticker_ == NULL) {
1600 FLAG_sliding_state_window = true; 1603 FLAG_sliding_state_window = true;
1601 return; 1604 return;
1602 } 1605 }
1603 // Otherwise, if the sliding state window computation has not been 1606 // Otherwise, if the sliding state window computation has not been
1604 // started we do it now. 1607 // started we do it now.
1605 if (sliding_state_window_ == NULL) { 1608 if (sliding_state_window_ == NULL) {
1606 sliding_state_window_ = new SlidingStateWindow(); 1609 sliding_state_window_ = new SlidingStateWindow(Isolate::Current());
1607 } 1610 }
1608 #endif 1611 #endif
1609 } 1612 }
1610 1613
1611 1614
1612 Mutex* SamplerRegistry::mutex_ = OS::CreateMutex(); 1615 Mutex* SamplerRegistry::mutex_ = OS::CreateMutex();
1613 List<Sampler*>* SamplerRegistry::active_samplers_ = NULL; 1616 List<Sampler*>* SamplerRegistry::active_samplers_ = NULL;
1614 1617
1615 1618
1616 bool SamplerRegistry::IterateActiveSamplers(VisitSampler func, void* param) { 1619 bool SamplerRegistry::IterateActiveSamplers(VisitSampler func, void* param) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { 1657 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) {
1655 ASSERT(sampler->IsActive()); 1658 ASSERT(sampler->IsActive());
1656 ScopedLock lock(mutex_); 1659 ScopedLock lock(mutex_);
1657 ASSERT(active_samplers_ != NULL); 1660 ASSERT(active_samplers_ != NULL);
1658 bool removed = active_samplers_->RemoveElement(sampler); 1661 bool removed = active_samplers_->RemoveElement(sampler);
1659 ASSERT(removed); 1662 ASSERT(removed);
1660 USE(removed); 1663 USE(removed);
1661 } 1664 }
1662 1665
1663 } } // namespace v8::internal 1666 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jump-target-heavy.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698