Chromium Code Reviews| 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 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 UpdateControlDependencyToLeaveFunction(control); | 1011 UpdateControlDependencyToLeaveFunction(control); |
| 1012 environment()->BindAccumulator(value); | 1012 environment()->BindAccumulator(value); |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 | 1015 |
| 1016 void BytecodeGraphBuilder::BuildBinaryOp( | 1016 void BytecodeGraphBuilder::BuildBinaryOp( |
| 1017 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { | 1017 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { |
| 1018 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 1018 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0)); |
| 1019 Node* right = environment()->LookupAccumulator(); | 1019 Node* right = environment()->LookupAccumulator(); |
| 1020 Node* node = NewNode(js_op, left, right); | 1020 Node* node = NewNode(js_op, left, right); |
| 1021 | |
| 1022 AddEmptyFrameStateInputs(node); | 1021 AddEmptyFrameStateInputs(node); |
| 1023 environment()->BindAccumulator(node); | 1022 environment()->BindAccumulator(node); |
| 1024 } | 1023 } |
| 1025 | 1024 |
| 1026 | 1025 |
| 1027 void BytecodeGraphBuilder::VisitAdd( | 1026 void BytecodeGraphBuilder::VisitAdd( |
| 1028 const interpreter::BytecodeArrayIterator& iterator) { | 1027 const interpreter::BytecodeArrayIterator& iterator) { |
| 1029 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1028 BinaryOperationHints hints = BinaryOperationHints::Any(); |
| 1030 BuildBinaryOp(javascript()->Add(language_mode(), hints), iterator); | 1029 BuildBinaryOp(javascript()->Add(language_mode(), hints), iterator); |
| 1031 } | 1030 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1248 environment()->BindAccumulator(node); | 1247 environment()->BindAccumulator(node); |
| 1249 } | 1248 } |
| 1250 | 1249 |
| 1251 | 1250 |
| 1252 void BytecodeGraphBuilder::VisitToName( | 1251 void BytecodeGraphBuilder::VisitToName( |
| 1253 const interpreter::BytecodeArrayIterator& iterator) { | 1252 const interpreter::BytecodeArrayIterator& iterator) { |
| 1254 BuildCastOperator(javascript()->ToName(), iterator); | 1253 BuildCastOperator(javascript()->ToName(), iterator); |
| 1255 } | 1254 } |
| 1256 | 1255 |
| 1257 | 1256 |
| 1257 void BytecodeGraphBuilder::VisitToObject( | |
| 1258 const interpreter::BytecodeArrayIterator& iterator) { | |
| 1259 BuildCastOperator(javascript()->ToObject(), iterator); | |
| 1260 } | |
| 1261 | |
| 1262 | |
| 1258 void BytecodeGraphBuilder::VisitToNumber( | 1263 void BytecodeGraphBuilder::VisitToNumber( |
| 1259 const interpreter::BytecodeArrayIterator& iterator) { | 1264 const interpreter::BytecodeArrayIterator& iterator) { |
| 1260 BuildCastOperator(javascript()->ToNumber(), iterator); | 1265 BuildCastOperator(javascript()->ToNumber(), iterator); |
| 1261 } | 1266 } |
| 1262 | 1267 |
| 1263 | 1268 |
| 1264 void BytecodeGraphBuilder::VisitToObject( | |
| 1265 const interpreter::BytecodeArrayIterator& iterator) { | |
| 1266 BuildCastOperator(javascript()->ToObject(), iterator); | |
| 1267 } | |
| 1268 | |
| 1269 | |
| 1270 void BytecodeGraphBuilder::VisitJump( | 1269 void BytecodeGraphBuilder::VisitJump( |
| 1271 const interpreter::BytecodeArrayIterator& iterator) { | 1270 const interpreter::BytecodeArrayIterator& iterator) { |
| 1272 BuildJump(); | 1271 BuildJump(); |
| 1273 } | 1272 } |
| 1274 | 1273 |
| 1275 | 1274 |
| 1276 void BytecodeGraphBuilder::VisitJumpConstant( | 1275 void BytecodeGraphBuilder::VisitJumpConstant( |
| 1277 const interpreter::BytecodeArrayIterator& iterator) { | 1276 const interpreter::BytecodeArrayIterator& iterator) { |
| 1278 BuildJump(); | 1277 BuildJump(); |
| 1279 } | 1278 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1367 const interpreter::BytecodeArrayIterator& iterator) { | 1366 const interpreter::BytecodeArrayIterator& iterator) { |
| 1368 Node* control = | 1367 Node* control = |
| 1369 NewNode(common()->Return(), environment()->LookupAccumulator()); | 1368 NewNode(common()->Return(), environment()->LookupAccumulator()); |
| 1370 UpdateControlDependencyToLeaveFunction(control); | 1369 UpdateControlDependencyToLeaveFunction(control); |
| 1371 set_environment(nullptr); | 1370 set_environment(nullptr); |
| 1372 } | 1371 } |
| 1373 | 1372 |
| 1374 | 1373 |
| 1375 void BytecodeGraphBuilder::VisitForInPrepare( | 1374 void BytecodeGraphBuilder::VisitForInPrepare( |
| 1376 const interpreter::BytecodeArrayIterator& iterator) { | 1375 const interpreter::BytecodeArrayIterator& iterator) { |
| 1377 UNIMPLEMENTED(); | 1376 // Bytecode generator only reaches here if the receiver is not null |
| 1377 // or undefined, whereas ast-graph-builder has to check. Bytecodes | |
| 1378 // have already cast the object to JSReceiver, but JSForInPrepare | |
|
Benedikt Meurer
2015/12/18 07:55:50
Hm, I don't understand this comment. JSForInPrepar
| |
| 1379 // will do it again. | |
| 1380 Node* receiver = | |
| 1381 environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
| 1382 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver); | |
| 1383 AddEmptyFrameStateInputs(prepare); | |
| 1384 Node* cache_type = NewNode(common()->Projection(0), prepare); | |
| 1385 Node* cache_array = NewNode(common()->Projection(1), prepare); | |
| 1386 Node* cache_length = NewNode(common()->Projection(2), prepare); | |
| 1387 environment()->BindRegister(iterator.GetRegisterOperand(1), cache_type); | |
| 1388 environment()->BindRegister(iterator.GetRegisterOperand(2), cache_array); | |
| 1389 environment()->BindRegister(iterator.GetRegisterOperand(3), cache_length); | |
| 1390 } | |
| 1391 | |
| 1392 | |
| 1393 void BytecodeGraphBuilder::VisitForInDone( | |
| 1394 const interpreter::BytecodeArrayIterator& iterator) { | |
| 1395 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
| 1396 Node* cache_length = | |
| 1397 environment()->LookupRegister(iterator.GetRegisterOperand(1)); | |
| 1398 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length); | |
| 1399 AddEmptyFrameStateInputs(exit_cond); | |
| 1400 environment()->BindAccumulator(exit_cond); | |
| 1378 } | 1401 } |
| 1379 | 1402 |
| 1380 | 1403 |
| 1381 void BytecodeGraphBuilder::VisitForInNext( | 1404 void BytecodeGraphBuilder::VisitForInNext( |
| 1382 const interpreter::BytecodeArrayIterator& iterator) { | 1405 const interpreter::BytecodeArrayIterator& iterator) { |
| 1383 UNIMPLEMENTED(); | 1406 Node* receiver = |
| 1407 environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
| 1408 Node* cache_type = | |
| 1409 environment()->LookupRegister(iterator.GetRegisterOperand(1)); | |
| 1410 Node* cache_array = | |
| 1411 environment()->LookupRegister(iterator.GetRegisterOperand(2)); | |
| 1412 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(3)); | |
| 1413 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array, | |
| 1414 cache_type, index); | |
| 1415 AddEmptyFrameStateInputs(value); | |
| 1416 environment()->BindAccumulator(value); | |
| 1384 } | 1417 } |
| 1385 | 1418 |
| 1386 | 1419 |
| 1387 void BytecodeGraphBuilder::VisitForInDone( | 1420 void BytecodeGraphBuilder::VisitForInStep( |
| 1388 const interpreter::BytecodeArrayIterator& iterator) { | 1421 const interpreter::BytecodeArrayIterator& iterator) { |
| 1389 UNIMPLEMENTED(); | 1422 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); |
| 1423 index = NewNode(javascript()->ForInStep(), index); | |
| 1424 AddEmptyFrameStateInputs(index); | |
| 1425 environment()->BindRegister(iterator.GetRegisterOperand(0), index); | |
| 1390 } | 1426 } |
| 1391 | 1427 |
| 1392 | 1428 |
| 1393 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( | 1429 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( |
| 1394 int source_offset, int target_offset) { | 1430 int source_offset, int target_offset) { |
| 1395 DCHECK_GE(source_offset, target_offset); | 1431 DCHECK_GE(source_offset, target_offset); |
| 1396 const ZoneVector<int>* branch_sites = | 1432 const ZoneVector<int>* branch_sites = |
| 1397 branch_analysis()->BackwardBranchesTargetting(target_offset); | 1433 branch_analysis()->BackwardBranchesTargetting(target_offset); |
| 1398 if (branch_sites->back() == source_offset) { | 1434 if (branch_sites->back() == source_offset) { |
| 1399 // The set of back branches is complete, merge them. | 1435 // The set of back branches is complete, merge them. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1632 | 1668 |
| 1633 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { | 1669 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { |
| 1634 if (environment()->IsMarkedAsUnreachable()) return; | 1670 if (environment()->IsMarkedAsUnreachable()) return; |
| 1635 environment()->MarkAsUnreachable(); | 1671 environment()->MarkAsUnreachable(); |
| 1636 exit_controls_.push_back(exit); | 1672 exit_controls_.push_back(exit); |
| 1637 } | 1673 } |
| 1638 | 1674 |
| 1639 } // namespace compiler | 1675 } // namespace compiler |
| 1640 } // namespace internal | 1676 } // namespace internal |
| 1641 } // namespace v8 | 1677 } // namespace v8 |
| OLD | NEW |