Chromium Code Reviews| Index: src/compiler/js-typed-lowering.cc |
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
| index a37f818761d6c4cc97dd0207af3e5a47862c8c7e..bcc4584bba0b19a467d05fa54021e94ee9b107d4 100644 |
| --- a/src/compiler/js-typed-lowering.cc |
| +++ b/src/compiler/js-typed-lowering.cc |
| @@ -1590,6 +1590,10 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) { |
| Handle<JSFunction>::cast(target_type->AsConstant()->Value()); |
| Handle<SharedFunctionInfo> shared(function->shared(), isolate()); |
| + // Class constructors are callable, but [[Call]] will raise an exception. |
| + // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList). |
|
Michael Starzinger
2015/11/04 13:43:14
nit: Parenthesis look weird, can we add a trailing
Benedikt Meurer
2015/11/04 13:51:09
Done.
|
| + if (IsClassConstructor(shared->kind())) return NoChange(); |
| + |
| // Grab the context from the {function}. |
| Node* context = jsgraph()->Constant(handle(function->context(), isolate())); |
| NodeProperties::ReplaceContextInput(node, context); |
| @@ -1611,12 +1615,17 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) { |
| CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; |
| if (p.AllowTailCalls()) flags |= CallDescriptor::kSupportsTailCalls; |
| - if (shared->internal_formal_parameter_count() == arity) { |
| + if (shared->internal_formal_parameter_count() == arity || |
| + shared->internal_formal_parameter_count() == |
| + SharedFunctionInfo::kDontAdaptArgumentsSentinel) { |
| // Patch {node} to a direct call. |
| + node->InsertInput(graph()->zone(), arity + 2, |
| + jsgraph()->Int32Constant(arity)); |
| NodeProperties::ChangeOp(node, |
| common()->Call(Linkage::GetJSCallDescriptor( |
| graph()->zone(), false, 1 + arity, flags))); |
| } else { |
| + // Patch {node} to an indirect call via the ArgumentsAdaptorTrampoline. |
| Callable callable = CodeFactory::ArgumentAdaptor(isolate()); |
| node->InsertInput(graph()->zone(), 0, |
| jsgraph()->HeapConstant(callable.code())); |