chore: replace exists with panics

main
Sean McBride 4 years ago
parent 9eb5541afa
commit 4742a86d39

@ -1,5 +1,6 @@
/* Code from https://github.com/gwsystems/silverfish/blob/master/runtime/memory/64bit_nix.c */ /* Code from https://github.com/gwsystems/silverfish/blob/master/runtime/memory/64bit_nix.c */
#include "current_sandbox.h" #include "current_sandbox.h"
#include "panic.h"
#include "runtime.h" #include "runtime.h"
#include "sandbox.h" #include "sandbox.h"
#include "types.h" #include "types.h"
@ -36,16 +37,12 @@ expand_memory(void)
void *map_result = mmap(page_address, WASM_PAGE_SIZE, PROT_READ | PROT_WRITE, void *map_result = mmap(page_address, WASM_PAGE_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (map_result == MAP_FAILED) {
perror("Mapping of new memory failed");
exit(1);
}
// TODO: check sandbox->linear_memory_max_size // TODO: Refactor to return RC signifying out-of-mem to caller
if (local_sandbox_member_cache.linear_memory_size > sandbox->linear_memory_max_size) { if (map_result == MAP_FAILED) panic("Mapping of new memory failed");
printf("expand_memory - Out of Memory!\n"); if (local_sandbox_member_cache.linear_memory_size > sandbox->linear_memory_max_size)
exit(EXIT_FAILURE); panic("expand_memory - Out of Memory!\n");
}
local_sandbox_member_cache.linear_memory_size += WASM_PAGE_SIZE; local_sandbox_member_cache.linear_memory_size += WASM_PAGE_SIZE;
// local_sandbox_member_cache is "forked state", so update authoritative member // local_sandbox_member_cache is "forked state", so update authoritative member
sandbox->linear_memory_size = local_sandbox_member_cache.linear_memory_size; sandbox->linear_memory_size = local_sandbox_member_cache.linear_memory_size;

Loading…
Cancel
Save