OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime-profiler.h" | 5 #include "src/runtime-profiler.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 int ticks = shared->profiler_ticks(); | 401 int ticks = shared->profiler_ticks(); |
402 | 402 |
403 if (shared->bytecode_array()->Size() > kMaxSizeOptIgnition) { | 403 if (shared->bytecode_array()->Size() > kMaxSizeOptIgnition) { |
404 return OptimizationReason::kDoNotOptimize; | 404 return OptimizationReason::kDoNotOptimize; |
405 } | 405 } |
406 | 406 |
407 if (ticks >= kProfilerTicksBeforeOptimization) { | 407 if (ticks >= kProfilerTicksBeforeOptimization) { |
408 int typeinfo, generic, total, type_percentage, generic_percentage; | 408 int typeinfo, generic, total, type_percentage, generic_percentage; |
409 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, | 409 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, |
410 &generic_percentage); | 410 &generic_percentage); |
411 if (type_percentage >= FLAG_type_info_threshold && | 411 if (type_percentage >= FLAG_type_info_threshold) { |
412 generic_percentage <= FLAG_generic_ic_threshold) { | |
413 // If this particular function hasn't had any ICs patched for enough | 412 // If this particular function hasn't had any ICs patched for enough |
414 // ticks, optimize it now. | 413 // ticks, optimize it now. |
415 return OptimizationReason::kHotAndStable; | 414 return OptimizationReason::kHotAndStable; |
416 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { | 415 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { |
417 return OptimizationReason::kHotWithoutMuchTypeInfo; | 416 return OptimizationReason::kHotWithoutMuchTypeInfo; |
418 } else { | 417 } else { |
419 if (FLAG_trace_opt_verbose) { | 418 if (FLAG_trace_opt_verbose) { |
420 PrintF("[not yet optimizing "); | 419 PrintF("[not yet optimizing "); |
421 function->PrintName(); | 420 function->PrintName(); |
422 PrintF(", not enough type info: %d/%d (%d%%)]\n", typeinfo, total, | 421 PrintF(", not enough type info: %d/%d (%d%%)]\n", typeinfo, total, |
423 type_percentage); | 422 type_percentage); |
424 } | 423 } |
425 return OptimizationReason::kDoNotOptimize; | 424 return OptimizationReason::kDoNotOptimize; |
426 } | 425 } |
427 } else if (!any_ic_changed_ && | 426 } else if (!any_ic_changed_ && |
428 shared->bytecode_array()->Size() < kMaxSizeEarlyOptIgnition) { | 427 shared->bytecode_array()->Size() < kMaxSizeEarlyOptIgnition) { |
429 // If no IC was patched since the last tick and this function is very | 428 // If no IC was patched since the last tick and this function is very |
430 // small, optimistically optimize it now. | 429 // small, optimistically optimize it now. |
431 int typeinfo, generic, total, type_percentage, generic_percentage; | 430 int typeinfo, generic, total, type_percentage, generic_percentage; |
432 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, | 431 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, |
433 &generic_percentage); | 432 &generic_percentage); |
434 if (type_percentage >= FLAG_type_info_threshold && | 433 if (type_percentage >= FLAG_type_info_threshold) { |
435 generic_percentage <= FLAG_generic_ic_threshold) { | |
436 return OptimizationReason::kSmallFunction; | 434 return OptimizationReason::kSmallFunction; |
437 } | 435 } |
438 } | 436 } |
439 return OptimizationReason::kDoNotOptimize; | 437 return OptimizationReason::kDoNotOptimize; |
440 } | 438 } |
441 | 439 |
442 void RuntimeProfiler::MarkCandidatesForOptimization() { | 440 void RuntimeProfiler::MarkCandidatesForOptimization() { |
443 HandleScope scope(isolate_); | 441 HandleScope scope(isolate_); |
444 | 442 |
445 if (!isolate_->use_crankshaft()) return; | 443 if (!isolate_->use_crankshaft()) return; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 if (ticks < Smi::kMaxValue) { | 480 if (ticks < Smi::kMaxValue) { |
483 shared_function_info->set_profiler_ticks(ticks + 1); | 481 shared_function_info->set_profiler_ticks(ticks + 1); |
484 } | 482 } |
485 } | 483 } |
486 } | 484 } |
487 any_ic_changed_ = false; | 485 any_ic_changed_ = false; |
488 } | 486 } |
489 | 487 |
490 } // namespace internal | 488 } // namespace internal |
491 } // namespace v8 | 489 } // namespace v8 |
OLD | NEW |