refactor: decompose types.h

main
Sean McBride 4 years ago
parent 486a72647b
commit d6f10cac7a

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "sandbox.h" #include "sandbox.h"
#include "types.h"
void current_sandbox_close_file_descriptor(int io_handle_index); void current_sandbox_close_file_descriptor(int io_handle_index);
struct sandbox * current_sandbox_get(void); struct sandbox * current_sandbox_get(void);

@ -0,0 +1,25 @@
#pragma once
#include <stdint.h>
extern int32_t debuglog_file_descriptor;
/**
* debuglog is a macro that behaves based on the macros DEBUG and LOG_TO_FILE
* If DEBUG is not set, debuglog does nothing
* If DEBUG is set and LOG_TO_FILE is set, debuglog prints to the logfile defined in debuglog_file_descriptor
* If DEBUG is set and LOG_TO_FILE is not set, debuglog prints to STDOUT
*/
#ifdef DEBUG
#ifdef LOG_TO_FILE
#define debuglog(fmt, ...) \
dprintf(debuglog_file_descriptor, "C: %02d, T: 0x%lx, F: %s> \n\t" fmt "\n", sched_getcpu(), pthread_self(), \
__func__, ##__VA_ARGS__);
#else /* !LOG_TO_FILE */
#define debuglog(fmt, ...) \
fprintf(stderr, "C: %02d, T: 0x%lx, F: %s> \n\t" fmt "\n", sched_getcpu(), pthread_self(), __func__, \
##__VA_ARGS__);
#endif /* LOG_TO_FILE */
#else /* !DEBUG */
#define debuglog(fmt, ...)
#endif /* DEBUG */

@ -0,0 +1,5 @@
#pragma once
#define HTTP_MAX_HEADER_COUNT 16
#define HTTP_MAX_HEADER_LENGTH 32
#define HTTP_MAX_HEADER_VALUE_LENGTH 64

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "types.h" #include "http.h"
/* all in-memory ptrs.. don't mess around with that! */ /* all in-memory ptrs.. don't mess around with that! */
struct http_header { struct http_header {

@ -2,14 +2,20 @@
#include <http_parser.h> #include <http_parser.h>
#include <sys/uio.h> #include <sys/uio.h>
#include "types.h"
/* Conditionally load libuv */ /* Conditionally load libuv */
#ifdef USE_HTTP_UVIO #ifdef USE_HTTP_UVIO
#include <uv.h> #include <uv.h>
#endif #endif
#include "http.h"
#define HTTP_RESPONSE_200_OK "HTTP/1.1 200 OK\r\n"
#define HTTP_RESPONSE_CONTENT_LENGTH "Content-Length: "
#define HTTP_RESPONSE_CONTENT_LENGTH_TERMINATOR "\r\n\r\n" /* content body follows this */
#define HTTP_RESPONSE_CONTENT_TYPE "Content-Type: "
#define HTTP_RESPONSE_CONTENT_TYPE_PLAIN "text/plain"
#define HTTP_RESPONSE_CONTENT_TYPE_TERMINATOR " \r\n"
struct http_response_header { struct http_response_header {
char *header; char *header;
int length; int length;

@ -1,11 +1,29 @@
#pragma once #pragma once
#include <string.h>
#include <uv.h> #include <uv.h>
#include "http.h"
#include "panic.h" #include "panic.h"
#include "software_interrupt.h" #include "software_interrupt.h"
#include "types.h" #include "types.h"
/* Wasm initialization functions generated by the compiler */
#define MODULE_INITIALIZE_GLOBALS "populate_globals"
#define MODULE_INITIALIZE_MEMORY "populate_memory"
#define MODULE_INITIALIZE_TABLE "populate_table"
#define MODULE_INITIALIZE_LIBC "wasmf___init_libc"
#define MODULE_MAIN "wasmf_main"
#define MODULE_DEFAULT_REQUEST_RESPONSE_SIZE (PAGE_SIZE)
#define MODULE_MAX_ARGUMENT_COUNT 16
#define MODULE_MAX_ARGUMENT_SIZE 64
#define MODULE_MAX_MODULE_COUNT 128
#define MODULE_MAX_NAME_LENGTH 32
#define MODULE_MAX_PATH_LENGTH 256
#define MODULE_MAX_PENDING_CLIENT_REQUESTS 1000
struct module { struct module {
char name[MODULE_MAX_NAME_LENGTH]; char name[MODULE_MAX_NAME_LENGTH];
char path[MODULE_MAX_PATH_LENGTH]; char path[MODULE_MAX_PATH_LENGTH];

@ -3,6 +3,13 @@
#include <sys/epoll.h> /* for epoll_create1(), epoll_ctl(), struct epoll_event */ #include <sys/epoll.h> /* for epoll_create1(), epoll_ctl(), struct epoll_event */
#include "types.h" #include "types.h"
#define LISTENER_THREAD_CORE_ID 0 /* Dedicated Listener Core */
#define LISTENER_THREAD_MAX_EPOLL_EVENTS 1024
#define RUNTIME_LOG_FILE "awesome.log"
#define RUNTIME_MAX_SANDBOX_REQUEST_COUNT (1 << 19) /* random! */
#define RUNTIME_READ_WRITE_VECTOR_LENGTH 16
extern int runtime_epoll_file_descriptor; extern int runtime_epoll_file_descriptor;
extern uint32_t runtime_total_worker_processors; extern uint32_t runtime_total_worker_processors;

@ -3,16 +3,21 @@
#include <ucontext.h> #include <ucontext.h>
#include <uv.h> #include <uv.h>
#include <stdbool.h> #include <stdbool.h>
#include "sandbox_request.h"
#include "arch/context.h" #include "arch/context.h"
#include "debuglog.h"
#include "deque.h" #include "deque.h"
#include "http_request.h" #include "http_request.h"
#include "http_response.h" #include "http_response.h"
#include "module.h" #include "module.h"
#include "ps_list.h" #include "ps_list.h"
#include "sandbox_request.h"
#include "software_interrupt.h" #include "software_interrupt.h"
#define SANDBOX_FILE_DESCRIPTOR_PREOPEN_MAGIC (707707707) /* upside down LOLLOLLOL 🤣😂🤣*/
#define SANDBOX_MAX_IO_HANDLE_COUNT 32
#define SANDBOX_MAX_MEMORY (1L << 32) /* 4GB */
/********************* /*********************
* Structs and Types * * Structs and Types *
********************/ ********************/
@ -323,12 +328,12 @@ sandbox_print_perf(struct sandbox *sandbox)
queued_us, initializing_us, runnable_us, running_us, blocked_us, returned_us); queued_us, initializing_us, runnable_us, running_us, blocked_us, returned_us);
} }
void sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sandbox_request, INLINE void sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sandbox_request,
uint64_t allocation_timestamp) __attribute__((always_inline)); uint64_t allocation_timestamp);
void sandbox_set_as_runnable(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); INLINE void sandbox_set_as_runnable(struct sandbox *sandbox, sandbox_state_t last_state);
void sandbox_set_as_running(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); INLINE void sandbox_set_as_running(struct sandbox *sandbox, sandbox_state_t last_state);
void sandbox_set_as_blocked(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); INLINE void sandbox_set_as_blocked(struct sandbox *sandbox, sandbox_state_t last_state);
void sandbox_set_as_preempted(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); INLINE void sandbox_set_as_preempted(struct sandbox *sandbox, sandbox_state_t last_state);
void sandbox_set_as_returned(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); INLINE void sandbox_set_as_returned(struct sandbox *sandbox, sandbox_state_t last_state);
void sandbox_set_as_complete(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); INLINE void sandbox_set_as_complete(struct sandbox *sandbox, sandbox_state_t last_state);
void sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); INLINE void sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state);

@ -2,10 +2,10 @@
#include <stdbool.h> #include <stdbool.h>
#include "debuglog.h"
#include "deque.h" #include "deque.h"
#include "module.h" #include "module.h"
#include "runtime.h" #include "runtime.h"
#include "types.h"
extern float runtime_processor_speed_MHz; extern float runtime_processor_speed_MHz;

@ -8,6 +8,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define SOFTWARE_INTERRUPT_TIME_TO_START_IN_USEC (10 * 1000) /* 10 ms */
#define SOFTWARE_INTERRUPT_INTERVAL_DURATION_IN_USEC (5 * 1000) /* 5 ms */
/************ /************
* Externs * * Externs *
***********/ ***********/

@ -1,34 +1,13 @@
#pragma once #pragma once
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <math.h>
#include <printf.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <time.h>
#include <unistd.h>
#define EXPORT __attribute__((visibility("default")))
#define IMPORT __attribute__((visibility("default")))
#define INLINE __attribute__((always_inline))
#define WEAK __attribute__((weak))
#ifndef PAGE_SIZE #ifndef PAGE_SIZE
#define PAGE_SIZE (1 << 12) #define PAGE_SIZE (1 << 12)
#endif #endif
#define PAGE_ALIGNED __attribute__((aligned(PAGE_SIZE)))
/* For this family of macros, do NOT pass zero as the pow2 */ /* For this family of macros, do NOT pass zero as the pow2 */
#define round_to_pow2(x, pow2) (((unsigned long)(x)) & (~((pow2)-1))) #define round_to_pow2(x, pow2) (((unsigned long)(x)) & (~((pow2)-1)))
#define round_up_to_pow2(x, pow2) (round_to_pow2(((unsigned long)x) + (pow2)-1, (pow2))) #define round_up_to_pow2(x, pow2) (round_to_pow2(((unsigned long)x) + (pow2)-1, (pow2)))
@ -36,21 +15,22 @@
#define round_to_page(x) round_to_pow2(x, PAGE_SIZE) #define round_to_page(x) round_to_pow2(x, PAGE_SIZE)
#define round_up_to_page(x) round_up_to_pow2(x, PAGE_SIZE) #define round_up_to_page(x) round_up_to_pow2(x, PAGE_SIZE)
#define EXPORT __attribute__((visibility("default")))
#define IMPORT __attribute__((visibility("default")))
#define INLINE __attribute__((always_inline))
#define PAGE_ALIGNED __attribute__((aligned(PAGE_SIZE)))
#define WEAK __attribute__((weak))
/* FIXME: per-module configuration? */ /* FIXME: per-module configuration? */
#define WASM_PAGE_SIZE (1024 * 64) /* 64KB */ #define WASM_PAGE_SIZE (1024 * 64) /* 64KB */
#define WASM_START_PAGES (1 << 8) /* 16MB */ #define WASM_START_PAGES (1 << 8) /* 16MB */
#define WASM_MAX_PAGES (1 << 15) /* 4GB */ #define WASM_MAX_PAGES (1 << 15) /* 4GB */
#define WASM_STACK_SIZE (1 << 19) /* 512KB */ #define WASM_STACK_SIZE (1 << 19) /* 512KB */
#define SBOX_MAX_MEM (1L << 32) /* 4GB */
/* These are per module symbols and I'd need to dlsym for each module. instead just use global constants, see above /* These are per module symbols and I'd need to dlsym for each module. instead just use global constants, see above
macros. The code generator compiles in the starting number of wasm pages, and the maximum number of pages If we try macros. The code generator compiles in the starting number of wasm pages, and the maximum number of pages If we try
and allocate more than max_pages, we should fault */ and allocate more than max_pages, we should fault */
// TODO: Should this be deleted?
// extern uint32_t starting_pages;
// extern uint32_t max_pages;
/* The code generator also compiles in stubs that populate the linear memory and function table */ /* The code generator also compiles in stubs that populate the linear memory and function table */
void populate_memory(void); void populate_memory(void);
void populate_table(void); void populate_table(void);
@ -72,83 +52,9 @@ struct sandbox_context_cache {
extern __thread struct sandbox_context_cache local_sandbox_context_cache; extern __thread struct sandbox_context_cache local_sandbox_context_cache;
/* TODO: LOG_TO_FILE logic is untested */
extern int32_t runtime_log_file_descriptor;
/* functions in the module to lookup and call per sandbox. */ /* functions in the module to lookup and call per sandbox. */
typedef int32_t (*mod_main_fn_t)(int32_t a, int32_t b); typedef int32_t (*mod_main_fn_t)(int32_t a, int32_t b);
typedef void (*mod_glb_fn_t)(void); typedef void (*mod_glb_fn_t)(void);
typedef void (*mod_mem_fn_t)(void); typedef void (*mod_mem_fn_t)(void);
typedef void (*mod_tbl_fn_t)(void); typedef void (*mod_tbl_fn_t)(void);
typedef void (*mod_libc_fn_t)(int32_t, int32_t); typedef void (*mod_libc_fn_t)(int32_t, int32_t);
/**
* debuglog is a macro that behaves based on the macros DEBUG and LOG_TO_FILE
* If DEBUG is not set, debuglog does nothing
* If DEBUG is set and LOG_TO_FILE is set, debuglog prints to the logfile defined in runtime_log_file_descriptor
* If DEBUG is set adn LOG_TO_FILE is not set, debuglog prints to STDOUT
*/
#ifdef DEBUG
#ifdef LOG_TO_FILE
#define debuglog(fmt, ...) \
dprintf(runtime_log_file_descriptor, "C: %02d, T: 0x%lx, F: %s> \n\t" fmt "\n", sched_getcpu(), \
pthread_self(), __func__, ##__VA_ARGS__);
#else /* !LOG_TO_FILE */
#define debuglog(fmt, ...) \
fprintf(stderr, "C: %02d, T: 0x%lx, F: %s> \n\t" fmt "\n", sched_getcpu(), pthread_self(), __func__, \
##__VA_ARGS__);
#endif /* LOG_TO_FILE */
#else /* !DEBUG */
#define debuglog(fmt, ...)
#endif /* DEBUG */
#define HTTP_MAX_HEADER_COUNT 16
#define HTTP_MAX_HEADER_LENGTH 32
#define HTTP_MAX_HEADER_VALUE_LENGTH 64
#define HTTP_RESPONSE_200_OK "HTTP/1.1 200 OK\r\n"
#define HTTP_RESPONSE_CONTENT_LENGTH "Content-Length: "
#define HTTP_RESPONSE_CONTENT_LENGTH_TERMINATOR "\r\n\r\n" /* content body follows this */
#define HTTP_RESPONSE_CONTENT_TYPE "Content-Type: "
#define HTTP_RESPONSE_CONTENT_TYPE_PLAIN "text/plain"
#define HTTP_RESPONSE_CONTENT_TYPE_TERMINATOR " \r\n"
#define JSON_MAX_ELEMENT_COUNT 16
#define JSON_MAX_ELEMENT_SIZE 1024
#define LISTENER_THREAD_CORE_ID 0 /* Dedicated Listener Core */
#define LISTENER_THREAD_MAX_EPOLL_EVENTS 1024
#define MODULE_DEFAULT_REQUEST_RESPONSE_SIZE (PAGE_SIZE)
/* Wasm initialization functions generated by the compiler */
#define MODULE_INITIALIZE_GLOBALS "populate_globals"
#define MODULE_INITIALIZE_MEMORY "populate_memory"
#define MODULE_INITIALIZE_TABLE "populate_table"
#define MODULE_INITIALIZE_LIBC "wasmf___init_libc"
#define MODULE_MAIN "wasmf_main"
#define MODULE_MAX_ARGUMENT_COUNT 16
#define MODULE_MAX_ARGUMENT_SIZE 64
#define MODULE_MAX_MODULE_COUNT 128
#define MODULE_MAX_NAME_LENGTH 32
#define MODULE_MAX_PATH_LENGTH 256
#define MODULE_MAX_PENDING_CLIENT_REQUESTS 1000
#define RUNTIME_LOG_FILE "awesome.log"
#define RUNTIME_READ_WRITE_VECTOR_LENGTH 16
#define RUNTIME_MAX_SANDBOX_REQUEST_COUNT (1 << 19) /* random! */
#define SANDBOX_FILE_DESCRIPTOR_PREOPEN_MAGIC (707707707) /* upside down LOLLOLLOL 🤣😂🤣*/
#define SANDBOX_MAX_IO_HANDLE_COUNT 32
#define SOFTWARE_INTERRUPT_TIME_TO_START_IN_USEC (10 * 1000) /* 10 ms */
#define SOFTWARE_INTERRUPT_INTERVAL_DURATION_IN_USEC (5 * 1000) /* 5 ms */
/*
* The runtime explicitly requires at least two cores, allocating all as worker threads
* minus the dedicated listener core
*/
#define WORKER_THREAD_CORE_COUNT (NCORES - 1)

@ -2,7 +2,9 @@
#include <uv.h> #include <uv.h>
#include "types.h" /* If multicore, use all but the dedicated listener core
If there are fewer cores than this, main dynamically overrides this and uses all available */
#define WORKER_THREAD_CORE_COUNT (NCORES > 1 ? NCORES - 1 : NCORES)
extern __thread uv_loop_t worker_thread_uvio_handle; extern __thread uv_loop_t worker_thread_uvio_handle;

@ -1,7 +1,7 @@
#include <signal.h> #include <assert.h>
#include <pthread.h> #include <pthread.h>
#include <signal.h>
#include "types.h" #include <stdbool.h>
/** /**
* Called by the inline assembly in arch_context_switch to send a SIGUSR1 in order to restore a previously preempted * Called by the inline assembly in arch_context_switch to send a SIGUSR1 in order to restore a previously preempted

@ -1,5 +1,4 @@
#include "current_sandbox.h" #include "current_sandbox.h"
#include "types.h"
/* current sandbox that is active.. */ /* current sandbox that is active.. */
static __thread struct sandbox *worker_thread_current_sandbox = NULL; static __thread struct sandbox *worker_thread_current_sandbox = NULL;

@ -1,5 +1,7 @@
/* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */ /* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */
#include <assert.h>
#include <ck_pr.h> #include <ck_pr.h>
#include <math.h>
#include "runtime.h" #include "runtime.h"
#include "worker_thread.h" #include "worker_thread.h"

@ -1,4 +1,5 @@
#include "global_request_scheduler.h" #include "global_request_scheduler.h"
#include "runtime.h"
static struct deque_sandbox *global_request_scheduler_deque; static struct deque_sandbox *global_request_scheduler_deque;
static pthread_mutex_t global_request_scheduler_deque_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t global_request_scheduler_deque_mutex = PTHREAD_MUTEX_INITIALIZER;

@ -1,5 +1,6 @@
#include <uv.h> #include <uv.h>
#include "http.h"
#include "http_request.h" #include "http_request.h"
#include "http_response.h" #include "http_response.h"
#include "http_parser_settings.h" #include "http_parser_settings.h"

@ -1,9 +1,10 @@
#include "http_response.h" #include <assert.h>
#ifdef USE_HTTP_UVIO #ifdef USE_HTTP_UVIO
#include <uv.h> #include <uv.h>
#endif #endif
#include "http_response.h"
/*************************************************** /***************************************************
* General HTTP Response Functions * * General HTTP Response Functions *
**************************************************/ **************************************************/

@ -1,11 +1,11 @@
#include <uv.h> #include <uv.h>
#include "current_sandbox.h" #include "current_sandbox.h"
#include "debuglog.h"
#include "http_request.h" #include "http_request.h"
#include "panic.h" #include "panic.h"
#include "runtime.h" #include "runtime.h"
#include "sandbox.h" #include "sandbox.h"
#include "types.h"
#include "worker_thread.h" #include "worker_thread.h"
// What should we tell the child program its UID and GID are? // What should we tell the child program its UID and GID are?

@ -1,3 +1,4 @@
#include "debuglog.h"
#include "local_runqueue_list.h" #include "local_runqueue_list.h"
#include "local_runqueue.h" #include "local_runqueue.h"
#include "global_request_scheduler.h" #include "global_request_scheduler.h"

@ -1,6 +1,7 @@
#include <stdint.h> #include <stdint.h>
#include "current_sandbox.h" #include "current_sandbox.h"
#include "debuglog.h"
#include "global_request_scheduler.h" #include "global_request_scheduler.h"
#include "local_runqueue.h" #include "local_runqueue.h"
#include "local_runqueue_minheap.h" #include "local_runqueue_minheap.h"

@ -8,6 +8,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include "debuglog.h"
#include "module.h" #include "module.h"
#include "panic.h" #include "panic.h"
#include "runtime.h" #include "runtime.h"
@ -17,7 +18,7 @@
/* Conditionally used by debuglog when DEBUG is set */ /* Conditionally used by debuglog when DEBUG is set */
#ifdef DEBUG #ifdef DEBUG
int32_t runtime_log_file_descriptor = -1; int32_t debuglog_file_descriptor = -1;
#endif #endif
float runtime_processor_speed_MHz = 0; float runtime_processor_speed_MHz = 0;
@ -138,13 +139,13 @@ runtime_process_debug_log_behavior()
fclose(stdout); fclose(stdout);
fclose(stderr); fclose(stderr);
fclose(stdin); fclose(stdin);
runtime_log_file_descriptor = open(RUNTIME_LOG_FILE, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU | S_IRWXG); debuglog_file_descriptor = open(RUNTIME_LOG_FILE, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU | S_IRWXG);
if (runtime_log_file_descriptor < 0) { if (debuglog_file_descriptor < 0) {
perror("open"); perror("open");
exit(-1); exit(-1);
} }
#else #else
runtime_log_file_descriptor = 1; debuglog_file_descriptor = 1;
#endif /* LOG_TO_FILE */ #endif /* LOG_TO_FILE */
} }
#endif /* DEBUG */ #endif /* DEBUG */

@ -1,3 +1,6 @@
#include <assert.h>
#include <string.h>
#include "runtime.h" #include "runtime.h"
#include "types.h" #include "types.h"

@ -3,13 +3,18 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <uv.h> #include <uv.h>
#include "debuglog.h"
#include "http.h"
#include "module.h" #include "module.h"
#include "module_database.h" #include "module_database.h"
#include "panic.h" #include "panic.h"
#include "runtime.h" #include "runtime.h"
#include "types.h"
const int JSON_MAX_ELEMENT_COUNT = 16;
const int JSON_MAX_ELEMENT_SIZE = 1024;
/************************* /*************************
* Private Static Inline * * Private Static Inline *

@ -12,7 +12,6 @@
#include "runtime.h" #include "runtime.h"
#include "sandbox_request.h" #include "sandbox_request.h"
#include "software_interrupt.h" #include "software_interrupt.h"
#include "types.h"
/*************************** /***************************
* Shared Process State * * Shared Process State *

@ -5,6 +5,7 @@
#include <uv.h> #include <uv.h>
#include "current_sandbox.h" #include "current_sandbox.h"
#include "debuglog.h"
#include "http_parser_settings.h" #include "http_parser_settings.h"
#include "libuv_callbacks.h" #include "libuv_callbacks.h"
#include "local_completion_queue.h" #include "local_completion_queue.h"
@ -12,7 +13,6 @@
#include "panic.h" #include "panic.h"
#include "runtime.h" #include "runtime.h"
#include "sandbox.h" #include "sandbox.h"
#include "types.h"
#include "worker_thread.h" #include "worker_thread.h"
/** /**
@ -360,7 +360,7 @@ sandbox_allocate_memory(struct module *module)
char * error_message = NULL; char * error_message = NULL;
unsigned long linear_memory_size = WASM_PAGE_SIZE * WASM_START_PAGES; /* The initial pages */ unsigned long linear_memory_size = WASM_PAGE_SIZE * WASM_START_PAGES; /* The initial pages */
uint64_t linear_memory_max_size = (uint64_t)SBOX_MAX_MEM; uint64_t linear_memory_max_size = (uint64_t)SANDBOX_MAX_MEMORY;
struct sandbox *sandbox = NULL; struct sandbox *sandbox = NULL;
unsigned long sandbox_size = sizeof(struct sandbox) + module->max_request_or_response_size; unsigned long sandbox_size = sizeof(struct sandbox) + module->max_request_or_response_size;
@ -835,7 +835,7 @@ err:
void void
sandbox_free_linear_memory(struct sandbox *sandbox) sandbox_free_linear_memory(struct sandbox *sandbox)
{ {
int rc = munmap(sandbox->linear_memory_start, SBOX_MAX_MEM + PAGE_SIZE); int rc = munmap(sandbox->linear_memory_start, SANDBOX_MAX_MEMORY + PAGE_SIZE);
if (rc == -1) panic("sandbox_free_linear_memory - munmap failed\n"); if (rc == -1) panic("sandbox_free_linear_memory - munmap failed\n");
} }

@ -9,13 +9,13 @@
#include "arch/context.h" #include "arch/context.h"
#include "current_sandbox.h" #include "current_sandbox.h"
#include "debuglog.h"
#include "local_runqueue.h" #include "local_runqueue.h"
#include "module.h" #include "module.h"
#include "panic.h" #include "panic.h"
#include "runtime.h" #include "runtime.h"
#include "sandbox.h" #include "sandbox.h"
#include "software_interrupt.h" #include "software_interrupt.h"
#include "types.h"
/******************* /*******************
* Process Globals * * Process Globals *

@ -6,6 +6,7 @@
#include <uv.h> #include <uv.h>
#include "current_sandbox.h" #include "current_sandbox.h"
#include "debuglog.h"
#include "global_request_scheduler.h" #include "global_request_scheduler.h"
#include "local_completion_queue.h" #include "local_completion_queue.h"
#include "local_runqueue.h" #include "local_runqueue.h"
@ -13,7 +14,6 @@
#include "local_runqueue_minheap.h" #include "local_runqueue_minheap.h"
#include "panic.h" #include "panic.h"
#include "runtime.h" #include "runtime.h"
#include "types.h"
#include "worker_thread.h" #include "worker_thread.h"
/*************************** /***************************

Loading…
Cancel
Save