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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 static const int kOSRCodeSizeAllowancePerTickIgnition = | 50 static const int kOSRCodeSizeAllowancePerTickIgnition = |
51 2 * interpreter::Interpreter::kCodeSizeMultiplier; | 51 2 * interpreter::Interpreter::kCodeSizeMultiplier; |
52 | 52 |
53 // Maximum size in bytes of generated code for a function to be optimized | 53 // Maximum size in bytes of generated code for a function to be optimized |
54 // the very first time it is seen on the stack. | 54 // the very first time it is seen on the stack. |
55 static const int kMaxSizeEarlyOpt = | 55 static const int kMaxSizeEarlyOpt = |
56 5 * FullCodeGenerator::kCodeSizeMultiplier; | 56 5 * FullCodeGenerator::kCodeSizeMultiplier; |
57 static const int kMaxSizeEarlyOptIgnition = | 57 static const int kMaxSizeEarlyOptIgnition = |
58 5 * interpreter::Interpreter::kCodeSizeMultiplier; | 58 5 * interpreter::Interpreter::kCodeSizeMultiplier; |
59 | 59 |
60 // Certain functions are simply too big to be worth optimizing. | |
61 static const int kMaxSizeOptFromBytecode = 250 * 1024; | |
Michael Starzinger
2017/01/30 12:42:11
nit: Can we call this "kMaxSizeOptIgnition" to fol
mvstanton
2017/01/30 14:55:37
"We are not using the code size multiplier here be
| |
62 | |
60 #define OPTIMIZATION_REASON_LIST(V) \ | 63 #define OPTIMIZATION_REASON_LIST(V) \ |
61 V(DoNotOptimize, "do not optimize") \ | 64 V(DoNotOptimize, "do not optimize") \ |
62 V(HotAndStable, "hot and stable") \ | 65 V(HotAndStable, "hot and stable") \ |
63 V(HotEnoughForBaseline, "hot enough for baseline") \ | 66 V(HotEnoughForBaseline, "hot enough for baseline") \ |
64 V(HotWithoutMuchTypeInfo, "not much type info but very hot") \ | 67 V(HotWithoutMuchTypeInfo, "not much type info but very hot") \ |
65 V(SmallFunction, "small function") | 68 V(SmallFunction, "small function") |
66 | 69 |
67 enum class OptimizationReason : uint8_t { | 70 enum class OptimizationReason : uint8_t { |
68 #define OPTIMIZATION_REASON_CONSTANTS(Constant, message) k##Constant, | 71 #define OPTIMIZATION_REASON_CONSTANTS(Constant, message) k##Constant, |
69 OPTIMIZATION_REASON_LIST(OPTIMIZATION_REASON_CONSTANTS) | 72 OPTIMIZATION_REASON_LIST(OPTIMIZATION_REASON_CONSTANTS) |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 return true; | 390 return true; |
388 } | 391 } |
389 return false; | 392 return false; |
390 } | 393 } |
391 | 394 |
392 OptimizationReason RuntimeProfiler::ShouldOptimizeIgnition( | 395 OptimizationReason RuntimeProfiler::ShouldOptimizeIgnition( |
393 JSFunction* function, JavaScriptFrame* frame) { | 396 JSFunction* function, JavaScriptFrame* frame) { |
394 SharedFunctionInfo* shared = function->shared(); | 397 SharedFunctionInfo* shared = function->shared(); |
395 int ticks = shared->profiler_ticks(); | 398 int ticks = shared->profiler_ticks(); |
396 | 399 |
400 if (shared->bytecode_array()->Size() > kMaxSizeOptFromBytecode) { | |
Michael Starzinger
2017/01/30 12:42:11
nit: s/Size/instruction_size/ to avoid dispatched
Michael Starzinger
2017/01/30 12:54:48
Ooops, looked at the wrong use-site. Please disreg
mvstanton
2017/01/30 14:55:37
Per discussion, Size() is now the right predicate.
| |
401 return OptimizationReason::kDoNotOptimize; | |
402 } | |
403 | |
397 if (ticks >= kProfilerTicksBeforeOptimization) { | 404 if (ticks >= kProfilerTicksBeforeOptimization) { |
398 int typeinfo, generic, total, type_percentage, generic_percentage; | 405 int typeinfo, generic, total, type_percentage, generic_percentage; |
399 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, | 406 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, |
400 &generic_percentage); | 407 &generic_percentage); |
401 if (type_percentage >= FLAG_type_info_threshold && | 408 if (type_percentage >= FLAG_type_info_threshold && |
402 generic_percentage <= FLAG_generic_ic_threshold) { | 409 generic_percentage <= FLAG_generic_ic_threshold) { |
403 // If this particular function hasn't had any ICs patched for enough | 410 // If this particular function hasn't had any ICs patched for enough |
404 // ticks, optimize it now. | 411 // ticks, optimize it now. |
405 return OptimizationReason::kHotAndStable; | 412 return OptimizationReason::kHotAndStable; |
406 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { | 413 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 if (ticks < Smi::kMaxValue) { | 479 if (ticks < Smi::kMaxValue) { |
473 shared_function_info->set_profiler_ticks(ticks + 1); | 480 shared_function_info->set_profiler_ticks(ticks + 1); |
474 } | 481 } |
475 } | 482 } |
476 } | 483 } |
477 any_ic_changed_ = false; | 484 any_ic_changed_ = false; |
478 } | 485 } |
479 | 486 |
480 } // namespace internal | 487 } // namespace internal |
481 } // namespace v8 | 488 } // namespace v8 |
OLD | NEW |