59 #include "runtime/threadSMR.hpp"
60 #include "runtime/vm_version.hpp"
61 #include "services/attachListener.hpp"
62 #include "services/mallocTracker.hpp"
63 #include "services/memTracker.hpp"
64 #include "services/nmtCommon.hpp"
65 #include "services/threadService.hpp"
66 #include "utilities/align.hpp"
67 #include "utilities/defaultStream.hpp"
68 #include "utilities/events.hpp"
69
70 # include <signal.h>
71 # include <errno.h>
72
73 OSThread* os::_starting_thread = NULL;
74 address os::_polling_page = NULL;
75 volatile int32_t* os::_mem_serialize_page = NULL;
76 uintptr_t os::_serialize_page_mask = 0;
77 volatile unsigned int os::_rand_seed = 1;
78 int os::_processor_count = 0;
79 int os::_initial_active_processor_count = 0;
80 size_t os::_page_sizes[os::page_sizes_max];
81
82 #ifndef PRODUCT
83 julong os::num_mallocs = 0; // # of calls to malloc/realloc
84 julong os::alloc_bytes = 0; // # of bytes allocated
85 julong os::num_frees = 0; // # of calls to free
86 julong os::free_bytes = 0; // # of bytes freed
87 #endif
88
89 static size_t cur_malloc_words = 0; // current size for MallocMaxTestWords
90
91 void os_init_globals() {
92 // Called from init_globals().
93 // See Threads::create_vm() in thread.cpp, and init.cpp.
94 os::init_globals();
95 }
96
97 static time_t get_timezone(const struct tm* time_struct) {
98 #if defined(_ALLBSD_SOURCE)
1729 if (result != NULL) {
1730 MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC);
1731 }
1732 }
1733 return result;
1734 }
1735
1736 void os::split_reserved_memory(char *base, size_t size,
1737 size_t split, bool realloc) {
1738 pd_split_reserved_memory(base, size, split, realloc);
1739 }
1740
1741 bool os::commit_memory(char* addr, size_t bytes, bool executable) {
1742 bool res = pd_commit_memory(addr, bytes, executable);
1743 if (res) {
1744 MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC);
1745 }
1746 return res;
1747 }
1748
1749 bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
1750 bool executable) {
1751 bool res = os::pd_commit_memory(addr, size, alignment_hint, executable);
1752 if (res) {
1753 MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1754 }
1755 return res;
1756 }
1757
1758 void os::commit_memory_or_exit(char* addr, size_t bytes, bool executable,
1759 const char* mesg) {
1760 pd_commit_memory_or_exit(addr, bytes, executable, mesg);
1761 MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC);
1762 }
1763
1764 void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint,
1765 bool executable, const char* mesg) {
1766 os::pd_commit_memory_or_exit(addr, size, alignment_hint, executable, mesg);
1767 MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1768 }
1769
1770 bool os::uncommit_memory(char* addr, size_t bytes) {
1771 bool res;
1772 if (MemTracker::tracking_level() > NMT_minimal) {
1773 Tracker tkr(Tracker::uncommit);
1774 res = pd_uncommit_memory(addr, bytes);
1775 if (res) {
|
59 #include "runtime/threadSMR.hpp"
60 #include "runtime/vm_version.hpp"
61 #include "services/attachListener.hpp"
62 #include "services/mallocTracker.hpp"
63 #include "services/memTracker.hpp"
64 #include "services/nmtCommon.hpp"
65 #include "services/threadService.hpp"
66 #include "utilities/align.hpp"
67 #include "utilities/defaultStream.hpp"
68 #include "utilities/events.hpp"
69
70 # include <signal.h>
71 # include <errno.h>
72
73 OSThread* os::_starting_thread = NULL;
74 address os::_polling_page = NULL;
75 volatile int32_t* os::_mem_serialize_page = NULL;
76 uintptr_t os::_serialize_page_mask = 0;
77 volatile unsigned int os::_rand_seed = 1;
78 int os::_processor_count = 0;
79 bool os::_nvdimm_present = false;
80 int os::_nvdimm_fd = -1;
81 address os::_dram_heap_base = NULL;
82 address os::_nvdimm_heap_base = NULL;
83 uint os::_nvdimm_region_length = 0;
84 int os::_initial_active_processor_count = 0;
85 size_t os::_page_sizes[os::page_sizes_max];
86
87 #ifndef PRODUCT
88 julong os::num_mallocs = 0; // # of calls to malloc/realloc
89 julong os::alloc_bytes = 0; // # of bytes allocated
90 julong os::num_frees = 0; // # of calls to free
91 julong os::free_bytes = 0; // # of bytes freed
92 #endif
93
94 static size_t cur_malloc_words = 0; // current size for MallocMaxTestWords
95
96 void os_init_globals() {
97 // Called from init_globals().
98 // See Threads::create_vm() in thread.cpp, and init.cpp.
99 os::init_globals();
100 }
101
102 static time_t get_timezone(const struct tm* time_struct) {
103 #if defined(_ALLBSD_SOURCE)
1734 if (result != NULL) {
1735 MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC);
1736 }
1737 }
1738 return result;
1739 }
1740
1741 void os::split_reserved_memory(char *base, size_t size,
1742 size_t split, bool realloc) {
1743 pd_split_reserved_memory(base, size, split, realloc);
1744 }
1745
1746 bool os::commit_memory(char* addr, size_t bytes, bool executable) {
1747 bool res = pd_commit_memory(addr, bytes, executable);
1748 if (res) {
1749 MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC);
1750 }
1751 return res;
1752 }
1753
1754 bool os::commit_memory(char* addr, size_t size, bool executable, int file_desc, size_t offset) {
1755
1756 bool res = false;
1757
1758 if (os::map_memory_to_file(addr, size, file_desc, offset, executable, false) != NULL) {
1759 MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1760 return true;
1761 }
1762 return false;
1763 }
1764
1765 bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
1766 bool executable) {
1767 bool res = os::pd_commit_memory(addr, size, alignment_hint, executable);
1768 if (res) {
1769 MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1770 }
1771 return res;
1772 }
1773
1774 bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
1775 bool executable, int file_desc, size_t offset) {
1776
1777 // ignoring alignemnt hint.
1778 bool res = false;
1779 if (os::map_memory_to_file(addr, size, file_desc, offset, executable, false) != NULL) {
1780 MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1781 return true;
1782 }
1783 return false;
1784 }
1785
1786 void os::commit_memory_or_exit(char* addr, size_t bytes, bool executable,
1787 const char* mesg) {
1788 pd_commit_memory_or_exit(addr, bytes, executable, mesg);
1789 MemTracker::record_virtual_memory_commit((address)addr, bytes, CALLER_PC);
1790 }
1791
1792 void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint,
1793 bool executable, const char* mesg) {
1794 os::pd_commit_memory_or_exit(addr, size, alignment_hint, executable, mesg);
1795 MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC);
1796 }
1797
1798 bool os::uncommit_memory(char* addr, size_t bytes) {
1799 bool res;
1800 if (MemTracker::tracking_level() > NMT_minimal) {
1801 Tracker tkr(Tracker::uncommit);
1802 res = pd_uncommit_memory(addr, bytes);
1803 if (res) {
|