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

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

Issue 9403009: Count ICs that have type information. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix confusing --trace-opt output Created 8 years, 10 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 void RuntimeProfiler::GlobalSetup() { 96 void RuntimeProfiler::GlobalSetup() {
97 ASSERT(!has_been_globally_set_up_); 97 ASSERT(!has_been_globally_set_up_);
98 enabled_ = V8::UseCrankshaft() && FLAG_opt; 98 enabled_ = V8::UseCrankshaft() && FLAG_opt;
99 #ifdef DEBUG 99 #ifdef DEBUG
100 has_been_globally_set_up_ = true; 100 has_been_globally_set_up_ = true;
101 #endif 101 #endif
102 } 102 }
103 103
104 104
105 static void GetICCounts(JSFunction* function,
106 int* ic_with_typeinfo_count,
107 int* ic_total_count,
108 int* percentage) {
109 *ic_total_count = 0;
110 *ic_with_typeinfo_count = 0;
111 Object* raw_info =
112 function->shared()->code()->type_feedback_info();
113 if (raw_info->IsTypeFeedbackInfo()) {
114 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(raw_info);
115 *ic_with_typeinfo_count = info->ic_with_typeinfo_count();
116 *ic_total_count = info->ic_total_count();
117 }
118 *percentage = *ic_total_count > 0
119 ? 100 * *ic_with_typeinfo_count / *ic_total_count
120 : 100;
121 }
122
123
105 void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) { 124 void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) {
106 ASSERT(function->IsOptimizable()); 125 ASSERT(function->IsOptimizable());
107 if (FLAG_trace_opt) { 126 if (FLAG_trace_opt) {
108 PrintF("[marking "); 127 PrintF("[marking ");
109 function->PrintName(); 128 function->PrintName();
110 PrintF(" 0x%" V8PRIxPTR, reinterpret_cast<intptr_t>(function->address())); 129 PrintF(" 0x%" V8PRIxPTR, reinterpret_cast<intptr_t>(function->address()));
111 PrintF(" for recompilation, reason: %s", reason); 130 PrintF(" for recompilation, reason: %s", reason);
131 if (FLAG_type_info_threshold > 0) {
132 int typeinfo, total, percentage;
133 GetICCounts(function, &typeinfo, &total, &percentage);
134 PrintF(", ICs with typeinfo: %d/%d (%d%%)", typeinfo, total, percentage);
135 }
112 PrintF("]\n"); 136 PrintF("]\n");
113 } 137 }
114 138
115 // The next call to the function will trigger optimization. 139 // The next call to the function will trigger optimization.
116 function->MarkForLazyRecompilation(); 140 function->MarkForLazyRecompilation();
117 } 141 }
118 142
119 143
120 void RuntimeProfiler::AttemptOnStackReplacement(JSFunction* function) { 144 void RuntimeProfiler::AttemptOnStackReplacement(JSFunction* function) {
121 // See AlwaysFullCompiler (in compiler.cc) comment on why we need 145 // See AlwaysFullCompiler (in compiler.cc) comment on why we need
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 if (function->shared()->is_toplevel() 275 if (function->shared()->is_toplevel()
252 && (frame_count > 1 276 && (frame_count > 1
253 || function->shared()->SourceSize() > kMaxToplevelSourceSize)) { 277 || function->shared()->SourceSize() > kMaxToplevelSourceSize)) {
254 continue; 278 continue;
255 } 279 }
256 280
257 if (FLAG_watch_ic_patching) { 281 if (FLAG_watch_ic_patching) {
258 int ticks = function->shared()->profiler_ticks(); 282 int ticks = function->shared()->profiler_ticks();
259 283
260 if (ticks >= kProfilerTicksBeforeOptimization) { 284 if (ticks >= kProfilerTicksBeforeOptimization) {
261 // If this particular function hasn't had any ICs patched for enough 285 int typeinfo, total, percentage;
262 // ticks, optimize it now. 286 GetICCounts(function, &typeinfo, &total, &percentage);
263 Optimize(function, "hot and stable"); 287 if (percentage >= FLAG_type_info_threshold) {
288 // If this particular function hasn't had any ICs patched for enough
289 // ticks, optimize it now.
290 Optimize(function, "hot and stable");
291 } else {
292 if (FLAG_trace_opt_verbose) {
293 PrintF("[not yet optimizing ");
294 function->PrintName();
295 PrintF(", not enough type info: %d/%d (%d%%)]\n",
296 typeinfo, total, percentage);
297 }
298 }
264 } else if (!any_ic_changed_ && 299 } else if (!any_ic_changed_ &&
265 function->shared()->code()->instruction_size() < kMaxSizeEarlyOpt) { 300 function->shared()->code()->instruction_size() < kMaxSizeEarlyOpt) {
266 // If no IC was patched since the last tick and this function is very 301 // If no IC was patched since the last tick and this function is very
267 // small, optimistically optimize it now. 302 // small, optimistically optimize it now.
268 Optimize(function, "small function"); 303 Optimize(function, "small function");
269 } else if (!code_generated_ && 304 } else if (!code_generated_ &&
270 !any_ic_changed_ && 305 !any_ic_changed_ &&
271 total_code_generated_ > 0 && 306 total_code_generated_ > 0 &&
272 total_code_generated_ < 2000) { 307 total_code_generated_ < 2000) {
273 // If no code was generated and no IC was patched since the last tick, 308 // If no code was generated and no IC was patched since the last tick,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 465
431 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { 466 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
432 if (!RuntimeProfiler::IsSomeIsolateInJS()) { 467 if (!RuntimeProfiler::IsSomeIsolateInJS()) {
433 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); 468 return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
434 } 469 }
435 return false; 470 return false;
436 } 471 }
437 472
438 473
439 } } // namespace v8::internal 474 } } // namespace v8::internal
OLDNEW
« src/objects-inl.h ('K') | « src/objects-visiting-inl.h ('k') | src/type-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698