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

Side by Side Diff: src/compiler/js-inlining-heuristic.cc

Issue 2330883002: [turbofan] Call frequencies for JSCallFunction and JSCallConstruct. (Closed)
Patch Set: Rebase onto the correct CL. Created 4 years, 3 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/compiler/js-inlining-heuristic.h ('k') | src/compiler/js-intrinsic-lowering.cc » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/js-inlining-heuristic.h" 5 #include "src/compiler/js-inlining-heuristic.h"
6 6
7 #include "src/compilation-info.h" 7 #include "src/compilation-info.h"
8 #include "src/compiler/common-operator.h" 8 #include "src/compiler/common-operator.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/simplified-operator.h" 10 #include "src/compiler/simplified-operator.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 "%d exceeds maximum allowed level %d\n", 116 "%d exceeds maximum allowed level %d\n",
117 node->id(), node->op()->mnemonic(), level, 117 node->id(), node->op()->mnemonic(), level,
118 FLAG_max_inlining_levels); 118 FLAG_max_inlining_levels);
119 return NoChange(); 119 return NoChange();
120 } 120 }
121 } 121 }
122 } 122 }
123 123
124 // Gather feedback on how often this call site has been hit before. 124 // Gather feedback on how often this call site has been hit before.
125 if (node->opcode() == IrOpcode::kJSCallFunction) { 125 if (node->opcode() == IrOpcode::kJSCallFunction) {
126 CallFunctionParameters p = CallFunctionParametersOf(node->op()); 126 CallFunctionParameters const p = CallFunctionParametersOf(node->op());
127 if (p.feedback().IsValid()) { 127 candidate.frequency = p.frequency();
128 CallICNexus nexus(p.feedback().vector(), p.feedback().slot());
129 candidate.calls = nexus.ExtractCallCount();
130 }
131 } else { 128 } else {
132 DCHECK_EQ(IrOpcode::kJSCallConstruct, node->opcode()); 129 CallConstructParameters const p = CallConstructParametersOf(node->op());
133 CallConstructParameters p = CallConstructParametersOf(node->op()); 130 candidate.frequency = p.frequency();
134 if (p.feedback().IsValid()) {
135 CallICNexus nexus(p.feedback().vector(), p.feedback().slot());
136 candidate.calls = nexus.ExtractCallCount();
137 }
138 } 131 }
139 132
140 // Handling of special inlining modes right away: 133 // Handling of special inlining modes right away:
141 // - For restricted inlining: stop all handling at this point. 134 // - For restricted inlining: stop all handling at this point.
142 // - For stressing inlining: immediately handle all functions. 135 // - For stressing inlining: immediately handle all functions.
143 switch (mode_) { 136 switch (mode_) {
144 case kRestrictedInlining: 137 case kRestrictedInlining:
145 return NoChange(); 138 return NoChange();
146 case kStressInlining: 139 case kStressInlining:
147 return InlineCandidate(candidate); 140 return InlineCandidate(candidate);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (reduction.Changed()) { 264 if (reduction.Changed()) {
272 cumulative_count_ += function->shared()->ast_node_count(); 265 cumulative_count_ += function->shared()->ast_node_count();
273 } 266 }
274 } 267 }
275 268
276 return Replace(value); 269 return Replace(value);
277 } 270 }
278 271
279 bool JSInliningHeuristic::CandidateCompare::operator()( 272 bool JSInliningHeuristic::CandidateCompare::operator()(
280 const Candidate& left, const Candidate& right) const { 273 const Candidate& left, const Candidate& right) const {
281 if (left.calls != right.calls) { 274 if (left.frequency > right.frequency) {
282 return left.calls > right.calls; 275 return true;
276 } else if (left.frequency < right.frequency) {
277 return false;
278 } else {
279 return left.node->id() > right.node->id();
283 } 280 }
284 return left.node->id() > right.node->id();
285 } 281 }
286 282
287 void JSInliningHeuristic::PrintCandidates() { 283 void JSInliningHeuristic::PrintCandidates() {
288 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size()); 284 PrintF("Candidates for inlining (size=%zu):\n", candidates_.size());
289 for (const Candidate& candidate : candidates_) { 285 for (const Candidate& candidate : candidates_) {
290 PrintF(" #%d:%s, calls:%d\n", candidate.node->id(), 286 PrintF(" #%d:%s, frequency:%g\n", candidate.node->id(),
291 candidate.node->op()->mnemonic(), candidate.calls); 287 candidate.node->op()->mnemonic(), candidate.frequency);
292 for (int i = 0; i < candidate.num_functions; ++i) { 288 for (int i = 0; i < candidate.num_functions; ++i) {
293 Handle<JSFunction> function = candidate.functions[i]; 289 Handle<JSFunction> function = candidate.functions[i];
294 PrintF(" - size[source]:%d, size[ast]:%d, name: %s\n", 290 PrintF(" - size[source]:%d, size[ast]:%d, name: %s\n",
295 function->shared()->SourceSize(), 291 function->shared()->SourceSize(),
296 function->shared()->ast_node_count(), 292 function->shared()->ast_node_count(),
297 function->shared()->DebugName()->ToCString().get()); 293 function->shared()->DebugName()->ToCString().get());
298 } 294 }
299 } 295 }
300 } 296 }
301 297
302 Graph* JSInliningHeuristic::graph() const { return jsgraph()->graph(); } 298 Graph* JSInliningHeuristic::graph() const { return jsgraph()->graph(); }
303 299
304 CommonOperatorBuilder* JSInliningHeuristic::common() const { 300 CommonOperatorBuilder* JSInliningHeuristic::common() const {
305 return jsgraph()->common(); 301 return jsgraph()->common();
306 } 302 }
307 303
308 SimplifiedOperatorBuilder* JSInliningHeuristic::simplified() const { 304 SimplifiedOperatorBuilder* JSInliningHeuristic::simplified() const {
309 return jsgraph()->simplified(); 305 return jsgraph()->simplified();
310 } 306 }
311 307
312 } // namespace compiler 308 } // namespace compiler
313 } // namespace internal 309 } // namespace internal
314 } // namespace v8 310 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-inlining-heuristic.h ('k') | src/compiler/js-intrinsic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698