294 size_t alignment_hint = 0);
295 static char* reserve_memory(size_t bytes, char* addr,
296 size_t alignment_hint, MEMFLAGS flags);
297 static char* reserve_memory_aligned(size_t size, size_t alignment);
298 static char* attempt_reserve_memory_at(size_t bytes, char* addr);
299 static void split_reserved_memory(char *base, size_t size,
300 size_t split, bool realloc);
301 static bool commit_memory(char* addr, size_t bytes, bool executable);
302 static bool commit_memory(char* addr, size_t size, size_t alignment_hint,
303 bool executable);
304 // Same as commit_memory() that either succeeds or calls
305 // vm_exit_out_of_memory() with the specified mesg.
306 static void commit_memory_or_exit(char* addr, size_t bytes,
307 bool executable, const char* mesg);
308 static void commit_memory_or_exit(char* addr, size_t size,
309 size_t alignment_hint,
310 bool executable, const char* mesg);
311 static bool uncommit_memory(char* addr, size_t bytes);
312 static bool release_memory(char* addr, size_t bytes);
313
314 static void pretouch_memory(char* start, char* end);
315
316 enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX };
317 static bool protect_memory(char* addr, size_t bytes, ProtType prot,
318 bool is_committed = true);
319
320 static bool guard_memory(char* addr, size_t bytes);
321 static bool unguard_memory(char* addr, size_t bytes);
322 static bool create_stack_guard_pages(char* addr, size_t bytes);
323 static bool pd_create_stack_guard_pages(char* addr, size_t bytes);
324 static bool remove_stack_guard_pages(char* addr, size_t bytes);
325
326 static char* map_memory(int fd, const char* file_name, size_t file_offset,
327 char *addr, size_t bytes, bool read_only = false,
328 bool allow_exec = false);
329 static char* remap_memory(int fd, const char* file_name, size_t file_offset,
330 char *addr, size_t bytes, bool read_only,
331 bool allow_exec);
332 static bool unmap_memory(char *addr, size_t bytes);
333 static void free_memory(char *addr, size_t bytes, size_t alignment_hint);
|
294 size_t alignment_hint = 0);
295 static char* reserve_memory(size_t bytes, char* addr,
296 size_t alignment_hint, MEMFLAGS flags);
297 static char* reserve_memory_aligned(size_t size, size_t alignment);
298 static char* attempt_reserve_memory_at(size_t bytes, char* addr);
299 static void split_reserved_memory(char *base, size_t size,
300 size_t split, bool realloc);
301 static bool commit_memory(char* addr, size_t bytes, bool executable);
302 static bool commit_memory(char* addr, size_t size, size_t alignment_hint,
303 bool executable);
304 // Same as commit_memory() that either succeeds or calls
305 // vm_exit_out_of_memory() with the specified mesg.
306 static void commit_memory_or_exit(char* addr, size_t bytes,
307 bool executable, const char* mesg);
308 static void commit_memory_or_exit(char* addr, size_t size,
309 size_t alignment_hint,
310 bool executable, const char* mesg);
311 static bool uncommit_memory(char* addr, size_t bytes);
312 static bool release_memory(char* addr, size_t bytes);
313
314 // Touch memory pages that cover the memory range from start to end (exclusive)
315 // to make the OS back the memory range with actual memory.
316 // Current implementation may not touch the last page if unaligned addresses
317 // are passed.
318 static void pretouch_memory(char* start, char* end);
319
320 enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX };
321 static bool protect_memory(char* addr, size_t bytes, ProtType prot,
322 bool is_committed = true);
323
324 static bool guard_memory(char* addr, size_t bytes);
325 static bool unguard_memory(char* addr, size_t bytes);
326 static bool create_stack_guard_pages(char* addr, size_t bytes);
327 static bool pd_create_stack_guard_pages(char* addr, size_t bytes);
328 static bool remove_stack_guard_pages(char* addr, size_t bytes);
329
330 static char* map_memory(int fd, const char* file_name, size_t file_offset,
331 char *addr, size_t bytes, bool read_only = false,
332 bool allow_exec = false);
333 static char* remap_memory(int fd, const char* file_name, size_t file_offset,
334 char *addr, size_t bytes, bool read_only,
335 bool allow_exec);
336 static bool unmap_memory(char *addr, size_t bytes);
337 static void free_memory(char *addr, size_t bytes, size_t alignment_hint);
|