src/cpu/x86/vm/c1_Runtime1_x86.cpp

Print this page




1564         LP64_ONLY(__ pop(rdx);)
1565         __ pop(rcx);
1566         __ pop(rsi);
1567         __ ret(0);
1568       }
1569       break;
1570 
1571 #ifndef SERIALGC
1572     case g1_pre_barrier_slow_id:
1573       {
1574         StubFrame f(sasm, "g1_pre_barrier", dont_gc_arguments);
1575         // arg0 : previous value of memory
1576 
1577         BarrierSet* bs = Universe::heap()->barrier_set();
1578         if (bs->kind() != BarrierSet::G1SATBCTLogging) {
1579           __ movptr(rax, (int)id);
1580           __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
1581           __ should_not_reach_here();
1582           break;
1583         }
1584 
1585         __ push(rax);
1586         __ push(rdx);
1587 
1588         const Register pre_val = rax;
1589         const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1590         const Register tmp = rdx;
1591 
1592         NOT_LP64(__ get_thread(thread);)
1593 
1594         Address in_progress(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1595                                              PtrQueue::byte_offset_of_active()));
1596 
1597         Address queue_index(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1598                                              PtrQueue::byte_offset_of_index()));
1599         Address buffer(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1600                                         PtrQueue::byte_offset_of_buf()));
1601 
1602 
1603         Label done;
1604         Label runtime;
1605 
1606         // Can we store original value in the thread's buffer?
1607 
1608         LP64_ONLY(__ movslq(tmp, queue_index);)
1609 #ifdef _LP64

1610         __ cmpq(tmp, 0);
1611 #else
1612         __ cmpl(queue_index, 0);
1613 #endif
1614         __ jcc(Assembler::equal, runtime);
1615 #ifdef _LP64
1616         __ subq(tmp, wordSize);
1617         __ movl(queue_index, tmp);
1618         __ addq(tmp, buffer);
1619 #else
1620         __ subl(queue_index, wordSize);
1621         __ movl(tmp, buffer);
1622         __ addl(tmp, queue_index);
1623 #endif
1624 
1625         // prev_val (rax)
1626         f.load_argument(0, pre_val);
1627         __ movptr(Address(tmp, 0), pre_val);
1628         __ jmp(done);
1629 
1630         __ bind(runtime);
1631         // load the pre-value
1632         __ push(rcx);











1633         f.load_argument(0, rcx);
1634         __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), rcx, thread);










1635         __ pop(rcx);
1636 
1637         __ bind(done);

1638         __ pop(rdx);
1639         __ pop(rax);
1640       }
1641       break;
1642 
1643     case g1_post_barrier_slow_id:
1644       {
1645         StubFrame f(sasm, "g1_post_barrier", dont_gc_arguments);
1646 
1647 
1648         // arg0: store_address
1649         Address store_addr(rbp, 2*BytesPerWord);
1650 
1651         BarrierSet* bs = Universe::heap()->barrier_set();
1652         CardTableModRefBS* ct = (CardTableModRefBS*)bs;
1653         Label done;
1654         Label runtime;
1655 
1656         // At this point we know new_value is non-NULL and the new_value crosses regsion.
1657         // Must check to see if card is already dirty
1658 
1659         const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1660 
1661         Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
1662                                              PtrQueue::byte_offset_of_index()));
1663         Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
1664                                         PtrQueue::byte_offset_of_buf()));
1665 
1666         __ push(rax);
1667         __ push(rdx);
1668 
1669         NOT_LP64(__ get_thread(thread);)
1670         ExternalAddress cardtable((address)ct->byte_map_base);
1671         assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
1672 
1673         const Register card_addr = rdx;
1674 #ifdef _LP64
1675         const Register tmp = rscratch1;
1676         f.load_argument(0, card_addr);
1677         __ shrq(card_addr, CardTableModRefBS::card_shift);
1678         __ lea(tmp, cardtable);
1679         // get the address of the card
1680         __ addq(card_addr, tmp);
1681 #else
1682         const Register card_index = rdx;
1683         f.load_argument(0, card_index);
1684         __ shrl(card_index, CardTableModRefBS::card_shift);
1685 
1686         Address index(noreg, card_index, Address::times_1);
1687         __ leal(card_addr, __ as_Address(ArrayAddress(cardtable, index)));
1688 #endif
1689 
1690         __ cmpb(Address(card_addr, 0), 0);
1691         __ jcc(Assembler::equal, done);
1692 
1693         // storing region crossing non-NULL, card is clean.
1694         // dirty card and log.
1695 
1696         __ movb(Address(card_addr, 0), 0);
1697 
1698         __ cmpl(queue_index, 0);
1699         __ jcc(Assembler::equal, runtime);
1700         __ subl(queue_index, wordSize);
1701 
1702         const Register buffer_addr = rbx;
1703         __ push(rbx);
1704 
1705         __ movptr(buffer_addr, buffer);
1706 
1707 #ifdef _LP64
1708         __ movslq(rscratch1, queue_index);
1709         __ addptr(buffer_addr, rscratch1);
1710 #else
1711         __ addptr(buffer_addr, queue_index);
1712 #endif
1713         __ movptr(Address(buffer_addr, 0), card_addr);
1714 
1715         __ pop(rbx);
1716         __ jmp(done);
1717 
1718         __ bind(runtime);
1719         NOT_LP64(__ push(rcx);)










