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

Side by Side Diff: src/compiler/js-call-reducer.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/bytecode-graph-builder.cc ('k') | src/compiler/js-inlining-heuristic.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 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-call-reducer.h" 5 #include "src/compiler/js-call-reducer.h"
6 6
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
11 #include "src/type-feedback-vector-inl.h" 11 #include "src/type-feedback-vector-inl.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace compiler { 15 namespace compiler {
16 16
17 namespace {
18
19 VectorSlotPair CallCountFeedback(VectorSlotPair p) {
20 // Extract call count from {p}.
21 if (!p.IsValid()) return VectorSlotPair();
22 CallICNexus n(p.vector(), p.slot());
23 int const call_count = n.ExtractCallCount();
24 if (call_count <= 0) return VectorSlotPair();
25
26 // Create megamorphic CallIC feedback with the given {call_count}.
27 StaticFeedbackVectorSpec spec;
28 FeedbackVectorSlot slot = spec.AddCallICSlot();
29 Handle<TypeFeedbackMetadata> metadata =
30 TypeFeedbackMetadata::New(n.GetIsolate(), &spec);
31 Handle<TypeFeedbackVector> vector =
32 TypeFeedbackVector::New(n.GetIsolate(), metadata);
33 CallICNexus nexus(vector, slot);
34 nexus.ConfigureMegamorphic(call_count);
35 return VectorSlotPair(vector, slot);
36 }
37
38 } // namespace
39
40
41 Reduction JSCallReducer::Reduce(Node* node) { 17 Reduction JSCallReducer::Reduce(Node* node) {
42 switch (node->opcode()) { 18 switch (node->opcode()) {
43 case IrOpcode::kJSCallConstruct: 19 case IrOpcode::kJSCallConstruct:
44 return ReduceJSCallConstruct(node); 20 return ReduceJSCallConstruct(node);
45 case IrOpcode::kJSCallFunction: 21 case IrOpcode::kJSCallFunction:
46 return ReduceJSCallFunction(node); 22 return ReduceJSCallFunction(node);
47 default: 23 default:
48 break; 24 break;
49 } 25 }
50 return NoChange(); 26 return NoChange();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ++arity; 135 ++arity;
160 } 136 }
161 // Drop the {target} from the {node}. 137 // Drop the {target} from the {node}.
162 node->RemoveInput(0); 138 node->RemoveInput(0);
163 --arity; 139 --arity;
164 } else { 140 } else {
165 return NoChange(); 141 return NoChange();
166 } 142 }
167 // Change {node} to the new {JSCallFunction} operator. 143 // Change {node} to the new {JSCallFunction} operator.
168 NodeProperties::ChangeOp( 144 NodeProperties::ChangeOp(
169 node, javascript()->CallFunction(arity, CallCountFeedback(p.feedback()), 145 node, javascript()->CallFunction(arity, p.frequency(), VectorSlotPair(),
170 convert_mode, p.tail_call_mode())); 146 convert_mode, p.tail_call_mode()));
171 // Change context of {node} to the Function.prototype.apply context, 147 // Change context of {node} to the Function.prototype.apply context,
172 // to ensure any exception is thrown in the correct context. 148 // to ensure any exception is thrown in the correct context.
173 NodeProperties::ReplaceContextInput( 149 NodeProperties::ReplaceContextInput(
174 node, jsgraph()->HeapConstant(handle(apply->context(), isolate()))); 150 node, jsgraph()->HeapConstant(handle(apply->context(), isolate())));
175 // Try to further reduce the JSCallFunction {node}. 151 // Try to further reduce the JSCallFunction {node}.
176 Reduction const reduction = ReduceJSCallFunction(node); 152 Reduction const reduction = ReduceJSCallFunction(node);
177 return reduction.Changed() ? reduction : Changed(node); 153 return reduction.Changed() ? reduction : Changed(node);
178 } 154 }
179 155
(...skipping 19 matching lines...) Expand all
199 convert_mode = ConvertReceiverMode::kNullOrUndefined; 175 convert_mode = ConvertReceiverMode::kNullOrUndefined;
200 node->ReplaceInput(0, node->InputAt(1)); 176 node->ReplaceInput(0, node->InputAt(1));
201 node->ReplaceInput(1, jsgraph()->UndefinedConstant()); 177 node->ReplaceInput(1, jsgraph()->UndefinedConstant());
202 } else { 178 } else {
203 // Just remove the target, which is the first value input. 179 // Just remove the target, which is the first value input.
204 convert_mode = ConvertReceiverMode::kAny; 180 convert_mode = ConvertReceiverMode::kAny;
205 node->RemoveInput(0); 181 node->RemoveInput(0);
206 --arity; 182 --arity;
207 } 183 }
208 NodeProperties::ChangeOp( 184 NodeProperties::ChangeOp(
209 node, javascript()->CallFunction(arity, CallCountFeedback(p.feedback()), 185 node, javascript()->CallFunction(arity, p.frequency(), VectorSlotPair(),
210 convert_mode, p.tail_call_mode())); 186 convert_mode, p.tail_call_mode()));
211 // Try to further reduce the JSCallFunction {node}. 187 // Try to further reduce the JSCallFunction {node}.
212 Reduction const reduction = ReduceJSCallFunction(node); 188 Reduction const reduction = ReduceJSCallFunction(node);
213 return reduction.Changed() ? reduction : Changed(node); 189 return reduction.Changed() ? reduction : Changed(node);
214 } 190 }
215 191
216 192
217 Reduction JSCallReducer::ReduceJSCallFunction(Node* node) { 193 Reduction JSCallReducer::ReduceJSCallFunction(Node* node) {
218 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); 194 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
219 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); 195 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 NodeProperties::ReplaceValueInput(node, jsgraph()->Constant(bound_this), 256 NodeProperties::ReplaceValueInput(node, jsgraph()->Constant(bound_this),
281 1); 257 1);
282 // Insert the [[BoundArguments]] for {node}. 258 // Insert the [[BoundArguments]] for {node}.
283 for (int i = 0; i < bound_arguments->length(); ++i) { 259 for (int i = 0; i < bound_arguments->length(); ++i) {
284 node->InsertInput( 260 node->InsertInput(
285 graph()->zone(), i + 2, 261 graph()->zone(), i + 2,
286 jsgraph()->Constant(handle(bound_arguments->get(i), isolate()))); 262 jsgraph()->Constant(handle(bound_arguments->get(i), isolate())));
287 arity++; 263 arity++;
288 } 264 }
289 NodeProperties::ChangeOp(node, javascript()->CallFunction( 265 NodeProperties::ChangeOp(node, javascript()->CallFunction(
290 arity, CallCountFeedback(p.feedback()), 266 arity, p.frequency(), VectorSlotPair(),
291 convert_mode, p.tail_call_mode())); 267 convert_mode, p.tail_call_mode()));
292 // Try to further reduce the JSCallFunction {node}. 268 // Try to further reduce the JSCallFunction {node}.
293 Reduction const reduction = ReduceJSCallFunction(node); 269 Reduction const reduction = ReduceJSCallFunction(node);
294 return reduction.Changed() ? reduction : Changed(node); 270 return reduction.Changed() ? reduction : Changed(node);
295 } 271 }
296 272
297 // Don't mess with other {node}s that have a constant {target}. 273 // Don't mess with other {node}s that have a constant {target}.
298 // TODO(bmeurer): Also support proxies here. 274 // TODO(bmeurer): Also support proxies here.
299 return NoChange(); 275 return NoChange();
300 } 276 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 return jsgraph()->javascript(); 478 return jsgraph()->javascript();
503 } 479 }
504 480
505 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { 481 SimplifiedOperatorBuilder* JSCallReducer::simplified() const {
506 return jsgraph()->simplified(); 482 return jsgraph()->simplified();
507 } 483 }
508 484
509 } // namespace compiler 485 } // namespace compiler
510 } // namespace internal 486 } // namespace internal
511 } // namespace v8 487 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | src/compiler/js-inlining-heuristic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698