| 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/compilation-info.h" | 7 #include "src/compilation-info.h" |
| 8 #include "src/compiler/bytecode-branch-analysis.h" | 8 #include "src/compiler/bytecode-branch-analysis.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
| (...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 void BytecodeGraphBuilder::VisitToNumber() { | 1457 void BytecodeGraphBuilder::VisitToNumber() { |
| 1458 BuildCastOperator(javascript()->ToNumber()); | 1458 BuildCastOperator(javascript()->ToNumber()); |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 void BytecodeGraphBuilder::VisitJump() { BuildJump(); } | 1461 void BytecodeGraphBuilder::VisitJump() { BuildJump(); } |
| 1462 | 1462 |
| 1463 void BytecodeGraphBuilder::VisitJumpConstant() { BuildJump(); } | 1463 void BytecodeGraphBuilder::VisitJumpConstant() { BuildJump(); } |
| 1464 | 1464 |
| 1465 void BytecodeGraphBuilder::VisitJumpIfTrue() { BuildJumpIfTrue(); } |
| 1465 | 1466 |
| 1466 void BytecodeGraphBuilder::VisitJumpIfTrue() { | 1467 void BytecodeGraphBuilder::VisitJumpIfTrueConstant() { BuildJumpIfTrue(); } |
| 1467 BuildJumpIfEqual(jsgraph()->TrueConstant()); | |
| 1468 } | |
| 1469 | 1468 |
| 1470 void BytecodeGraphBuilder::VisitJumpIfTrueConstant() { | 1469 void BytecodeGraphBuilder::VisitJumpIfFalse() { BuildJumpIfFalse(); } |
| 1471 BuildJumpIfEqual(jsgraph()->TrueConstant()); | |
| 1472 } | |
| 1473 | 1470 |
| 1474 void BytecodeGraphBuilder::VisitJumpIfFalse() { | 1471 void BytecodeGraphBuilder::VisitJumpIfFalseConstant() { BuildJumpIfFalse(); } |
| 1475 BuildJumpIfEqual(jsgraph()->FalseConstant()); | |
| 1476 } | |
| 1477 | |
| 1478 void BytecodeGraphBuilder::VisitJumpIfFalseConstant() { | |
| 1479 BuildJumpIfEqual(jsgraph()->FalseConstant()); | |
| 1480 } | |
| 1481 | 1472 |
| 1482 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue() { | 1473 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue() { |
| 1483 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); | 1474 BuildJumpIfToBooleanTrue(); |
| 1484 } | 1475 } |
| 1485 | 1476 |
| 1486 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant() { | 1477 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant() { |
| 1487 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); | 1478 BuildJumpIfToBooleanTrue(); |
| 1488 } | 1479 } |
| 1489 | 1480 |
| 1490 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse() { | 1481 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse() { |
| 1491 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); | 1482 BuildJumpIfToBooleanFalse(); |
| 1492 } | 1483 } |
| 1493 | 1484 |
| 1494 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant() { | 1485 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant() { |
| 1495 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); | 1486 BuildJumpIfToBooleanFalse(); |
| 1496 } | 1487 } |
| 1497 | 1488 |
| 1498 void BytecodeGraphBuilder::VisitJumpIfNotHole() { BuildJumpIfNotHole(); } | 1489 void BytecodeGraphBuilder::VisitJumpIfNotHole() { BuildJumpIfNotHole(); } |
| 1499 | 1490 |
| 1500 void BytecodeGraphBuilder::VisitJumpIfNotHoleConstant() { | 1491 void BytecodeGraphBuilder::VisitJumpIfNotHoleConstant() { |
| 1501 BuildJumpIfNotHole(); | 1492 BuildJumpIfNotHole(); |
| 1502 } | 1493 } |
| 1503 | 1494 |
| 1504 void BytecodeGraphBuilder::VisitJumpIfNull() { | 1495 void BytecodeGraphBuilder::VisitJumpIfNull() { |
| 1505 BuildJumpIfEqual(jsgraph()->NullConstant()); | 1496 BuildJumpIfEqual(jsgraph()->NullConstant()); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 } | 1712 } |
| 1722 | 1713 |
| 1723 void BytecodeGraphBuilder::BuildLoopExitsForFunctionExit() { | 1714 void BytecodeGraphBuilder::BuildLoopExitsForFunctionExit() { |
| 1724 BuildLoopExitsUntilLoop(-1); | 1715 BuildLoopExitsUntilLoop(-1); |
| 1725 } | 1716 } |
| 1726 | 1717 |
| 1727 void BytecodeGraphBuilder::BuildJump() { | 1718 void BytecodeGraphBuilder::BuildJump() { |
| 1728 MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset()); | 1719 MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset()); |
| 1729 } | 1720 } |
| 1730 | 1721 |
| 1731 | 1722 void BytecodeGraphBuilder::BuildJumpIf(Node* condition) { |
| 1732 void BytecodeGraphBuilder::BuildConditionalJump(Node* condition) { | |
| 1733 NewBranch(condition); | 1723 NewBranch(condition); |
| 1734 Environment* if_false_environment = environment()->CopyForConditional(); | 1724 Environment* if_false_environment = environment()->CopyForConditional(); |
| 1735 NewIfTrue(); | 1725 NewIfTrue(); |
| 1736 MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset()); | 1726 MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset()); |
| 1737 set_environment(if_false_environment); | 1727 set_environment(if_false_environment); |
| 1738 NewIfFalse(); | 1728 NewIfFalse(); |
| 1739 } | 1729 } |
| 1740 | 1730 |
| 1731 void BytecodeGraphBuilder::BuildJumpIfNot(Node* condition) { |
| 1732 NewBranch(condition); |
| 1733 Environment* if_true_environment = environment()->CopyForConditional(); |
| 1734 NewIfFalse(); |
| 1735 MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset()); |
| 1736 set_environment(if_true_environment); |
| 1737 NewIfTrue(); |
| 1738 } |
| 1741 | 1739 |
| 1742 void BytecodeGraphBuilder::BuildJumpIfEqual(Node* comperand) { | 1740 void BytecodeGraphBuilder::BuildJumpIfEqual(Node* comperand) { |
| 1743 Node* accumulator = environment()->LookupAccumulator(); | 1741 Node* accumulator = environment()->LookupAccumulator(); |
| 1744 Node* condition = | 1742 Node* condition = |
| 1745 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), | 1743 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), |
| 1746 accumulator, comperand); | 1744 accumulator, comperand); |
| 1747 BuildConditionalJump(condition); | 1745 BuildJumpIf(condition); |
| 1748 } | 1746 } |
| 1749 | 1747 |
| 1748 void BytecodeGraphBuilder::BuildJumpIfFalse() { |
| 1749 BuildJumpIfNot(environment()->LookupAccumulator()); |
| 1750 } |
| 1750 | 1751 |
| 1751 void BytecodeGraphBuilder::BuildJumpIfToBooleanEqual(Node* comperand) { | 1752 void BytecodeGraphBuilder::BuildJumpIfTrue() { |
| 1753 BuildJumpIf(environment()->LookupAccumulator()); |
| 1754 } |
| 1755 |
| 1756 void BytecodeGraphBuilder::BuildJumpIfToBooleanTrue() { |
| 1752 Node* accumulator = environment()->LookupAccumulator(); | 1757 Node* accumulator = environment()->LookupAccumulator(); |
| 1753 Node* to_boolean = | 1758 Node* condition = |
| 1754 NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator); | 1759 NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator); |
| 1760 BuildJumpIf(condition); |
| 1761 } |
| 1762 |
| 1763 void BytecodeGraphBuilder::BuildJumpIfToBooleanFalse() { |
| 1764 Node* accumulator = environment()->LookupAccumulator(); |
| 1755 Node* condition = | 1765 Node* condition = |
| 1756 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), to_boolean, | 1766 NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator); |
| 1757 comperand); | 1767 BuildJumpIfNot(condition); |
| 1758 BuildConditionalJump(condition); | |
| 1759 } | 1768 } |
| 1760 | 1769 |
| 1761 void BytecodeGraphBuilder::BuildJumpIfNotHole() { | 1770 void BytecodeGraphBuilder::BuildJumpIfNotHole() { |
| 1762 Node* accumulator = environment()->LookupAccumulator(); | 1771 Node* accumulator = environment()->LookupAccumulator(); |
| 1763 Node* condition = | 1772 Node* condition = |
| 1764 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), | 1773 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), |
| 1765 accumulator, jsgraph()->TheHoleConstant()); | 1774 accumulator, jsgraph()->TheHoleConstant()); |
| 1766 Node* node = | 1775 BuildJumpIfNot(condition); |
| 1767 NewNode(common()->Select(MachineRepresentation::kTagged), condition, | |
| 1768 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); | |
| 1769 BuildConditionalJump(node); | |
| 1770 } | 1776 } |
| 1771 | 1777 |
| 1772 Node** BytecodeGraphBuilder::EnsureInputBufferSize(int size) { | 1778 Node** BytecodeGraphBuilder::EnsureInputBufferSize(int size) { |
| 1773 if (size > input_buffer_size_) { | 1779 if (size > input_buffer_size_) { |
| 1774 size = size + kInputBufferSizeIncrement + input_buffer_size_; | 1780 size = size + kInputBufferSizeIncrement + input_buffer_size_; |
| 1775 input_buffer_ = local_zone()->NewArray<Node*>(size); | 1781 input_buffer_ = local_zone()->NewArray<Node*>(size); |
| 1776 input_buffer_size_ = size; | 1782 input_buffer_size_ = size; |
| 1777 } | 1783 } |
| 1778 return input_buffer_; | 1784 return input_buffer_; |
| 1779 } | 1785 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 // Phi does not exist yet, introduce one. | 1957 // Phi does not exist yet, introduce one. |
| 1952 value = NewPhi(inputs, value, control); | 1958 value = NewPhi(inputs, value, control); |
| 1953 value->ReplaceInput(inputs - 1, other); | 1959 value->ReplaceInput(inputs - 1, other); |
| 1954 } | 1960 } |
| 1955 return value; | 1961 return value; |
| 1956 } | 1962 } |
| 1957 | 1963 |
| 1958 } // namespace compiler | 1964 } // namespace compiler |
| 1959 } // namespace internal | 1965 } // namespace internal |
| 1960 } // namespace v8 | 1966 } // namespace v8 |
| OLD | NEW |