Fix JS ratio computation on startup.
Review URL: http://codereview.chromium.org/6826026 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7562 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
164e3a4173
commit
c53727f591
@ -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,12 @@ void RuntimeProfiler::UpdateStateRatio(SamplerState current_state) {
|
||||
ASSERT(IsPowerOf2(kStateWindowSize));
|
||||
state_window_position_ = (state_window_position_ + 1) &
|
||||
(kStateWindowSize - 1);
|
||||
// Note: to calculate correct ratio we have to track how many valid
|
||||
// ticks are actually in the state window, because on profiler
|
||||
// startup this number can be less than the window size.
|
||||
state_window_ticks_ = Min(kStateWindowSize, state_window_ticks_ + 1);
|
||||
NoBarrier_Store(&js_ratio_, state_counts_[IN_JS_STATE] * 100 /
|
||||
kStateWindowSize);
|
||||
state_window_ticks_);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user