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

Side by Side Diff: src/log.cc

Issue 9666052: Landing for pliard@chromium.org: Remove static initializers in v8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 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/log.h ('k') | src/once.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 17 matching lines...) Expand all
28 #include <stdarg.h> 28 #include <stdarg.h>
29 29
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "bootstrapper.h" 32 #include "bootstrapper.h"
33 #include "code-stubs.h" 33 #include "code-stubs.h"
34 #include "deoptimizer.h" 34 #include "deoptimizer.h"
35 #include "global-handles.h" 35 #include "global-handles.h"
36 #include "log.h" 36 #include "log.h"
37 #include "macro-assembler.h" 37 #include "macro-assembler.h"
38 #include "platform.h"
38 #include "runtime-profiler.h" 39 #include "runtime-profiler.h"
39 #include "serialize.h" 40 #include "serialize.h"
40 #include "string-stream.h" 41 #include "string-stream.h"
41 #include "vm-state-inl.h" 42 #include "vm-state-inl.h"
42 43
43 namespace v8 { 44 namespace v8 {
44 namespace internal { 45 namespace internal {
45 46
46 // 47 //
47 // Sliding state window. Updates counters to keep track of the last 48 // Sliding state window. Updates counters to keep track of the last
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 FLAG_sliding_state_window = true; 1720 FLAG_sliding_state_window = true;
1720 return; 1721 return;
1721 } 1722 }
1722 // Otherwise, if the sliding state window computation has not been 1723 // Otherwise, if the sliding state window computation has not been
1723 // started we do it now. 1724 // started we do it now.
1724 if (sliding_state_window_ == NULL) { 1725 if (sliding_state_window_ == NULL) {
1725 sliding_state_window_ = new SlidingStateWindow(Isolate::Current()); 1726 sliding_state_window_ = new SlidingStateWindow(Isolate::Current());
1726 } 1727 }
1727 } 1728 }
1728 1729
1730 // Protects the state below.
1731 static LazyMutex active_samplers_mutex = LAZY_MUTEX_INITIALIZER;
1729 1732
1730 Mutex* SamplerRegistry::mutex_ = OS::CreateMutex();
1731 List<Sampler*>* SamplerRegistry::active_samplers_ = NULL; 1733 List<Sampler*>* SamplerRegistry::active_samplers_ = NULL;
1732 1734
1733 1735
1734 bool SamplerRegistry::IterateActiveSamplers(VisitSampler func, void* param) { 1736 bool SamplerRegistry::IterateActiveSamplers(VisitSampler func, void* param) {
1735 ScopedLock lock(mutex_); 1737 ScopedLock lock(active_samplers_mutex.Pointer());
1736 for (int i = 0; 1738 for (int i = 0;
1737 ActiveSamplersExist() && i < active_samplers_->length(); 1739 ActiveSamplersExist() && i < active_samplers_->length();
1738 ++i) { 1740 ++i) {
1739 func(active_samplers_->at(i), param); 1741 func(active_samplers_->at(i), param);
1740 } 1742 }
1741 return ActiveSamplersExist(); 1743 return ActiveSamplersExist();
1742 } 1744 }
1743 1745
1744 1746
1745 static void ComputeCpuProfiling(Sampler* sampler, void* flag_ptr) { 1747 static void ComputeCpuProfiling(Sampler* sampler, void* flag_ptr) {
1746 bool* flag = reinterpret_cast<bool*>(flag_ptr); 1748 bool* flag = reinterpret_cast<bool*>(flag_ptr);
1747 *flag |= sampler->IsProfiling(); 1749 *flag |= sampler->IsProfiling();
1748 } 1750 }
1749 1751
1750 1752
1751 SamplerRegistry::State SamplerRegistry::GetState() { 1753 SamplerRegistry::State SamplerRegistry::GetState() {
1752 bool flag = false; 1754 bool flag = false;
1753 if (!IterateActiveSamplers(&ComputeCpuProfiling, &flag)) { 1755 if (!IterateActiveSamplers(&ComputeCpuProfiling, &flag)) {
1754 return HAS_NO_SAMPLERS; 1756 return HAS_NO_SAMPLERS;
1755 } 1757 }
1756 return flag ? HAS_CPU_PROFILING_SAMPLERS : HAS_SAMPLERS; 1758 return flag ? HAS_CPU_PROFILING_SAMPLERS : HAS_SAMPLERS;
1757 } 1759 }
1758 1760
1759 1761
1760 void SamplerRegistry::AddActiveSampler(Sampler* sampler) { 1762 void SamplerRegistry::AddActiveSampler(Sampler* sampler) {
1761 ASSERT(sampler->IsActive()); 1763 ASSERT(sampler->IsActive());
1762 ScopedLock lock(mutex_); 1764 ScopedLock lock(active_samplers_mutex.Pointer());
1763 if (active_samplers_ == NULL) { 1765 if (active_samplers_ == NULL) {
1764 active_samplers_ = new List<Sampler*>; 1766 active_samplers_ = new List<Sampler*>;
1765 } else { 1767 } else {
1766 ASSERT(!active_samplers_->Contains(sampler)); 1768 ASSERT(!active_samplers_->Contains(sampler));
1767 } 1769 }
1768 active_samplers_->Add(sampler); 1770 active_samplers_->Add(sampler);
1769 } 1771 }
1770 1772
1771 1773
1772 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { 1774 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) {
1773 ASSERT(sampler->IsActive()); 1775 ASSERT(sampler->IsActive());
1774 ScopedLock lock(mutex_); 1776 ScopedLock lock(active_samplers_mutex.Pointer());
1775 ASSERT(active_samplers_ != NULL); 1777 ASSERT(active_samplers_ != NULL);
1776 bool removed = active_samplers_->RemoveElement(sampler); 1778 bool removed = active_samplers_->RemoveElement(sampler);
1777 ASSERT(removed); 1779 ASSERT(removed);
1778 USE(removed); 1780 USE(removed);
1779 } 1781 }
1780 1782
1781 } } // namespace v8::internal 1783 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/once.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698