< prev index next >

src/share/vm/runtime/os.hpp

Print this page




 104   friend class JVMCIVMStructs;
 105   friend class MallocTracker;
 106  public:
 107   enum { page_sizes_max = 9 }; // Size of _page_sizes array (8 plus a sentinel)
 108 
 109  private:
 110   static OSThread*          _starting_thread;
 111   static address            _polling_page;
 112   static volatile int32_t * _mem_serialize_page;
 113   static uintptr_t          _serialize_page_mask;
 114  public:
 115   static size_t             _page_sizes[page_sizes_max];
 116 
 117  private:
 118   static void init_page_sizes(size_t default_page_size) {
 119     _page_sizes[0] = default_page_size;
 120     _page_sizes[1] = 0; // sentinel
 121   }
 122 
 123   static char*  pd_reserve_memory(size_t bytes, char* addr = 0,
 124                                size_t alignment_hint = 0);
 125   static char*  pd_attempt_reserve_memory_at(size_t bytes, char* addr);
 126   static void   pd_split_reserved_memory(char *base, size_t size,
 127                                       size_t split, bool realloc);
 128   static bool   pd_commit_memory(char* addr, size_t bytes, bool executable);
 129   static bool   pd_commit_memory(char* addr, size_t size, size_t alignment_hint,
 130                                  bool executable);
 131   // Same as pd_commit_memory() that either succeeds or calls
 132   // vm_exit_out_of_memory() with the specified mesg.
 133   static void   pd_commit_memory_or_exit(char* addr, size_t bytes,
 134                                          bool executable, const char* mesg);
 135   static void   pd_commit_memory_or_exit(char* addr, size_t size,
 136                                          size_t alignment_hint,
 137                                          bool executable, const char* mesg);
 138   static bool   pd_uncommit_memory(char* addr, size_t bytes);
 139   static bool   pd_release_memory(char* addr, size_t bytes);
 140 
 141   static char*  pd_map_memory(int fd, const char* file_name, size_t file_offset,
 142                            char *addr, size_t bytes, bool read_only = false,
 143                            bool allow_exec = false);
 144   static char*  pd_remap_memory(int fd, const char* file_name, size_t file_offset,
 145                              char *addr, size_t bytes, bool read_only,


 289   // The region_{min,max}_size parameters should be the values
 290   // passed to page_size_for_region() and page_size should be the result of that
 291   // call.  The (optional) base and size parameters should come from the
 292   // ReservedSpace base() and size() methods.
 293   static void trace_page_sizes(const char* str, const size_t* page_sizes, int count);
 294   static void trace_page_sizes(const char* str,
 295                                const size_t region_min_size,
 296                                const size_t region_max_size,
 297                                const size_t page_size,
 298                                const char* base,
 299                                const size_t size);
 300   static void trace_page_sizes_for_requested_size(const char* str,
 301                                                   const size_t requested_size,
 302                                                   const size_t page_size,
 303                                                   const size_t alignment,
 304                                                   const char* base,
 305                                                   const size_t size);
 306 
 307   static int    vm_allocation_granularity();
 308   static char*  reserve_memory(size_t bytes, char* addr = 0,
 309                                size_t alignment_hint = 0);

 310   static char*  reserve_memory(size_t bytes, char* addr,
 311                                size_t alignment_hint, MEMFLAGS flags);
 312   static char*  reserve_memory_aligned(size_t size, size_t alignment);
 313   static char*  attempt_reserve_memory_at(size_t bytes, char* addr);

 314   static void   split_reserved_memory(char *base, size_t size,
 315                                       size_t split, bool realloc);
 316   static bool   commit_memory(char* addr, size_t bytes, bool executable);
 317   static bool   commit_memory(char* addr, size_t size, size_t alignment_hint,
 318                               bool executable);
 319   // Same as commit_memory() that either succeeds or calls
 320   // vm_exit_out_of_memory() with the specified mesg.
 321   static void   commit_memory_or_exit(char* addr, size_t bytes,
 322                                       bool executable, const char* mesg);
 323   static void   commit_memory_or_exit(char* addr, size_t size,
 324                                       size_t alignment_hint,
 325                                       bool executable, const char* mesg);
 326   static bool   uncommit_memory(char* addr, size_t bytes);
 327   static bool   release_memory(char* addr, size_t bytes);
 328 
 329   // Touch memory pages that cover the memory range from start to end (exclusive)
 330   // to make the OS back the memory range with actual memory.
 331   // Current implementation may not touch the last page if unaligned addresses
 332   // are passed.
 333   static void   pretouch_memory(void* start, void* end);
 334 
 335   enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX };
 336   static bool   protect_memory(char* addr, size_t bytes, ProtType prot,
 337                                bool is_committed = true);
 338 
 339   static bool   guard_memory(char* addr, size_t bytes);
 340   static bool   unguard_memory(char* addr, size_t bytes);
 341   static bool   create_stack_guard_pages(char* addr, size_t bytes);
 342   static bool   pd_create_stack_guard_pages(char* addr, size_t bytes);
 343   static bool   remove_stack_guard_pages(char* addr, size_t bytes);






 344 
 345   static char*  map_memory(int fd, const char* file_name, size_t file_offset,
 346                            char *addr, size_t bytes, bool read_only = false,
 347                            bool allow_exec = false);
 348   static char*  remap_memory(int fd, const char* file_name, size_t file_offset,
 349                              char *addr, size_t bytes, bool read_only,
 350                              bool allow_exec);
 351   static bool   unmap_memory(char *addr, size_t bytes);
 352   static void   free_memory(char *addr, size_t bytes, size_t alignment_hint);
 353   static void   realign_memory(char *addr, size_t bytes, size_t alignment_hint);
 354 
 355   // NUMA-specific interface
 356   static bool   numa_has_static_binding();
 357   static bool   numa_has_group_homing();
 358   static void   numa_make_local(char *addr, size_t bytes, int lgrp_hint);
 359   static void   numa_make_global(char *addr, size_t bytes);
 360   static size_t numa_get_groups_num();
 361   static size_t numa_get_leaf_groups(int *ids, size_t size);
 362   static bool   numa_topology_changed();
 363   static int    numa_get_group_id();




 104   friend class JVMCIVMStructs;
 105   friend class MallocTracker;
 106  public:
 107   enum { page_sizes_max = 9 }; // Size of _page_sizes array (8 plus a sentinel)
 108 
 109  private:
 110   static OSThread*          _starting_thread;
 111   static address            _polling_page;
 112   static volatile int32_t * _mem_serialize_page;
 113   static uintptr_t          _serialize_page_mask;
 114  public:
 115   static size_t             _page_sizes[page_sizes_max];
 116 
 117  private:
 118   static void init_page_sizes(size_t default_page_size) {
 119     _page_sizes[0] = default_page_size;
 120     _page_sizes[1] = 0; // sentinel
 121   }
 122 
 123   static char*  pd_reserve_memory(size_t bytes, char* addr = 0,
 124                                size_t alignment_hint = 0, int file_desc = -1);
 125   static char*  pd_attempt_reserve_memory_at(size_t bytes, char* addr, int file_desc = -1);
 126   static void   pd_split_reserved_memory(char *base, size_t size,
 127                                       size_t split, bool realloc);
 128   static bool   pd_commit_memory(char* addr, size_t bytes, bool executable);
 129   static bool   pd_commit_memory(char* addr, size_t size, size_t alignment_hint,
 130                                  bool executable);
 131   // Same as pd_commit_memory() that either succeeds or calls
 132   // vm_exit_out_of_memory() with the specified mesg.
 133   static void   pd_commit_memory_or_exit(char* addr, size_t bytes,
 134                                          bool executable, const char* mesg);
 135   static void   pd_commit_memory_or_exit(char* addr, size_t size,
 136                                          size_t alignment_hint,
 137                                          bool executable, const char* mesg);
 138   static bool   pd_uncommit_memory(char* addr, size_t bytes);
 139   static bool   pd_release_memory(char* addr, size_t bytes);
 140 
 141   static char*  pd_map_memory(int fd, const char* file_name, size_t file_offset,
 142                            char *addr, size_t bytes, bool read_only = false,
 143                            bool allow_exec = false);
 144   static char*  pd_remap_memory(int fd, const char* file_name, size_t file_offset,
 145                              char *addr, size_t bytes, bool read_only,


 289   // The region_{min,max}_size parameters should be the values
 290   // passed to page_size_for_region() and page_size should be the result of that
 291   // call.  The (optional) base and size parameters should come from the
 292   // ReservedSpace base() and size() methods.
 293   static void trace_page_sizes(const char* str, const size_t* page_sizes, int count);
 294   static void trace_page_sizes(const char* str,
 295                                const size_t region_min_size,
 296                                const size_t region_max_size,
 297                                const size_t page_size,
 298                                const char* base,
 299                                const size_t size);
 300   static void trace_page_sizes_for_requested_size(const char* str,
 301                                                   const size_t requested_size,
 302                                                   const size_t page_size,
 303                                                   const size_t alignment,
 304                                                   const char* base,
 305                                                   const size_t size);
 306 
 307   static int    vm_allocation_granularity();
 308   static char*  reserve_memory(size_t bytes, char* addr = 0,
 309                                size_t alignment_hint = 0, int file_desc = -1);
 310   static char*  reserve_memory(size_t bytes, int file_desc);
 311   static char*  reserve_memory(size_t bytes, char* addr,
 312                                size_t alignment_hint, MEMFLAGS flags);
 313   static char*  reserve_memory_aligned(size_t size, size_t alignment, int file_desc = -1);
 314   static char*  attempt_reserve_memory_at(size_t bytes, char* addr, int file_desc = -1);
 315 
 316   static void   split_reserved_memory(char *base, size_t size,
 317                                       size_t split, bool realloc);
 318   static bool   commit_memory(char* addr, size_t bytes, bool executable);
 319   static bool   commit_memory(char* addr, size_t size, size_t alignment_hint,
 320                               bool executable);
 321   // Same as commit_memory() that either succeeds or calls
 322   // vm_exit_out_of_memory() with the specified mesg.
 323   static void   commit_memory_or_exit(char* addr, size_t bytes,
 324                                       bool executable, const char* mesg);
 325   static void   commit_memory_or_exit(char* addr, size_t size,
 326                                       size_t alignment_hint,
 327                                       bool executable, const char* mesg);
 328   static bool   uncommit_memory(char* addr, size_t bytes);
 329   static bool   release_memory(char* addr, size_t bytes);
 330 
 331   // Touch memory pages that cover the memory range from start to end (exclusive)
 332   // to make the OS back the memory range with actual memory.
 333   // Current implementation may not touch the last page if unaligned addresses
 334   // are passed.
 335   static void   pretouch_memory(void* start, void* end);
 336 
 337   enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX };
 338   static bool   protect_memory(char* addr, size_t bytes, ProtType prot,
 339                                bool is_committed = true);
 340 
 341   static bool   guard_memory(char* addr, size_t bytes);
 342   static bool   unguard_memory(char* addr, size_t bytes);
 343   static bool   create_stack_guard_pages(char* addr, size_t bytes);
 344   static bool   pd_create_stack_guard_pages(char* addr, size_t bytes);
 345   static bool   remove_stack_guard_pages(char* addr, size_t bytes);
 346 
 347   // Map the given address to the file descriptor.
 348   static char*  map_memory_to_file(char* base, size_t size, int fd);
 349 
 350   // Helper function to create a new file with template jvmheap.XXXXXX
 351   static int create_file_for_heap(const char* dir, size_t size);
 352 
 353   static char*  map_memory(int fd, const char* file_name, size_t file_offset,
 354                            char *addr, size_t bytes, bool read_only = false,
 355                            bool allow_exec = false);
 356   static char*  remap_memory(int fd, const char* file_name, size_t file_offset,
 357                              char *addr, size_t bytes, bool read_only,
 358                              bool allow_exec);
 359   static bool   unmap_memory(char *addr, size_t bytes);
 360   static void   free_memory(char *addr, size_t bytes, size_t alignment_hint);
 361   static void   realign_memory(char *addr, size_t bytes, size_t alignment_hint);
 362 
 363   // NUMA-specific interface
 364   static bool   numa_has_static_binding();
 365   static bool   numa_has_group_homing();
 366   static void   numa_make_local(char *addr, size_t bytes, int lgrp_hint);
 367   static void   numa_make_global(char *addr, size_t bytes);
 368   static size_t numa_get_groups_num();
 369   static size_t numa_get_leaf_groups(int *ids, size_t size);
 370   static bool   numa_topology_changed();
 371   static int    numa_get_group_id();


< prev index next >