Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/runtime-profiler.cc

Issue 2427283004: [interpreter] Also optimize small functions earlier. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 static const int kOSRCodeSizeAllowancePerTick = 48 static const int kOSRCodeSizeAllowancePerTick =
49 4 * FullCodeGenerator::kCodeSizeMultiplier; 49 4 * FullCodeGenerator::kCodeSizeMultiplier;
50 static const int kOSRCodeSizeAllowancePerTickIgnition = 50 static const int kOSRCodeSizeAllowancePerTickIgnition =
51 4 * interpreter::Interpreter::kCodeSizeMultiplier; 51 4 * 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 =
58 5 * interpreter::Interpreter::kCodeSizeMultiplier;
57 59
58 #define OPTIMIZATION_REASON_LIST(V) \ 60 #define OPTIMIZATION_REASON_LIST(V) \
59 V(DoNotOptimize, "do not optimize") \ 61 V(DoNotOptimize, "do not optimize") \
60 V(HotAndStable, "hot and stable") \ 62 V(HotAndStable, "hot and stable") \
61 V(HotEnoughForBaseline, "hot enough for baseline") \ 63 V(HotEnoughForBaseline, "hot enough for baseline") \
62 V(HotWithoutMuchTypeInfo, "not much type info but very hot") \ 64 V(HotWithoutMuchTypeInfo, "not much type info but very hot") \
63 V(SmallFunction, "small function") 65 V(SmallFunction, "small function")
64 66
65 enum class OptimizationReason : uint8_t { 67 enum class OptimizationReason : uint8_t {
66 #define OPTIMIZATION_REASON_CONSTANTS(Constant, message) k##Constant, 68 #define OPTIMIZATION_REASON_CONSTANTS(Constant, message) k##Constant,
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 return OptimizationReason::kHotWithoutMuchTypeInfo; 417 return OptimizationReason::kHotWithoutMuchTypeInfo;
416 } else { 418 } else {
417 if (FLAG_trace_opt_verbose) { 419 if (FLAG_trace_opt_verbose) {
418 PrintF("[not yet optimizing "); 420 PrintF("[not yet optimizing ");
419 function->PrintName(); 421 function->PrintName();
420 PrintF(", not enough type info: %d/%d (%d%%)]\n", typeinfo, total, 422 PrintF(", not enough type info: %d/%d (%d%%)]\n", typeinfo, total,
421 type_percentage); 423 type_percentage);
422 } 424 }
423 return OptimizationReason::kDoNotOptimize; 425 return OptimizationReason::kDoNotOptimize;
424 } 426 }
427 } else if (!any_ic_changed_ &&
428 shared->bytecode_array()->Size() < kMaxSizeEarlyOptIgnition) {
429 // If no IC was patched since the last tick and this function is very
mythria 2016/10/19 13:17:29 Just for my understanding, any_ic_changed_ means i
Benedikt Meurer 2016/10/19 13:19:40 That's a good point, I missed that. Can you put th
430 // small, optimistically optimize it now.
431 int typeinfo, generic, total, type_percentage, generic_percentage;
432 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage,
433 &generic_percentage);
434 if (type_percentage >= FLAG_type_info_threshold &&
435 generic_percentage <= FLAG_generic_ic_threshold) {
436 return OptimizationReason::kSmallFunction;
437 }
425 } 438 }
426 // TODO(rmcilroy): Consider whether we should optimize small functions when
427 // they are first seen on the stack (e.g., kMaxSizeEarlyOpt).
428 return OptimizationReason::kDoNotOptimize; 439 return OptimizationReason::kDoNotOptimize;
429 } 440 }
430 441
431 void RuntimeProfiler::MarkCandidatesForOptimization() { 442 void RuntimeProfiler::MarkCandidatesForOptimization() {
432 HandleScope scope(isolate_); 443 HandleScope scope(isolate_);
433 444
434 if (!isolate_->use_crankshaft()) return; 445 if (!isolate_->use_crankshaft()) return;
435 446
436 DisallowHeapAllocation no_gc; 447 DisallowHeapAllocation no_gc;
437 448
(...skipping 30 matching lines...) Expand all
468 } else { 479 } else {
469 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); 480 DCHECK_EQ(next_tier, Compiler::OPTIMIZED);
470 MaybeOptimizeFullCodegen(function, frame, frame_count); 481 MaybeOptimizeFullCodegen(function, frame, frame_count);
471 } 482 }
472 } 483 }
473 any_ic_changed_ = false; 484 any_ic_changed_ = false;
474 } 485 }
475 486
476 } // namespace internal 487 } // namespace internal
477 } // namespace v8 488 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698