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 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1170 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1170 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1171 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1171 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1172 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1172 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1173 | 1173 |
1174 // Slot index of 0 is used indicate no feedback slot is available. Assert | 1174 // Slot index of 0 is used indicate no feedback slot is available. Assert |
1175 // the assumption that slot index 0 is never a valid feedback slot. | 1175 // the assumption that slot index 0 is never a valid feedback slot. |
1176 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 1176 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
1177 VectorSlotPair feedback = | 1177 VectorSlotPair feedback = |
1178 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); | 1178 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); |
1179 | 1179 |
1180 float const frequency = ComputeCallFrequency(); | |
1180 const Operator* call = javascript()->CallFunction( | 1181 const Operator* call = javascript()->CallFunction( |
1181 arg_count + 1, feedback, receiver_hint, tail_call_mode); | 1182 arg_count + 1, frequency, feedback, receiver_hint, tail_call_mode); |
1182 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1183 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1183 environment()->BindAccumulator(value, &states); | 1184 environment()->BindAccumulator(value, &states); |
1184 } | 1185 } |
1185 | 1186 |
1186 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } | 1187 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } |
1187 | 1188 |
1188 void BytecodeGraphBuilder::VisitTailCall() { | 1189 void BytecodeGraphBuilder::VisitTailCall() { |
1189 TailCallMode tail_call_mode = | 1190 TailCallMode tail_call_mode = |
1190 bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled() | 1191 bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled() |
1191 ? TailCallMode::kAllow | 1192 ? TailCallMode::kAllow |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1280 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1281 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1281 // Slot index of 0 is used indicate no feedback slot is available. Assert | 1282 // Slot index of 0 is used indicate no feedback slot is available. Assert |
1282 // the assumption that slot index 0 is never a valid feedback slot. | 1283 // the assumption that slot index 0 is never a valid feedback slot. |
1283 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 1284 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
1284 VectorSlotPair feedback = | 1285 VectorSlotPair feedback = |
1285 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); | 1286 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); |
1286 | 1287 |
1287 Node* new_target = environment()->LookupAccumulator(); | 1288 Node* new_target = environment()->LookupAccumulator(); |
1288 Node* callee = environment()->LookupRegister(callee_reg); | 1289 Node* callee = environment()->LookupRegister(callee_reg); |
1289 | 1290 |
1290 const Operator* call = | 1291 float const frequency = ComputeCallFrequency(); |
1291 javascript()->CallConstruct(static_cast<int>(arg_count) + 2, feedback); | 1292 const Operator* call = javascript()->CallConstruct( |
1293 static_cast<int>(arg_count) + 2, frequency, feedback); | |
1292 Node* value = ProcessCallNewArguments(call, callee, new_target, first_arg, | 1294 Node* value = ProcessCallNewArguments(call, callee, new_target, first_arg, |
1293 arg_count + 2); | 1295 arg_count + 2); |
1294 environment()->BindAccumulator(value, &states); | 1296 environment()->BindAccumulator(value, &states); |
1295 } | 1297 } |
1296 | 1298 |
1297 void BytecodeGraphBuilder::BuildThrow() { | 1299 void BytecodeGraphBuilder::BuildThrow() { |
1298 FrameStateBeforeAndAfter states(this); | 1300 FrameStateBeforeAndAfter states(this); |
1299 Node* value = environment()->LookupAccumulator(); | 1301 Node* value = environment()->LookupAccumulator(); |
1300 Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); | 1302 Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); |
1301 environment()->BindAccumulator(call, &states); | 1303 environment()->BindAccumulator(call, &states); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1352 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); | 1354 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); |
1353 DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); | 1355 DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); |
1354 Object* feedback = feedback_vector()->Get(slot); | 1356 Object* feedback = feedback_vector()->Get(slot); |
1355 CompareOperationHint hint = CompareOperationHint::kAny; | 1357 CompareOperationHint hint = CompareOperationHint::kAny; |
1356 if (feedback->IsSmi()) { | 1358 if (feedback->IsSmi()) { |
1357 hint = CompareOperationHintFromFeedback((Smi::cast(feedback))->value()); | 1359 hint = CompareOperationHintFromFeedback((Smi::cast(feedback))->value()); |
1358 } | 1360 } |
1359 return hint; | 1361 return hint; |
1360 } | 1362 } |
1361 | 1363 |
1364 float BytecodeGraphBuilder::ComputeCallFrequency() const { | |
1365 if (int const slot_index = bytecode_iterator().GetIndexOperand(3)) { | |
rmcilroy
2016/09/12 09:05:41
Drive-by-nit. Not super keen on this getting the b
Benedikt Meurer
2016/09/13 17:45:07
Done.
| |
1366 FeedbackVectorSlot const slot = feedback_vector()->ToSlot(slot_index + 1); | |
1367 Object* const feedback_extra = feedback_vector()->Get(slot); | |
1368 if (feedback_extra->IsSmi()) return Smi::cast(feedback_extra)->value(); | |
1369 } | |
1370 return 0.0f; | |
1371 } | |
1372 | |
1362 void BytecodeGraphBuilder::VisitAdd() { | 1373 void BytecodeGraphBuilder::VisitAdd() { |
1363 BuildBinaryOp( | 1374 BuildBinaryOp( |
1364 javascript()->Add(GetBinaryOperationHint(kBinaryOperationHintIndex))); | 1375 javascript()->Add(GetBinaryOperationHint(kBinaryOperationHintIndex))); |
1365 } | 1376 } |
1366 | 1377 |
1367 void BytecodeGraphBuilder::VisitSub() { | 1378 void BytecodeGraphBuilder::VisitSub() { |
1368 BuildBinaryOp(javascript()->Subtract( | 1379 BuildBinaryOp(javascript()->Subtract( |
1369 GetBinaryOperationHint(kBinaryOperationHintIndex))); | 1380 GetBinaryOperationHint(kBinaryOperationHintIndex))); |
1370 } | 1381 } |
1371 | 1382 |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2076 // Phi does not exist yet, introduce one. | 2087 // Phi does not exist yet, introduce one. |
2077 value = NewPhi(inputs, value, control); | 2088 value = NewPhi(inputs, value, control); |
2078 value->ReplaceInput(inputs - 1, other); | 2089 value->ReplaceInput(inputs - 1, other); |
2079 } | 2090 } |
2080 return value; | 2091 return value; |
2081 } | 2092 } |
2082 | 2093 |
2083 } // namespace compiler | 2094 } // namespace compiler |
2084 } // namespace internal | 2095 } // namespace internal |
2085 } // namespace v8 | 2096 } // namespace v8 |
OLD | NEW |