| 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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 | 1062 |
| 1063 void BytecodeGraphBuilder::BuildCall() { | 1063 void BytecodeGraphBuilder::BuildCall() { |
| 1064 FrameStateBeforeAndAfter states(this); | 1064 FrameStateBeforeAndAfter states(this); |
| 1065 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver | 1065 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver |
| 1066 // register has been loaded with null / undefined explicitly or we are sure it | 1066 // register has been loaded with null / undefined explicitly or we are sure it |
| 1067 // is not null / undefined. | 1067 // is not null / undefined. |
| 1068 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | 1068 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; |
| 1069 Node* callee = | 1069 Node* callee = |
| 1070 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1070 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1071 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1071 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
| 1072 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1072 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
| 1073 VectorSlotPair feedback = | 1073 VectorSlotPair feedback = |
| 1074 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); | 1074 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); |
| 1075 | 1075 |
| 1076 // TODO(ishell): provide correct tail_call_mode value to CallFunction. | 1076 // TODO(ishell): provide correct tail_call_mode value to CallFunction. |
| 1077 const Operator* call = javascript()->CallFunction( | 1077 const Operator* call = javascript()->CallFunction( |
| 1078 arg_count + 1, language_mode(), feedback, receiver_hint); | 1078 arg_count + 1, language_mode(), feedback, receiver_hint); |
| 1079 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1079 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
| 1080 environment()->BindAccumulator(value, &states); | 1080 environment()->BindAccumulator(value, &states); |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 void BytecodeGraphBuilder::VisitCall() { BuildCall(); } | 1083 void BytecodeGraphBuilder::VisitCall() { BuildCall(); } |
| 1084 | 1084 |
| 1085 void BytecodeGraphBuilder::VisitCallWide() { BuildCall(); } | 1085 void BytecodeGraphBuilder::VisitCallWide() { BuildCall(); } |
| 1086 | 1086 |
| 1087 void BytecodeGraphBuilder::BuildCallJSRuntime() { | 1087 void BytecodeGraphBuilder::BuildCallJSRuntime() { |
| 1088 FrameStateBeforeAndAfter states(this); | 1088 FrameStateBeforeAndAfter states(this); |
| 1089 Node* callee = | 1089 Node* callee = |
| 1090 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); | 1090 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); |
| 1091 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1091 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
| 1092 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1092 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
| 1093 | 1093 |
| 1094 // Create node to perform the JS runtime call. | 1094 // Create node to perform the JS runtime call. |
| 1095 const Operator* call = | 1095 const Operator* call = |
| 1096 javascript()->CallFunction(arg_count + 1, language_mode()); | 1096 javascript()->CallFunction(arg_count + 1, language_mode()); |
| 1097 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1097 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
| 1098 environment()->BindAccumulator(value, &states); | 1098 environment()->BindAccumulator(value, &states); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 void BytecodeGraphBuilder::VisitCallJSRuntime() { BuildCallJSRuntime(); } | 1101 void BytecodeGraphBuilder::VisitCallJSRuntime() { BuildCallJSRuntime(); } |
| 1102 | 1102 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1113 } | 1113 } |
| 1114 Node* value = MakeNode(call_runtime_op, static_cast<int>(arity), all, false); | 1114 Node* value = MakeNode(call_runtime_op, static_cast<int>(arity), all, false); |
| 1115 return value; | 1115 return value; |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 void BytecodeGraphBuilder::BuildCallRuntime() { | 1118 void BytecodeGraphBuilder::BuildCallRuntime() { |
| 1119 FrameStateBeforeAndAfter states(this); | 1119 FrameStateBeforeAndAfter states(this); |
| 1120 Runtime::FunctionId functionId = | 1120 Runtime::FunctionId functionId = |
| 1121 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); | 1121 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); |
| 1122 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 1122 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
| 1123 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1123 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
| 1124 | 1124 |
| 1125 // Create node to perform the runtime call. | 1125 // Create node to perform the runtime call. |
| 1126 const Operator* call = javascript()->CallRuntime(functionId, arg_count); | 1126 const Operator* call = javascript()->CallRuntime(functionId, arg_count); |
| 1127 Node* value = ProcessCallRuntimeArguments(call, first_arg, arg_count); | 1127 Node* value = ProcessCallRuntimeArguments(call, first_arg, arg_count); |
| 1128 environment()->BindAccumulator(value, &states); | 1128 environment()->BindAccumulator(value, &states); |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 void BytecodeGraphBuilder::VisitCallRuntime() { BuildCallRuntime(); } | 1131 void BytecodeGraphBuilder::VisitCallRuntime() { BuildCallRuntime(); } |
| 1132 | 1132 |
| 1133 void BytecodeGraphBuilder::VisitCallRuntimeWide() { BuildCallRuntime(); } | 1133 void BytecodeGraphBuilder::VisitCallRuntimeWide() { BuildCallRuntime(); } |
| 1134 | 1134 |
| 1135 void BytecodeGraphBuilder::BuildCallRuntimeForPair() { | 1135 void BytecodeGraphBuilder::BuildCallRuntimeForPair() { |
| 1136 FrameStateBeforeAndAfter states(this); | 1136 FrameStateBeforeAndAfter states(this); |
| 1137 Runtime::FunctionId functionId = | 1137 Runtime::FunctionId functionId = |
| 1138 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); | 1138 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); |
| 1139 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 1139 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
| 1140 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1140 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
| 1141 interpreter::Register first_return = | 1141 interpreter::Register first_return = |
| 1142 bytecode_iterator().GetRegisterOperand(3); | 1142 bytecode_iterator().GetRegisterOperand(3); |
| 1143 | 1143 |
| 1144 // Create node to perform the runtime call. | 1144 // Create node to perform the runtime call. |
| 1145 const Operator* call = javascript()->CallRuntime(functionId, arg_count); | 1145 const Operator* call = javascript()->CallRuntime(functionId, arg_count); |
| 1146 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); | 1146 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); |
| 1147 environment()->BindRegistersToProjections(first_return, return_pair, &states); | 1147 environment()->BindRegistersToProjections(first_return, return_pair, &states); |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 void BytecodeGraphBuilder::VisitCallRuntimeForPair() { | 1150 void BytecodeGraphBuilder::VisitCallRuntimeForPair() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1169 // Original constructor is the same as the callee. | 1169 // Original constructor is the same as the callee. |
| 1170 all[arity - 1] = environment()->LookupRegister(callee); | 1170 all[arity - 1] = environment()->LookupRegister(callee); |
| 1171 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); | 1171 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); |
| 1172 return value; | 1172 return value; |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 void BytecodeGraphBuilder::BuildCallConstruct() { | 1175 void BytecodeGraphBuilder::BuildCallConstruct() { |
| 1176 FrameStateBeforeAndAfter states(this); | 1176 FrameStateBeforeAndAfter states(this); |
| 1177 interpreter::Register callee = bytecode_iterator().GetRegisterOperand(0); | 1177 interpreter::Register callee = bytecode_iterator().GetRegisterOperand(0); |
| 1178 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 1178 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
| 1179 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1179 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
| 1180 | 1180 |
| 1181 // TODO(turbofan): Pass the feedback here. | 1181 // TODO(turbofan): Pass the feedback here. |
| 1182 const Operator* call = javascript()->CallConstruct( | 1182 const Operator* call = javascript()->CallConstruct( |
| 1183 static_cast<int>(arg_count) + 2, VectorSlotPair()); | 1183 static_cast<int>(arg_count) + 2, VectorSlotPair()); |
| 1184 Node* value = ProcessCallNewArguments(call, callee, first_arg, arg_count + 2); | 1184 Node* value = ProcessCallNewArguments(call, callee, first_arg, arg_count + 2); |
| 1185 environment()->BindAccumulator(value, &states); | 1185 environment()->BindAccumulator(value, &states); |
| 1186 } | 1186 } |
| 1187 | 1187 |
| 1188 void BytecodeGraphBuilder::VisitNew() { BuildCallConstruct(); } | 1188 void BytecodeGraphBuilder::VisitNew() { BuildCallConstruct(); } |
| 1189 | 1189 |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 // Phi does not exist yet, introduce one. | 1813 // Phi does not exist yet, introduce one. |
| 1814 value = NewPhi(inputs, value, control); | 1814 value = NewPhi(inputs, value, control); |
| 1815 value->ReplaceInput(inputs - 1, other); | 1815 value->ReplaceInput(inputs - 1, other); |
| 1816 } | 1816 } |
| 1817 return value; | 1817 return value; |
| 1818 } | 1818 } |
| 1819 | 1819 |
| 1820 } // namespace compiler | 1820 } // namespace compiler |
| 1821 } // namespace internal | 1821 } // namespace internal |
| 1822 } // namespace v8 | 1822 } // namespace v8 |
| OLD | NEW |