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 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 environment()->BindAccumulator(node, &states); | 1387 environment()->BindAccumulator(node, &states); |
1388 } | 1388 } |
1389 | 1389 |
1390 | 1390 |
1391 void BytecodeGraphBuilder::VisitToName( | 1391 void BytecodeGraphBuilder::VisitToName( |
1392 const interpreter::BytecodeArrayIterator& iterator) { | 1392 const interpreter::BytecodeArrayIterator& iterator) { |
1393 BuildCastOperator(javascript()->ToName(), iterator); | 1393 BuildCastOperator(javascript()->ToName(), iterator); |
1394 } | 1394 } |
1395 | 1395 |
1396 | 1396 |
| 1397 void BytecodeGraphBuilder::VisitToObject( |
| 1398 const interpreter::BytecodeArrayIterator& iterator) { |
| 1399 BuildCastOperator(javascript()->ToObject(), iterator); |
| 1400 } |
| 1401 |
| 1402 |
1397 void BytecodeGraphBuilder::VisitToNumber( | 1403 void BytecodeGraphBuilder::VisitToNumber( |
1398 const interpreter::BytecodeArrayIterator& iterator) { | 1404 const interpreter::BytecodeArrayIterator& iterator) { |
1399 BuildCastOperator(javascript()->ToNumber(), iterator); | 1405 BuildCastOperator(javascript()->ToNumber(), iterator); |
1400 } | 1406 } |
1401 | 1407 |
1402 | 1408 |
1403 void BytecodeGraphBuilder::VisitToObject( | |
1404 const interpreter::BytecodeArrayIterator& iterator) { | |
1405 BuildCastOperator(javascript()->ToObject(), iterator); | |
1406 } | |
1407 | |
1408 | |
1409 void BytecodeGraphBuilder::VisitJump( | 1409 void BytecodeGraphBuilder::VisitJump( |
1410 const interpreter::BytecodeArrayIterator& iterator) { | 1410 const interpreter::BytecodeArrayIterator& iterator) { |
1411 BuildJump(); | 1411 BuildJump(); |
1412 } | 1412 } |
1413 | 1413 |
1414 | 1414 |
1415 void BytecodeGraphBuilder::VisitJumpConstant( | 1415 void BytecodeGraphBuilder::VisitJumpConstant( |
1416 const interpreter::BytecodeArrayIterator& iterator) { | 1416 const interpreter::BytecodeArrayIterator& iterator) { |
1417 BuildJump(); | 1417 BuildJump(); |
1418 } | 1418 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 const interpreter::BytecodeArrayIterator& iterator) { | 1506 const interpreter::BytecodeArrayIterator& iterator) { |
1507 Node* control = | 1507 Node* control = |
1508 NewNode(common()->Return(), environment()->LookupAccumulator()); | 1508 NewNode(common()->Return(), environment()->LookupAccumulator()); |
1509 UpdateControlDependencyToLeaveFunction(control); | 1509 UpdateControlDependencyToLeaveFunction(control); |
1510 set_environment(nullptr); | 1510 set_environment(nullptr); |
1511 } | 1511 } |
1512 | 1512 |
1513 | 1513 |
1514 void BytecodeGraphBuilder::VisitForInPrepare( | 1514 void BytecodeGraphBuilder::VisitForInPrepare( |
1515 const interpreter::BytecodeArrayIterator& iterator) { | 1515 const interpreter::BytecodeArrayIterator& iterator) { |
1516 UNIMPLEMENTED(); | 1516 Node* prepare = nullptr; |
| 1517 { |
| 1518 FrameStateBeforeAndAfter states(this, iterator); |
| 1519 Node* receiver = environment()->LookupAccumulator(); |
| 1520 prepare = NewNode(javascript()->ForInPrepare(), receiver); |
| 1521 environment()->RecordAfterState(prepare, &states); |
| 1522 } |
| 1523 // Project cache_type, cache_array, cache_length into register |
| 1524 // operands 1, 2, 3. |
| 1525 for (int i = 0; i < 3; i++) { |
| 1526 environment()->BindRegister(iterator.GetRegisterOperand(i), |
| 1527 NewNode(common()->Projection(i), prepare)); |
| 1528 } |
| 1529 } |
| 1530 |
| 1531 |
| 1532 void BytecodeGraphBuilder::VisitForInDone( |
| 1533 const interpreter::BytecodeArrayIterator& iterator) { |
| 1534 FrameStateBeforeAndAfter states(this, iterator); |
| 1535 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); |
| 1536 Node* cache_length = |
| 1537 environment()->LookupRegister(iterator.GetRegisterOperand(1)); |
| 1538 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length); |
| 1539 environment()->BindAccumulator(exit_cond, &states); |
1517 } | 1540 } |
1518 | 1541 |
1519 | 1542 |
1520 void BytecodeGraphBuilder::VisitForInNext( | 1543 void BytecodeGraphBuilder::VisitForInNext( |
1521 const interpreter::BytecodeArrayIterator& iterator) { | 1544 const interpreter::BytecodeArrayIterator& iterator) { |
1522 UNIMPLEMENTED(); | 1545 FrameStateBeforeAndAfter states(this, iterator); |
| 1546 Node* receiver = |
| 1547 environment()->LookupRegister(iterator.GetRegisterOperand(0)); |
| 1548 Node* cache_type = |
| 1549 environment()->LookupRegister(iterator.GetRegisterOperand(1)); |
| 1550 Node* cache_array = |
| 1551 environment()->LookupRegister(iterator.GetRegisterOperand(2)); |
| 1552 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(3)); |
| 1553 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array, |
| 1554 cache_type, index); |
| 1555 environment()->BindAccumulator(value, &states); |
1523 } | 1556 } |
1524 | 1557 |
1525 | 1558 |
1526 void BytecodeGraphBuilder::VisitForInDone( | 1559 void BytecodeGraphBuilder::VisitForInStep( |
1527 const interpreter::BytecodeArrayIterator& iterator) { | 1560 const interpreter::BytecodeArrayIterator& iterator) { |
1528 UNIMPLEMENTED(); | 1561 FrameStateBeforeAndAfter states(this, iterator); |
| 1562 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); |
| 1563 index = NewNode(javascript()->ForInStep(), index); |
| 1564 environment()->BindAccumulator(index, &states); |
1529 } | 1565 } |
1530 | 1566 |
1531 | 1567 |
1532 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( | 1568 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( |
1533 int source_offset, int target_offset) { | 1569 int source_offset, int target_offset) { |
1534 DCHECK_GE(source_offset, target_offset); | 1570 DCHECK_GE(source_offset, target_offset); |
1535 const ZoneVector<int>* branch_sites = | 1571 const ZoneVector<int>* branch_sites = |
1536 branch_analysis()->BackwardBranchesTargetting(target_offset); | 1572 branch_analysis()->BackwardBranchesTargetting(target_offset); |
1537 if (branch_sites->back() == source_offset) { | 1573 if (branch_sites->back() == source_offset) { |
1538 // The set of back branches is complete, merge them. | 1574 // The set of back branches is complete, merge them. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 | 1807 |
1772 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { | 1808 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { |
1773 if (environment()->IsMarkedAsUnreachable()) return; | 1809 if (environment()->IsMarkedAsUnreachable()) return; |
1774 environment()->MarkAsUnreachable(); | 1810 environment()->MarkAsUnreachable(); |
1775 exit_controls_.push_back(exit); | 1811 exit_controls_.push_back(exit); |
1776 } | 1812 } |
1777 | 1813 |
1778 } // namespace compiler | 1814 } // namespace compiler |
1779 } // namespace internal | 1815 } // namespace internal |
1780 } // namespace v8 | 1816 } // namespace v8 |
OLD | NEW |