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

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

Issue 5890003: Make V8 compilable with profiling support turned off. (Closed) Base URL: https://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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/log.cc ('k') | src/top.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 344
345 void RuntimeProfiler::OptimizeSoon(JSFunction* function) { 345 void RuntimeProfiler::OptimizeSoon(JSFunction* function) {
346 if (!IsOptimizable(function)) return; 346 if (!IsOptimizable(function)) return;
347 PendingListNode* node = new PendingListNode(function); 347 PendingListNode* node = new PendingListNode(function);
348 node->set_next(optimize_soon_list); 348 node->set_next(optimize_soon_list);
349 optimize_soon_list = node; 349 optimize_soon_list = node;
350 } 350 }
351 351
352 352
353 #ifdef ENABLE_LOGGING_AND_PROFILING
353 static void UpdateStateRatio(SamplerState current_state) { 354 static void UpdateStateRatio(SamplerState current_state) {
354 static const int kStateWindowSize = 128; 355 static const int kStateWindowSize = 128;
355 static SamplerState state_window[kStateWindowSize]; 356 static SamplerState state_window[kStateWindowSize];
356 static int state_window_position = 0; 357 static int state_window_position = 0;
357 static int state_counts[2] = { kStateWindowSize, 0 }; 358 static int state_counts[2] = { kStateWindowSize, 0 };
358 359
359 SamplerState old_state = state_window[state_window_position]; 360 SamplerState old_state = state_window[state_window_position];
360 state_counts[old_state]--; 361 state_counts[old_state]--;
361 state_window[state_window_position] = current_state; 362 state_window[state_window_position] = current_state;
362 state_counts[current_state]++; 363 state_counts[current_state]++;
363 ASSERT(IsPowerOf2(kStateWindowSize)); 364 ASSERT(IsPowerOf2(kStateWindowSize));
364 state_window_position = (state_window_position + 1) & 365 state_window_position = (state_window_position + 1) &
365 (kStateWindowSize - 1); 366 (kStateWindowSize - 1);
366 NoBarrier_Store(&js_ratio, state_counts[IN_JS_STATE] * 100 / 367 NoBarrier_Store(&js_ratio, state_counts[IN_JS_STATE] * 100 /
367 kStateWindowSize); 368 kStateWindowSize);
368 } 369 }
370 #endif
369 371
370 372
371 void RuntimeProfiler::NotifyTick() { 373 void RuntimeProfiler::NotifyTick() {
374 #ifdef ENABLE_LOGGING_AND_PROFILING
372 // Record state sample. 375 // Record state sample.
373 SamplerState state = Top::IsInJSState() 376 SamplerState state = Top::IsInJSState()
374 ? IN_JS_STATE 377 ? IN_JS_STATE
375 : IN_NON_JS_STATE; 378 : IN_NON_JS_STATE;
376 UpdateStateRatio(state); 379 UpdateStateRatio(state);
377 StackGuard::RequestRuntimeProfilerTick(); 380 StackGuard::RequestRuntimeProfilerTick();
381 #endif
378 } 382 }
379 383
380 384
381 void RuntimeProfiler::MarkCompactPrologue(bool is_compacting) { 385 void RuntimeProfiler::MarkCompactPrologue(bool is_compacting) {
382 if (is_compacting) { 386 if (is_compacting) {
383 // Clear all samples before mark-sweep-compact because every 387 // Clear all samples before mark-sweep-compact because every
384 // function might move. 388 // function might move.
385 ClearSampleBuffer(); 389 ClearSampleBuffer();
386 } else { 390 } else {
387 // Clear only new space entries on mark-sweep since none of the 391 // Clear only new space entries on mark-sweep since none of the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 return sampler_window; 425 return sampler_window;
422 } 426 }
423 427
424 428
425 int RuntimeProfiler::SamplerWindowSize() { 429 int RuntimeProfiler::SamplerWindowSize() {
426 return kSamplerWindowSize; 430 return kSamplerWindowSize;
427 } 431 }
428 432
429 433
430 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { 434 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
435 #ifdef ENABLE_LOGGING_AND_PROFILING
431 static const int kNonJSTicksThreshold = 100; 436 static const int kNonJSTicksThreshold = 100;
432 // We suspend the runtime profiler thread when not running 437 // We suspend the runtime profiler thread when not running
433 // JavaScript. If the CPU profiler is active we must not do this 438 // JavaScript. If the CPU profiler is active we must not do this
434 // because it samples both JavaScript and C++ code. 439 // because it samples both JavaScript and C++ code.
435 if (RuntimeProfiler::IsEnabled() && 440 if (RuntimeProfiler::IsEnabled() &&
436 !CpuProfiler::is_profiling() && 441 !CpuProfiler::is_profiling() &&
437 !(FLAG_prof && FLAG_prof_auto)) { 442 !(FLAG_prof && FLAG_prof_auto)) {
438 if (Top::IsInJSState()) { 443 if (Top::IsInJSState()) {
439 non_js_ticks_ = 0; 444 non_js_ticks_ = 0;
440 } else { 445 } else {
441 if (non_js_ticks_ < kNonJSTicksThreshold) { 446 if (non_js_ticks_ < kNonJSTicksThreshold) {
442 ++non_js_ticks_; 447 ++non_js_ticks_;
443 } else { 448 } else {
444 if (Top::WaitForJSState()) return true; 449 if (Top::WaitForJSState()) return true;
445 } 450 }
446 } 451 }
447 } 452 }
453 #endif
448 return false; 454 return false;
449 } 455 }
450 456
451 457
452 } } // namespace v8::internal 458 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/top.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698