OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 23 matching lines...) Expand all Loading... | |
34 #include "compiler.h" | 34 #include "compiler.h" |
35 #include "debug.h" | 35 #include "debug.h" |
36 #include "full-codegen.h" | 36 #include "full-codegen.h" |
37 #include "parser.h" | 37 #include "parser.h" |
38 #include "scopes.h" | 38 #include "scopes.h" |
39 #include "stub-cache.h" | 39 #include "stub-cache.h" |
40 | 40 |
41 namespace v8 { | 41 namespace v8 { |
42 namespace internal { | 42 namespace internal { |
43 | 43 |
44 | |
45 class JumpPatchSite BASE_EMBEDDED { | |
46 public: | |
47 JumpPatchSite(MacroAssembler* masm) : masm_(masm), info_emitted_(false) { } | |
Vitaly Repeshko
2010/12/10 13:38:56
Missing "explicit".
fschneider
2010/12/10 14:32:17
Done.
| |
48 | |
49 ~JumpPatchSite() { | |
50 ASSERT(patch_site_.is_bound() == info_emitted_); | |
51 } | |
52 | |
53 void EmitJump(NearLabel* target) { | |
54 ASSERT(!patch_site_.is_bound() && !info_emitted_); | |
55 masm_->bind(&patch_site_); | |
56 masm_->jmp(target); | |
57 } | |
58 | |
59 void EmitPatchInfo() { | |
60 int delta_to_patch_site = masm_->SizeOfCodeGeneratedSince(&patch_site_); | |
61 ASSERT(is_int8(delta_to_patch_site)); | |
62 masm_->test(eax, Immediate(delta_to_patch_site)); | |
63 info_emitted_ = true; | |
64 } | |
65 | |
66 bool is_bound() { return patch_site_.is_bound(); } | |
Vitaly Repeshko
2010/12/10 13:38:56
Can it be made const?
fschneider
2010/12/10 14:32:17
Done.
| |
67 | |
68 private: | |
69 MacroAssembler* masm_; | |
70 Label patch_site_; | |
71 bool info_emitted_; | |
Vitaly Repeshko
2010/12/10 13:38:56
Should probably be guarded by #ifdef DEBUG.
fschneider
2010/12/10 14:32:17
Done.
| |
72 }; | |
73 | |
74 | |
44 #define __ ACCESS_MASM(masm_) | 75 #define __ ACCESS_MASM(masm_) |
45 | 76 |
46 // Generate code for a JS function. On entry to the function the receiver | 77 // Generate code for a JS function. On entry to the function the receiver |
47 // and arguments have been pushed on the stack left to right, with the | 78 // and arguments have been pushed on the stack left to right, with the |
48 // return address on top of them. The actual argument count matches the | 79 // return address on top of them. The actual argument count matches the |
49 // formal parameter count expected by the function. | 80 // formal parameter count expected by the function. |
50 // | 81 // |
51 // The live registers are: | 82 // The live registers are: |
52 // o edi: the JS function object being called (ie, ourselves) | 83 // o edi: the JS function object being called (ie, ourselves) |
53 // o esi: our context | 84 // o esi: our context |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 Comment cmnt(masm_, "[ Case comparison"); | 739 Comment cmnt(masm_, "[ Case comparison"); |
709 __ bind(&next_test); | 740 __ bind(&next_test); |
710 next_test.Unuse(); | 741 next_test.Unuse(); |
711 | 742 |
712 // Compile the label expression. | 743 // Compile the label expression. |
713 VisitForAccumulatorValue(clause->label()); | 744 VisitForAccumulatorValue(clause->label()); |
714 | 745 |
715 // Perform the comparison as if via '==='. | 746 // Perform the comparison as if via '==='. |
716 __ mov(edx, Operand(esp, 0)); // Switch value. | 747 __ mov(edx, Operand(esp, 0)); // Switch value. |
717 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); | 748 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); |
749 JumpPatchSite patch_site(masm_); | |
718 if (inline_smi_code) { | 750 if (inline_smi_code) { |
719 NearLabel slow_case; | 751 NearLabel slow_case; |
720 __ mov(ecx, edx); | 752 __ mov(ecx, edx); |
721 __ or_(ecx, Operand(eax)); | 753 __ or_(ecx, Operand(eax)); |
722 __ test(ecx, Immediate(kSmiTagMask)); | 754 __ test(ecx, Immediate(kSmiTagMask)); |
723 __ j(not_zero, &slow_case, not_taken); | 755 patch_site.EmitJump(&slow_case); |
724 __ cmp(edx, Operand(eax)); | 756 __ cmp(edx, Operand(eax)); |
725 __ j(not_equal, &next_test); | 757 __ j(not_equal, &next_test); |
726 __ Drop(1); // Switch value is no longer needed. | 758 __ Drop(1); // Switch value is no longer needed. |
727 __ jmp(clause->body_target()->entry_label()); | 759 __ jmp(clause->body_target()->entry_label()); |
728 __ bind(&slow_case); | 760 __ bind(&slow_case); |
729 } | 761 } |
730 | 762 |
731 // Record position before stub call for type feedback. | 763 // Record position before stub call for type feedback. |
732 SetSourcePosition(clause->position()); | 764 SetSourcePosition(clause->position()); |
733 | |
734 Handle<Code> ic = CompareIC::GetUninitialized(Token::EQ_STRICT); | 765 Handle<Code> ic = CompareIC::GetUninitialized(Token::EQ_STRICT); |
735 __ call(ic, RelocInfo::CODE_TARGET); | 766 EmitCallIC(ic, &patch_site); |
736 | 767 |
737 __ test(eax, Operand(eax)); | 768 __ test(eax, Operand(eax)); |
738 __ j(not_equal, &next_test); | 769 __ j(not_equal, &next_test); |
739 __ Drop(1); // Switch value is no longer needed. | 770 __ Drop(1); // Switch value is no longer needed. |
740 __ jmp(clause->body_target()->entry_label()); | 771 __ jmp(clause->body_target()->entry_label()); |
741 } | 772 } |
742 | 773 |
743 // Discard the test value and jump to the default if present, otherwise to | 774 // Discard the test value and jump to the default if present, otherwise to |
744 // the end of the statement. | 775 // the end of the statement. |
745 __ bind(&next_test); | 776 __ bind(&next_test); |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1545 SetSourcePosition(prop->position()); | 1576 SetSourcePosition(prop->position()); |
1546 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | 1577 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
1547 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1578 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
1548 } | 1579 } |
1549 | 1580 |
1550 | 1581 |
1551 void FullCodeGenerator::EmitConstantSmiAdd(Expression* expr, | 1582 void FullCodeGenerator::EmitConstantSmiAdd(Expression* expr, |
1552 OverwriteMode mode, | 1583 OverwriteMode mode, |
1553 bool left_is_constant_smi, | 1584 bool left_is_constant_smi, |
1554 Smi* value) { | 1585 Smi* value) { |
1555 NearLabel call_stub; | 1586 NearLabel call_stub, done; |
1556 Label done; | |
1557 __ add(Operand(eax), Immediate(value)); | 1587 __ add(Operand(eax), Immediate(value)); |
1558 __ j(overflow, &call_stub); | 1588 __ j(overflow, &call_stub); |
1559 __ test(eax, Immediate(kSmiTagMask)); | 1589 __ test(eax, Immediate(kSmiTagMask)); |
1560 __ j(zero, &done); | 1590 JumpPatchSite patch_site(masm_); |
1591 patch_site.EmitJump(&call_stub); | |
1592 __ jmp(&done); | |
1561 | 1593 |
1562 // Undo the optimistic add operation and call the shared stub. | 1594 // Undo the optimistic add operation and call the shared stub. |
1563 __ bind(&call_stub); | 1595 __ bind(&call_stub); |
1564 __ sub(Operand(eax), Immediate(value)); | 1596 __ sub(Operand(eax), Immediate(value)); |
1565 Token::Value op = Token::ADD; | 1597 Token::Value op = Token::ADD; |
1566 TypeRecordingBinaryOpStub stub(op, mode); | 1598 TypeRecordingBinaryOpStub stub(op, mode); |
1567 if (left_is_constant_smi) { | 1599 if (left_is_constant_smi) { |
1568 __ mov(edx, Immediate(value)); | 1600 __ mov(edx, Immediate(value)); |
1569 } else { | 1601 } else { |
1570 __ mov(edx, eax); | 1602 __ mov(edx, eax); |
1571 __ mov(eax, Immediate(value)); | 1603 __ mov(eax, Immediate(value)); |
1572 } | 1604 } |
1573 __ CallStub(&stub); | 1605 EmitCallIC(stub.GetCode(), &patch_site); |
1606 | |
1574 __ bind(&done); | 1607 __ bind(&done); |
1575 context()->Plug(eax); | 1608 context()->Plug(eax); |
1576 } | 1609 } |
1577 | 1610 |
1578 | 1611 |
1579 void FullCodeGenerator::EmitConstantSmiSub(Expression* expr, | 1612 void FullCodeGenerator::EmitConstantSmiSub(Expression* expr, |
1580 OverwriteMode mode, | 1613 OverwriteMode mode, |
1581 bool left_is_constant_smi, | 1614 bool left_is_constant_smi, |
1582 Smi* value) { | 1615 Smi* value) { |
1583 Label call_stub, done; | 1616 NearLabel call_stub, done; |
1584 if (left_is_constant_smi) { | 1617 if (left_is_constant_smi) { |
1585 __ mov(ecx, eax); | 1618 __ mov(ecx, eax); |
1586 __ mov(eax, Immediate(value)); | 1619 __ mov(eax, Immediate(value)); |
1587 __ sub(Operand(eax), ecx); | 1620 __ sub(Operand(eax), ecx); |
1588 } else { | 1621 } else { |
1589 __ sub(Operand(eax), Immediate(value)); | 1622 __ sub(Operand(eax), Immediate(value)); |
1590 } | 1623 } |
1591 __ j(overflow, &call_stub); | 1624 __ j(overflow, &call_stub); |
1592 __ test(eax, Immediate(kSmiTagMask)); | 1625 __ test(eax, Immediate(kSmiTagMask)); |
1593 __ j(zero, &done); | 1626 JumpPatchSite patch_site(masm_); |
1627 patch_site.EmitJump(&call_stub); | |
1628 __ jmp(&done); | |
1594 | 1629 |
1595 __ bind(&call_stub); | 1630 __ bind(&call_stub); |
1596 if (left_is_constant_smi) { | 1631 if (left_is_constant_smi) { |
1597 __ mov(edx, Immediate(value)); | 1632 __ mov(edx, Immediate(value)); |
1598 __ mov(eax, ecx); | 1633 __ mov(eax, ecx); |
1599 } else { | 1634 } else { |
1600 __ add(Operand(eax), Immediate(value)); // Undo the subtraction. | 1635 __ add(Operand(eax), Immediate(value)); // Undo the subtraction. |
1601 __ mov(edx, eax); | 1636 __ mov(edx, eax); |
1602 __ mov(eax, Immediate(value)); | 1637 __ mov(eax, Immediate(value)); |
1603 } | 1638 } |
1604 Token::Value op = Token::SUB; | 1639 Token::Value op = Token::SUB; |
1605 TypeRecordingBinaryOpStub stub(op, mode); | 1640 TypeRecordingBinaryOpStub stub(op, mode); |
1606 __ CallStub(&stub); | 1641 EmitCallIC(stub.GetCode(), &patch_site); |
1642 | |
1607 __ bind(&done); | 1643 __ bind(&done); |
1608 context()->Plug(eax); | 1644 context()->Plug(eax); |
1609 } | 1645 } |
1610 | 1646 |
1611 | 1647 |
1612 void FullCodeGenerator::EmitConstantSmiShiftOp(Expression* expr, | 1648 void FullCodeGenerator::EmitConstantSmiShiftOp(Expression* expr, |
1613 Token::Value op, | 1649 Token::Value op, |
1614 OverwriteMode mode, | 1650 OverwriteMode mode, |
1615 Smi* value) { | 1651 Smi* value) { |
1616 Label call_stub, smi_case, done; | 1652 NearLabel call_stub, done; |
1617 int shift_value = value->value() & 0x1f; | 1653 int shift_value = value->value() & 0x1f; |
1618 | 1654 |
1619 __ test(eax, Immediate(kSmiTagMask)); | 1655 __ test(eax, Immediate(kSmiTagMask)); |
1620 __ j(zero, &smi_case); | 1656 // Patch site. |
1657 JumpPatchSite patch_site(masm_); | |
1658 patch_site.EmitJump(&call_stub); | |
1621 | 1659 |
1622 __ bind(&call_stub); | 1660 // Smi case. |
1623 __ mov(edx, eax); | |
1624 __ mov(eax, Immediate(value)); | |
1625 TypeRecordingBinaryOpStub stub(op, mode); | |
1626 __ CallStub(&stub); | |
1627 __ jmp(&done); | |
1628 | |
1629 __ bind(&smi_case); | |
1630 switch (op) { | 1661 switch (op) { |
1631 case Token::SHL: | 1662 case Token::SHL: |
1632 if (shift_value != 0) { | 1663 if (shift_value != 0) { |
1633 __ mov(edx, eax); | 1664 __ mov(edx, eax); |
1634 if (shift_value > 1) { | 1665 if (shift_value > 1) { |
1635 __ shl(edx, shift_value - 1); | 1666 __ shl(edx, shift_value - 1); |
1636 } | 1667 } |
1637 // Convert int result to smi, checking that it is in int range. | 1668 // Convert int result to smi, checking that it is in int range. |
1638 ASSERT(kSmiTagSize == 1); // Adjust code if not the case. | 1669 ASSERT(kSmiTagSize == 1); // Adjust code if not the case. |
1639 __ add(edx, Operand(edx)); | 1670 __ add(edx, Operand(edx)); |
(...skipping 18 matching lines...) Expand all Loading... | |
1658 __ mov(eax, edx); // Put result back into eax. | 1689 __ mov(eax, edx); // Put result back into eax. |
1659 } else { | 1690 } else { |
1660 __ SmiUntag(eax); | 1691 __ SmiUntag(eax); |
1661 __ shr(eax, shift_value); | 1692 __ shr(eax, shift_value); |
1662 __ SmiTag(eax); | 1693 __ SmiTag(eax); |
1663 } | 1694 } |
1664 break; | 1695 break; |
1665 default: | 1696 default: |
1666 UNREACHABLE(); | 1697 UNREACHABLE(); |
1667 } | 1698 } |
1699 __ jmp(&done); | |
1700 | |
1701 // Call stub. | |
1702 __ bind(&call_stub); | |
1703 __ mov(edx, eax); | |
1704 __ mov(eax, Immediate(value)); | |
1705 TypeRecordingBinaryOpStub stub(op, mode); | |
1706 EmitCallIC(stub.GetCode(), &patch_site); | |
1668 | 1707 |
1669 __ bind(&done); | 1708 __ bind(&done); |
1670 context()->Plug(eax); | 1709 context()->Plug(eax); |
1671 } | 1710 } |
1672 | 1711 |
1673 | 1712 |
1674 void FullCodeGenerator::EmitConstantSmiBitOp(Expression* expr, | 1713 void FullCodeGenerator::EmitConstantSmiBitOp(Expression* expr, |
1675 Token::Value op, | 1714 Token::Value op, |
1676 OverwriteMode mode, | 1715 OverwriteMode mode, |
1677 Smi* value) { | 1716 Smi* value) { |
1678 Label smi_case, done; | 1717 NearLabel call_stub, done; |
1679 __ test(eax, Immediate(kSmiTagMask)); | 1718 __ test(eax, Immediate(kSmiTagMask)); |
1680 __ j(zero, &smi_case); | 1719 // Patch site. The first invocation of the stub will be patch the jmp with |
1720 // the required conditional jump. | |
1721 JumpPatchSite patch_site(masm_); | |
1722 patch_site.EmitJump(&call_stub); | |
1681 | 1723 |
1682 // The order of the arguments does not matter for bit-ops with a | 1724 // Smi case. |
1683 // constant operand. | |
1684 __ mov(edx, Immediate(value)); | |
1685 TypeRecordingBinaryOpStub stub(op, mode); | |
1686 __ CallStub(&stub); | |
1687 __ jmp(&done); | |
1688 | |
1689 __ bind(&smi_case); | |
1690 switch (op) { | 1725 switch (op) { |
1691 case Token::BIT_OR: | 1726 case Token::BIT_OR: |
1692 __ or_(Operand(eax), Immediate(value)); | 1727 __ or_(Operand(eax), Immediate(value)); |
1693 break; | 1728 break; |
1694 case Token::BIT_XOR: | 1729 case Token::BIT_XOR: |
1695 __ xor_(Operand(eax), Immediate(value)); | 1730 __ xor_(Operand(eax), Immediate(value)); |
1696 break; | 1731 break; |
1697 case Token::BIT_AND: | 1732 case Token::BIT_AND: |
1698 __ and_(Operand(eax), Immediate(value)); | 1733 __ and_(Operand(eax), Immediate(value)); |
1699 break; | 1734 break; |
1700 default: | 1735 default: |
1701 UNREACHABLE(); | 1736 UNREACHABLE(); |
1702 } | 1737 } |
1738 __ jmp(&done); | |
1739 | |
1740 // The order of the arguments does not matter for bit-ops with a | |
1741 // constant operand. | |
1742 __ bind(&call_stub); | |
1743 __ mov(edx, Immediate(value)); | |
1744 TypeRecordingBinaryOpStub stub(op, mode); | |
1745 EmitCallIC(stub.GetCode(), &patch_site); | |
1703 | 1746 |
1704 __ bind(&done); | 1747 __ bind(&done); |
1705 context()->Plug(eax); | 1748 context()->Plug(eax); |
1706 } | 1749 } |
1707 | 1750 |
1708 | 1751 |
1709 void FullCodeGenerator::EmitConstantSmiBinaryOp(Expression* expr, | 1752 void FullCodeGenerator::EmitConstantSmiBinaryOp(Expression* expr, |
1710 Token::Value op, | 1753 Token::Value op, |
1711 OverwriteMode mode, | 1754 OverwriteMode mode, |
1712 bool left_is_constant_smi, | 1755 bool left_is_constant_smi, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1746 EmitConstantSmiBinaryOp(expr, op, mode, false, value); | 1789 EmitConstantSmiBinaryOp(expr, op, mode, false, value); |
1747 return; | 1790 return; |
1748 } else if (constant == kLeftConstant) { | 1791 } else if (constant == kLeftConstant) { |
1749 Smi* value = Smi::cast(*left->AsLiteral()->handle()); | 1792 Smi* value = Smi::cast(*left->AsLiteral()->handle()); |
1750 EmitConstantSmiBinaryOp(expr, op, mode, true, value); | 1793 EmitConstantSmiBinaryOp(expr, op, mode, true, value); |
1751 return; | 1794 return; |
1752 } | 1795 } |
1753 | 1796 |
1754 // Do combined smi check of the operands. Left operand is on the | 1797 // Do combined smi check of the operands. Left operand is on the |
1755 // stack. Right operand is in eax. | 1798 // stack. Right operand is in eax. |
1756 Label done, stub_call, smi_case; | 1799 NearLabel done, stub_call; |
1757 __ pop(edx); | 1800 __ pop(edx); |
1758 __ mov(ecx, eax); | 1801 __ mov(ecx, eax); |
1759 __ or_(eax, Operand(edx)); | 1802 __ or_(eax, Operand(edx)); |
1760 __ test(eax, Immediate(kSmiTagMask)); | 1803 __ test(eax, Immediate(kSmiTagMask)); |
1761 __ j(zero, &smi_case); | 1804 JumpPatchSite patch_site(masm_); |
1805 patch_site.EmitJump(&stub_call); | |
1762 | 1806 |
1763 __ bind(&stub_call); | 1807 // Smi case. |
1764 __ mov(eax, ecx); | |
1765 TypeRecordingBinaryOpStub stub(op, mode); | |
1766 __ CallStub(&stub); | |
1767 __ jmp(&done); | |
1768 | |
1769 __ bind(&smi_case); | |
1770 __ mov(eax, edx); // Copy left operand in case of a stub call. | 1808 __ mov(eax, edx); // Copy left operand in case of a stub call. |
1771 | 1809 |
1772 switch (op) { | 1810 switch (op) { |
1773 case Token::SAR: | 1811 case Token::SAR: |
1774 __ SmiUntag(eax); | 1812 __ SmiUntag(eax); |
1775 __ SmiUntag(ecx); | 1813 __ SmiUntag(ecx); |
1776 __ sar_cl(eax); // No checks of result necessary | 1814 __ sar_cl(eax); // No checks of result necessary |
1777 __ SmiTag(eax); | 1815 __ SmiTag(eax); |
1778 break; | 1816 break; |
1779 case Token::SHL: { | 1817 case Token::SHL: { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1827 break; | 1865 break; |
1828 case Token::BIT_AND: | 1866 case Token::BIT_AND: |
1829 __ and_(eax, Operand(ecx)); | 1867 __ and_(eax, Operand(ecx)); |
1830 break; | 1868 break; |
1831 case Token::BIT_XOR: | 1869 case Token::BIT_XOR: |
1832 __ xor_(eax, Operand(ecx)); | 1870 __ xor_(eax, Operand(ecx)); |
1833 break; | 1871 break; |
1834 default: | 1872 default: |
1835 UNREACHABLE(); | 1873 UNREACHABLE(); |
1836 } | 1874 } |
1875 __ jmp(&done); | |
1876 | |
1877 __ bind(&stub_call); | |
1878 __ mov(eax, ecx); | |
1879 TypeRecordingBinaryOpStub stub(op, mode); | |
1880 EmitCallIC(stub.GetCode(), &patch_site); | |
1837 | 1881 |
1838 __ bind(&done); | 1882 __ bind(&done); |
1839 context()->Plug(eax); | 1883 context()->Plug(eax); |
1840 } | 1884 } |
1841 | 1885 |
1842 | 1886 |
1843 void FullCodeGenerator::EmitBinaryOp(Token::Value op, | 1887 void FullCodeGenerator::EmitBinaryOp(Token::Value op, |
1844 OverwriteMode mode) { | 1888 OverwriteMode mode) { |
1845 __ pop(edx); | 1889 __ pop(edx); |
1846 TypeRecordingBinaryOpStub stub(op, mode); | 1890 TypeRecordingBinaryOpStub stub(op, mode); |
1847 __ CallStub(&stub); | 1891 __ CallStub(&stub); |
Vitaly Repeshko
2010/12/10 13:38:56
How about making patch site an optional parameter
fschneider
2010/12/10 14:32:17
Done.
| |
1892 __ nop(); // Signals no inlined smi code. | |
1848 context()->Plug(eax); | 1893 context()->Plug(eax); |
1849 } | 1894 } |
1850 | 1895 |
1851 | 1896 |
1852 void FullCodeGenerator::EmitAssignment(Expression* expr) { | 1897 void FullCodeGenerator::EmitAssignment(Expression* expr) { |
1853 // Invalid left-hand sides are rewritten to have a 'throw | 1898 // Invalid left-hand sides are rewritten to have a 'throw |
1854 // ReferenceError' on the left-hand side. | 1899 // ReferenceError' on the left-hand side. |
1855 if (!expr->IsValidLeftHandSide()) { | 1900 if (!expr->IsValidLeftHandSide()) { |
1856 VisitForEffect(expr); | 1901 VisitForEffect(expr); |
1857 return; | 1902 return; |
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3702 break; | 3747 break; |
3703 case KEYED_PROPERTY: | 3748 case KEYED_PROPERTY: |
3704 __ mov(Operand(esp, 2 * kPointerSize), eax); | 3749 __ mov(Operand(esp, 2 * kPointerSize), eax); |
3705 break; | 3750 break; |
3706 } | 3751 } |
3707 } | 3752 } |
3708 } | 3753 } |
3709 | 3754 |
3710 // Inline smi case if we are in a loop. | 3755 // Inline smi case if we are in a loop. |
3711 NearLabel stub_call; | 3756 NearLabel stub_call; |
3757 JumpPatchSite patch_site(masm_); | |
3712 Label done; | 3758 Label done; |
3713 if (ShouldInlineSmiCase(expr->op())) { | 3759 if (ShouldInlineSmiCase(expr->op())) { |
3714 if (expr->op() == Token::INC) { | 3760 if (expr->op() == Token::INC) { |
3715 __ add(Operand(eax), Immediate(Smi::FromInt(1))); | 3761 __ add(Operand(eax), Immediate(Smi::FromInt(1))); |
3716 } else { | 3762 } else { |
3717 __ sub(Operand(eax), Immediate(Smi::FromInt(1))); | 3763 __ sub(Operand(eax), Immediate(Smi::FromInt(1))); |
3718 } | 3764 } |
3719 __ j(overflow, &stub_call); | 3765 __ j(overflow, &stub_call); |
3720 // We could eliminate this smi check if we split the code at | 3766 // We could eliminate this smi check if we split the code at |
3721 // the first smi check before calling ToNumber. | 3767 // the first smi check before calling ToNumber. |
3722 __ test(eax, Immediate(kSmiTagMask)); | 3768 __ test(eax, Immediate(kSmiTagMask)); |
3723 __ j(zero, &done); | 3769 patch_site.EmitJump(&stub_call); |
3770 __ jmp(&done); | |
3771 | |
3724 __ bind(&stub_call); | 3772 __ bind(&stub_call); |
3725 // Call stub. Undo operation first. | 3773 // Call stub. Undo operation first. |
3726 if (expr->op() == Token::INC) { | 3774 if (expr->op() == Token::INC) { |
3727 __ sub(Operand(eax), Immediate(Smi::FromInt(1))); | 3775 __ sub(Operand(eax), Immediate(Smi::FromInt(1))); |
3728 } else { | 3776 } else { |
3729 __ add(Operand(eax), Immediate(Smi::FromInt(1))); | 3777 __ add(Operand(eax), Immediate(Smi::FromInt(1))); |
3730 } | 3778 } |
3731 } | 3779 } |
3732 | 3780 |
3733 // Record position before stub call. | 3781 // Record position before stub call. |
3734 SetSourcePosition(expr->position()); | 3782 SetSourcePosition(expr->position()); |
3735 | 3783 |
3736 // Call stub for +1/-1. | 3784 // Call stub for +1/-1. |
3737 __ mov(edx, eax); | 3785 __ mov(edx, eax); |
3738 __ mov(eax, Immediate(Smi::FromInt(1))); | 3786 __ mov(eax, Immediate(Smi::FromInt(1))); |
3739 TypeRecordingBinaryOpStub stub(expr->binary_op(), | 3787 TypeRecordingBinaryOpStub stub(expr->binary_op(), |
3740 NO_OVERWRITE); | 3788 NO_OVERWRITE); |
3741 __ CallStub(&stub); | 3789 EmitCallIC(stub.GetCode(), &patch_site); |
3790 | |
3742 __ bind(&done); | 3791 __ bind(&done); |
3743 | |
3744 // Store the value returned in eax. | 3792 // Store the value returned in eax. |
3745 switch (assign_type) { | 3793 switch (assign_type) { |
3746 case VARIABLE: | 3794 case VARIABLE: |
3747 if (expr->is_postfix()) { | 3795 if (expr->is_postfix()) { |
3748 // Perform the assignment as if via '='. | 3796 // Perform the assignment as if via '='. |
3749 { EffectContext context(this); | 3797 { EffectContext context(this); |
3750 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3798 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
3751 Token::ASSIGN); | 3799 Token::ASSIGN); |
3752 } | 3800 } |
3753 // For all contexts except EffectContext We have the result on | 3801 // For all contexts except EffectContext We have the result on |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3998 cc = greater_equal; | 4046 cc = greater_equal; |
3999 __ pop(edx); | 4047 __ pop(edx); |
4000 break; | 4048 break; |
4001 case Token::IN: | 4049 case Token::IN: |
4002 case Token::INSTANCEOF: | 4050 case Token::INSTANCEOF: |
4003 default: | 4051 default: |
4004 UNREACHABLE(); | 4052 UNREACHABLE(); |
4005 } | 4053 } |
4006 | 4054 |
4007 bool inline_smi_code = ShouldInlineSmiCase(op); | 4055 bool inline_smi_code = ShouldInlineSmiCase(op); |
4056 JumpPatchSite patch_site(masm_); | |
4008 if (inline_smi_code) { | 4057 if (inline_smi_code) { |
4009 NearLabel slow_case; | 4058 NearLabel slow_case; |
4010 __ mov(ecx, Operand(edx)); | 4059 __ mov(ecx, Operand(edx)); |
4011 __ or_(ecx, Operand(eax)); | 4060 __ or_(ecx, Operand(eax)); |
4012 __ test(ecx, Immediate(kSmiTagMask)); | 4061 __ test(ecx, Immediate(kSmiTagMask)); |
4013 __ j(not_zero, &slow_case, not_taken); | 4062 patch_site.EmitJump(&slow_case); |
4014 __ cmp(edx, Operand(eax)); | 4063 __ cmp(edx, Operand(eax)); |
4015 Split(cc, if_true, if_false, NULL); | 4064 Split(cc, if_true, if_false, NULL); |
4016 __ bind(&slow_case); | 4065 __ bind(&slow_case); |
4017 } | 4066 } |
4018 | 4067 |
4019 // Record position and call the compare IC. | 4068 // Record position and call the compare IC. |
4069 SetSourcePosition(expr->position()); | |
4020 Handle<Code> ic = CompareIC::GetUninitialized(op); | 4070 Handle<Code> ic = CompareIC::GetUninitialized(op); |
4021 SetSourcePosition(expr->position()); | 4071 EmitCallIC(ic, &patch_site); |
4022 __ call(ic, RelocInfo::CODE_TARGET); | 4072 |
4023 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 4073 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
4024 __ test(eax, Operand(eax)); | 4074 __ test(eax, Operand(eax)); |
4025 Split(cc, if_true, if_false, fall_through); | 4075 Split(cc, if_true, if_false, fall_through); |
4026 } | 4076 } |
4027 } | 4077 } |
4028 | 4078 |
4029 // Convert the result of the comparison into one expected for this | 4079 // Convert the result of the comparison into one expected for this |
4030 // expression's context. | 4080 // expression's context. |
4031 context()->Plug(if_true, if_false); | 4081 context()->Plug(if_true, if_false); |
4032 } | 4082 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4116 case Code::KEYED_STORE_IC: | 4166 case Code::KEYED_STORE_IC: |
4117 __ nop(); // Signals no inlined code. | 4167 __ nop(); // Signals no inlined code. |
4118 break; | 4168 break; |
4119 default: | 4169 default: |
4120 // Do nothing. | 4170 // Do nothing. |
4121 break; | 4171 break; |
4122 } | 4172 } |
4123 } | 4173 } |
4124 | 4174 |
4125 | 4175 |
4176 void FullCodeGenerator::EmitCallIC(Handle<Code> ic, JumpPatchSite* patch_site) { | |
4177 __ call(ic, RelocInfo::CODE_TARGET); | |
4178 if (patch_site->is_bound()) { | |
4179 patch_site->EmitPatchInfo(); | |
4180 } else { | |
4181 __ nop(); // Signals no inlined code. | |
4182 } | |
4183 } | |
4184 | |
4185 | |
4126 void FullCodeGenerator::StoreToFrameField(int frame_offset, Register value) { | 4186 void FullCodeGenerator::StoreToFrameField(int frame_offset, Register value) { |
4127 ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset); | 4187 ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset); |
4128 __ mov(Operand(ebp, frame_offset), value); | 4188 __ mov(Operand(ebp, frame_offset), value); |
4129 } | 4189 } |
4130 | 4190 |
4131 | 4191 |
4132 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4192 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
4133 __ mov(dst, ContextOperand(esi, context_index)); | 4193 __ mov(dst, ContextOperand(esi, context_index)); |
4134 } | 4194 } |
4135 | 4195 |
(...skipping 27 matching lines...) Expand all Loading... | |
4163 // And return. | 4223 // And return. |
4164 __ ret(0); | 4224 __ ret(0); |
4165 } | 4225 } |
4166 | 4226 |
4167 | 4227 |
4168 #undef __ | 4228 #undef __ |
4169 | 4229 |
4170 } } // namespace v8::internal | 4230 } } // namespace v8::internal |
4171 | 4231 |
4172 #endif // V8_TARGET_ARCH_IA32 | 4232 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |