Chromium Code Reviews| 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 = 1; |
| 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 // Number of times a interpreted function has to be seen on the stack before | |
| 30 // it is optimized (with Turbofan, ignition is only optimized with Turbofan). | |
| 31 static const int kProfilerTicksBeforeOptimizingInterpretedFunction = 4; | |
|
mythria
2016/10/26 08:17:15
In my experiments on Octane I found 4 to be a good
| |
| 29 // If the function optimization was disabled due to high deoptimization count, | 32 // 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, | 33 // 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. | 34 // then we try to reenable optimization for this function. |
| 32 static const int kProfilerTicksBeforeReenablingOptimization = 250; | 35 static const int kProfilerTicksBeforeReenablingOptimization = 250; |
| 33 // If a function does not have enough type info (according to | 36 // If a function does not have enough type info (according to |
| 34 // FLAG_type_info_threshold), but has seen a huge number of ticks, | 37 // FLAG_type_info_threshold), but has seen a huge number of ticks, |
| 35 // optimize it as it is. | 38 // optimize it as it is. |
| 36 static const int kTicksWhenNotEnoughTypeInfo = 100; | 39 static const int kTicksWhenNotEnoughTypeInfo = 100; |
| 37 // We only have one byte to store the number of ticks. | 40 // We only have one byte to store the number of ticks. |
| 38 STATIC_ASSERT(kProfilerTicksBeforeOptimization < 256); | 41 STATIC_ASSERT(kProfilerTicksBeforeOptimization < 256); |
| 42 STATIC_ASSERT(kProfilerTicksBeforeOptimizingInterpretedFunction < 256); | |
| 39 STATIC_ASSERT(kProfilerTicksBeforeReenablingOptimization < 256); | 43 STATIC_ASSERT(kProfilerTicksBeforeReenablingOptimization < 256); |
| 40 STATIC_ASSERT(kTicksWhenNotEnoughTypeInfo < 256); | 44 STATIC_ASSERT(kTicksWhenNotEnoughTypeInfo < 256); |
| 41 | 45 |
| 42 // Maximum size in bytes of generate code for a function to allow OSR. | 46 // Maximum size in bytes of generate code for a function to allow OSR. |
| 43 static const int kOSRCodeSizeAllowanceBase = | 47 static const int kOSRCodeSizeAllowanceBase = |
| 44 100 * FullCodeGenerator::kCodeSizeMultiplier; | 48 100 * FullCodeGenerator::kCodeSizeMultiplier; |
|
mythria
2016/10/26 08:17:15
In my initial patch, I also changed this metric fo
| |
| 45 static const int kOSRCodeSizeAllowanceBaseIgnition = | 49 static const int kOSRCodeSizeAllowanceBaseIgnition = |
| 46 100 * interpreter::Interpreter::kCodeSizeMultiplier; | 50 10 * interpreter::Interpreter::kCodeSizeMultiplier; |
|
mythria
2016/10/26 08:17:15
This and the change to OSRCodeSizeAllowancePerTIck
| |
| 47 | 51 |
| 48 static const int kOSRCodeSizeAllowancePerTick = | 52 static const int kOSRCodeSizeAllowancePerTick = |
| 49 4 * FullCodeGenerator::kCodeSizeMultiplier; | 53 4 * FullCodeGenerator::kCodeSizeMultiplier; |
| 50 static const int kOSRCodeSizeAllowancePerTickIgnition = | 54 static const int kOSRCodeSizeAllowancePerTickIgnition = |
| 51 4 * interpreter::Interpreter::kCodeSizeMultiplier; | 55 2 * interpreter::Interpreter::kCodeSizeMultiplier; |
| 52 | 56 |
| 53 // Maximum size in bytes of generated code for a function to be optimized | 57 // Maximum size in bytes of generated code for a function to be optimized |
| 54 // the very first time it is seen on the stack. | 58 // the very first time it is seen on the stack. |
| 55 static const int kMaxSizeEarlyOpt = | 59 static const int kMaxSizeEarlyOpt = |
| 56 5 * FullCodeGenerator::kCodeSizeMultiplier; | 60 5 * FullCodeGenerator::kCodeSizeMultiplier; |
| 57 static const int kMaxSizeEarlyOptIgnition = | 61 static const int kMaxSizeEarlyOptIgnition = |
| 58 5 * interpreter::Interpreter::kCodeSizeMultiplier; | 62 5 * interpreter::Interpreter::kCodeSizeMultiplier; |
| 59 | 63 |
| 60 #define OPTIMIZATION_REASON_LIST(V) \ | 64 #define OPTIMIZATION_REASON_LIST(V) \ |
| 61 V(DoNotOptimize, "do not optimize") \ | 65 V(DoNotOptimize, "do not optimize") \ |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 return true; | 401 return true; |
| 398 } | 402 } |
| 399 return false; | 403 return false; |
| 400 } | 404 } |
| 401 | 405 |
| 402 OptimizationReason RuntimeProfiler::ShouldOptimizeIgnition( | 406 OptimizationReason RuntimeProfiler::ShouldOptimizeIgnition( |
| 403 JSFunction* function, JavaScriptFrame* frame) { | 407 JSFunction* function, JavaScriptFrame* frame) { |
| 404 SharedFunctionInfo* shared = function->shared(); | 408 SharedFunctionInfo* shared = function->shared(); |
| 405 int ticks = shared->profiler_ticks(); | 409 int ticks = shared->profiler_ticks(); |
| 406 | 410 |
| 407 if (ticks >= kProfilerTicksBeforeOptimization) { | 411 if (ticks >= kProfilerTicksBeforeOptimizingInterpretedFunction) { |
| 408 int typeinfo, generic, total, type_percentage, generic_percentage; | 412 int typeinfo, generic, total, type_percentage, generic_percentage; |
| 409 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, | 413 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, |
| 410 &generic_percentage); | 414 &generic_percentage); |
| 411 if (type_percentage >= FLAG_type_info_threshold && | 415 if (type_percentage >= FLAG_type_info_threshold && |
| 412 generic_percentage <= FLAG_generic_ic_threshold) { | 416 generic_percentage <= FLAG_generic_ic_threshold) { |
| 413 // If this particular function hasn't had any ICs patched for enough | 417 // If this particular function hasn't had any ICs patched for enough |
| 414 // ticks, optimize it now. | 418 // ticks, optimize it now. |
| 415 return OptimizationReason::kHotAndStable; | 419 return OptimizationReason::kHotAndStable; |
| 416 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { | 420 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { |
| 417 return OptimizationReason::kHotWithoutMuchTypeInfo; | 421 return OptimizationReason::kHotWithoutMuchTypeInfo; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 } else { | 483 } else { |
| 480 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); | 484 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); |
| 481 MaybeOptimizeFullCodegen(function, frame, frame_count); | 485 MaybeOptimizeFullCodegen(function, frame, frame_count); |
| 482 } | 486 } |
| 483 } | 487 } |
| 484 any_ic_changed_ = false; | 488 any_ic_changed_ = false; |
| 485 } | 489 } |
| 486 | 490 |
| 487 } // namespace internal | 491 } // namespace internal |
| 488 } // namespace v8 | 492 } // namespace v8 |
| OLD | NEW |