OLD | NEW |
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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 node->ReplaceInput(0, a.allocation()); | 1256 node->ReplaceInput(0, a.allocation()); |
1257 node->ReplaceInput(1, a.effect()); | 1257 node->ReplaceInput(1, a.effect()); |
1258 node->set_op(common()->Finish(1)); | 1258 node->set_op(common()->Finish(1)); |
1259 node->TrimInputCount(2); | 1259 node->TrimInputCount(2); |
1260 return Changed(node); | 1260 return Changed(node); |
1261 } | 1261 } |
1262 return NoChange(); | 1262 return NoChange(); |
1263 } | 1263 } |
1264 | 1264 |
1265 | 1265 |
| 1266 Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) { |
| 1267 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); |
| 1268 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); |
| 1269 int const arity = static_cast<int>(p.arity() - 2); |
| 1270 Node* const function = NodeProperties::GetValueInput(node, 0); |
| 1271 Type* const function_type = NodeProperties::GetBounds(function).upper; |
| 1272 Node* const receiver = NodeProperties::GetValueInput(node, 1); |
| 1273 Type* const receiver_type = NodeProperties::GetBounds(receiver).upper; |
| 1274 Node* const effect = NodeProperties::GetEffectInput(node); |
| 1275 Node* const control = NodeProperties::GetControlInput(node); |
| 1276 |
| 1277 // Check that {function} is actually a JSFunction with the correct arity. |
| 1278 if (function_type->IsFunction() && |
| 1279 function_type->AsFunction()->Arity() == arity) { |
| 1280 // Check that the {receiver} doesn't need to be wrapped. |
| 1281 if (receiver_type->Is(Type::ReceiverOrUndefined())) { |
| 1282 Node* const context = graph()->NewNode( |
| 1283 simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), |
| 1284 function, effect, control); |
| 1285 NodeProperties::ReplaceContextInput(node, context); |
| 1286 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; |
| 1287 if (is_strict(p.language_mode())) { |
| 1288 flags |= CallDescriptor::kSupportsTailCalls; |
| 1289 } |
| 1290 node->set_op(common()->Call(Linkage::GetJSCallDescriptor( |
| 1291 graph()->zone(), false, 1 + arity, flags))); |
| 1292 return Changed(node); |
| 1293 } |
| 1294 } |
| 1295 return NoChange(); |
| 1296 } |
| 1297 |
| 1298 |
1266 Reduction JSTypedLowering::ReduceJSForInDone(Node* node) { | 1299 Reduction JSTypedLowering::ReduceJSForInDone(Node* node) { |
1267 DCHECK_EQ(IrOpcode::kJSForInDone, node->opcode()); | 1300 DCHECK_EQ(IrOpcode::kJSForInDone, node->opcode()); |
1268 node->set_op(machine()->Word32Equal()); | 1301 node->set_op(machine()->Word32Equal()); |
1269 node->TrimInputCount(2); | 1302 node->TrimInputCount(2); |
1270 return Changed(node); | 1303 return Changed(node); |
1271 } | 1304 } |
1272 | 1305 |
1273 | 1306 |
1274 Reduction JSTypedLowering::ReduceJSForInPrepare(Node* node) { | 1307 Reduction JSTypedLowering::ReduceJSForInPrepare(Node* node) { |
1275 DCHECK_EQ(IrOpcode::kJSForInPrepare, node->opcode()); | 1308 DCHECK_EQ(IrOpcode::kJSForInPrepare, node->opcode()); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 case IrOpcode::kJSCreateClosure: | 1657 case IrOpcode::kJSCreateClosure: |
1625 return ReduceJSCreateClosure(node); | 1658 return ReduceJSCreateClosure(node); |
1626 case IrOpcode::kJSCreateLiteralArray: | 1659 case IrOpcode::kJSCreateLiteralArray: |
1627 return ReduceJSCreateLiteralArray(node); | 1660 return ReduceJSCreateLiteralArray(node); |
1628 case IrOpcode::kJSCreateLiteralObject: | 1661 case IrOpcode::kJSCreateLiteralObject: |
1629 return ReduceJSCreateLiteralObject(node); | 1662 return ReduceJSCreateLiteralObject(node); |
1630 case IrOpcode::kJSCreateWithContext: | 1663 case IrOpcode::kJSCreateWithContext: |
1631 return ReduceJSCreateWithContext(node); | 1664 return ReduceJSCreateWithContext(node); |
1632 case IrOpcode::kJSCreateBlockContext: | 1665 case IrOpcode::kJSCreateBlockContext: |
1633 return ReduceJSCreateBlockContext(node); | 1666 return ReduceJSCreateBlockContext(node); |
| 1667 case IrOpcode::kJSCallFunction: |
| 1668 return ReduceJSCallFunction(node); |
1634 case IrOpcode::kJSForInDone: | 1669 case IrOpcode::kJSForInDone: |
1635 return ReduceJSForInDone(node); | 1670 return ReduceJSForInDone(node); |
1636 case IrOpcode::kJSForInNext: | 1671 case IrOpcode::kJSForInNext: |
1637 return ReduceJSForInNext(node); | 1672 return ReduceJSForInNext(node); |
1638 case IrOpcode::kJSForInPrepare: | 1673 case IrOpcode::kJSForInPrepare: |
1639 return ReduceJSForInPrepare(node); | 1674 return ReduceJSForInPrepare(node); |
1640 case IrOpcode::kJSForInStep: | 1675 case IrOpcode::kJSForInStep: |
1641 return ReduceJSForInStep(node); | 1676 return ReduceJSForInStep(node); |
1642 default: | 1677 default: |
1643 break; | 1678 break; |
(...skipping 28 matching lines...) Expand all Loading... |
1672 } | 1707 } |
1673 | 1708 |
1674 | 1709 |
1675 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1710 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1676 return jsgraph()->machine(); | 1711 return jsgraph()->machine(); |
1677 } | 1712 } |
1678 | 1713 |
1679 } // namespace compiler | 1714 } // namespace compiler |
1680 } // namespace internal | 1715 } // namespace internal |
1681 } // namespace v8 | 1716 } // namespace v8 |
OLD | NEW |