| 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/ast/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler/bytecode-branch-analysis.h" | 10 #include "src/compiler/bytecode-branch-analysis.h" |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 FrameStateBeforeAndAfter states(this); | 1157 FrameStateBeforeAndAfter states(this); |
| 1158 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | 1158 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; |
| 1159 Node* callee = | 1159 Node* callee = |
| 1160 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1160 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1161 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1161 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
| 1162 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1162 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
| 1163 | 1163 |
| 1164 // Slot index of 0 is used indicate no feedback slot is available. Assert | 1164 // Slot index of 0 is used indicate no feedback slot is available. Assert |
| 1165 // the assumption that slot index 0 is never a valid feedback slot. | 1165 // the assumption that slot index 0 is never a valid feedback slot. |
| 1166 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 1166 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
| 1167 VectorSlotPair feedback = | 1167 int const slot_id = bytecode_iterator().GetIndexOperand(3); |
| 1168 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); | 1168 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); |
| 1169 | 1169 |
| 1170 float const frequency = ComputeCallFrequency(slot_id); |
| 1170 const Operator* call = javascript()->CallFunction( | 1171 const Operator* call = javascript()->CallFunction( |
| 1171 arg_count + 1, feedback, receiver_hint, tail_call_mode); | 1172 arg_count + 1, frequency, feedback, receiver_hint, tail_call_mode); |
| 1172 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1173 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
| 1173 environment()->BindAccumulator(value, &states); | 1174 environment()->BindAccumulator(value, &states); |
| 1174 } | 1175 } |
| 1175 | 1176 |
| 1176 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } | 1177 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } |
| 1177 | 1178 |
| 1178 void BytecodeGraphBuilder::VisitTailCall() { | 1179 void BytecodeGraphBuilder::VisitTailCall() { |
| 1179 TailCallMode tail_call_mode = | 1180 TailCallMode tail_call_mode = |
| 1180 bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled() | 1181 bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled() |
| 1181 ? TailCallMode::kAllow | 1182 ? TailCallMode::kAllow |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 } | 1265 } |
| 1265 | 1266 |
| 1266 void BytecodeGraphBuilder::VisitNew() { | 1267 void BytecodeGraphBuilder::VisitNew() { |
| 1267 FrameStateBeforeAndAfter states(this); | 1268 FrameStateBeforeAndAfter states(this); |
| 1268 interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0); | 1269 interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0); |
| 1269 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 1270 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
| 1270 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1271 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
| 1271 // Slot index of 0 is used indicate no feedback slot is available. Assert | 1272 // Slot index of 0 is used indicate no feedback slot is available. Assert |
| 1272 // the assumption that slot index 0 is never a valid feedback slot. | 1273 // the assumption that slot index 0 is never a valid feedback slot. |
| 1273 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 1274 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
| 1274 VectorSlotPair feedback = | 1275 int const slot_id = bytecode_iterator().GetIndexOperand(3); |
| 1275 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); | 1276 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); |
| 1276 | 1277 |
| 1277 Node* new_target = environment()->LookupAccumulator(); | 1278 Node* new_target = environment()->LookupAccumulator(); |
| 1278 Node* callee = environment()->LookupRegister(callee_reg); | 1279 Node* callee = environment()->LookupRegister(callee_reg); |
| 1279 | 1280 |
| 1280 const Operator* call = | 1281 float const frequency = ComputeCallFrequency(slot_id); |
| 1281 javascript()->CallConstruct(static_cast<int>(arg_count) + 2, feedback); | 1282 const Operator* call = javascript()->CallConstruct( |
| 1283 static_cast<int>(arg_count) + 2, frequency, feedback); |
| 1282 Node* value = ProcessCallNewArguments(call, callee, new_target, first_arg, | 1284 Node* value = ProcessCallNewArguments(call, callee, new_target, first_arg, |
| 1283 arg_count + 2); | 1285 arg_count + 2); |
| 1284 environment()->BindAccumulator(value, &states); | 1286 environment()->BindAccumulator(value, &states); |
| 1285 } | 1287 } |
| 1286 | 1288 |
| 1287 void BytecodeGraphBuilder::BuildThrow() { | 1289 void BytecodeGraphBuilder::BuildThrow() { |
| 1288 FrameStateBeforeAndAfter states(this); | 1290 FrameStateBeforeAndAfter states(this); |
| 1289 Node* value = environment()->LookupAccumulator(); | 1291 Node* value = environment()->LookupAccumulator(); |
| 1290 Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); | 1292 Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); |
| 1291 environment()->BindAccumulator(call, &states); | 1293 environment()->BindAccumulator(call, &states); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); | 1344 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); |
| 1343 DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); | 1345 DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); |
| 1344 Object* feedback = feedback_vector()->Get(slot); | 1346 Object* feedback = feedback_vector()->Get(slot); |
| 1345 CompareOperationHint hint = CompareOperationHint::kAny; | 1347 CompareOperationHint hint = CompareOperationHint::kAny; |
| 1346 if (feedback->IsSmi()) { | 1348 if (feedback->IsSmi()) { |
| 1347 hint = CompareOperationHintFromFeedback((Smi::cast(feedback))->value()); | 1349 hint = CompareOperationHintFromFeedback((Smi::cast(feedback))->value()); |
| 1348 } | 1350 } |
| 1349 return hint; | 1351 return hint; |
| 1350 } | 1352 } |
| 1351 | 1353 |
| 1354 float BytecodeGraphBuilder::ComputeCallFrequency(int slot_id) const { |
| 1355 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { |
| 1356 CallICNexus nexus(feedback_vector(), feedback_vector()->ToSlot(slot_id)); |
| 1357 return nexus.ExtractCallCount(); |
| 1358 } |
| 1359 return 0.0f; |
| 1360 } |
| 1361 |
| 1352 void BytecodeGraphBuilder::VisitAdd() { | 1362 void BytecodeGraphBuilder::VisitAdd() { |
| 1353 BuildBinaryOp( | 1363 BuildBinaryOp( |
| 1354 javascript()->Add(GetBinaryOperationHint(kBinaryOperationHintIndex))); | 1364 javascript()->Add(GetBinaryOperationHint(kBinaryOperationHintIndex))); |
| 1355 } | 1365 } |
| 1356 | 1366 |
| 1357 void BytecodeGraphBuilder::VisitSub() { | 1367 void BytecodeGraphBuilder::VisitSub() { |
| 1358 BuildBinaryOp(javascript()->Subtract( | 1368 BuildBinaryOp(javascript()->Subtract( |
| 1359 GetBinaryOperationHint(kBinaryOperationHintIndex))); | 1369 GetBinaryOperationHint(kBinaryOperationHintIndex))); |
| 1360 } | 1370 } |
| 1361 | 1371 |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 // Phi does not exist yet, introduce one. | 2088 // Phi does not exist yet, introduce one. |
| 2079 value = NewPhi(inputs, value, control); | 2089 value = NewPhi(inputs, value, control); |
| 2080 value->ReplaceInput(inputs - 1, other); | 2090 value->ReplaceInput(inputs - 1, other); |
| 2081 } | 2091 } |
| 2082 return value; | 2092 return value; |
| 2083 } | 2093 } |
| 2084 | 2094 |
| 2085 } // namespace compiler | 2095 } // namespace compiler |
| 2086 } // namespace internal | 2096 } // namespace internal |
| 2087 } // namespace v8 | 2097 } // namespace v8 |
| OLD | NEW |