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 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 all[1] = environment()->LookupRegister(receiver); | 1034 all[1] = environment()->LookupRegister(receiver); |
1035 int receiver_index = receiver.index(); | 1035 int receiver_index = receiver.index(); |
1036 for (int i = 2; i < static_cast<int>(arity); ++i) { | 1036 for (int i = 2; i < static_cast<int>(arity); ++i) { |
1037 all[i] = environment()->LookupRegister( | 1037 all[i] = environment()->LookupRegister( |
1038 interpreter::Register(receiver_index + i - 1)); | 1038 interpreter::Register(receiver_index + i - 1)); |
1039 } | 1039 } |
1040 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); | 1040 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); |
1041 return value; | 1041 return value; |
1042 } | 1042 } |
1043 | 1043 |
1044 void BytecodeGraphBuilder::BuildCall() { | 1044 void BytecodeGraphBuilder::BuildCall(TailCallMode tail_call_mode) { |
1045 FrameStateBeforeAndAfter states(this); | 1045 FrameStateBeforeAndAfter states(this); |
1046 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver | 1046 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver |
1047 // register has been loaded with null / undefined explicitly or we are sure it | 1047 // register has been loaded with null / undefined explicitly or we are sure it |
1048 // is not null / undefined. | 1048 // is not null / undefined. |
1049 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | 1049 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; |
1050 Node* callee = | 1050 Node* callee = |
1051 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1051 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1052 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1052 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1053 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1053 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1054 VectorSlotPair feedback = | 1054 VectorSlotPair feedback = |
1055 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); | 1055 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); |
1056 | 1056 |
1057 // TODO(ishell): provide correct tail_call_mode value to CallFunction. | |
1058 const Operator* call = javascript()->CallFunction( | 1057 const Operator* call = javascript()->CallFunction( |
1059 arg_count + 1, language_mode(), feedback, receiver_hint); | 1058 arg_count + 1, language_mode(), feedback, receiver_hint, tail_call_mode); |
1060 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1059 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1061 environment()->BindAccumulator(value, &states); | 1060 environment()->BindAccumulator(value, &states); |
1062 } | 1061 } |
1063 | 1062 |
1064 void BytecodeGraphBuilder::VisitCall() { BuildCall(); } | 1063 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } |
1065 | 1064 |
1066 void BytecodeGraphBuilder::VisitCallWide() { BuildCall(); } | 1065 void BytecodeGraphBuilder::VisitCallWide() { |
| 1066 BuildCall(TailCallMode::kDisallow); |
| 1067 } |
| 1068 |
| 1069 void BytecodeGraphBuilder::VisitTailCall() { BuildCall(TailCallMode::kAllow); } |
| 1070 |
| 1071 void BytecodeGraphBuilder::VisitTailCallWide() { |
| 1072 BuildCall(TailCallMode::kAllow); |
| 1073 } |
1067 | 1074 |
1068 void BytecodeGraphBuilder::BuildCallJSRuntime() { | 1075 void BytecodeGraphBuilder::BuildCallJSRuntime() { |
1069 FrameStateBeforeAndAfter states(this); | 1076 FrameStateBeforeAndAfter states(this); |
1070 Node* callee = | 1077 Node* callee = |
1071 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); | 1078 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); |
1072 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1079 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1073 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1080 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1074 | 1081 |
1075 // Create node to perform the JS runtime call. | 1082 // Create node to perform the JS runtime call. |
1076 const Operator* call = | 1083 const Operator* call = |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 // Phi does not exist yet, introduce one. | 1803 // Phi does not exist yet, introduce one. |
1797 value = NewPhi(inputs, value, control); | 1804 value = NewPhi(inputs, value, control); |
1798 value->ReplaceInput(inputs - 1, other); | 1805 value->ReplaceInput(inputs - 1, other); |
1799 } | 1806 } |
1800 return value; | 1807 return value; |
1801 } | 1808 } |
1802 | 1809 |
1803 } // namespace compiler | 1810 } // namespace compiler |
1804 } // namespace internal | 1811 } // namespace internal |
1805 } // namespace v8 | 1812 } // namespace v8 |
OLD | NEW |