diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-12-16 11:52:08 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-12-16 11:52:08 -0800 |
commit | ea700a8851023a1967083f22daa40f4c7a4366bf (patch) | |
tree | adea168439fab99865adaf8589b34fe914bc1994 /deps/v8/src/runtime-profiler.cc | |
parent | 632da2a393a633f8da432096b14bec5915480115 (diff) | |
download | node-ea700a8851023a1967083f22daa40f4c7a4366bf.tar.gz |
Upgrade V8 to 3.0.2
Diffstat (limited to 'deps/v8/src/runtime-profiler.cc')
-rw-r--r-- | deps/v8/src/runtime-profiler.cc | 101 |
1 files changed, 17 insertions, 84 deletions
diff --git a/deps/v8/src/runtime-profiler.cc b/deps/v8/src/runtime-profiler.cc index 3c0490f8d..051dc5119 100644 --- a/deps/v8/src/runtime-profiler.cc +++ b/deps/v8/src/runtime-profiler.cc @@ -68,18 +68,12 @@ class PendingListNode : public Malloced { }; -enum SamplerState { - IN_NON_JS_STATE = 0, - IN_JS_STATE = 1 -}; - - // Optimization sampler constants. static const int kSamplerFrameCount = 2; static const int kSamplerFrameWeight[kSamplerFrameCount] = { 2, 1 }; static const int kSamplerWindowSize = 16; -static const int kSamplerTicksBetweenThresholdAdjustment = 32; +static const int kSamplerTicksDelta = 32; static const int kSamplerThresholdInit = 3; static const int kSamplerThresholdMin = 1; @@ -94,11 +88,6 @@ static const int kSizeLimit = 1500; static int sampler_threshold = kSamplerThresholdInit; static int sampler_threshold_size_factor = kSamplerThresholdSizeFactorInit; -static int sampler_ticks_until_threshold_adjustment = - kSamplerTicksBetweenThresholdAdjustment; - -// The ratio of ticks spent in JS code in percent. -static Atomic32 js_ratio; // The JSFunctions in the sampler window are not GC safe. Old-space // pointers are not cleared during mark-sweep collection and therefore @@ -272,71 +261,40 @@ void RuntimeProfiler::OptimizeNow() { // have a sample of the function, we mark it for optimizations // (eagerly or lazily). JSFunction* samples[kSamplerFrameCount]; - int sample_count = 0; - int frame_count = 0; + int count = 0; for (JavaScriptFrameIterator it; - frame_count++ < kSamplerFrameCount && !it.done(); + count < kSamplerFrameCount && !it.done(); it.Advance()) { JavaScriptFrame* frame = it.frame(); JSFunction* function = JSFunction::cast(frame->function()); - - // Adjust threshold each time we have processed - // a certain number of ticks. - if (sampler_ticks_until_threshold_adjustment > 0) { - sampler_ticks_until_threshold_adjustment--; - if (sampler_ticks_until_threshold_adjustment <= 0) { - // If the threshold is not already at the minimum - // modify and reset the ticks until next adjustment. - if (sampler_threshold > kSamplerThresholdMin) { - sampler_threshold -= kSamplerThresholdDelta; - sampler_ticks_until_threshold_adjustment = - kSamplerTicksBetweenThresholdAdjustment; - } - } + int function_size = function->shared()->SourceSize(); + int threshold_size_factor; + if (function_size > kSizeLimit) { + threshold_size_factor = sampler_threshold_size_factor; + } else { + threshold_size_factor = 1; } + int threshold = sampler_threshold * threshold_size_factor; + samples[count++] = function; if (function->IsMarkedForLazyRecompilation()) { Code* unoptimized = function->shared()->code(); int nesting = unoptimized->allow_osr_at_loop_nesting_level(); if (nesting == 0) AttemptOnStackReplacement(function); int new_nesting = Min(nesting + 1, Code::kMaxLoopNestingMarker); unoptimized->set_allow_osr_at_loop_nesting_level(new_nesting); - } - - // Do not record non-optimizable functions. - if (!IsOptimizable(function)) continue; - samples[sample_count++] = function; - - int function_size = function->shared()->SourceSize(); - int threshold_size_factor = (function_size > kSizeLimit) - ? sampler_threshold_size_factor - : 1; - - int threshold = sampler_threshold * threshold_size_factor; - int current_js_ratio = NoBarrier_Load(&js_ratio); - - // Adjust threshold depending on the ratio of time spent - // in JS code. - if (current_js_ratio < 20) { - // If we spend less than 20% of the time in JS code, - // do not optimize. - continue; - } else if (current_js_ratio < 75) { - // Below 75% of time spent in JS code, only optimize very - // frequently used functions. - threshold *= 3; - } - - if (LookupSample(function) >= threshold) { - Optimize(function, false, 0); - CompilationCache::MarkForEagerOptimizing(Handle<JSFunction>(function)); + } else if (LookupSample(function) >= threshold) { + if (IsOptimizable(function)) { + Optimize(function, false, 0); + CompilationCache::MarkForEagerOptimizing(Handle<JSFunction>(function)); + } } } // Add the collected functions as samples. It's important not to do // this as part of collecting them because this will interfere with // the sample lookup in case of recursive functions. - for (int i = 0; i < sample_count; i++) { + for (int i = 0; i < count; i++) { AddSample(samples[i], kSamplerFrameWeight[i]); } } @@ -350,30 +308,7 @@ void RuntimeProfiler::OptimizeSoon(JSFunction* function) { } -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(); } @@ -406,8 +341,6 @@ void RuntimeProfiler::Setup() { void RuntimeProfiler::Reset() { sampler_threshold = kSamplerThresholdInit; - sampler_ticks_until_threshold_adjustment = - kSamplerTicksBetweenThresholdAdjustment; sampler_threshold_size_factor = kSamplerThresholdSizeFactorInit; } |