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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 1410633006: [turbofan] Implement the call protocol properly for direct calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments. Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/linkage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 Node* effect = NodeProperties::GetEffectInput(node); 1583 Node* effect = NodeProperties::GetEffectInput(node);
1584 Node* control = NodeProperties::GetControlInput(node); 1584 Node* control = NodeProperties::GetControlInput(node);
1585 1585
1586 // Check if {target} is a known JSFunction. 1586 // Check if {target} is a known JSFunction.
1587 if (target_type->IsConstant() && 1587 if (target_type->IsConstant() &&
1588 target_type->AsConstant()->Value()->IsJSFunction()) { 1588 target_type->AsConstant()->Value()->IsJSFunction()) {
1589 Handle<JSFunction> function = 1589 Handle<JSFunction> function =
1590 Handle<JSFunction>::cast(target_type->AsConstant()->Value()); 1590 Handle<JSFunction>::cast(target_type->AsConstant()->Value());
1591 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); 1591 Handle<SharedFunctionInfo> shared(function->shared(), isolate());
1592 1592
1593 // Class constructors are callable, but [[Call]] will raise an exception.
1594 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList ).
1595 if (IsClassConstructor(shared->kind())) return NoChange();
1596
1593 // Grab the context from the {function}. 1597 // Grab the context from the {function}.
1594 Node* context = jsgraph()->Constant(handle(function->context(), isolate())); 1598 Node* context = jsgraph()->Constant(handle(function->context(), isolate()));
1595 NodeProperties::ReplaceContextInput(node, context); 1599 NodeProperties::ReplaceContextInput(node, context);
1596 1600
1597 // Check if we need to convert the {receiver}. 1601 // Check if we need to convert the {receiver}.
1598 if (is_sloppy(shared->language_mode()) && !shared->native() && 1602 if (is_sloppy(shared->language_mode()) && !shared->native() &&
1599 !receiver_type->Is(Type::Receiver())) { 1603 !receiver_type->Is(Type::Receiver())) {
1600 receiver = effect = 1604 receiver = effect =
1601 graph()->NewNode(javascript()->ConvertReceiver(convert_mode), 1605 graph()->NewNode(javascript()->ConvertReceiver(convert_mode),
1602 receiver, context, frame_state, effect, control); 1606 receiver, context, frame_state, effect, control);
1603 NodeProperties::ReplaceEffectInput(node, effect); 1607 NodeProperties::ReplaceEffectInput(node, effect);
1604 NodeProperties::ReplaceValueInput(node, receiver, 1); 1608 NodeProperties::ReplaceValueInput(node, receiver, 1);
1605 } 1609 }
1606 1610
1607 // Remove the eager bailout frame state. 1611 // Remove the eager bailout frame state.
1608 NodeProperties::RemoveFrameStateInput(node, 1); 1612 NodeProperties::RemoveFrameStateInput(node, 1);
1609 1613
1610 // Compute flags for the call. 1614 // Compute flags for the call.
1611 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; 1615 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState;
1612 if (p.AllowTailCalls()) flags |= CallDescriptor::kSupportsTailCalls; 1616 if (p.AllowTailCalls()) flags |= CallDescriptor::kSupportsTailCalls;
1613 1617
1614 if (shared->internal_formal_parameter_count() == arity) { 1618 if (shared->internal_formal_parameter_count() == arity ||
1619 shared->internal_formal_parameter_count() ==
1620 SharedFunctionInfo::kDontAdaptArgumentsSentinel) {
1615 // Patch {node} to a direct call. 1621 // Patch {node} to a direct call.
1622 node->InsertInput(graph()->zone(), arity + 2,
1623 jsgraph()->Int32Constant(arity));
1616 NodeProperties::ChangeOp(node, 1624 NodeProperties::ChangeOp(node,
1617 common()->Call(Linkage::GetJSCallDescriptor( 1625 common()->Call(Linkage::GetJSCallDescriptor(
1618 graph()->zone(), false, 1 + arity, flags))); 1626 graph()->zone(), false, 1 + arity, flags)));
1619 } else { 1627 } else {
1628 // Patch {node} to an indirect call via the ArgumentsAdaptorTrampoline.
1620 Callable callable = CodeFactory::ArgumentAdaptor(isolate()); 1629 Callable callable = CodeFactory::ArgumentAdaptor(isolate());
1621 node->InsertInput(graph()->zone(), 0, 1630 node->InsertInput(graph()->zone(), 0,
1622 jsgraph()->HeapConstant(callable.code())); 1631 jsgraph()->HeapConstant(callable.code()));
1623 node->InsertInput(graph()->zone(), 2, jsgraph()->Int32Constant(arity)); 1632 node->InsertInput(graph()->zone(), 2, jsgraph()->Int32Constant(arity));
1624 node->InsertInput( 1633 node->InsertInput(
1625 graph()->zone(), 3, 1634 graph()->zone(), 3,
1626 jsgraph()->Int32Constant(shared->internal_formal_parameter_count())); 1635 jsgraph()->Int32Constant(shared->internal_formal_parameter_count()));
1627 NodeProperties::ChangeOp( 1636 NodeProperties::ChangeOp(
1628 node, common()->Call(Linkage::GetStubCallDescriptor( 1637 node, common()->Call(Linkage::GetStubCallDescriptor(
1629 isolate(), graph()->zone(), callable.descriptor(), 1638 isolate(), graph()->zone(), callable.descriptor(),
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 } 2140 }
2132 2141
2133 2142
2134 MachineOperatorBuilder* JSTypedLowering::machine() const { 2143 MachineOperatorBuilder* JSTypedLowering::machine() const {
2135 return jsgraph()->machine(); 2144 return jsgraph()->machine();
2136 } 2145 }
2137 2146
2138 } // namespace compiler 2147 } // namespace compiler
2139 } // namespace internal 2148 } // namespace internal
2140 } // namespace v8 2149 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/linkage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698