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

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

Issue 2946893004: [WIP] Start adding JSCallWithVarargs
Patch Set: REBASE Created 3 years, 6 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 | « src/compiler/js-call-reducer.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | 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 69a1925b0a20bd85011b31c1fc006051715bb58e..5c1e394e3f256f3dcbd563d4e63649fc66d73b77 100644
--- a/src/compiler/js-call-reducer.cc
+++ b/src/compiler/js-call-reducer.cc
@@ -40,6 +40,20 @@ Reduction JSCallReducer::Reduce(Node* node) {
return NoChange();
}
+void JSCallReducer::Finalize() {
+ std::set<Node*> const waitlist = std::move(waitlist_);
+ for (Node* node : waitlist) {
+ if (!node->IsDead()) {
+ Reduction const reduction = Reduce(node);
+ if (reduction.Changed()) {
+ Node* replacement = reduction.replacement();
+ if (replacement != node) {
+ Replace(node, replacement);
+ }
+ }
+ }
+ }
+}
// ES6 section 22.1.1 The Array Constructor
Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
@@ -707,16 +721,45 @@ Reduction JSCallReducer::ReduceCallOrConstructWithArrayLikeOrSpread(
if (arguments_list->opcode() != IrOpcode::kJSCreateArguments)
return NoChange();
for (Edge edge : arguments_list->use_edges()) {
+ if (!NodeProperties::IsValueEdge(edge)) continue;
Node* const user = edge.from();
- if (user == node) continue;
- // Ignore uses as frame state's locals or parameters.
- if (user->opcode() == IrOpcode::kStateValues) continue;
- // Ignore uses as frame state's accumulator.
- if (user->opcode() == IrOpcode::kFrameState &&
- user->InputAt(2) == arguments_list) {
- continue;
+ switch (user->opcode()) {
+ case IrOpcode::kStateValues:
+ // Ignore uses as frame state's locals or parameters.
+ continue;
+ case IrOpcode::kFrameState:
+ // Ignore uses as frame state's accumulator.
+ if (user->InputAt(2) == arguments_list) continue;
+ break;
+ case IrOpcode::kReferenceEqual:
+ // Ignore uses for comparisons.
+ continue;
+ case IrOpcode::kJSCallWithArrayLike:
+ // Ignore uses as argumentsList input to calls with array like.
+ if (user->InputAt(2) == arguments_list) continue;
+ break;
+ case IrOpcode::kJSCallWithSpread: {
+ // Ignore uses as spread input to calls with spread.
+ SpreadWithArityParameter p = SpreadWithArityParameterOf(user->op());
+ int const arity = static_cast<int>(p.arity() - 1);
+ if (user->InputAt(arity) == arguments_list) continue;
+ break;
+ }
+ case IrOpcode::kJSConstructWithSpread: {
+ // Ignore uses as spread input to construct with spread.
+ SpreadWithArityParameter p = SpreadWithArityParameterOf(user->op());
+ int const arity = static_cast<int>(p.arity() - 2);
+ if (user->InputAt(arity) == arguments_list) continue;
+ break;
+ }
+ default:
+ break;
}
- if (!NodeProperties::IsValueEdge(edge)) continue;
+ // We currently reduce the {node} to something better than what
+ // it already is, but we might be able to do something about the
+ // {node} later, so put it onto the waitlist and try again during
+ // the finalization phase.
+ waitlist_.insert(node);
return NoChange();
}
« no previous file with comments | « src/compiler/js-call-reducer.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698