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

Unified Diff: src/runtime-profiler.cc

Issue 5720003: Fix bug that disabled optimization when profiling. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime-profiler.cc
===================================================================
--- src/runtime-profiler.cc (revision 5961)
+++ src/runtime-profiler.cc (working copy)
@@ -350,7 +350,30 @@
}
+static void UpdateStateRatio(SamplerState current_state) {
+ static const int kStateWindowSize = 128;
+ static SamplerState state_window[kStateWindowSize];
+ static int state_window_position = 0;
+ static int state_counts[2] = { kStateWindowSize, 0 };
+
+ SamplerState old_state = state_window[state_window_position];
+ state_counts[old_state]--;
+ state_window[state_window_position] = current_state;
+ state_counts[current_state]++;
+ ASSERT(IsPowerOf2(kStateWindowSize));
+ state_window_position = (state_window_position + 1) &
+ (kStateWindowSize - 1);
+ NoBarrier_Store(&js_ratio, state_counts[IN_JS_STATE] * 100 /
+ kStateWindowSize);
+}
+
+
void RuntimeProfiler::NotifyTick() {
+ // Record state sample.
+ SamplerState state = Top::IsInJSState()
+ ? IN_JS_STATE
+ : IN_NON_JS_STATE;
+ UpdateStateRatio(state);
StackGuard::RequestRuntimeProfilerTick();
}
@@ -404,24 +427,6 @@
}
-static void AddStateSample(SamplerState current_state) {
- static const int kStateWindowSize = 128;
- static SamplerState state_window[kStateWindowSize];
- static int state_window_position = 0;
- static int state_counts[2] = { kStateWindowSize, 0 };
-
- SamplerState old_state = state_window[state_window_position];
- state_counts[old_state]--;
- state_window[state_window_position] = current_state;
- state_counts[current_state]++;
- ASSERT(IsPowerOf2(kStateWindowSize));
- state_window_position = (state_window_position + 1) &
- (kStateWindowSize - 1);
- NoBarrier_Store(&js_ratio, state_counts[IN_JS_STATE] * 100 /
- kStateWindowSize);
-}
-
-
bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
static const int kNonJSTicksThreshold = 100;
// We suspend the runtime profiler thread when not running
@@ -431,10 +436,8 @@
!CpuProfiler::is_profiling() &&
!(FLAG_prof && FLAG_prof_auto)) {
if (Top::IsInJSState()) {
- AddStateSample(IN_JS_STATE);
non_js_ticks_ = 0;
} else {
- AddStateSample(IN_NON_JS_STATE);
if (non_js_ticks_ < kNonJSTicksThreshold) {
++non_js_ticks_;
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698