1
1
#pragma once
2
2
3
- #include <string.h>
4
- #include <sys/socket.h>
5
- #include <sys/types.h>
6
- #include <netdb.h>
7
-
8
- #include "admissions_control.h"
9
- #include "admissions_info.h"
10
3
#include "current_wasm_module_instance.h"
11
- #include "panic.h"
12
4
#include "pool.h"
13
- #include "sledge_abi_symbols.h"
14
- #include "tcp_server.h"
15
5
#include "types.h"
16
6
#include "sledge_abi_symbols.h"
17
7
#include "wasm_stack.h"
18
8
#include "wasm_memory.h"
19
- #include "wasm_table.h"
20
9
21
10
extern thread_local int worker_thread_idx ;
22
11
@@ -28,9 +17,15 @@ struct module_pool {
28
17
struct wasm_stack_pool stack ;
29
18
} CACHE_PAD_ALIGNED ;
30
19
20
+ enum module_type
21
+ {
22
+ APP_MODULE ,
23
+ PREPROCESS_MODULE
24
+ };
31
25
struct module {
32
- char * path ;
33
- uint32_t stack_size ; /* a specification? */
26
+ char * path ;
27
+ uint32_t stack_size ; /* a specification? */
28
+ enum module_type type ;
34
29
35
30
/* Handle and ABI Symbols for *.so file */
36
31
struct sledge_abi_symbols abi ;
@@ -41,12 +36,13 @@ struct module {
41
36
struct module_pool * pools ;
42
37
} CACHE_PAD_ALIGNED ;
43
38
39
+
44
40
/********************************
45
41
* Public Methods from module.c *
46
42
*******************************/
47
43
48
44
void module_free (struct module * module );
49
- struct module * module_alloc (char * path );
45
+ struct module * module_alloc (char * path , enum module_type type );
50
46
51
47
/*************************
52
48
* Public Static Inlines *
@@ -115,7 +111,8 @@ module_alloc_table(struct module *module)
115
111
static inline void
116
112
module_initialize_pools (struct module * module )
117
113
{
118
- for (int i = 0 ; i < runtime_worker_threads_count ; i ++ ) {
114
+ /* Create only a single pool for the preprocessing module, since it is executed only by the event core. */
115
+ for (int i = 0 ; i < (module -> type == APP_MODULE ? runtime_worker_threads_count : 1 ); i ++ ) {
119
116
wasm_memory_pool_init (& module -> pools [i ].memory , false);
120
117
wasm_stack_pool_init (& module -> pools [i ].stack , false);
121
118
}
@@ -124,7 +121,7 @@ module_initialize_pools(struct module *module)
124
121
static inline void
125
122
module_deinitialize_pools (struct module * module )
126
123
{
127
- for (int i = 0 ; i < runtime_worker_threads_count ; i ++ ) {
124
+ for (int i = 0 ; i < ( module -> type == APP_MODULE ? runtime_worker_threads_count : 1 ) ; i ++ ) {
128
125
wasm_memory_pool_deinit (& module -> pools [i ].memory );
129
126
wasm_stack_pool_deinit (& module -> pools [i ].stack );
130
127
}
0 commit comments