< prev index next >

src/hotspot/share/runtime/os.cpp

Print this page




1730   bool res = os::pd_commit_memory(addr, size, alignment_hint, executable);
1731   if (res) {
1732     MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1733   }
1734   return res;
1735 }
1736 
1737 void os::commit_memory_or_exit(char* addr, size_t bytes, bool executable,
1738                                const char* mesg) {
1739   pd_commit_memory_or_exit(addr, bytes, executable, mesg);
1740   MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC);
1741 }
1742 
1743 void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint,
1744                                bool executable, const char* mesg) {
1745   os::pd_commit_memory_or_exit(addr, size, alignment_hint, executable, mesg);
1746   MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1747 }
1748 
1749 bool os::uncommit_memory(char* addr, size_t bytes) {
1750   bool res;
1751   if (MemTracker::tracking_level() > NMT_minimal) {
1752     Tracker tkr = MemTracker::get_virtual_memory_uncommit_tracker();
1753     res = pd_uncommit_memory(addr, bytes);
1754     if (res) {
1755       tkr.record((address)addr, bytes);
1756     }
1757   } else {
1758     res = pd_uncommit_memory(addr, bytes);
1759   }
1760   return res;
1761 }
1762 
1763 bool os::release_memory(char* addr, size_t bytes) {
1764   bool res;
1765   if (MemTracker::tracking_level() > NMT_minimal) {
1766     Tracker tkr = MemTracker::get_virtual_memory_release_tracker();
1767     res = pd_release_memory(addr, bytes);
1768     if (res) {
1769       tkr.record((address)addr, bytes);
1770     }
1771   } else {
1772     res = pd_release_memory(addr, bytes);
1773   }
1774   return res;
1775 }
1776 
1777 void os::pretouch_memory(void* start, void* end, size_t page_size) {
1778   for (volatile char *p = (char*)start; p < (char*)end; p += page_size) {
1779     *p = 0;
1780   }
1781 }
1782 
1783 char* os::map_memory(int fd, const char* file_name, size_t file_offset,
1784                            char *addr, size_t bytes, bool read_only,
1785                            bool allow_exec) {
1786   char* result = pd_map_memory(fd, file_name, file_offset, addr, bytes, read_only, allow_exec);
1787   if (result != NULL) {
1788     MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC);
1789   }
1790   return result;
1791 }
1792 
1793 char* os::remap_memory(int fd, const char* file_name, size_t file_offset,
1794                              char *addr, size_t bytes, bool read_only,
1795                              bool allow_exec) {
1796   return pd_remap_memory(fd, file_name, file_offset, addr, bytes,
1797                     read_only, allow_exec);
1798 }
1799 
1800 bool os::unmap_memory(char *addr, size_t bytes) {
1801   bool result;
1802   if (MemTracker::tracking_level() > NMT_minimal) {
1803     Tracker tkr = MemTracker::get_virtual_memory_release_tracker();
1804     result = pd_unmap_memory(addr, bytes);
1805     if (result) {
1806       tkr.record((address)addr, bytes);
1807     }
1808   } else {
1809     result = pd_unmap_memory(addr, bytes);
1810   }
1811   return result;
1812 }
1813 
1814 void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) {
1815   pd_free_memory(addr, bytes, alignment_hint);
1816 }
1817 
1818 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
1819   pd_realign_memory(addr, bytes, alignment_hint);
1820 }
1821 
1822 #ifndef _WINDOWS
1823 /* try to switch state from state "from" to state "to"
1824  * returns the state set after the method is complete
1825  */
1826 os::SuspendResume::State os::SuspendResume::switch_state(os::SuspendResume::State from,
1827                                                          os::SuspendResume::State to)
1828 {
1829   os::SuspendResume::State result =
1830     (os::SuspendResume::State) Atomic::cmpxchg((jint) to, (jint *) &_state, (jint) from);
1831   if (result == from) {


1730   bool res = os::pd_commit_memory(addr, size, alignment_hint, executable);
1731   if (res) {
1732     MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1733   }
1734   return res;
1735 }
1736 
1737 void os::commit_memory_or_exit(char* addr, size_t bytes, bool executable,
1738                                const char* mesg) {
1739   pd_commit_memory_or_exit(addr, bytes, executable, mesg);
1740   MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC);
1741 }
1742 
1743 void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint,
1744                                bool executable, const char* mesg) {
1745   os::pd_commit_memory_or_exit(addr, size, alignment_hint, executable, mesg);
1746   MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1747 }
1748 
1749 bool os::uncommit_memory(char* addr, size_t bytes) {
1750   bool res = pd_uncommit_memory(addr, bytes);



1751   if (res) {
1752     MemTracker::record_virtual_memory_uncommit(addr, bytes);



1753   }
1754   return res;
1755 }
1756 
1757 bool os::release_memory(char* addr, size_t bytes) {
1758   bool res = pd_release_memory(addr, bytes);



1759   if (res) {
1760     MemTracker::record_virtual_memory_release(addr, bytes);



1761   }
1762   return res;
1763 }
1764 
1765 void os::pretouch_memory(void* start, void* end, size_t page_size) {
1766   for (volatile char *p = (char*)start; p < (char*)end; p += page_size) {
1767     *p = 0;
1768   }
1769 }
1770 
1771 char* os::map_memory(int fd, const char* file_name, size_t file_offset,
1772                            char *addr, size_t bytes, bool read_only,
1773                            bool allow_exec) {
1774   char* result = pd_map_memory(fd, file_name, file_offset, addr, bytes, read_only, allow_exec);
1775   if (result != NULL) {
1776     MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC);
1777   }
1778   return result;
1779 }
1780 
1781 char* os::remap_memory(int fd, const char* file_name, size_t file_offset,
1782                              char *addr, size_t bytes, bool read_only,
1783                              bool allow_exec) {
1784   return pd_remap_memory(fd, file_name, file_offset, addr, bytes,
1785                     read_only, allow_exec);
1786 }
1787 
1788 bool os::unmap_memory(char *addr, size_t bytes) {
1789   bool res = pd_unmap_memory(addr, bytes);
1790   if (res) {
1791     MemTracker::record_virtual_memory_release(addr, bytes);






1792   }
1793   return res;
1794 }
1795 
1796 void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) {
1797   pd_free_memory(addr, bytes, alignment_hint);
1798 }
1799 
1800 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
1801   pd_realign_memory(addr, bytes, alignment_hint);
1802 }
1803 
1804 #ifndef _WINDOWS
1805 /* try to switch state from state "from" to state "to"
1806  * returns the state set after the method is complete
1807  */
1808 os::SuspendResume::State os::SuspendResume::switch_state(os::SuspendResume::State from,
1809                                                          os::SuspendResume::State to)
1810 {
1811   os::SuspendResume::State result =
1812     (os::SuspendResume::State) Atomic::cmpxchg((jint) to, (jint *) &_state, (jint) from);
1813   if (result == from) {
< prev index next >