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

Unified Diff: src/compiler/js-call-reducer.cc

Issue 2721483003: [turbofan] Make sure that CallIC feedback actually helps. (Closed)
Patch Set: Fix logic error. Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-call-reducer.cc
diff --git a/src/compiler/js-call-reducer.cc b/src/compiler/js-call-reducer.cc
index fe15f5fa237d09f028712023e725ef2fee765191..a7c9c001bfc357e52bbc3667729a9763c5c0c8e1 100644
--- a/src/compiler/js-call-reducer.cc
+++ b/src/compiler/js-call-reducer.cc
@@ -485,6 +485,32 @@ Reduction JSCallReducer::ReduceSpreadCall(Node* node, int arity) {
return Changed(node);
}
+namespace {
+
+bool ShouldUseCallICFeedback(Node* node) {
+ HeapObjectMatcher m(node);
+ if (m.HasValue() || m.IsJSCreateClosure()) {
+ // Don't use CallIC feedback when we know the function
+ // being called, i.e. either know the closure itself or
+ // at least the SharedFunctionInfo.
+ return false;
+ } else if (m.IsPhi()) {
+ // Protect against endless loops here.
+ Node* control = NodeProperties::GetControlInput(node);
+ if (control->opcode() == IrOpcode::kLoop) return false;
+ // Check if {node} is a Phi of nodes which shouldn't
+ // use CallIC feedback (not looking through loops).
+ int const value_input_count = m.node()->op()->ValueInputCount();
+ for (int n = 0; n < value_input_count; ++n) {
+ if (ShouldUseCallICFeedback(node->InputAt(n))) return true;
+ }
+ return false;
+ }
+ return true;
+}
+
+} // namespace
+
Reduction JSCallReducer::ReduceJSCall(Node* node) {
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
CallParameters const& p = CallParametersOf(node->op());
@@ -624,6 +650,9 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
NodeProperties::ReplaceEffectInput(node, effect);
return ReduceArrayConstructor(node);
} else if (feedback->IsWeakCell()) {
+ // Check if we want to use CallIC feedback here.
+ if (!ShouldUseCallICFeedback(target)) return NoChange();
+
Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback);
if (cell->value()->IsJSFunction()) {
Node* target_function =
@@ -744,6 +773,9 @@ Reduction JSCallReducer::ReduceJSConstruct(Node* node) {
NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
return Changed(node);
} else if (feedback->IsWeakCell()) {
+ // Check if we want to use CallIC feedback here.
+ if (!ShouldUseCallICFeedback(target)) return NoChange();
+
Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback);
if (cell->value()->IsJSFunction()) {
Node* target_function =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698