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" |
11 #include "src/compilation-cache.h" | 11 #include "src/compilation-cache.h" |
12 #include "src/compiler.h" | 12 #include "src/compiler.h" |
13 #include "src/execution.h" | 13 #include "src/execution.h" |
14 #include "src/frames-inl.h" | 14 #include "src/frames-inl.h" |
15 #include "src/full-codegen/full-codegen.h" | 15 #include "src/full-codegen/full-codegen.h" |
16 #include "src/global-handles.h" | 16 #include "src/global-handles.h" |
17 #include "src/interpreter/interpreter.h" | 17 #include "src/interpreter/interpreter.h" |
18 | 18 |
19 namespace v8 { | 19 namespace v8 { |
20 namespace internal { | 20 namespace internal { |
21 | 21 |
22 | 22 |
23 // Number of times a function has to be seen on the stack before it is | 23 // Number of times a function has to be seen on the stack before it is |
24 // compiled for baseline. | 24 // compiled for baseline. |
25 static const int kProfilerTicksBeforeBaseline = 1; | 25 static const int kProfilerTicksBeforeBaseline = 0; |
26 // Number of times a function has to be seen on the stack before it is | 26 // Number of times a function has to be seen on the stack before it is |
27 // optimized. | 27 // optimized. |
28 static const int kProfilerTicksBeforeOptimization = 2; | 28 static const int kProfilerTicksBeforeOptimization = 2; |
29 // If the function optimization was disabled due to high deoptimization count, | 29 // If the function optimization was disabled due to high deoptimization count, |
30 // but the function is hot and has been seen on the stack this number of times, | 30 // but the function is hot and has been seen on the stack this number of times, |
31 // then we try to reenable optimization for this function. | 31 // then we try to reenable optimization for this function. |
32 static const int kProfilerTicksBeforeReenablingOptimization = 250; | 32 static const int kProfilerTicksBeforeReenablingOptimization = 250; |
33 // If a function does not have enough type info (according to | 33 // If a function does not have enough type info (according to |
34 // FLAG_type_info_threshold), but has seen a huge number of ticks, | 34 // FLAG_type_info_threshold), but has seen a huge number of ticks, |
35 // optimize it as it is. | 35 // optimize it as it is. |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // have a sample of the function, we mark it for optimizations | 440 // have a sample of the function, we mark it for optimizations |
441 // (eagerly or lazily). | 441 // (eagerly or lazily). |
442 int frame_count = 0; | 442 int frame_count = 0; |
443 int frame_count_limit = FLAG_frame_count; | 443 int frame_count_limit = FLAG_frame_count; |
444 for (JavaScriptFrameIterator it(isolate_); | 444 for (JavaScriptFrameIterator it(isolate_); |
445 frame_count++ < frame_count_limit && !it.done(); | 445 frame_count++ < frame_count_limit && !it.done(); |
446 it.Advance()) { | 446 it.Advance()) { |
447 JavaScriptFrame* frame = it.frame(); | 447 JavaScriptFrame* frame = it.frame(); |
448 JSFunction* function = frame->function(); | 448 JSFunction* function = frame->function(); |
449 | 449 |
450 List<JSFunction*> functions(4); | |
451 frame->GetFunctions(&functions); | |
452 for (int i = functions.length(); --i >= 0; ) { | |
453 SharedFunctionInfo* shared_function_info = functions[i]->shared(); | |
454 int ticks = shared_function_info->profiler_ticks(); | |
455 if (ticks < Smi::kMaxValue) { | |
456 shared_function_info->set_profiler_ticks(ticks + 1); | |
457 } | |
458 } | |
459 | |
460 Compiler::CompilationTier next_tier = | 450 Compiler::CompilationTier next_tier = |
461 Compiler::NextCompilationTier(function); | 451 Compiler::NextCompilationTier(function); |
462 if (function->shared()->IsInterpreted()) { | 452 if (function->shared()->IsInterpreted()) { |
463 if (next_tier == Compiler::BASELINE) { | 453 if (next_tier == Compiler::BASELINE) { |
464 MaybeBaselineIgnition(function, frame); | 454 MaybeBaselineIgnition(function, frame); |
465 } else { | 455 } else { |
466 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); | 456 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); |
467 MaybeOptimizeIgnition(function, frame); | 457 MaybeOptimizeIgnition(function, frame); |
468 } | 458 } |
469 } else { | 459 } else { |
470 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); | 460 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); |
471 MaybeOptimizeFullCodegen(function, frame, frame_count); | 461 MaybeOptimizeFullCodegen(function, frame, frame_count); |
472 } | 462 } |
| 463 |
| 464 // Update shared function info ticks after checking for whether functions |
| 465 // should be optimized to keep FCG (which updates ticks on code) and |
| 466 // Ignition (which updates ticks on shared function info) in sync. |
| 467 List<JSFunction*> functions(4); |
| 468 frame->GetFunctions(&functions); |
| 469 for (int i = functions.length(); --i >= 0;) { |
| 470 SharedFunctionInfo* shared_function_info = functions[i]->shared(); |
| 471 int ticks = shared_function_info->profiler_ticks(); |
| 472 if (ticks < Smi::kMaxValue) { |
| 473 shared_function_info->set_profiler_ticks(ticks + 1); |
| 474 } |
| 475 } |
473 } | 476 } |
474 any_ic_changed_ = false; | 477 any_ic_changed_ = false; |
475 } | 478 } |
476 | 479 |
477 } // namespace internal | 480 } // namespace internal |
478 } // namespace v8 | 481 } // namespace v8 |
OLD | NEW |