1720         __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
1721         NOT_LP64(__ pop(rcx);)
1722 
1723         __ bind(done);







1724         __ pop(rdx);



1725         __ pop(rax);
1726 
1727       }
1728       break;
1729 #endif // !SERIALGC
1730 
1731     default:
1732       { StubFrame f(sasm, "unimplemented entry", dont_gc_arguments);
1733         __ movptr(rax, (int)id);
1734         __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
1735         __ should_not_reach_here();
1736       }
1737       break;
1738   }
1739   return oop_maps;
1740 }
1741 
1742 #undef __


1564         LP64_ONLY(__ pop(rdx);)
1565         __ pop(rcx);
1566         __ pop(rsi);
1567         __ ret(0);
1568       }
1569       break;
1570 
1571 #ifndef SERIALGC
1572     case g1_pre_barrier_slow_id:
1573       {
1574         StubFrame f(sasm, "g1_pre_barrier", dont_gc_arguments);
1575         // arg0 : previous value of memory
1576 
1577         BarrierSet* bs = Universe::heap()->barrier_set();
1578         if (bs->kind() != BarrierSet::G1SATBCTLogging) {
1579           __ movptr(rax, (int)id);
1580           __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
1581           __ should_not_reach_here();
1582           break;
1583         }

1584         __ push(rax);
1585         __ push(rdx);
1586 
1587         const Register pre_val = rax;
1588         const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1589         const Register tmp = rdx;
1590 
1591         NOT_LP64(__ get_thread(thread);)
1592 
1593         Address in_progress(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1594                                              PtrQueue::byte_offset_of_active()));
1595 
1596         Address queue_index(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1597                                              PtrQueue::byte_offset_of_index()));
1598         Address buffer(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1599                                         PtrQueue::byte_offset_of_buf()));
1600 
1601 
1602         Label done;
1603         Label runtime;
1604 
1605         // Can we store original value in the thread's buffer?
1606 

1607 #ifdef _LP64
1608         __ movslq(tmp, queue_index);
1609         __ cmpq(tmp, 0);
1610 #else
1611         __ cmpl(queue_index, 0);
1612 #endif
1613         __ jcc(Assembler::equal, runtime);
1614 #ifdef _LP64
1615         __ subq(tmp, wordSize);
1616         __ movl(queue_index, tmp);
1617         __ addq(tmp, buffer);
1618 #else
1619         __ subl(queue_index, wordSize);
1620         __ movl(tmp, buffer);
1621         __ addl(tmp, queue_index);
1622 #endif
1623 
1624         // prev_val (rax)
1625         f.load_argument(0, pre_val);
1626         __ movptr(Address(tmp, 0), pre_val);
1627         __ jmp(done);
1628 
1629         __ bind(runtime);

1630         __ push(rcx);
1631 #ifdef _LP64
1632         __ push(r8);
1633         __ push(r9);
1634         __ push(r10);
1635         __ push(r11);
1636 #  ifndef _WIN64
1637         __ push(rdi);
1638         __ push(rsi);
1639 #  endif
1640 #endif
1641         // load the pre-value
1642         f.load_argument(0, rcx);
1643         __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), rcx, thread);
1644 #ifdef _LP64
1645 #  ifndef _WIN64
1646         __ pop(rsi);
1647         __ pop(rdi);
1648 #  endif
1649         __ pop(r11);
1650         __ pop(r10);
1651         __ pop(r9);
1652         __ pop(r8);
1653 #endif
1654         __ pop(rcx);

