| OLD | NEW |
| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 function->PrintName(); | 305 function->PrintName(); |
| 306 PrintF(", not enough type info: %d/%d (%d%%)]\n", | 306 PrintF(", not enough type info: %d/%d (%d%%)]\n", |
| 307 typeinfo, total, percentage); | 307 typeinfo, total, percentage); |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 } else if (!any_ic_changed_ && | 310 } else if (!any_ic_changed_ && |
| 311 function->shared()->code()->instruction_size() < kMaxSizeEarlyOpt) { | 311 function->shared()->code()->instruction_size() < kMaxSizeEarlyOpt) { |
| 312 // If no IC was patched since the last tick and this function is very | 312 // If no IC was patched since the last tick and this function is very |
| 313 // small, optimistically optimize it now. | 313 // small, optimistically optimize it now. |
| 314 Optimize(function, "small function"); | 314 Optimize(function, "small function"); |
| 315 } else if (!code_generated_ && | |
| 316 !any_ic_changed_ && | |
| 317 total_code_generated_ > 0 && | |
| 318 total_code_generated_ < 2000) { | |
| 319 // If no code was generated and no IC was patched since the last tick, | |
| 320 // but a little code has already been generated since last Reset(), | |
| 321 // then type info might already be stable and we can optimize now. | |
| 322 Optimize(function, "stable on startup"); | |
| 323 } else { | 315 } else { |
| 324 function->shared()->set_profiler_ticks(ticks + 1); | 316 function->shared()->set_profiler_ticks(ticks + 1); |
| 325 } | 317 } |
| 326 } else { // !FLAG_watch_ic_patching | 318 } else { // !FLAG_watch_ic_patching |
| 327 samples[sample_count++] = function; | 319 samples[sample_count++] = function; |
| 328 | 320 |
| 329 int function_size = function->shared()->SourceSize(); | 321 int function_size = function->shared()->SourceSize(); |
| 330 int threshold_size_factor = (function_size > kSizeLimit) | 322 int threshold_size_factor = (function_size > kSizeLimit) |
| 331 ? sampler_threshold_size_factor_ | 323 ? sampler_threshold_size_factor_ |
| 332 : 1; | 324 : 1; |
| 333 | 325 |
| 334 int threshold = sampler_threshold_ * threshold_size_factor; | 326 int threshold = sampler_threshold_ * threshold_size_factor; |
| 335 | 327 |
| 336 if (LookupSample(function) >= threshold) { | 328 if (LookupSample(function) >= threshold) { |
| 337 Optimize(function, "sampler window lookup"); | 329 Optimize(function, "sampler window lookup"); |
| 338 } | 330 } |
| 339 } | 331 } |
| 340 } | 332 } |
| 341 if (FLAG_watch_ic_patching) { | 333 if (FLAG_watch_ic_patching) { |
| 342 any_ic_changed_ = false; | 334 any_ic_changed_ = false; |
| 343 code_generated_ = false; | |
| 344 } else { // !FLAG_watch_ic_patching | 335 } else { // !FLAG_watch_ic_patching |
| 345 // Add the collected functions as samples. It's important not to do | 336 // Add the collected functions as samples. It's important not to do |
| 346 // this as part of collecting them because this will interfere with | 337 // this as part of collecting them because this will interfere with |
| 347 // the sample lookup in case of recursive functions. | 338 // the sample lookup in case of recursive functions. |
| 348 for (int i = 0; i < sample_count; i++) { | 339 for (int i = 0; i < sample_count; i++) { |
| 349 AddSample(samples[i], kSamplerFrameWeight[i]); | 340 AddSample(samples[i], kSamplerFrameWeight[i]); |
| 350 } | 341 } |
| 351 } | 342 } |
| 352 } | 343 } |
| 353 | 344 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 367 if (!FLAG_watch_ic_patching) { | 358 if (!FLAG_watch_ic_patching) { |
| 368 ClearSampleBuffer(); | 359 ClearSampleBuffer(); |
| 369 } | 360 } |
| 370 // If the ticker hasn't already started, make sure to do so to get | 361 // If the ticker hasn't already started, make sure to do so to get |
| 371 // the ticks for the runtime profiler. | 362 // the ticks for the runtime profiler. |
| 372 if (IsEnabled()) isolate_->logger()->EnsureTickerStarted(); | 363 if (IsEnabled()) isolate_->logger()->EnsureTickerStarted(); |
| 373 } | 364 } |
| 374 | 365 |
| 375 | 366 |
| 376 void RuntimeProfiler::Reset() { | 367 void RuntimeProfiler::Reset() { |
| 377 if (FLAG_watch_ic_patching) { | 368 if (!FLAG_watch_ic_patching) { |
| 378 total_code_generated_ = 0; | |
| 379 } else { // !FLAG_watch_ic_patching | |
| 380 sampler_threshold_ = kSamplerThresholdInit; | 369 sampler_threshold_ = kSamplerThresholdInit; |
| 381 sampler_threshold_size_factor_ = kSamplerThresholdSizeFactorInit; | 370 sampler_threshold_size_factor_ = kSamplerThresholdSizeFactorInit; |
| 382 sampler_ticks_until_threshold_adjustment_ = | 371 sampler_ticks_until_threshold_adjustment_ = |
| 383 kSamplerTicksBetweenThresholdAdjustment; | 372 kSamplerTicksBetweenThresholdAdjustment; |
| 384 } | 373 } |
| 385 } | 374 } |
| 386 | 375 |
| 387 | 376 |
| 388 void RuntimeProfiler::TearDown() { | 377 void RuntimeProfiler::TearDown() { |
| 389 // Nothing to do. | 378 // Nothing to do. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 467 |
| 479 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { | 468 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { |
| 480 if (!RuntimeProfiler::IsSomeIsolateInJS()) { | 469 if (!RuntimeProfiler::IsSomeIsolateInJS()) { |
| 481 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); | 470 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); |
| 482 } | 471 } |
| 483 return false; | 472 return false; |
| 484 } | 473 } |
| 485 | 474 |
| 486 | 475 |
| 487 } } // namespace v8::internal | 476 } } // namespace v8::internal |
| OLD | NEW |