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

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

Issue 441643008: Track number of generic ICs per function (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-printer.cc ('k') | 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/runtime-profiler.h" 7 #include "src/runtime-profiler.h"
8 8
9 #include "src/assembler.h" 9 #include "src/assembler.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 static const int kMaxSizeEarlyOpt = 50 static const int kMaxSizeEarlyOpt =
51 5 * FullCodeGenerator::kCodeSizeMultiplier; 51 5 * FullCodeGenerator::kCodeSizeMultiplier;
52 52
53 53
54 RuntimeProfiler::RuntimeProfiler(Isolate* isolate) 54 RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
55 : isolate_(isolate), 55 : isolate_(isolate),
56 any_ic_changed_(false) { 56 any_ic_changed_(false) {
57 } 57 }
58 58
59 59
60 static void GetICCounts(Code* shared_code, 60 static void GetICCounts(Code* shared_code, int* ic_with_type_info_count,
61 int* ic_with_type_info_count, 61 int* ic_generic_count, int* ic_total_count,
62 int* ic_total_count, 62 int* type_info_percentage, int* generic_percentage) {
63 int* percentage) {
64 *ic_total_count = 0; 63 *ic_total_count = 0;
64 *ic_generic_count = 0;
65 *ic_with_type_info_count = 0; 65 *ic_with_type_info_count = 0;
66 Object* raw_info = shared_code->type_feedback_info(); 66 Object* raw_info = shared_code->type_feedback_info();
67 if (raw_info->IsTypeFeedbackInfo()) { 67 if (raw_info->IsTypeFeedbackInfo()) {
68 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(raw_info); 68 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(raw_info);
69 *ic_with_type_info_count = info->ic_with_type_info_count(); 69 *ic_with_type_info_count = info->ic_with_type_info_count();
70 *ic_generic_count = info->ic_generic_count();
70 *ic_total_count = info->ic_total_count(); 71 *ic_total_count = info->ic_total_count();
71 } 72 }
72 *percentage = *ic_total_count > 0 73 if (*ic_total_count > 0) {
73 ? 100 * *ic_with_type_info_count / *ic_total_count 74 *type_info_percentage = 100 * *ic_with_type_info_count / *ic_total_count;
74 : 100; 75 *generic_percentage = 100 * *ic_generic_count / *ic_total_count;
76 } else {
77 *type_info_percentage = 100; // Compared against lower bound.
78 *generic_percentage = 0; // Compared against upper bound.
79 }
75 } 80 }
76 81
77 82
78 void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) { 83 void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) {
79 DCHECK(function->IsOptimizable()); 84 DCHECK(function->IsOptimizable());
80 85
81 if (FLAG_trace_opt && function->PassesFilter(FLAG_hydrogen_filter)) { 86 if (FLAG_trace_opt && function->PassesFilter(FLAG_hydrogen_filter)) {
82 PrintF("[marking "); 87 PrintF("[marking ");
83 function->ShortPrint(); 88 function->ShortPrint();
84 PrintF(" for recompilation, reason: %s", reason); 89 PrintF(" for recompilation, reason: %s", reason);
85 if (FLAG_type_info_threshold > 0) { 90 if (FLAG_type_info_threshold > 0) {
86 int typeinfo, total, percentage; 91 int typeinfo, generic, total, type_percentage, generic_percentage;
87 GetICCounts(function->shared()->code(), &typeinfo, &total, &percentage); 92 GetICCounts(function->shared()->code(), &typeinfo, &generic, &total,
88 PrintF(", ICs with typeinfo: %d/%d (%d%%)", typeinfo, total, percentage); 93 &type_percentage, &generic_percentage);
94 PrintF(", ICs with typeinfo: %d/%d (%d%%)", typeinfo, total,
95 type_percentage);
96 PrintF(", generic ICs: %d/%d (%d%%)", generic, total, generic_percentage);
89 } 97 }
90 PrintF("]\n"); 98 PrintF("]\n");
91 } 99 }
92 100
93 101
94 if (isolate_->concurrent_recompilation_enabled() && 102 if (isolate_->concurrent_recompilation_enabled() &&
95 !isolate_->bootstrapper()->IsActive()) { 103 !isolate_->bootstrapper()->IsActive()) {
96 if (isolate_->concurrent_osr_enabled() && 104 if (isolate_->concurrent_osr_enabled() &&
97 isolate_->optimizing_compiler_thread()->IsQueuedForOSR(function)) { 105 isolate_->optimizing_compiler_thread()->IsQueuedForOSR(function)) {
98 // Do not attempt regular recompilation if we already queued this for OSR. 106 // Do not attempt regular recompilation if we already queued this for OSR.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 shared_code->set_profiler_ticks(ticks + 1); 228 shared_code->set_profiler_ticks(ticks + 1);
221 } 229 }
222 } 230 }
223 continue; 231 continue;
224 } 232 }
225 if (!function->IsOptimizable()) continue; 233 if (!function->IsOptimizable()) continue;
226 234
227 int ticks = shared_code->profiler_ticks(); 235 int ticks = shared_code->profiler_ticks();
228 236
229 if (ticks >= kProfilerTicksBeforeOptimization) { 237 if (ticks >= kProfilerTicksBeforeOptimization) {
230 int typeinfo, total, percentage; 238 int typeinfo, generic, total, type_percentage, generic_percentage;
231 GetICCounts(shared_code, &typeinfo, &total, &percentage); 239 GetICCounts(shared_code, &typeinfo, &generic, &total, &type_percentage,
232 if (percentage >= FLAG_type_info_threshold) { 240 &generic_percentage);
241 if (type_percentage >= FLAG_type_info_threshold &&
242 generic_percentage <= FLAG_generic_ic_threshold) {
233 // If this particular function hasn't had any ICs patched for enough 243 // If this particular function hasn't had any ICs patched for enough
234 // ticks, optimize it now. 244 // ticks, optimize it now.
235 Optimize(function, "hot and stable"); 245 Optimize(function, "hot and stable");
236 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { 246 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) {
237 Optimize(function, "not much type info but very hot"); 247 Optimize(function, "not much type info but very hot");
238 } else { 248 } else {
239 shared_code->set_profiler_ticks(ticks + 1); 249 shared_code->set_profiler_ticks(ticks + 1);
240 if (FLAG_trace_opt_verbose) { 250 if (FLAG_trace_opt_verbose) {
241 PrintF("[not yet optimizing "); 251 PrintF("[not yet optimizing ");
242 function->PrintName(); 252 function->PrintName();
243 PrintF(", not enough type info: %d/%d (%d%%)]\n", 253 PrintF(", not enough type info: %d/%d (%d%%)]\n", typeinfo, total,
244 typeinfo, total, percentage); 254 type_percentage);
245 } 255 }
246 } 256 }
247 } else if (!any_ic_changed_ && 257 } else if (!any_ic_changed_ &&
248 shared_code->instruction_size() < kMaxSizeEarlyOpt) { 258 shared_code->instruction_size() < kMaxSizeEarlyOpt) {
249 // If no IC was patched since the last tick and this function is very 259 // If no IC was patched since the last tick and this function is very
250 // small, optimistically optimize it now. 260 // small, optimistically optimize it now.
251 Optimize(function, "small function"); 261 int typeinfo, generic, total, type_percentage, generic_percentage;
262 GetICCounts(shared_code, &typeinfo, &generic, &total, &type_percentage,
263 &generic_percentage);
264 if (type_percentage >= FLAG_type_info_threshold &&
265 generic_percentage <= FLAG_generic_ic_threshold) {
266 Optimize(function, "small function");
267 } else {
268 shared_code->set_profiler_ticks(ticks + 1);
269 }
252 } else { 270 } else {
253 shared_code->set_profiler_ticks(ticks + 1); 271 shared_code->set_profiler_ticks(ticks + 1);
254 } 272 }
255 } 273 }
256 any_ic_changed_ = false; 274 any_ic_changed_ = false;
257 } 275 }
258 276
259 277
260 } } // namespace v8::internal 278 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-printer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698