Reviewers: Kasper Lund,
Description:
Fix JS ratio computation on startup.
Please review this at http://codereview.chromium.org/6826026/
Affected files:
M src/runtime-profiler.h
M src/runtime-profiler.cc
Index: src/runtime-profiler.cc
diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc
index
28755e3ebef77cd11c2beb460adede8460fd5b4d..028af49f12dffdee37ad34613668e2bb28c63ec3
100644
--- a/src/runtime-profiler.cc
+++ b/src/runtime-profiler.cc
@@ -130,9 +130,11 @@ RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
js_ratio_(0),
sampler_window_position_(0),
optimize_soon_list_(NULL),
- state_window_position_(0) {
- state_counts_[0] = kStateWindowSize;
- state_counts_[1] = 0;
+ state_window_position_(0),
+ state_window_ticks_(0) {
+ state_counts_[IN_NON_JS_STATE] = kStateWindowSize;
+ state_counts_[IN_JS_STATE] = 0;
+ STATIC_ASSERT(IN_NON_JS_STATE == 0);
memset(state_window_, 0, sizeof(state_window_));
ClearSampleBuffer();
}
@@ -344,8 +346,9 @@ void RuntimeProfiler::UpdateStateRatio(SamplerState
current_state) {
ASSERT(IsPowerOf2(kStateWindowSize));
state_window_position_ = (state_window_position_ + 1) &
(kStateWindowSize - 1);
+ state_window_ticks_ = Min(kStateWindowSize, state_window_ticks_ + 1);
NoBarrier_Store(&js_ratio_, state_counts_[IN_JS_STATE] * 100 /
- kStateWindowSize);
+ state_window_ticks_);
}
#endif
Index: src/runtime-profiler.h
diff --git a/src/runtime-profiler.h b/src/runtime-profiler.h
index
8074035a92da02d37c4c8217db7f9275c508d98a..3656893ae783c556bf1215bba30c4ffc1c057f7d
100644
--- a/src/runtime-profiler.h
+++ b/src/runtime-profiler.h
@@ -40,13 +40,6 @@ class Object;
class PendingListNode;
class Semaphore;
-
-enum SamplerState {
- IN_NON_JS_STATE = 0,
- IN_JS_STATE = 1
-};
-
-
class RuntimeProfiler {
public:
explicit RuntimeProfiler(Isolate* isolate);
@@ -101,6 +94,11 @@ class RuntimeProfiler {
static const int kSamplerWindowSize = 16;
static const int kStateWindowSize = 128;
+ enum SamplerState {
+ IN_NON_JS_STATE = 0,
+ IN_JS_STATE = 1
+ };
+
static void HandleWakeUp(Isolate* isolate);
void Optimize(JSFunction* function, bool eager, int delay);
@@ -137,6 +135,7 @@ class RuntimeProfiler {
SamplerState state_window_[kStateWindowSize];
int state_window_position_;
+ int state_window_ticks_;
int state_counts_[2];
// Possible state values:
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev