Просмотр исходного кода

Make max table size configurable through macro (#2632)

Xu Jun 2 лет назад
Родитель
Сommit
872db7c22a

+ 4 - 0
core/config.h

@@ -519,4 +519,8 @@
 #define WASM_MAX_INSTANCE_CONTEXTS 8
 #endif
 
+#ifndef WASM_TABLE_MAX_SIZE
+#define WASM_TABLE_MAX_SIZE 1024
+#endif
+
 #endif /* end of _CONFIG_H_ */

+ 0 - 2
core/iwasm/interpreter/wasm.h

@@ -94,8 +94,6 @@ typedef void *table_elem_type_t;
 #define REF_CELL_NUM ((uint32)sizeof(uintptr_t) / sizeof(uint32))
 #endif
 
-#define TABLE_MAX_SIZE (1024)
-
 #define INIT_EXPR_TYPE_I32_CONST 0x41
 #define INIT_EXPR_TYPE_I64_CONST 0x42
 #define INIT_EXPR_TYPE_F32_CONST 0x43

+ 3 - 2
core/iwasm/interpreter/wasm_loader.c

@@ -1500,8 +1500,9 @@ fail:
 static void
 adjust_table_max_size(uint32 init_size, uint32 max_size_flag, uint32 *max_size)
 {
-    uint32 default_max_size =
-        init_size * 2 > TABLE_MAX_SIZE ? init_size * 2 : TABLE_MAX_SIZE;
+    uint32 default_max_size = init_size * 2 > WASM_TABLE_MAX_SIZE
+                                  ? init_size * 2
+                                  : WASM_TABLE_MAX_SIZE;
 
     if (max_size_flag) {
         /* module defines the table limitation */

+ 3 - 2
core/iwasm/interpreter/wasm_mini_loader.c

@@ -440,8 +440,9 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
 static void
 adjust_table_max_size(uint32 init_size, uint32 max_size_flag, uint32 *max_size)
 {
-    uint32 default_max_size =
-        init_size * 2 > TABLE_MAX_SIZE ? init_size * 2 : TABLE_MAX_SIZE;
+    uint32 default_max_size = init_size * 2 > WASM_TABLE_MAX_SIZE
+                                  ? init_size * 2
+                                  : WASM_TABLE_MAX_SIZE;
 
     if (max_size_flag) {
         /* module defines the table limitation */