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/compiler/js-typed-lowering.h" | 5 #include "src/compiler/js-typed-lowering.h" |
6 | 6 |
7 #include "src/ast/modules.h" | 7 #include "src/ast/modules.h" |
8 #include "src/builtins/builtins-utils.h" | 8 #include "src/builtins/builtins-utils.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compilation-dependencies.h" | 10 #include "src/compilation-dependencies.h" |
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 NodeProperties::ChangeOp( | 2016 NodeProperties::ChangeOp( |
2017 node, common()->Call(Linkage::GetStubCallDescriptor( | 2017 node, common()->Call(Linkage::GetStubCallDescriptor( |
2018 isolate(), graph()->zone(), callable.descriptor(), 1 + arity, | 2018 isolate(), graph()->zone(), callable.descriptor(), 1 + arity, |
2019 CallDescriptor::kNeedsFrameState))); | 2019 CallDescriptor::kNeedsFrameState))); |
2020 return Changed(node); | 2020 return Changed(node); |
2021 } | 2021 } |
2022 | 2022 |
2023 return NoChange(); | 2023 return NoChange(); |
2024 } | 2024 } |
2025 | 2025 |
| 2026 Reduction JSTypedLowering::ReduceJSCallForwardVarargs(Node* node) { |
| 2027 DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, node->opcode()); |
| 2028 CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op()); |
| 2029 Node* target = NodeProperties::GetValueInput(node, 0); |
| 2030 Type* target_type = NodeProperties::GetType(target); |
| 2031 |
| 2032 // Check if {target} is a JSFunction. |
| 2033 if (target_type->Is(Type::Function())) { |
| 2034 // Compute flags for the call. |
| 2035 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; |
| 2036 if (p.tail_call_mode() == TailCallMode::kAllow) { |
| 2037 flags |= CallDescriptor::kSupportsTailCalls; |
| 2038 } |
| 2039 |
| 2040 // Patch {node} to an indirect call via CallFunctionForwardVarargs. |
| 2041 Callable callable = CodeFactory::CallFunctionForwardVarargs(isolate()); |
| 2042 node->InsertInput(graph()->zone(), 0, |
| 2043 jsgraph()->HeapConstant(callable.code())); |
| 2044 node->InsertInput(graph()->zone(), 2, jsgraph()->Constant(p.start_index())); |
| 2045 NodeProperties::ChangeOp( |
| 2046 node, |
| 2047 common()->Call(Linkage::GetStubCallDescriptor( |
| 2048 isolate(), graph()->zone(), callable.descriptor(), 1, flags))); |
| 2049 return Changed(node); |
| 2050 } |
| 2051 |
| 2052 return NoChange(); |
| 2053 } |
2026 | 2054 |
2027 Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) { | 2055 Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) { |
2028 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); | 2056 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); |
2029 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); | 2057 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); |
2030 int const arity = static_cast<int>(p.arity() - 2); | 2058 int const arity = static_cast<int>(p.arity() - 2); |
2031 ConvertReceiverMode convert_mode = p.convert_mode(); | 2059 ConvertReceiverMode convert_mode = p.convert_mode(); |
2032 Node* target = NodeProperties::GetValueInput(node, 0); | 2060 Node* target = NodeProperties::GetValueInput(node, 0); |
2033 Type* target_type = NodeProperties::GetType(target); | 2061 Type* target_type = NodeProperties::GetType(target); |
2034 Node* receiver = NodeProperties::GetValueInput(node, 1); | 2062 Node* receiver = NodeProperties::GetValueInput(node, 1); |
2035 Type* receiver_type = NodeProperties::GetType(receiver); | 2063 Type* receiver_type = NodeProperties::GetType(receiver); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 case IrOpcode::kJSStoreContext: | 2407 case IrOpcode::kJSStoreContext: |
2380 return ReduceJSStoreContext(node); | 2408 return ReduceJSStoreContext(node); |
2381 case IrOpcode::kJSLoadModule: | 2409 case IrOpcode::kJSLoadModule: |
2382 return ReduceJSLoadModule(node); | 2410 return ReduceJSLoadModule(node); |
2383 case IrOpcode::kJSStoreModule: | 2411 case IrOpcode::kJSStoreModule: |
2384 return ReduceJSStoreModule(node); | 2412 return ReduceJSStoreModule(node); |
2385 case IrOpcode::kJSConvertReceiver: | 2413 case IrOpcode::kJSConvertReceiver: |
2386 return ReduceJSConvertReceiver(node); | 2414 return ReduceJSConvertReceiver(node); |
2387 case IrOpcode::kJSCallConstruct: | 2415 case IrOpcode::kJSCallConstruct: |
2388 return ReduceJSCallConstruct(node); | 2416 return ReduceJSCallConstruct(node); |
| 2417 case IrOpcode::kJSCallForwardVarargs: |
| 2418 return ReduceJSCallForwardVarargs(node); |
2389 case IrOpcode::kJSCallFunction: | 2419 case IrOpcode::kJSCallFunction: |
2390 return ReduceJSCallFunction(node); | 2420 return ReduceJSCallFunction(node); |
2391 case IrOpcode::kJSForInNext: | 2421 case IrOpcode::kJSForInNext: |
2392 return ReduceJSForInNext(node); | 2422 return ReduceJSForInNext(node); |
2393 case IrOpcode::kJSLoadMessage: | 2423 case IrOpcode::kJSLoadMessage: |
2394 return ReduceJSLoadMessage(node); | 2424 return ReduceJSLoadMessage(node); |
2395 case IrOpcode::kJSStoreMessage: | 2425 case IrOpcode::kJSStoreMessage: |
2396 return ReduceJSStoreMessage(node); | 2426 return ReduceJSStoreMessage(node); |
2397 case IrOpcode::kJSGeneratorStore: | 2427 case IrOpcode::kJSGeneratorStore: |
2398 return ReduceJSGeneratorStore(node); | 2428 return ReduceJSGeneratorStore(node); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 } | 2460 } |
2431 | 2461 |
2432 | 2462 |
2433 CompilationDependencies* JSTypedLowering::dependencies() const { | 2463 CompilationDependencies* JSTypedLowering::dependencies() const { |
2434 return dependencies_; | 2464 return dependencies_; |
2435 } | 2465 } |
2436 | 2466 |
2437 } // namespace compiler | 2467 } // namespace compiler |
2438 } // namespace internal | 2468 } // namespace internal |
2439 } // namespace v8 | 2469 } // namespace v8 |
OLD | NEW |