269 270 // Return the default page size. 271 static int vm_page_size(); 272 273 // Returns the page size to use for a region of memory. 274 // region_size / min_pages will always be greater than or equal to the 275 // returned value. The returned value will divide region_size. 276 static size_t page_size_for_region_aligned(size_t region_size, size_t min_pages); 277 278 // Returns the page size to use for a region of memory. 279 // region_size / min_pages will always be greater than or equal to the 280 // returned value. The returned value might not divide region_size. 281 static size_t page_size_for_region_unaligned(size_t region_size, size_t min_pages); 282 283 // Return the largest page size that can be used 284 static size_t max_page_size() { 285 // The _page_sizes array is sorted in descending order. 286 return _page_sizes[0]; 287 } 288 289 // Methods for tracing page sizes returned by the above method; enabled by 290 // TracePageSizes. The region_{min,max}_size parameters should be the values 291 // passed to page_size_for_region() and page_size should be the result of that 292 // call. The (optional) base and size parameters should come from the 293 // ReservedSpace base() and size() methods. 294 static void trace_page_sizes(const char* str, const size_t* page_sizes, 295 int count) PRODUCT_RETURN; 296 static void trace_page_sizes(const char* str, const size_t region_min_size, 297 const size_t region_max_size, 298 const size_t page_size, 299 const char* base = NULL, 300 const size_t size = 0) PRODUCT_RETURN; 301 302 static int vm_allocation_granularity(); 303 static char* reserve_memory(size_t bytes, char* addr = 0, 304 size_t alignment_hint = 0); 305 static char* reserve_memory(size_t bytes, char* addr, 306 size_t alignment_hint, MEMFLAGS flags); 307 static char* reserve_memory_aligned(size_t size, size_t alignment); 308 static char* attempt_reserve_memory_at(size_t bytes, char* addr); 309 static void split_reserved_memory(char *base, size_t size, 310 size_t split, bool realloc); 311 static bool commit_memory(char* addr, size_t bytes, bool executable); 312 static bool commit_memory(char* addr, size_t size, size_t alignment_hint, 313 bool executable); 314 // Same as commit_memory() that either succeeds or calls 315 // vm_exit_out_of_memory() with the specified mesg. 316 static void commit_memory_or_exit(char* addr, size_t bytes, 317 bool executable, const char* mesg); 318 static void commit_memory_or_exit(char* addr, size_t size, 319 size_t alignment_hint, 320 bool executable, const char* mesg); | 269 270 // Return the default page size. 271 static int vm_page_size(); 272 273 // Returns the page size to use for a region of memory. 274 // region_size / min_pages will always be greater than or equal to the 275 // returned value. The returned value will divide region_size. 276 static size_t page_size_for_region_aligned(size_t region_size, size_t min_pages); 277 278 // Returns the page size to use for a region of memory. 279 // region_size / min_pages will always be greater than or equal to the 280 // returned value. The returned value might not divide region_size. 281 static size_t page_size_for_region_unaligned(size_t region_size, size_t min_pages); 282 283 // Return the largest page size that can be used 284 static size_t max_page_size() { 285 // The _page_sizes array is sorted in descending order. 286 return _page_sizes[0]; 287 } 288 289 // Methods for tracing page sizes returned by the above method. 290 // The region_{min,max}_size parameters should be the values 291 // passed to page_size_for_region() and page_size should be the result of that 292 // call. The (optional) base and size parameters should come from the 293 // ReservedSpace base() and size() methods. 294 static void trace_page_sizes(const char* str, const size_t* page_sizes, int count); 295 static void trace_page_sizes(const char* str, 296 const size_t region_min_size, 297 const size_t region_max_size, 298 const size_t page_size, 299 const char* base, 300 const size_t size); 301 static void trace_page_sizes_for_requested_size(const char* str, 302 const size_t requested_size, 303 const size_t page_size, 304 const size_t alignment, 305 const char* base, 306 const size_t size); 307 308 static int vm_allocation_granularity(); 309 static char* reserve_memory(size_t bytes, char* addr = 0, 310 size_t alignment_hint = 0); 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); 314 static char* attempt_reserve_memory_at(size_t bytes, char* addr); 315 static void split_reserved_memory(char *base, size_t size, 316 size_t split, bool realloc); 317 static bool commit_memory(char* addr, size_t bytes, bool executable); 318 static bool commit_memory(char* addr, size_t size, size_t alignment_hint, 319 bool executable); 320 // Same as commit_memory() that either succeeds or calls 321 // vm_exit_out_of_memory() with the specified mesg. 322 static void commit_memory_or_exit(char* addr, size_t bytes, 323 bool executable, const char* mesg); 324 static void commit_memory_or_exit(char* addr, size_t size, 325 size_t alignment_hint, 326 bool executable, const char* mesg); |