Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: src/ia32/assembler-ia32.cc

Issue 3388004: Add support for near labels.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 // Relative address, relative to point after address. 1504 // Relative address, relative to point after address.
1505 int imm32 = pos - (fixup_pos + sizeof(int32_t)); 1505 int imm32 = pos - (fixup_pos + sizeof(int32_t));
1506 long_at_put(fixup_pos, imm32); 1506 long_at_put(fixup_pos, imm32);
1507 } 1507 }
1508 disp.next(L); 1508 disp.next(L);
1509 } 1509 }
1510 L->bind_to(pos); 1510 L->bind_to(pos);
1511 } 1511 }
1512 1512
1513 1513
1514 void Assembler::link_to(Label* L, Label* appendix) {
1515 EnsureSpace ensure_space(this);
1516 last_pc_ = NULL;
1517 if (appendix->is_linked()) {
1518 if (L->is_linked()) {
1519 // Append appendix to L's list.
1520 Label p;
1521 Label q = *L;
1522 do {
1523 p = q;
1524 Displacement disp = disp_at(&q);
1525 disp.next(&q);
1526 } while (q.is_linked());
1527 Displacement disp = disp_at(&p);
1528 disp.link_to(appendix);
1529 disp_at_put(&p, disp);
1530 p.Unuse(); // to avoid assertion failure in ~Label
1531 } else {
1532 // L is empty, simply use appendix.
1533 *L = *appendix;
1534 }
1535 }
1536 appendix->Unuse(); // appendix should not be used anymore
1537 }
1538
1539
1540 void Assembler::bind(Label* L) { 1514 void Assembler::bind(Label* L) {
1541 EnsureSpace ensure_space(this); 1515 EnsureSpace ensure_space(this);
1542 last_pc_ = NULL; 1516 last_pc_ = NULL;
1543 ASSERT(!L->is_bound()); // label can only be bound once 1517 ASSERT(!L->is_bound()); // label can only be bound once
1544 bind_to(L, pc_offset()); 1518 bind_to(L, pc_offset());
1545 } 1519 }
1546 1520
1547 1521
1522 void Assembler::bind(NearLabel* L) {
1523 ASSERT(!L->is_bound());
1524 last_pc_ = NULL;
1525 while (L->unresolved_branches_ > 0) {
1526 int branch_pos = L->unresolved_positions_[L->unresolved_branches_ - 1];
1527 int disp = pc_offset() - branch_pos;
1528 ASSERT(is_int8(disp));
1529 set_byte_at(branch_pos - sizeof(int8_t), disp);
1530 L->unresolved_branches_--;
1531 }
1532 L->bind_to(pc_offset());
1533 }
1534
1548 void Assembler::call(Label* L) { 1535 void Assembler::call(Label* L) {
1549 EnsureSpace ensure_space(this); 1536 EnsureSpace ensure_space(this);
1550 last_pc_ = pc_; 1537 last_pc_ = pc_;
1551 if (L->is_bound()) { 1538 if (L->is_bound()) {
1552 const int long_size = 5; 1539 const int long_size = 5;
1553 int offs = L->pos() - pc_offset(); 1540 int offs = L->pos() - pc_offset();
1554 ASSERT(offs <= 0); 1541 ASSERT(offs <= 0);
1555 // 1110 1000 #32-bit disp. 1542 // 1110 1000 #32-bit disp.
1556 EMIT(0xE8); 1543 EMIT(0xE8);
1557 emit(offs - long_size); 1544 emit(offs - long_size);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 1621
1635 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) { 1622 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) {
1636 EnsureSpace ensure_space(this); 1623 EnsureSpace ensure_space(this);
1637 last_pc_ = pc_; 1624 last_pc_ = pc_;
1638 ASSERT(RelocInfo::IsCodeTarget(rmode)); 1625 ASSERT(RelocInfo::IsCodeTarget(rmode));
1639 EMIT(0xE9); 1626 EMIT(0xE9);
1640 emit(reinterpret_cast<intptr_t>(code.location()), rmode); 1627 emit(reinterpret_cast<intptr_t>(code.location()), rmode);
1641 } 1628 }
1642 1629
1643 1630
1631 void Assembler::jmp(NearLabel* L) {
1632 EnsureSpace ensure_space(this);
1633 last_pc_ = pc_;
1634 if (L->is_bound()) {
1635 const int short_size = 2;
1636 int offs = L->pos() - pc_offset();
1637 ASSERT(offs <= 0);
1638 ASSERT(is_int8(offs - short_size));
1639 // 1110 1011 #8-bit disp.
1640 EMIT(0xEB);
1641 EMIT((offs - short_size) & 0xFF);
1642 } else {
1643 EMIT(0xEB);
1644 EMIT(0x00); // The displacement will be resolved later.
1645 L->link_to(pc_offset());
1646 }
1647 }
1648
1644 1649
1645 void Assembler::j(Condition cc, Label* L, Hint hint) { 1650 void Assembler::j(Condition cc, Label* L, Hint hint) {
1646 EnsureSpace ensure_space(this); 1651 EnsureSpace ensure_space(this);
1647 last_pc_ = pc_; 1652 last_pc_ = pc_;
1648 ASSERT(0 <= cc && cc < 16); 1653 ASSERT(0 <= cc && cc < 16);
1649 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); 1654 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint);
1650 if (L->is_bound()) { 1655 if (L->is_bound()) {
1651 const int short_size = 2; 1656 const int short_size = 2;
1652 const int long_size = 6; 1657 const int long_size = 6;
1653 int offs = L->pos() - pc_offset(); 1658 int offs = L->pos() - pc_offset();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 EnsureSpace ensure_space(this); 1694 EnsureSpace ensure_space(this);
1690 last_pc_ = pc_; 1695 last_pc_ = pc_;
1691 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); 1696 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint);
1692 // 0000 1111 1000 tttn #32-bit disp 1697 // 0000 1111 1000 tttn #32-bit disp
1693 EMIT(0x0F); 1698 EMIT(0x0F);
1694 EMIT(0x80 | cc); 1699 EMIT(0x80 | cc);
1695 emit(reinterpret_cast<intptr_t>(code.location()), RelocInfo::CODE_TARGET); 1700 emit(reinterpret_cast<intptr_t>(code.location()), RelocInfo::CODE_TARGET);
1696 } 1701 }
1697 1702
1698 1703
1704 void Assembler::j(Condition cc, NearLabel* L, Hint hint) {
1705 EnsureSpace ensure_space(this);
1706 last_pc_ = pc_;
1707 ASSERT(0 <= cc && cc < 16);
1708 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint);
1709 if (L->is_bound()) {
1710 const int short_size = 2;
1711 int offs = L->pos() - pc_offset();
1712 ASSERT(offs <= 0);
1713 ASSERT(is_int8(offs - short_size));
1714 // 0111 tttn #8-bit disp
1715 EMIT(0x70 | cc);
1716 EMIT((offs - short_size) & 0xFF);
1717 } else {
1718 EMIT(0x70 | cc);
1719 EMIT(0x00); // The displacement will be resolved later.
1720 L->link_to(pc_offset());
1721 }
1722 }
1723
1724
1699 // FPU instructions. 1725 // FPU instructions.
1700 1726
1701 void Assembler::fld(int i) { 1727 void Assembler::fld(int i) {
1702 EnsureSpace ensure_space(this); 1728 EnsureSpace ensure_space(this);
1703 last_pc_ = pc_; 1729 last_pc_ = pc_;
1704 emit_farith(0xD9, 0xC0, i); 1730 emit_farith(0xD9, 0xC0, i);
1705 } 1731 }
1706 1732
1707 1733
1708 void Assembler::fstp(int i) { 1734 void Assembler::fstp(int i) {
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 fprintf(coverage_log, "%s\n", file_line); 2638 fprintf(coverage_log, "%s\n", file_line);
2613 fflush(coverage_log); 2639 fflush(coverage_log);
2614 } 2640 }
2615 } 2641 }
2616 2642
2617 #endif 2643 #endif
2618 2644
2619 } } // namespace v8::internal 2645 } } // namespace v8::internal
2620 2646
2621 #endif // V8_TARGET_ARCH_IA32 2647 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698