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