OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 static const int kSizeLimit = 1500; | 59 static const int kSizeLimit = 1500; |
60 | 60 |
61 | 61 |
62 Atomic32 RuntimeProfiler::state_ = 0; | 62 Atomic32 RuntimeProfiler::state_ = 0; |
63 // TODO(isolates): Create the semaphore lazily and clean it up when no | 63 // TODO(isolates): Create the semaphore lazily and clean it up when no |
64 // longer required. | 64 // longer required. |
65 Semaphore* RuntimeProfiler::semaphore_ = OS::CreateSemaphore(0); | 65 Semaphore* RuntimeProfiler::semaphore_ = OS::CreateSemaphore(0); |
66 | 66 |
67 #ifdef DEBUG | 67 #ifdef DEBUG |
68 bool RuntimeProfiler::has_been_globally_setup_ = false; | 68 bool RuntimeProfiler::has_been_globally_set_up_ = false; |
69 #endif | 69 #endif |
70 bool RuntimeProfiler::enabled_ = false; | 70 bool RuntimeProfiler::enabled_ = false; |
71 | 71 |
72 | 72 |
73 RuntimeProfiler::RuntimeProfiler(Isolate* isolate) | 73 RuntimeProfiler::RuntimeProfiler(Isolate* isolate) |
74 : isolate_(isolate), | 74 : isolate_(isolate), |
75 sampler_threshold_(kSamplerThresholdInit), | 75 sampler_threshold_(kSamplerThresholdInit), |
76 sampler_threshold_size_factor_(kSamplerThresholdSizeFactorInit), | 76 sampler_threshold_size_factor_(kSamplerThresholdSizeFactorInit), |
77 sampler_ticks_until_threshold_adjustment_( | 77 sampler_ticks_until_threshold_adjustment_( |
78 kSamplerTicksBetweenThresholdAdjustment), | 78 kSamplerTicksBetweenThresholdAdjustment), |
79 sampler_window_position_(0) { | 79 sampler_window_position_(0) { |
80 ClearSampleBuffer(); | 80 ClearSampleBuffer(); |
81 } | 81 } |
82 | 82 |
83 | 83 |
84 void RuntimeProfiler::GlobalSetup() { | 84 void RuntimeProfiler::GlobalSetup() { |
85 ASSERT(!has_been_globally_setup_); | 85 ASSERT(!has_been_globally_set_up_); |
86 enabled_ = V8::UseCrankshaft() && FLAG_opt; | 86 enabled_ = V8::UseCrankshaft() && FLAG_opt; |
87 #ifdef DEBUG | 87 #ifdef DEBUG |
88 has_been_globally_setup_ = true; | 88 has_been_globally_set_up_ = true; |
89 #endif | 89 #endif |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 void RuntimeProfiler::Optimize(JSFunction* function) { | 93 void RuntimeProfiler::Optimize(JSFunction* function) { |
94 ASSERT(function->IsOptimizable()); | 94 ASSERT(function->IsOptimizable()); |
95 if (FLAG_trace_opt) { | 95 if (FLAG_trace_opt) { |
96 PrintF("[marking "); | 96 PrintF("[marking "); |
97 function->PrintName(); | 97 function->PrintName(); |
98 PrintF(" 0x%" V8PRIxPTR, reinterpret_cast<intptr_t>(function->address())); | 98 PrintF(" 0x%" V8PRIxPTR, reinterpret_cast<intptr_t>(function->address())); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 AddSample(samples[i], kSamplerFrameWeight[i]); | 238 AddSample(samples[i], kSamplerFrameWeight[i]); |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 | 242 |
243 void RuntimeProfiler::NotifyTick() { | 243 void RuntimeProfiler::NotifyTick() { |
244 isolate_->stack_guard()->RequestRuntimeProfilerTick(); | 244 isolate_->stack_guard()->RequestRuntimeProfilerTick(); |
245 } | 245 } |
246 | 246 |
247 | 247 |
248 void RuntimeProfiler::Setup() { | 248 void RuntimeProfiler::SetUp() { |
249 ASSERT(has_been_globally_setup_); | 249 ASSERT(has_been_globally_set_up_); |
250 ClearSampleBuffer(); | 250 ClearSampleBuffer(); |
251 // If the ticker hasn't already started, make sure to do so to get | 251 // If the ticker hasn't already started, make sure to do so to get |
252 // the ticks for the runtime profiler. | 252 // the ticks for the runtime profiler. |
253 if (IsEnabled()) isolate_->logger()->EnsureTickerStarted(); | 253 if (IsEnabled()) isolate_->logger()->EnsureTickerStarted(); |
254 } | 254 } |
255 | 255 |
256 | 256 |
257 void RuntimeProfiler::Reset() { | 257 void RuntimeProfiler::Reset() { |
258 sampler_threshold_ = kSamplerThresholdInit; | 258 sampler_threshold_ = kSamplerThresholdInit; |
259 sampler_threshold_size_factor_ = kSamplerThresholdSizeFactorInit; | 259 sampler_threshold_size_factor_ = kSamplerThresholdSizeFactorInit; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 355 |
356 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { | 356 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { |
357 if (!RuntimeProfiler::IsSomeIsolateInJS()) { | 357 if (!RuntimeProfiler::IsSomeIsolateInJS()) { |
358 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); | 358 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); |
359 } | 359 } |
360 return false; | 360 return false; |
361 } | 361 } |
362 | 362 |
363 | 363 |
364 } } // namespace v8::internal | 364 } } // namespace v8::internal |
OLD | NEW |