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

Side by Side Diff: src/runtime-profiler.cc

Issue 9374015: Split experimental profiler flags (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updated comment Created 8 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime-profiler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // (eagerly or lazily). 197 // (eagerly or lazily).
198 JSFunction* samples[kSamplerFrameCount]; 198 JSFunction* samples[kSamplerFrameCount];
199 int sample_count = 0; 199 int sample_count = 0;
200 int frame_count = 0; 200 int frame_count = 0;
201 for (JavaScriptFrameIterator it(isolate_); 201 for (JavaScriptFrameIterator it(isolate_);
202 frame_count++ < kSamplerFrameCount && !it.done(); 202 frame_count++ < kSamplerFrameCount && !it.done();
203 it.Advance()) { 203 it.Advance()) {
204 JavaScriptFrame* frame = it.frame(); 204 JavaScriptFrame* frame = it.frame();
205 JSFunction* function = JSFunction::cast(frame->function()); 205 JSFunction* function = JSFunction::cast(frame->function());
206 206
207 if (!FLAG_counting_profiler) { 207 if (!FLAG_watch_ic_patching) {
208 // Adjust threshold each time we have processed 208 // Adjust threshold each time we have processed
209 // a certain number of ticks. 209 // a certain number of ticks.
210 if (sampler_ticks_until_threshold_adjustment_ > 0) { 210 if (sampler_ticks_until_threshold_adjustment_ > 0) {
211 sampler_ticks_until_threshold_adjustment_--; 211 sampler_ticks_until_threshold_adjustment_--;
212 if (sampler_ticks_until_threshold_adjustment_ <= 0) { 212 if (sampler_ticks_until_threshold_adjustment_ <= 0) {
213 // If the threshold is not already at the minimum 213 // If the threshold is not already at the minimum
214 // modify and reset the ticks until next adjustment. 214 // modify and reset the ticks until next adjustment.
215 if (sampler_threshold_ > kSamplerThresholdMin) { 215 if (sampler_threshold_ > kSamplerThresholdMin) {
216 sampler_threshold_ -= kSamplerThresholdDelta; 216 sampler_threshold_ -= kSamplerThresholdDelta;
217 sampler_ticks_until_threshold_adjustment_ = 217 sampler_ticks_until_threshold_adjustment_ =
218 kSamplerTicksBetweenThresholdAdjustment; 218 kSamplerTicksBetweenThresholdAdjustment;
219 } 219 }
220 } 220 }
221 } 221 }
222 } 222 }
223 223
224 if (function->IsMarkedForLazyRecompilation()) { 224 if (function->IsMarkedForLazyRecompilation()) {
225 Code* unoptimized = function->shared()->code(); 225 Code* unoptimized = function->shared()->code();
226 int nesting = unoptimized->allow_osr_at_loop_nesting_level(); 226 int nesting = unoptimized->allow_osr_at_loop_nesting_level();
227 if (nesting == 0) AttemptOnStackReplacement(function); 227 if (nesting == 0) AttemptOnStackReplacement(function);
228 int new_nesting = Min(nesting + 1, Code::kMaxLoopNestingMarker); 228 int new_nesting = Min(nesting + 1, Code::kMaxLoopNestingMarker);
229 unoptimized->set_allow_osr_at_loop_nesting_level(new_nesting); 229 unoptimized->set_allow_osr_at_loop_nesting_level(new_nesting);
230 } 230 }
231 231
232 // Do not record non-optimizable functions. 232 // Do not record non-optimizable functions.
233 if (!function->IsOptimizable()) continue; 233 if (!function->IsOptimizable()) continue;
234 234
235 if (FLAG_counting_profiler) { 235 if (FLAG_watch_ic_patching) {
236 int ticks = function->shared()->profiler_ticks(); 236 int ticks = function->shared()->profiler_ticks();
237 237
238 if (ticks >= kProfilerTicksBeforeOptimization) { 238 if (ticks >= kProfilerTicksBeforeOptimization) {
239 // If this particular function hasn't had any ICs patched for enough 239 // If this particular function hasn't had any ICs patched for enough
240 // ticks, optimize it now. 240 // ticks, optimize it now.
241 Optimize(function, "hot and stable"); 241 Optimize(function, "hot and stable");
242 } else if (!any_ic_changed_ && 242 } else if (!any_ic_changed_ &&
243 function->shared()->code()->instruction_size() < kMaxSizeEarlyOpt) { 243 function->shared()->code()->instruction_size() < kMaxSizeEarlyOpt) {
244 // If no IC was patched since the last tick and this function is very 244 // If no IC was patched since the last tick and this function is very
245 // small, optimistically optimize it now. 245 // small, optimistically optimize it now.
(...skipping 17 matching lines...) Expand all
263 ? sampler_threshold_size_factor_ 263 ? sampler_threshold_size_factor_
264 : 1; 264 : 1;
265 265
266 int threshold = sampler_threshold_ * threshold_size_factor; 266 int threshold = sampler_threshold_ * threshold_size_factor;
267 267
268 if (LookupSample(function) >= threshold) { 268 if (LookupSample(function) >= threshold) {
269 Optimize(function, "sampler window lookup"); 269 Optimize(function, "sampler window lookup");
270 } 270 }
271 } 271 }
272 } 272 }
273 if (FLAG_counting_profiler) { 273 if (FLAG_watch_ic_patching) {
274 any_ic_changed_ = false; 274 any_ic_changed_ = false;
275 code_generated_ = false; 275 code_generated_ = false;
276 } else { // !FLAG_counting_profiler 276 } else { // !FLAG_counting_profiler
277 // Add the collected functions as samples. It's important not to do 277 // Add the collected functions as samples. It's important not to do
278 // this as part of collecting them because this will interfere with 278 // this as part of collecting them because this will interfere with
279 // the sample lookup in case of recursive functions. 279 // the sample lookup in case of recursive functions.
280 for (int i = 0; i < sample_count; i++) { 280 for (int i = 0; i < sample_count; i++) {
281 AddSample(samples[i], kSamplerFrameWeight[i]); 281 AddSample(samples[i], kSamplerFrameWeight[i]);
282 } 282 }
283 } 283 }
284 } 284 }
285 285
286 286
287 void RuntimeProfiler::NotifyTick() { 287 void RuntimeProfiler::NotifyTick() {
288 isolate_->stack_guard()->RequestRuntimeProfilerTick(); 288 isolate_->stack_guard()->RequestRuntimeProfilerTick();
289 } 289 }
290 290
291 291
292 void RuntimeProfiler::SetUp() { 292 void RuntimeProfiler::SetUp() {
293 ASSERT(has_been_globally_set_up_); 293 ASSERT(has_been_globally_set_up_);
294 if (!FLAG_counting_profiler) { 294 if (!FLAG_watch_ic_patching) {
295 ClearSampleBuffer(); 295 ClearSampleBuffer();
296 } 296 }
297 // If the ticker hasn't already started, make sure to do so to get 297 // If the ticker hasn't already started, make sure to do so to get
298 // the ticks for the runtime profiler. 298 // the ticks for the runtime profiler.
299 if (IsEnabled()) isolate_->logger()->EnsureTickerStarted(); 299 if (IsEnabled()) isolate_->logger()->EnsureTickerStarted();
300 } 300 }
301 301
302 302
303 void RuntimeProfiler::Reset() { 303 void RuntimeProfiler::Reset() {
304 if (FLAG_counting_profiler) { 304 if (FLAG_watch_ic_patching) {
305 total_code_generated_ = 0; 305 total_code_generated_ = 0;
306 } else { // !FLAG_counting_profiler 306 } else { // !FLAG_counting_profiler
307 sampler_threshold_ = kSamplerThresholdInit; 307 sampler_threshold_ = kSamplerThresholdInit;
308 sampler_threshold_size_factor_ = kSamplerThresholdSizeFactorInit; 308 sampler_threshold_size_factor_ = kSamplerThresholdSizeFactorInit;
309 sampler_ticks_until_threshold_adjustment_ = 309 sampler_ticks_until_threshold_adjustment_ =
310 kSamplerTicksBetweenThresholdAdjustment; 310 kSamplerTicksBetweenThresholdAdjustment;
311 } 311 }
312 } 312 }
313 313
314 314
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 405
406 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { 406 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
407 if (!RuntimeProfiler::IsSomeIsolateInJS()) { 407 if (!RuntimeProfiler::IsSomeIsolateInJS()) {
408 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); 408 return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
409 } 409 }
410 return false; 410 return false;
411 } 411 }
412 412
413 413
414 } } // namespace v8::internal 414 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime-profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698