OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 | 1545 |
1546 | 1546 |
1547 void Assembler::bind(Label* L) { | 1547 void Assembler::bind(Label* L) { |
1548 EnsureSpace ensure_space(this); | 1548 EnsureSpace ensure_space(this); |
1549 last_pc_ = NULL; | 1549 last_pc_ = NULL; |
1550 ASSERT(!L->is_bound()); // label can only be bound once | 1550 ASSERT(!L->is_bound()); // label can only be bound once |
1551 bind_to(L, pc_offset()); | 1551 bind_to(L, pc_offset()); |
1552 } | 1552 } |
1553 | 1553 |
1554 | 1554 |
1555 void Assembler::bind(NearLabel* L) { | |
1556 ASSERT(!L->is_bound()); | |
1557 last_pc_ = NULL; | |
1558 while (L->unresolved_branches_ > 0) { | |
1559 int branch_pos = L->unresolved_positions_[L->unresolved_branches_ - 1]; | |
1560 int disp = pc_offset() - branch_pos; | |
1561 ASSERT(is_int8(disp)); | |
1562 set_byte_at(branch_pos - sizeof(int8_t), disp); | |
1563 L->unresolved_branches_--; | |
1564 } | |
1565 L->bind_to(pc_offset()); | |
1566 } | |
1567 | |
1568 | |
1569 void Assembler::call(Label* L) { | 1555 void Assembler::call(Label* L) { |
1570 positions_recorder()->WriteRecordedPositions(); | 1556 positions_recorder()->WriteRecordedPositions(); |
1571 EnsureSpace ensure_space(this); | 1557 EnsureSpace ensure_space(this); |
1572 last_pc_ = pc_; | 1558 last_pc_ = pc_; |
1573 if (L->is_bound()) { | 1559 if (L->is_bound()) { |
1574 const int long_size = 5; | 1560 const int long_size = 5; |
1575 int offs = L->pos() - pc_offset(); | 1561 int offs = L->pos() - pc_offset(); |
1576 ASSERT(offs <= 0); | 1562 ASSERT(offs <= 0); |
1577 // 1110 1000 #32-bit disp. | 1563 // 1110 1000 #32-bit disp. |
1578 EMIT(0xE8); | 1564 EMIT(0xE8); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 | 1661 |
1676 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) { | 1662 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) { |
1677 EnsureSpace ensure_space(this); | 1663 EnsureSpace ensure_space(this); |
1678 last_pc_ = pc_; | 1664 last_pc_ = pc_; |
1679 ASSERT(RelocInfo::IsCodeTarget(rmode)); | 1665 ASSERT(RelocInfo::IsCodeTarget(rmode)); |
1680 EMIT(0xE9); | 1666 EMIT(0xE9); |
1681 emit(reinterpret_cast<intptr_t>(code.location()), rmode); | 1667 emit(reinterpret_cast<intptr_t>(code.location()), rmode); |
1682 } | 1668 } |
1683 | 1669 |
1684 | 1670 |
1685 void Assembler::jmp(NearLabel* L) { | |
1686 EnsureSpace ensure_space(this); | |
1687 last_pc_ = pc_; | |
1688 if (L->is_bound()) { | |
1689 const int short_size = 2; | |
1690 int offs = L->pos() - pc_offset(); | |
1691 ASSERT(offs <= 0); | |
1692 ASSERT(is_int8(offs - short_size)); | |
1693 // 1110 1011 #8-bit disp. | |
1694 EMIT(0xEB); | |
1695 EMIT((offs - short_size) & 0xFF); | |
1696 } else { | |
1697 EMIT(0xEB); | |
1698 EMIT(0x00); // The displacement will be resolved later. | |
1699 L->link_to(pc_offset()); | |
1700 } | |
1701 } | |
1702 | |
1703 | |
1704 void Assembler::j(Condition cc, Label* L, Hint hint, Label::Distance distance) { | 1671 void Assembler::j(Condition cc, Label* L, Hint hint, Label::Distance distance) { |
1705 EnsureSpace ensure_space(this); | 1672 EnsureSpace ensure_space(this); |
1706 last_pc_ = pc_; | 1673 last_pc_ = pc_; |
1707 ASSERT(0 <= cc && cc < 16); | 1674 ASSERT(0 <= cc && cc < 16); |
1708 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); | 1675 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); |
1709 if (L->is_bound()) { | 1676 if (L->is_bound()) { |
1710 const int short_size = 2; | 1677 const int short_size = 2; |
1711 const int long_size = 6; | 1678 const int long_size = 6; |
1712 int offs = L->pos() - pc_offset(); | 1679 int offs = L->pos() - pc_offset(); |
1713 ASSERT(offs <= 0); | 1680 ASSERT(offs <= 0); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 EnsureSpace ensure_space(this); | 1718 EnsureSpace ensure_space(this); |
1752 last_pc_ = pc_; | 1719 last_pc_ = pc_; |
1753 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); | 1720 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); |
1754 // 0000 1111 1000 tttn #32-bit disp | 1721 // 0000 1111 1000 tttn #32-bit disp |
1755 EMIT(0x0F); | 1722 EMIT(0x0F); |
1756 EMIT(0x80 | cc); | 1723 EMIT(0x80 | cc); |
1757 emit(reinterpret_cast<intptr_t>(code.location()), RelocInfo::CODE_TARGET); | 1724 emit(reinterpret_cast<intptr_t>(code.location()), RelocInfo::CODE_TARGET); |
1758 } | 1725 } |
1759 | 1726 |
1760 | 1727 |
1761 void Assembler::j(Condition cc, NearLabel* L, Hint hint) { | |
1762 EnsureSpace ensure_space(this); | |
1763 last_pc_ = pc_; | |
1764 ASSERT(0 <= cc && cc < 16); | |
1765 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); | |
1766 if (L->is_bound()) { | |
1767 const int short_size = 2; | |
1768 int offs = L->pos() - pc_offset(); | |
1769 ASSERT(offs <= 0); | |
1770 ASSERT(is_int8(offs - short_size)); | |
1771 // 0111 tttn #8-bit disp | |
1772 EMIT(0x70 | cc); | |
1773 EMIT((offs - short_size) & 0xFF); | |
1774 } else { | |
1775 EMIT(0x70 | cc); | |
1776 EMIT(0x00); // The displacement will be resolved later. | |
1777 L->link_to(pc_offset()); | |
1778 } | |
1779 } | |
1780 | |
1781 | |
1782 // FPU instructions. | 1728 // FPU instructions. |
1783 | 1729 |
1784 void Assembler::fld(int i) { | 1730 void Assembler::fld(int i) { |
1785 EnsureSpace ensure_space(this); | 1731 EnsureSpace ensure_space(this); |
1786 last_pc_ = pc_; | 1732 last_pc_ = pc_; |
1787 emit_farith(0xD9, 0xC0, i); | 1733 emit_farith(0xD9, 0xC0, i); |
1788 } | 1734 } |
1789 | 1735 |
1790 | 1736 |
1791 void Assembler::fstp(int i) { | 1737 void Assembler::fstp(int i) { |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2881 fprintf(coverage_log, "%s\n", file_line); | 2827 fprintf(coverage_log, "%s\n", file_line); |
2882 fflush(coverage_log); | 2828 fflush(coverage_log); |
2883 } | 2829 } |
2884 } | 2830 } |
2885 | 2831 |
2886 #endif | 2832 #endif |
2887 | 2833 |
2888 } } // namespace v8::internal | 2834 } } // namespace v8::internal |
2889 | 2835 |
2890 #endif // V8_TARGET_ARCH_IA32 | 2836 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |