OLD | NEW |
---|---|
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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 ASSERT(IsPowerOf2(kStateWindowSize)); | 417 ASSERT(IsPowerOf2(kStateWindowSize)); |
418 state_window_position = (state_window_position + 1) & | 418 state_window_position = (state_window_position + 1) & |
419 (kStateWindowSize - 1); | 419 (kStateWindowSize - 1); |
420 NoBarrier_Store(&js_ratio, state_counts[IN_JS_STATE] * 100 / | 420 NoBarrier_Store(&js_ratio, state_counts[IN_JS_STATE] * 100 / |
421 kStateWindowSize); | 421 kStateWindowSize); |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { | 425 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { |
426 static const int kNonJSTicksThreshold = 100; | 426 static const int kNonJSTicksThreshold = 100; |
427 bool top_is_in_js_state = Top::IsInJSState(); | |
428 // Record state sample. | |
429 if (top_is_in_js_state) { | |
Florian Schneider
2010/12/10 14:02:55
Do you need to check for RuntimeProfiler::IsEnable
Karl Klose
2010/12/10 14:08:48
Done.
| |
430 AddStateSample(IN_JS_STATE); | |
431 } else { | |
432 AddStateSample(IN_NON_JS_STATE); | |
433 } | |
427 // We suspend the runtime profiler thread when not running | 434 // We suspend the runtime profiler thread when not running |
428 // JavaScript. If the CPU profiler is active we must not do this | 435 // JavaScript. If the CPU profiler is active we must not do this |
429 // because it samples both JavaScript and C++ code. | 436 // because it samples both JavaScript and C++ code. |
430 if (RuntimeProfiler::IsEnabled() && | 437 if (RuntimeProfiler::IsEnabled() && |
431 !CpuProfiler::is_profiling() && | 438 !CpuProfiler::is_profiling() && |
432 !(FLAG_prof && FLAG_prof_auto)) { | 439 !(FLAG_prof && FLAG_prof_auto)) { |
433 if (Top::IsInJSState()) { | 440 if (top_is_in_js_state) { |
434 AddStateSample(IN_JS_STATE); | |
435 non_js_ticks_ = 0; | 441 non_js_ticks_ = 0; |
436 } else { | 442 } else { |
437 AddStateSample(IN_NON_JS_STATE); | |
438 if (non_js_ticks_ < kNonJSTicksThreshold) { | 443 if (non_js_ticks_ < kNonJSTicksThreshold) { |
439 ++non_js_ticks_; | 444 ++non_js_ticks_; |
440 } else { | 445 } else { |
441 if (Top::WaitForJSState()) return true; | 446 if (Top::WaitForJSState()) return true; |
442 } | 447 } |
443 } | 448 } |
444 } | 449 } |
445 return false; | 450 return false; |
446 } | 451 } |
447 | 452 |
448 | 453 |
449 } } // namespace v8::internal | 454 } } // namespace v8::internal |
OLD | NEW |