OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 all[1] = environment()->LookupRegister(receiver); | 986 all[1] = environment()->LookupRegister(receiver); |
987 int receiver_index = receiver.index(); | 987 int receiver_index = receiver.index(); |
988 for (int i = 2; i < static_cast<int>(arity); ++i) { | 988 for (int i = 2; i < static_cast<int>(arity); ++i) { |
989 all[i] = environment()->LookupRegister( | 989 all[i] = environment()->LookupRegister( |
990 interpreter::Register(receiver_index + i - 1)); | 990 interpreter::Register(receiver_index + i - 1)); |
991 } | 991 } |
992 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); | 992 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); |
993 return value; | 993 return value; |
994 } | 994 } |
995 | 995 |
996 void BytecodeGraphBuilder::BuildCall() { | 996 void BytecodeGraphBuilder::BuildCall(TailCallMode tail_call_mode) { |
997 FrameStateBeforeAndAfter states(this); | 997 FrameStateBeforeAndAfter states(this); |
998 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver | 998 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver |
999 // register has been loaded with null / undefined explicitly or we are sure it | 999 // register has been loaded with null / undefined explicitly or we are sure it |
1000 // is not null / undefined. | 1000 // is not null / undefined. |
1001 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | 1001 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; |
1002 Node* callee = | 1002 Node* callee = |
1003 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1003 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1004 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1004 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1005 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1005 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1006 VectorSlotPair feedback = | 1006 VectorSlotPair feedback = |
1007 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); | 1007 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); |
1008 | 1008 |
1009 // TODO(ishell): provide correct tail_call_mode value to CallFunction. | 1009 const Operator* call = javascript()->CallFunction( |
1010 const Operator* call = | 1010 arg_count + 1, feedback, receiver_hint, tail_call_mode); |
1011 javascript()->CallFunction(arg_count + 1, feedback, receiver_hint); | |
1012 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1011 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1013 environment()->BindAccumulator(value, &states); | 1012 environment()->BindAccumulator(value, &states); |
1014 } | 1013 } |
1015 | 1014 |
1016 void BytecodeGraphBuilder::VisitCall() { BuildCall(); } | 1015 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } |
1017 | 1016 |
1018 void BytecodeGraphBuilder::VisitCallWide() { BuildCall(); } | 1017 void BytecodeGraphBuilder::VisitCallWide() { |
| 1018 BuildCall(TailCallMode::kDisallow); |
| 1019 } |
| 1020 |
| 1021 void BytecodeGraphBuilder::VisitTailCall() { BuildCall(TailCallMode::kAllow); } |
| 1022 |
| 1023 void BytecodeGraphBuilder::VisitTailCallWide() { |
| 1024 BuildCall(TailCallMode::kAllow); |
| 1025 } |
1019 | 1026 |
1020 void BytecodeGraphBuilder::BuildCallJSRuntime() { | 1027 void BytecodeGraphBuilder::BuildCallJSRuntime() { |
1021 FrameStateBeforeAndAfter states(this); | 1028 FrameStateBeforeAndAfter states(this); |
1022 Node* callee = | 1029 Node* callee = |
1023 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); | 1030 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); |
1024 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1031 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1025 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1032 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1026 | 1033 |
1027 // Create node to perform the JS runtime call. | 1034 // Create node to perform the JS runtime call. |
1028 const Operator* call = javascript()->CallFunction(arg_count + 1); | 1035 const Operator* call = javascript()->CallFunction(arg_count + 1); |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 // Phi does not exist yet, introduce one. | 1752 // Phi does not exist yet, introduce one. |
1746 value = NewPhi(inputs, value, control); | 1753 value = NewPhi(inputs, value, control); |
1747 value->ReplaceInput(inputs - 1, other); | 1754 value->ReplaceInput(inputs - 1, other); |
1748 } | 1755 } |
1749 return value; | 1756 return value; |
1750 } | 1757 } |
1751 | 1758 |
1752 } // namespace compiler | 1759 } // namespace compiler |
1753 } // namespace internal | 1760 } // namespace internal |
1754 } // namespace v8 | 1761 } // namespace v8 |
OLD | NEW |