| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 26 matching lines...) Expand all Loading... |
| 37 class Isolate; | 37 class Isolate; |
| 38 class JSFunction; | 38 class JSFunction; |
| 39 class Object; | 39 class Object; |
| 40 class PendingListNode; | 40 class PendingListNode; |
| 41 class Semaphore; | 41 class Semaphore; |
| 42 | 42 |
| 43 class RuntimeProfiler { | 43 class RuntimeProfiler { |
| 44 public: | 44 public: |
| 45 explicit RuntimeProfiler(Isolate* isolate); | 45 explicit RuntimeProfiler(Isolate* isolate); |
| 46 | 46 |
| 47 static bool IsEnabled(); | 47 static void GlobalSetup(); |
| 48 |
| 49 static inline bool IsEnabled() { |
| 50 ASSERT(has_been_globally_setup_); |
| 51 return enabled_; |
| 52 } |
| 48 | 53 |
| 49 void OptimizeNow(); | 54 void OptimizeNow(); |
| 50 void OptimizeSoon(JSFunction* function); | 55 void OptimizeSoon(JSFunction* function); |
| 51 | 56 |
| 52 void NotifyTick(); | 57 void NotifyTick(); |
| 53 | 58 |
| 54 void Setup(); | 59 void Setup(); |
| 55 void Reset(); | 60 void Reset(); |
| 56 void TearDown(); | 61 void TearDown(); |
| 57 | 62 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 SamplerState state_window_[kStateWindowSize]; | 141 SamplerState state_window_[kStateWindowSize]; |
| 137 int state_window_position_; | 142 int state_window_position_; |
| 138 int state_window_ticks_; | 143 int state_window_ticks_; |
| 139 int state_counts_[2]; | 144 int state_counts_[2]; |
| 140 | 145 |
| 141 // Possible state values: | 146 // Possible state values: |
| 142 // -1 => the profiler thread is waiting on the semaphore | 147 // -1 => the profiler thread is waiting on the semaphore |
| 143 // 0 or positive => the number of isolates running JavaScript code. | 148 // 0 or positive => the number of isolates running JavaScript code. |
| 144 static Atomic32 state_; | 149 static Atomic32 state_; |
| 145 static Semaphore* semaphore_; | 150 static Semaphore* semaphore_; |
| 151 |
| 152 #ifdef DEBUG |
| 153 static bool has_been_globally_setup_; |
| 154 #endif |
| 155 static bool enabled_; |
| 146 }; | 156 }; |
| 147 | 157 |
| 148 | 158 |
| 149 // Rate limiter intended to be used in the profiler thread. | 159 // Rate limiter intended to be used in the profiler thread. |
| 150 class RuntimeProfilerRateLimiter BASE_EMBEDDED { | 160 class RuntimeProfilerRateLimiter BASE_EMBEDDED { |
| 151 public: | 161 public: |
| 152 RuntimeProfilerRateLimiter() : non_js_ticks_(0) { } | 162 RuntimeProfilerRateLimiter() : non_js_ticks_(0) { } |
| 153 | 163 |
| 154 // Suspends the current thread (which must be the profiler thread) | 164 // Suspends the current thread (which must be the profiler thread) |
| 155 // when not executing JavaScript to minimize CPU usage. Returns | 165 // when not executing JavaScript to minimize CPU usage. Returns |
| (...skipping 26 matching lines...) Expand all Loading... |
| 182 | 192 |
| 183 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) { | 193 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) { |
| 184 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1); | 194 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1); |
| 185 ASSERT(new_state >= 0); | 195 ASSERT(new_state >= 0); |
| 186 USE(new_state); | 196 USE(new_state); |
| 187 } | 197 } |
| 188 | 198 |
| 189 } } // namespace v8::internal | 199 } } // namespace v8::internal |
| 190 | 200 |
| 191 #endif // V8_RUNTIME_PROFILER_H_ | 201 #endif // V8_RUNTIME_PROFILER_H_ |
| OLD | NEW |