diff options
-rw-r--r-- | src/binary-reader-ast.c | 16 | ||||
-rw-r--r-- | test/regress/regress-7.txt | 54 | ||||
-rw-r--r-- | test/regress/regress-8.txt | 54 |
3 files changed, 118 insertions, 6 deletions
diff --git a/src/binary-reader-ast.c b/src/binary-reader-ast.c index 956d2be1..b010c76f 100644 --- a/src/binary-reader-ast.c +++ b/src/binary-reader-ast.c @@ -280,7 +280,9 @@ static WabtResult on_import_global(uint32_t import_index, static WabtResult on_function_signatures_count(uint32_t count, void* user_data) { Context* ctx = user_data; - wabt_reserve_func_ptrs(ctx->allocator, &ctx->module->funcs, count); + wabt_reserve_func_ptrs(ctx->allocator, + &ctx->module->funcs, + ctx->module->num_func_imports + count); return WABT_OK; } @@ -311,7 +313,8 @@ static WabtResult on_function_signature(uint32_t index, static WabtResult on_table_count(uint32_t count, void* user_data) { Context* ctx = user_data; - wabt_reserve_table_ptrs(ctx->allocator, &ctx->module->tables, count); + wabt_reserve_table_ptrs(ctx->allocator, &ctx->module->tables, + ctx->module->num_table_imports + count); return WABT_OK; } @@ -338,7 +341,8 @@ static WabtResult on_table(uint32_t index, static WabtResult on_memory_count(uint32_t count, void* user_data) { Context* ctx = user_data; - wabt_reserve_memory_ptrs(ctx->allocator, &ctx->module->memories, count); + wabt_reserve_memory_ptrs(ctx->allocator, &ctx->module->memories, + ctx->module->num_memory_imports + count); return WABT_OK; } @@ -364,7 +368,8 @@ static WabtResult on_memory(uint32_t index, static WabtResult on_global_count(uint32_t count, void* user_data) { Context* ctx = user_data; - wabt_reserve_global_ptrs(ctx->allocator, &ctx->module->globals, count); + wabt_reserve_global_ptrs(ctx->allocator, &ctx->module->globals, + ctx->module->num_global_imports + count); return WABT_OK; } @@ -373,8 +378,7 @@ static WabtResult begin_global(uint32_t index, WabtBool mutable_, void* user_data) { Context* ctx = user_data; - assert(index - ctx->module->num_global_imports < - ctx->module->globals.capacity); + assert(index < ctx->module->globals.capacity); WabtModuleField* field = wabt_append_module_field(ctx->allocator, ctx->module); diff --git a/test/regress/regress-7.txt b/test/regress/regress-7.txt new file mode 100644 index 00000000..045253b9 --- /dev/null +++ b/test/regress/regress-7.txt @@ -0,0 +1,54 @@ +;;; TOOL: run-gen-wasm +magic +version +section(TYPE) { count[1] function params[0] results[0] } +section(IMPORT) { + count[10] + str("m") str("0") func_kind type[0] + str("m") str("1") func_kind type[0] + str("m") str("2") func_kind type[0] + str("m") str("3") func_kind type[0] + str("m") str("4") func_kind type[0] + str("m") str("5") func_kind type[0] + str("m") str("6") func_kind type[0] + str("m") str("7") func_kind type[0] + str("m") str("8") func_kind type[0] + str("m") str("9") func_kind type[0] +} +section(FUNCTION) { + count[10] + type[0] + type[0] + type[0] + type[0] + type[0] + type[0] + type[0] + type[0] + type[0] + type[0] +} +(;; STDOUT ;;; +(module + (type (;0;) (func)) + (import "m" "0" (func (;0;) (type 0))) + (import "m" "1" (func (;1;) (type 0))) + (import "m" "2" (func (;2;) (type 0))) + (import "m" "3" (func (;3;) (type 0))) + (import "m" "4" (func (;4;) (type 0))) + (import "m" "5" (func (;5;) (type 0))) + (import "m" "6" (func (;6;) (type 0))) + (import "m" "7" (func (;7;) (type 0))) + (import "m" "8" (func (;8;) (type 0))) + (import "m" "9" (func (;9;) (type 0))) + (func (;10;) (type 0)) + (func (;11;) (type 0)) + (func (;12;) (type 0)) + (func (;13;) (type 0)) + (func (;14;) (type 0)) + (func (;15;) (type 0)) + (func (;16;) (type 0)) + (func (;17;) (type 0)) + (func (;18;) (type 0)) + (func (;19;) (type 0))) +;;; STDOUT ;;) diff --git a/test/regress/regress-8.txt b/test/regress/regress-8.txt new file mode 100644 index 00000000..6a21b403 --- /dev/null +++ b/test/regress/regress-8.txt @@ -0,0 +1,54 @@ +;;; TOOL: run-gen-wasm +magic +version +section(TYPE) { count[1] function params[0] results[0] } +section(IMPORT) { + count[10] + str("m") str("0") global_kind i32 mut[0] + str("m") str("1") global_kind i32 mut[0] + str("m") str("2") global_kind i32 mut[0] + str("m") str("3") global_kind i32 mut[0] + str("m") str("4") global_kind i32 mut[0] + str("m") str("5") global_kind i32 mut[0] + str("m") str("6") global_kind i32 mut[0] + str("m") str("7") global_kind i32 mut[0] + str("m") str("8") global_kind i32 mut[0] + str("m") str("9") global_kind i32 mut[0] +} +section(GLOBAL) { + count[10] + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end + i64 mut[0] i64.const 0 end +} +(;; STDOUT ;;; +(module + (type (;0;) (func)) + (import "m" "0" (global (;0;) i32)) + (import "m" "1" (global (;1;) i32)) + (import "m" "2" (global (;2;) i32)) + (import "m" "3" (global (;3;) i32)) + (import "m" "4" (global (;4;) i32)) + (import "m" "5" (global (;5;) i32)) + (import "m" "6" (global (;6;) i32)) + (import "m" "7" (global (;7;) i32)) + (import "m" "8" (global (;8;) i32)) + (import "m" "9" (global (;9;) i32)) + (global (;10;) i64 (i64.const 0)) + (global (;11;) i64 (i64.const 0)) + (global (;12;) i64 (i64.const 0)) + (global (;13;) i64 (i64.const 0)) + (global (;14;) i64 (i64.const 0)) + (global (;15;) i64 (i64.const 0)) + (global (;16;) i64 (i64.const 0)) + (global (;17;) i64 (i64.const 0)) + (global (;18;) i64 (i64.const 0)) + (global (;19;) i64 (i64.const 0))) +;;; STDOUT ;;) |