1655         __ bind(done);
1656 
1657         __ pop(rdx);
1658         __ pop(rax);
1659       }
1660       break;
1661 
1662     case g1_post_barrier_slow_id:
1663       {
1664         StubFrame f(sasm, "g1_post_barrier", dont_gc_arguments);
1665 
1666 
1667         // arg0: store_address
1668         Address store_addr(rbp, 2*BytesPerWord);
1669 
1670         BarrierSet* bs = Universe::heap()->barrier_set();
1671         CardTableModRefBS* ct = (CardTableModRefBS*)bs;
1672         Label done;
1673         Label runtime;
1674 
1675         // At this point we know new_value is non-NULL and the new_value crosses regsion.
1676         // Must check to see if card is already dirty
1677 
1678         const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1679 
1680         Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
1681                                              PtrQueue::byte_offset_of_index()));
1682         Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
1683                                         PtrQueue::byte_offset_of_buf()));
1684 
1685         __ push(rax);
1686         __ push(rcx);
1687 
1688         NOT_LP64(__ get_thread(thread);)
1689         ExternalAddress cardtable((address)ct->byte_map_base);
1690         assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
1691 
1692         const Register card_addr = rcx;
1693 #ifdef _LP64
1694         const Register tmp = rscratch1;
1695         f.load_argument(0, card_addr);
1696         __ shrq(card_addr, CardTableModRefBS::card_shift);
1697         __ lea(tmp, cardtable);
1698         // get the address of the card
1699         __ addq(card_addr, tmp);
1700 #else
1701         const Register card_index = rcx;
1702         f.load_argument(0, card_index);
1703         __ shrl(card_index, CardTableModRefBS::card_shift);
1704 
1705         Address index(noreg, card_index, Address::times_1);
1706         __ leal(card_addr, __ as_Address(ArrayAddress(cardtable, index)));
1707 #endif
1708 
1709         __ cmpb(Address(card_addr, 0), 0);
1710         __ jcc(Assembler::equal, done);
1711 
1712         // storing region crossing non-NULL, card is clean.
1713         // dirty card and log.
1714 
1715         __ movb(Address(card_addr, 0), 0);
1716 
1717         __ cmpl(queue_index, 0);
1718         __ jcc(Assembler::equal, runtime);
1719         __ subl(queue_index, wordSize);
1720 
1721         const Register buffer_addr = rbx;
1722         __ push(rbx);
1723 
1724         __ movptr(buffer_addr, buffer);
1725 
1726 #ifdef _LP64
1727         __ movslq(rscratch1, queue_index);
1728         __ addptr(buffer_addr, rscratch1);
1729 #else
1730         __ addptr(buffer_addr, queue_index);
1731 #endif
1732         __ movptr(Address(buffer_addr, 0), card_addr);
1733 
1734         __ pop(rbx);
1735         __ jmp(done);
1736 
1737         __ bind(runtime);
1738         __ push(rdx);
1739 #ifdef _LP64
1740         __ push(r8);
1741         __ push(r9);
1742         __ push(r10);
1743         __ push(r11);
1744 #  ifndef _WIN64
1745         __ push(rdi);
1746         __ push(rsi);
1747 #  endif
1748 #endif
1749         __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
1750 #ifdef _LP64
1751 #  ifndef _WIN64
1752         __ pop(rsi);
1753         __ pop(rdi);
1754 #  endif
1755         __ pop(r11);
1756         __ pop(r10);
1757         __ pop(r9);
1758         __ pop(r8);
1759 #endif
1760         __ pop(rdx);
1761         __ bind(done);
1762 
1763         __ pop(rcx);
1764         __ pop(rax);
1765 
1766       }
1767       break;
1768 #endif // !SERIALGC
1769 
1770     default:
1771       { StubFrame f(sasm, "unimplemented entry", dont_gc_arguments);
1772         __ movptr(rax, (int)id);
1773         __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
1774         __ should_not_reach_here();
1775       }
1776       break;
1777   }
1778   return oop_maps;
1779 }
1780 
1781 #undef __