| Index: src/compiler/js-call-reducer.cc
|
| diff --git a/src/compiler/js-call-reducer.cc b/src/compiler/js-call-reducer.cc
|
| index 102191551b8980308998e0c260e22c9b2878dae6..0eb573f35215991534dc3a981f4ff3687cc522d7 100644
|
| --- a/src/compiler/js-call-reducer.cc
|
| +++ b/src/compiler/js-call-reducer.cc
|
| @@ -52,8 +52,8 @@ Reduction JSCallReducer::Reduce(Node* node) {
|
|
|
| // ES6 section 22.1.1 The Array Constructor
|
| Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
|
| - Node* target = NodeProperties::GetValueInput(node, 0);
|
| DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
|
| + Node* target = NodeProperties::GetValueInput(node, 0);
|
| CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
|
|
|
| // Check if we have an allocation site from the CallIC.
|
| @@ -80,6 +80,22 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
|
| }
|
|
|
|
|
| +// ES6 section 20.1.1 The Number Constructor
|
| +Reduction JSCallReducer::ReduceNumberConstructor(Node* node) {
|
| + DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
|
| + CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
|
| +
|
| + // Turn the {node} into a {JSToNumber} call.
|
| + DCHECK_LE(2u, p.arity());
|
| + Node* value = (p.arity() == 2) ? jsgraph()->ZeroConstant()
|
| + : NodeProperties::GetValueInput(node, 2);
|
| + NodeProperties::RemoveFrameStateInput(node, 1);
|
| + NodeProperties::ReplaceValueInputs(node, value);
|
| + NodeProperties::ChangeOp(node, javascript()->ToNumber());
|
| + return Changed(node);
|
| +}
|
| +
|
| +
|
| // ES6 section 19.2.3.1 Function.prototype.apply ( thisArg, argArray )
|
| Reduction JSCallReducer::ReduceFunctionPrototypeApply(Node* node) {
|
| DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
|
| @@ -235,10 +251,15 @@ Reduction JSCallReducer::ReduceJSCallFunction(Node* node) {
|
| }
|
| }
|
|
|
| - // Check for the ArrayConstructor.
|
| + // Check for the Array constructor.
|
| if (*function == function->native_context()->array_function()) {
|
| return ReduceArrayConstructor(node);
|
| }
|
| +
|
| + // Check for the Number constructor.
|
| + if (*function == function->native_context()->number_function()) {
|
| + return ReduceNumberConstructor(node);
|
| + }
|
| }
|
|
|
| // Don't mess with other {node}s that have a constant {target}.
|
|
|