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

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

Issue 2949813002: [turbofan] Introduce new JSConstructWithArrayLike operator. (Closed)
Patch Set: Address feedback. 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 feff55dd6264c33920d4e4535d4c08d6c8c08730..69a1925b0a20bd85011b31c1fc006051715bb58e 100644
--- a/src/compiler/js-call-reducer.cc
+++ b/src/compiler/js-call-reducer.cc
@@ -24,6 +24,8 @@ Reduction JSCallReducer::Reduce(Node* node) {
switch (node->opcode()) {
case IrOpcode::kJSConstruct:
return ReduceJSConstruct(node);
+ case IrOpcode::kJSConstructWithArrayLike:
+ return ReduceJSConstructWithArrayLike(node);
case IrOpcode::kJSConstructWithSpread:
return ReduceJSConstructWithSpread(node);
case IrOpcode::kJSCall:
@@ -436,6 +438,30 @@ Reduction JSCallReducer::ReduceReflectApply(Node* node) {
return reduction.Changed() ? reduction : Changed(node);
}
+// ES6 section 26.1.2 Reflect.construct ( target, argumentsList [, newTarget] )
+Reduction JSCallReducer::ReduceReflectConstruct(Node* node) {
+ DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
+ CallParameters const& p = CallParametersOf(node->op());
+ int arity = static_cast<int>(p.arity() - 2);
+ DCHECK_LE(0, arity);
+ // Massage value inputs appropriately.
+ node->RemoveInput(0);
+ node->RemoveInput(0);
+ while (arity < 2) {
+ node->InsertInput(graph()->zone(), arity++, jsgraph()->UndefinedConstant());
+ }
+ if (arity < 3) {
+ node->InsertInput(graph()->zone(), arity++, node->InputAt(0));
+ }
+ while (arity-- > 3) {
+ node->RemoveInput(arity);
+ }
+ NodeProperties::ChangeOp(node,
+ javascript()->ConstructWithArrayLike(p.frequency()));
+ Reduction const reduction = ReduceJSConstructWithArrayLike(node);
+ return reduction.Changed() ? reduction : Changed(node);
+}
+
// ES6 section 26.1.7 Reflect.getPrototypeOf ( target )
Reduction JSCallReducer::ReduceReflectGetPrototypeOf(Node* node) {
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
@@ -664,6 +690,7 @@ Reduction JSCallReducer::ReduceCallOrConstructWithArrayLikeOrSpread(
Node* node, int arity, CallFrequency const& frequency) {
DCHECK(node->opcode() == IrOpcode::kJSCallWithArrayLike ||
node->opcode() == IrOpcode::kJSCallWithSpread ||
+ node->opcode() == IrOpcode::kJSConstructWithArrayLike ||
node->opcode() == IrOpcode::kJSConstructWithSpread);
// In case of a call/construct with spread, we need to
@@ -855,6 +882,8 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
return ReduceObjectPrototypeIsPrototypeOf(node);
case Builtins::kReflectApply:
return ReduceReflectApply(node);
+ case Builtins::kReflectConstruct:
+ return ReduceReflectConstruct(node);
case Builtins::kReflectGetPrototypeOf:
return ReduceReflectGetPrototypeOf(node);
case Builtins::kArrayForEach:
@@ -1118,6 +1147,12 @@ Reduction JSCallReducer::ReduceJSConstruct(Node* node) {
return NoChange();
}
+Reduction JSCallReducer::ReduceJSConstructWithArrayLike(Node* node) {
+ DCHECK_EQ(IrOpcode::kJSConstructWithArrayLike, node->opcode());
+ CallFrequency frequency = CallFrequencyOf(node->op());
+ return ReduceCallOrConstructWithArrayLikeOrSpread(node, 1, frequency);
+}
+
Reduction JSCallReducer::ReduceJSConstructWithSpread(Node* node) {
DCHECK_EQ(IrOpcode::kJSConstructWithSpread, node->opcode());
SpreadWithArityParameter const& p = SpreadWithArityParameterOf(node->op());
« 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