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 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 } else { | 1518 } else { |
1519 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { | 1519 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { |
1520 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected | 1520 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected |
1521 } | 1521 } |
1522 // Relative address, relative to point after address. | 1522 // Relative address, relative to point after address. |
1523 int imm32 = pos - (fixup_pos + sizeof(int32_t)); | 1523 int imm32 = pos - (fixup_pos + sizeof(int32_t)); |
1524 long_at_put(fixup_pos, imm32); | 1524 long_at_put(fixup_pos, imm32); |
1525 } | 1525 } |
1526 disp.next(L); | 1526 disp.next(L); |
1527 } | 1527 } |
| 1528 while (L->is_near_linked()) { |
| 1529 int fixup_pos = L->near_link_pos(); |
| 1530 int offset_to_next = |
| 1531 static_cast<int>(*reinterpret_cast<int8_t*>(addr_at(fixup_pos))); |
| 1532 ASSERT(offset_to_next <= 0); |
| 1533 // Relative address, relative to point after address. |
| 1534 int disp = pos - fixup_pos - sizeof(int8_t); |
| 1535 ASSERT(0 <= disp && disp <= 127); |
| 1536 set_byte_at(fixup_pos, disp); |
| 1537 if (offset_to_next < 0) { |
| 1538 L->link_to(fixup_pos + offset_to_next, Label::kNear); |
| 1539 } else { |
| 1540 L->UnuseNear(); |
| 1541 } |
| 1542 } |
1528 L->bind_to(pos); | 1543 L->bind_to(pos); |
1529 } | 1544 } |
1530 | 1545 |
1531 | 1546 |
1532 void Assembler::bind(Label* L) { | 1547 void Assembler::bind(Label* L) { |
1533 EnsureSpace ensure_space(this); | 1548 EnsureSpace ensure_space(this); |
1534 last_pc_ = NULL; | 1549 last_pc_ = NULL; |
1535 ASSERT(!L->is_bound()); // label can only be bound once | 1550 ASSERT(!L->is_bound()); // label can only be bound once |
1536 bind_to(L, pc_offset()); | 1551 bind_to(L, pc_offset()); |
1537 } | 1552 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 unsigned ast_id) { | 1621 unsigned ast_id) { |
1607 positions_recorder()->WriteRecordedPositions(); | 1622 positions_recorder()->WriteRecordedPositions(); |
1608 EnsureSpace ensure_space(this); | 1623 EnsureSpace ensure_space(this); |
1609 last_pc_ = pc_; | 1624 last_pc_ = pc_; |
1610 ASSERT(RelocInfo::IsCodeTarget(rmode)); | 1625 ASSERT(RelocInfo::IsCodeTarget(rmode)); |
1611 EMIT(0xE8); | 1626 EMIT(0xE8); |
1612 emit(reinterpret_cast<intptr_t>(code.location()), rmode, ast_id); | 1627 emit(reinterpret_cast<intptr_t>(code.location()), rmode, ast_id); |
1613 } | 1628 } |
1614 | 1629 |
1615 | 1630 |
1616 void Assembler::jmp(Label* L) { | 1631 void Assembler::jmp(Label* L, Label::Distance distance) { |
1617 EnsureSpace ensure_space(this); | 1632 EnsureSpace ensure_space(this); |
1618 last_pc_ = pc_; | 1633 last_pc_ = pc_; |
1619 if (L->is_bound()) { | 1634 if (L->is_bound()) { |
1620 const int short_size = 2; | 1635 const int short_size = 2; |
1621 const int long_size = 5; | 1636 const int long_size = 5; |
1622 int offs = L->pos() - pc_offset(); | 1637 int offs = L->pos() - pc_offset(); |
1623 ASSERT(offs <= 0); | 1638 ASSERT(offs <= 0); |
1624 if (is_int8(offs - short_size)) { | 1639 if (is_int8(offs - short_size)) { |
1625 // 1110 1011 #8-bit disp. | 1640 // 1110 1011 #8-bit disp. |
1626 EMIT(0xEB); | 1641 EMIT(0xEB); |
1627 EMIT((offs - short_size) & 0xFF); | 1642 EMIT((offs - short_size) & 0xFF); |
1628 } else { | 1643 } else { |
1629 // 1110 1001 #32-bit disp. | 1644 // 1110 1001 #32-bit disp. |
1630 EMIT(0xE9); | 1645 EMIT(0xE9); |
1631 emit(offs - long_size); | 1646 emit(offs - long_size); |
1632 } | 1647 } |
| 1648 } else if (distance == Label::kNear) { |
| 1649 EMIT(0xEB); |
| 1650 emit_near_disp(L); |
1633 } else { | 1651 } else { |
1634 // 1110 1001 #32-bit disp. | 1652 // 1110 1001 #32-bit disp. |
1635 EMIT(0xE9); | 1653 EMIT(0xE9); |
1636 emit_disp(L, Displacement::UNCONDITIONAL_JUMP); | 1654 emit_disp(L, Displacement::UNCONDITIONAL_JUMP); |
1637 } | 1655 } |
1638 } | 1656 } |
1639 | 1657 |
1640 | 1658 |
1641 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) { | 1659 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) { |
1642 EnsureSpace ensure_space(this); | 1660 EnsureSpace ensure_space(this); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 EMIT(0xEB); | 1694 EMIT(0xEB); |
1677 EMIT((offs - short_size) & 0xFF); | 1695 EMIT((offs - short_size) & 0xFF); |
1678 } else { | 1696 } else { |
1679 EMIT(0xEB); | 1697 EMIT(0xEB); |
1680 EMIT(0x00); // The displacement will be resolved later. | 1698 EMIT(0x00); // The displacement will be resolved later. |
1681 L->link_to(pc_offset()); | 1699 L->link_to(pc_offset()); |
1682 } | 1700 } |
1683 } | 1701 } |
1684 | 1702 |
1685 | 1703 |
1686 void Assembler::j(Condition cc, Label* L, Hint hint) { | 1704 void Assembler::j(Condition cc, Label* L, Hint hint, Label::Distance distance) { |
1687 EnsureSpace ensure_space(this); | 1705 EnsureSpace ensure_space(this); |
1688 last_pc_ = pc_; | 1706 last_pc_ = pc_; |
1689 ASSERT(0 <= cc && cc < 16); | 1707 ASSERT(0 <= cc && cc < 16); |
1690 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); | 1708 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); |
1691 if (L->is_bound()) { | 1709 if (L->is_bound()) { |
1692 const int short_size = 2; | 1710 const int short_size = 2; |
1693 const int long_size = 6; | 1711 const int long_size = 6; |
1694 int offs = L->pos() - pc_offset(); | 1712 int offs = L->pos() - pc_offset(); |
1695 ASSERT(offs <= 0); | 1713 ASSERT(offs <= 0); |
1696 if (is_int8(offs - short_size)) { | 1714 if (is_int8(offs - short_size)) { |
1697 // 0111 tttn #8-bit disp | 1715 // 0111 tttn #8-bit disp |
1698 EMIT(0x70 | cc); | 1716 EMIT(0x70 | cc); |
1699 EMIT((offs - short_size) & 0xFF); | 1717 EMIT((offs - short_size) & 0xFF); |
1700 } else { | 1718 } else { |
1701 // 0000 1111 1000 tttn #32-bit disp | 1719 // 0000 1111 1000 tttn #32-bit disp |
1702 EMIT(0x0F); | 1720 EMIT(0x0F); |
1703 EMIT(0x80 | cc); | 1721 EMIT(0x80 | cc); |
1704 emit(offs - long_size); | 1722 emit(offs - long_size); |
1705 } | 1723 } |
| 1724 } else if (distance == Label::kNear) { |
| 1725 EMIT(0x70 | cc); |
| 1726 emit_near_disp(L); |
1706 } else { | 1727 } else { |
1707 // 0000 1111 1000 tttn #32-bit disp | 1728 // 0000 1111 1000 tttn #32-bit disp |
1708 // Note: could eliminate cond. jumps to this jump if condition | 1729 // Note: could eliminate cond. jumps to this jump if condition |
1709 // is the same however, seems to be rather unlikely case. | 1730 // is the same however, seems to be rather unlikely case. |
1710 EMIT(0x0F); | 1731 EMIT(0x0F); |
1711 EMIT(0x80 | cc); | 1732 EMIT(0x80 | cc); |
1712 emit_disp(L, Displacement::OTHER); | 1733 emit_disp(L, Displacement::OTHER); |
1713 } | 1734 } |
1714 } | 1735 } |
1715 | 1736 |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 fprintf(coverage_log, "%s\n", file_line); | 2881 fprintf(coverage_log, "%s\n", file_line); |
2861 fflush(coverage_log); | 2882 fflush(coverage_log); |
2862 } | 2883 } |
2863 } | 2884 } |
2864 | 2885 |
2865 #endif | 2886 #endif |
2866 | 2887 |
2867 } } // namespace v8::internal | 2888 } } // namespace v8::internal |
2868 | 2889 |
2869 #endif // V8_TARGET_ARCH_IA32 | 2890 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |