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

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

Issue 1670813005: Revert of Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/profiler/heap-snapshot-generator.cc ('k') | src/runtime/runtime.h » ('j') | 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/ast/scopeinfo.h" 8 #include "src/ast/scopeinfo.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // the very first time it is seen on the stack. 46 // the very first time it is seen on the stack.
47 static const int kMaxSizeEarlyOpt = 47 static const int kMaxSizeEarlyOpt =
48 5 * FullCodeGenerator::kCodeSizeMultiplier; 48 5 * FullCodeGenerator::kCodeSizeMultiplier;
49 49
50 50
51 RuntimeProfiler::RuntimeProfiler(Isolate* isolate) 51 RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
52 : isolate_(isolate), 52 : isolate_(isolate),
53 any_ic_changed_(false) { 53 any_ic_changed_(false) {
54 } 54 }
55 55
56 static void GetICCounts(JSFunction* function, int* ic_with_type_info_count, 56
57 int* ic_generic_count, int* ic_total_count, 57 static void GetICCounts(SharedFunctionInfo* shared,
58 int* type_info_percentage, int* generic_percentage) { 58 int* ic_with_type_info_count, int* ic_generic_count,
59 Code* shared_code = function->shared()->code(); 59 int* ic_total_count, int* type_info_percentage,
60 int* generic_percentage) {
61 Code* shared_code = shared->code();
60 *ic_total_count = 0; 62 *ic_total_count = 0;
61 *ic_generic_count = 0; 63 *ic_generic_count = 0;
62 *ic_with_type_info_count = 0; 64 *ic_with_type_info_count = 0;
63 Object* raw_info = shared_code->type_feedback_info(); 65 Object* raw_info = shared_code->type_feedback_info();
64 if (raw_info->IsTypeFeedbackInfo()) { 66 if (raw_info->IsTypeFeedbackInfo()) {
65 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(raw_info); 67 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(raw_info);
66 *ic_with_type_info_count = info->ic_with_type_info_count(); 68 *ic_with_type_info_count = info->ic_with_type_info_count();
67 *ic_generic_count = info->ic_generic_count(); 69 *ic_generic_count = info->ic_generic_count();
68 *ic_total_count = info->ic_total_count(); 70 *ic_total_count = info->ic_total_count();
69 } 71 }
70 72
71 // Harvest vector-ics as well 73 // Harvest vector-ics as well
72 TypeFeedbackVector* vector = function->feedback_vector(); 74 TypeFeedbackVector* vector = shared->feedback_vector();
73 int with = 0, gen = 0; 75 int with = 0, gen = 0;
74 vector->ComputeCounts(&with, &gen); 76 vector->ComputeCounts(&with, &gen);
75 *ic_with_type_info_count += with; 77 *ic_with_type_info_count += with;
76 *ic_generic_count += gen; 78 *ic_generic_count += gen;
77 79
78 if (*ic_total_count > 0) { 80 if (*ic_total_count > 0) {
79 *type_info_percentage = 100 * *ic_with_type_info_count / *ic_total_count; 81 *type_info_percentage = 100 * *ic_with_type_info_count / *ic_total_count;
80 *generic_percentage = 100 * *ic_generic_count / *ic_total_count; 82 *generic_percentage = 100 * *ic_generic_count / *ic_total_count;
81 } else { 83 } else {
82 *type_info_percentage = 100; // Compared against lower bound. 84 *type_info_percentage = 100; // Compared against lower bound.
83 *generic_percentage = 0; // Compared against upper bound. 85 *generic_percentage = 0; // Compared against upper bound.
84 } 86 }
85 } 87 }
86 88
87 89
88 void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) { 90 void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) {
89 if (FLAG_trace_opt && function->PassesFilter(FLAG_hydrogen_filter)) { 91 if (FLAG_trace_opt && function->PassesFilter(FLAG_hydrogen_filter)) {
90 PrintF("[marking "); 92 PrintF("[marking ");
91 function->ShortPrint(); 93 function->ShortPrint();
92 PrintF(" for recompilation, reason: %s", reason); 94 PrintF(" for recompilation, reason: %s", reason);
93 if (FLAG_type_info_threshold > 0) { 95 if (FLAG_type_info_threshold > 0) {
94 int typeinfo, generic, total, type_percentage, generic_percentage; 96 int typeinfo, generic, total, type_percentage, generic_percentage;
95 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, 97 GetICCounts(function->shared(), &typeinfo, &generic, &total,
96 &generic_percentage); 98 &type_percentage, &generic_percentage);
97 PrintF(", ICs with typeinfo: %d/%d (%d%%)", typeinfo, total, 99 PrintF(", ICs with typeinfo: %d/%d (%d%%)", typeinfo, total,
98 type_percentage); 100 type_percentage);
99 PrintF(", generic ICs: %d/%d (%d%%)", generic, total, generic_percentage); 101 PrintF(", generic ICs: %d/%d (%d%%)", generic, total, generic_percentage);
100 } 102 }
101 PrintF("]\n"); 103 PrintF("]\n");
102 } 104 }
103 105
104 function->AttemptConcurrentOptimization(); 106 function->AttemptConcurrentOptimization();
105 } 107 }
106 108
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 216 }
215 } 217 }
216 continue; 218 continue;
217 } 219 }
218 if (function->IsOptimized()) continue; 220 if (function->IsOptimized()) continue;
219 221
220 int ticks = shared_code->profiler_ticks(); 222 int ticks = shared_code->profiler_ticks();
221 223
222 if (ticks >= kProfilerTicksBeforeOptimization) { 224 if (ticks >= kProfilerTicksBeforeOptimization) {
223 int typeinfo, generic, total, type_percentage, generic_percentage; 225 int typeinfo, generic, total, type_percentage, generic_percentage;
224 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, 226 GetICCounts(shared, &typeinfo, &generic, &total, &type_percentage,
225 &generic_percentage); 227 &generic_percentage);
226 if (type_percentage >= FLAG_type_info_threshold && 228 if (type_percentage >= FLAG_type_info_threshold &&
227 generic_percentage <= FLAG_generic_ic_threshold) { 229 generic_percentage <= FLAG_generic_ic_threshold) {
228 // If this particular function hasn't had any ICs patched for enough 230 // If this particular function hasn't had any ICs patched for enough
229 // ticks, optimize it now. 231 // ticks, optimize it now.
230 Optimize(function, "hot and stable"); 232 Optimize(function, "hot and stable");
231 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { 233 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) {
232 Optimize(function, "not much type info but very hot"); 234 Optimize(function, "not much type info but very hot");
233 } else { 235 } else {
234 shared_code->set_profiler_ticks(ticks + 1); 236 shared_code->set_profiler_ticks(ticks + 1);
235 if (FLAG_trace_opt_verbose) { 237 if (FLAG_trace_opt_verbose) {
236 PrintF("[not yet optimizing "); 238 PrintF("[not yet optimizing ");
237 function->PrintName(); 239 function->PrintName();
238 PrintF(", not enough type info: %d/%d (%d%%)]\n", typeinfo, total, 240 PrintF(", not enough type info: %d/%d (%d%%)]\n", typeinfo, total,
239 type_percentage); 241 type_percentage);
240 } 242 }
241 } 243 }
242 } else if (!any_ic_changed_ && 244 } else if (!any_ic_changed_ &&
243 shared_code->instruction_size() < kMaxSizeEarlyOpt) { 245 shared_code->instruction_size() < kMaxSizeEarlyOpt) {
244 // If no IC was patched since the last tick and this function is very 246 // If no IC was patched since the last tick and this function is very
245 // small, optimistically optimize it now. 247 // small, optimistically optimize it now.
246 int typeinfo, generic, total, type_percentage, generic_percentage; 248 int typeinfo, generic, total, type_percentage, generic_percentage;
247 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, 249 GetICCounts(shared, &typeinfo, &generic, &total, &type_percentage,
248 &generic_percentage); 250 &generic_percentage);
249 if (type_percentage >= FLAG_type_info_threshold && 251 if (type_percentage >= FLAG_type_info_threshold &&
250 generic_percentage <= FLAG_generic_ic_threshold) { 252 generic_percentage <= FLAG_generic_ic_threshold) {
251 Optimize(function, "small function"); 253 Optimize(function, "small function");
252 } else { 254 } else {
253 shared_code->set_profiler_ticks(ticks + 1); 255 shared_code->set_profiler_ticks(ticks + 1);
254 } 256 }
255 } else { 257 } else {
256 shared_code->set_profiler_ticks(ticks + 1); 258 shared_code->set_profiler_ticks(ticks + 1);
257 } 259 }
258 } 260 }
259 any_ic_changed_ = false; 261 any_ic_changed_ = false;
260 } 262 }
261 263
262 264
263 } // namespace internal 265 } // namespace internal
264 } // namespace v8 266 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/heap-snapshot-generator.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698