mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-12 15:33:16 +00:00
Compare commits
4 Commits
1ecc3afe5b
...
bcf9261b98
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bcf9261b98 | ||
![]() |
7e9861f460 | ||
![]() |
e1f106fb4a | ||
![]() |
3473216850 |
|
@ -1267,6 +1267,9 @@ wasm_runtime_is_built_in_module(const char *module_name)
|
|||
|| !strcmp("wasi_snapshot_preview1", module_name)
|
||||
#if WASM_ENABLE_SPEC_TEST != 0
|
||||
|| !strcmp("spectest", module_name)
|
||||
#endif
|
||||
#if WASM_ENABLE_LIB_WASI_THREADS != 0
|
||||
|| !strcmp("foo", module_name)
|
||||
#endif
|
||||
|| !strcmp("", module_name));
|
||||
}
|
||||
|
|
|
@ -2904,6 +2904,29 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end,
|
|||
declare_init_page_count = spectest_memory_init_page;
|
||||
declare_max_page_count = spectest_memory_max_page;
|
||||
}
|
||||
#if WASM_ENABLE_LIB_WASI_THREADS != 0
|
||||
/* a case in wasi-testsuite which imports ("foo" "bar") */
|
||||
else if (!strcmp("foo", sub_module_name)) {
|
||||
uint32 spectest_memory_init_page = 1;
|
||||
uint32 spectest_memory_max_page = 1;
|
||||
|
||||
if (strcmp("bar", memory_name)) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"incompatible import type or unknown import");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (declare_init_page_count > spectest_memory_init_page
|
||||
|| declare_max_page_count < spectest_memory_max_page) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"incompatible import type");
|
||||
return false;
|
||||
}
|
||||
|
||||
declare_init_page_count = spectest_memory_init_page;
|
||||
declare_max_page_count = spectest_memory_max_page;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* now we believe all declaration are ok */
|
||||
memory->mem_type.flags = mem_flag;
|
||||
|
|
|
@ -1702,9 +1702,6 @@ check_linked_symbol(WASMModuleInstance *module_inst, char *error_buf,
|
|||
WASMModule *module = module_inst->module;
|
||||
uint32 i;
|
||||
|
||||
if (wasm_runtime_is_built_in_module(module->name))
|
||||
return true;
|
||||
|
||||
for (i = 0; i < module->import_function_count; i++) {
|
||||
WASMFunctionImport *func =
|
||||
&((module->import_functions + i)->u.function);
|
||||
|
@ -1713,40 +1710,37 @@ check_linked_symbol(WASMModuleInstance *module_inst, char *error_buf,
|
|||
&& !func->import_func_linked
|
||||
#endif
|
||||
) {
|
||||
#if WASM_ENABLE_WAMR_COMPILER == 0
|
||||
LOG_WARNING("warning: failed to link import function (%s, %s)",
|
||||
func->module_name, func->field_name);
|
||||
/* will throw exception only if calling */
|
||||
#else
|
||||
/* do nothing to avoid confused message */
|
||||
#endif /* WASM_ENABLE_WAMR_COMPILER == 0 */
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < module->import_global_count; i++) {
|
||||
WASMGlobalImport *global = &((module->import_globals + i)->u.global);
|
||||
if (!global->is_linked) {
|
||||
|
||||
if (!global->is_linked
|
||||
&& !wasm_runtime_is_built_in_module(global->module_name)) {
|
||||
#if WASM_ENABLE_SPEC_TEST != 0
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"unknown import or incompatible import type");
|
||||
return false;
|
||||
#else
|
||||
#if WASM_ENABLE_WAMR_COMPILER == 0
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"failed to link import global (%s, %s)",
|
||||
global->module_name, global->field_name);
|
||||
return false;
|
||||
#else
|
||||
/* do nothing to avoid confused message */
|
||||
#endif /* WASM_ENABLE_WAMR_COMPILER == 0 */
|
||||
#endif /* WASM_ENABLE_SPEC_TEST != 0 */
|
||||
}
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_WAMR_COMPILER == 0 && WASM_ENABLE_MULTI_MODULE != 0
|
||||
for (i = 0; i < module->import_table_count; i++) {
|
||||
WASMTableImport *table = &((module->import_tables + i)->u.table);
|
||||
if (!table->import_table_linked) {
|
||||
|
||||
if (!wasm_runtime_is_built_in_module(table->module_name)
|
||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||
&& !table->import_table_linked
|
||||
#endif
|
||||
) {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"failed to link import table (%s, %s)",
|
||||
table->module_name, table->field_name);
|
||||
|
@ -1756,7 +1750,12 @@ check_linked_symbol(WASMModuleInstance *module_inst, char *error_buf,
|
|||
|
||||
for (i = 0; i < module->import_memory_count; i++) {
|
||||
WASMMemoryImport *memory = &((module->import_memories + i)->u.memory);
|
||||
if (!memory->import_memory_linked) {
|
||||
|
||||
if (!wasm_runtime_is_built_in_module(memory->module_name)
|
||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||
&& !memory->import_memory_linked
|
||||
#endif
|
||||
) {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"failed to link import memory (%s, %s)",
|
||||
memory->module_name, memory->field_name);
|
||||
|
@ -1764,9 +1763,11 @@ check_linked_symbol(WASMModuleInstance *module_inst, char *error_buf,
|
|||
}
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||
#if WASM_ENABLE_TAGS != 0
|
||||
for (i = 0; i < module->import_tag_count; i++) {
|
||||
WASMTagImport *tag = &((module->import_tags + i)->u.tag);
|
||||
|
||||
if (!tag->import_tag_linked) {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"failed to link import tag (%s, %s)",
|
||||
|
@ -1775,7 +1776,7 @@ check_linked_symbol(WASMModuleInstance *module_inst, char *error_buf,
|
|||
}
|
||||
}
|
||||
#endif /* WASM_ENABLE_TAGS != 0 */
|
||||
#endif /* WASM_ENABLE_WAMR_COMPILER == 0 && WASM_ENABLE_MULTI_MODULE != 0 */
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
diff --git a/test/core/data.wast b/test/core/data.wast
|
||||
index b1e1239..a0f6967 100644
|
||||
index b1e12397..a0f69676 100644
|
||||
--- a/test/core/data.wast
|
||||
+++ b/test/core/data.wast
|
||||
@@ -312,7 +312,8 @@
|
||||
|
@ -43,26 +43,28 @@ index b1e1239..a0f6967 100644
|
|||
|
||||
|
||||
diff --git a/test/core/elem.wast b/test/core/elem.wast
|
||||
index 33b3f67..c72431c 100644
|
||||
index 4a399eca..3da365e5 100644
|
||||
--- a/test/core/elem.wast
|
||||
+++ b/test/core/elem.wast
|
||||
@@ -595,9 +595,11 @@
|
||||
(func $const-i32-d (type $out-i32) (i32.const 68))
|
||||
)
|
||||
@@ -594,6 +594,7 @@
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 65))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 66))
|
||||
|
||||
+(;
|
||||
(module $module2
|
||||
(type $out-i32 (func (result i32)))
|
||||
(import "module1" "shared-table" (table 10 funcref))
|
||||
@@ -606,7 +607,9 @@
|
||||
(assert_return (invoke $module1 "call-7") (i32.const 67))
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 68))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 66))
|
||||
+;)
|
||||
|
||||
+(;
|
||||
(module $module3
|
||||
(type $out-i32 (func (result i32)))
|
||||
@@ -608,9 +610,11 @@
|
||||
(func $const-i32-f (type $out-i32) (i32.const 70))
|
||||
)
|
||||
|
||||
+(;
|
||||
(import "module1" "shared-table" (table 10 funcref))
|
||||
@@ -619,6 +622,7 @@
|
||||
(assert_return (invoke $module1 "call-7") (i32.const 67))
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 69))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 70))
|
||||
|
@ -70,7 +72,7 @@ index 33b3f67..c72431c 100644
|
|||
|
||||
;; Element segments must match element type of table
|
||||
|
||||
@@ -643,6 +647,7 @@
|
||||
@@ -651,6 +655,7 @@
|
||||
|
||||
;; Initializing a table with an externref-type element segment
|
||||
|
||||
|
@ -78,7 +80,7 @@ index 33b3f67..c72431c 100644
|
|||
(module $m
|
||||
(table $t (export "table") 2 externref)
|
||||
(func (export "get") (param $i i32) (result externref)
|
||||
@@ -667,9 +672,11 @@
|
||||
@@ -675,9 +680,11 @@
|
||||
|
||||
(assert_return (invoke $m "get" (i32.const 0)) (ref.null extern))
|
||||
(assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137))
|
||||
|
@ -90,35 +92,13 @@ index 33b3f67..c72431c 100644
|
|||
(module $module4
|
||||
(func (result i32)
|
||||
i32.const 42
|
||||
@@ -690,3 +697,4 @@
|
||||
@@ -698,3 +705,4 @@
|
||||
)
|
||||
|
||||
(assert_return (invoke "call_imported_elem") (i32.const 42))
|
||||
+;)
|
||||
\ No newline at end of file
|
||||
diff --git a/test/core/try_catch.wast b/test/core/try_catch.wast
|
||||
index 2a0e9ff6..f243489d 100644
|
||||
--- a/test/core/try_catch.wast
|
||||
+++ b/test/core/try_catch.wast
|
||||
@@ -203,7 +203,6 @@
|
||||
|
||||
(assert_return (invoke "catch-param-i32" (i32.const 5)) (i32.const 5))
|
||||
|
||||
-(assert_return (invoke "catch-imported") (i32.const 2))
|
||||
|
||||
(assert_return (invoke "catchless-try" (i32.const 0)) (i32.const 0))
|
||||
(assert_return (invoke "catchless-try" (i32.const 1)) (i32.const 1))
|
||||
@@ -231,7 +230,6 @@
|
||||
)
|
||||
)
|
||||
|
||||
-(assert_return (invoke "imported-mismatch") (i32.const 3))
|
||||
|
||||
(assert_malformed
|
||||
(module quote "(module (func (catch_all)))")
|
||||
|
||||
diff --git a/test/core/ref_func.wast b/test/core/ref_func.wast
|
||||
index adb5cb7..6396013 100644
|
||||
index adb5cb78..6396013b 100644
|
||||
--- a/test/core/ref_func.wast
|
||||
+++ b/test/core/ref_func.wast
|
||||
@@ -4,7 +4,7 @@
|
||||
|
@ -131,7 +111,7 @@ index adb5cb7..6396013 100644
|
|||
(i32.add (local.get $x) (i32.const 1))
|
||||
)
|
||||
diff --git a/test/core/table_copy.wast b/test/core/table_copy.wast
|
||||
index 380e84e..59230cf 100644
|
||||
index 380e84ee..59230cfb 100644
|
||||
--- a/test/core/table_copy.wast
|
||||
+++ b/test/core/table_copy.wast
|
||||
@@ -14,11 +14,11 @@
|
||||
|
@ -441,7 +421,7 @@ index 380e84e..59230cf 100644
|
|||
(table $t1 30 30 funcref)
|
||||
(elem (table $t1) (i32.const 2) func 3 1 4 1)
|
||||
diff --git a/test/core/table_init.wast b/test/core/table_init.wast
|
||||
index 0b2d26f..3c595e5 100644
|
||||
index 0b2d26f7..3c595e5b 100644
|
||||
--- a/test/core/table_init.wast
|
||||
+++ b/test/core/table_init.wast
|
||||
@@ -14,11 +14,11 @@
|
||||
|
@ -546,3 +526,23 @@ index 0b2d26f..3c595e5 100644
|
|||
(table $t0 30 30 funcref)
|
||||
(table $t1 30 30 funcref)
|
||||
(elem (table $t1) (i32.const 2) func 3 1 4 1)
|
||||
diff --git a/test/core/try_catch.wast b/test/core/try_catch.wast
|
||||
index 2a0e9ff6..f243489d 100644
|
||||
--- a/test/core/try_catch.wast
|
||||
+++ b/test/core/try_catch.wast
|
||||
@@ -203,7 +203,6 @@
|
||||
|
||||
(assert_return (invoke "catch-param-i32" (i32.const 5)) (i32.const 5))
|
||||
|
||||
-(assert_return (invoke "catch-imported") (i32.const 2))
|
||||
|
||||
(assert_return (invoke "catchless-try" (i32.const 0)) (i32.const 0))
|
||||
(assert_return (invoke "catchless-try" (i32.const 1)) (i32.const 1))
|
||||
@@ -231,7 +230,6 @@
|
||||
)
|
||||
)
|
||||
|
||||
-(assert_return (invoke "imported-mismatch") (i32.const 3))
|
||||
|
||||
(assert_malformed
|
||||
(module quote "(module (func (catch_all)))")
|
||||
|
|
|
@ -43,26 +43,28 @@ index b1e1239..a0f6967 100644
|
|||
|
||||
|
||||
diff --git a/test/core/elem.wast b/test/core/elem.wast
|
||||
index 33b3f67..c72431c 100644
|
||||
index 33b3f67..a4c1a2d 100644
|
||||
--- a/test/core/elem.wast
|
||||
+++ b/test/core/elem.wast
|
||||
@@ -595,9 +595,11 @@
|
||||
(func $const-i32-d (type $out-i32) (i32.const 68))
|
||||
)
|
||||
@@ -586,6 +586,7 @@
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 65))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 66))
|
||||
|
||||
+(;
|
||||
(module $module2
|
||||
(type $out-i32 (func (result i32)))
|
||||
(import "module1" "shared-table" (table 10 funcref))
|
||||
@@ -598,7 +599,9 @@
|
||||
(assert_return (invoke $module1 "call-7") (i32.const 67))
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 68))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 66))
|
||||
+;)
|
||||
|
||||
+(;
|
||||
(module $module3
|
||||
(type $out-i32 (func (result i32)))
|
||||
@@ -608,9 +610,11 @@
|
||||
(func $const-i32-f (type $out-i32) (i32.const 70))
|
||||
)
|
||||
|
||||
+(;
|
||||
(import "module1" "shared-table" (table 10 funcref))
|
||||
@@ -611,6 +614,7 @@
|
||||
(assert_return (invoke $module1 "call-7") (i32.const 67))
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 69))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 70))
|
||||
|
@ -95,7 +97,6 @@ index 33b3f67..c72431c 100644
|
|||
|
||||
(assert_return (invoke "call_imported_elem") (i32.const 42))
|
||||
+;)
|
||||
\ No newline at end of file
|
||||
diff --git a/test/core/if.wast b/test/core/if.wast
|
||||
index 2ea45f6..6f07304 100644
|
||||
--- a/test/core/if.wast
|
||||
|
|
|
@ -70,10 +70,10 @@ index 4090b2c..18f66b4 100644
|
|||
;; Start section
|
||||
(module binary
|
||||
diff --git a/test/core/data.wast b/test/core/data.wast
|
||||
index b1e1239..74a7b04 100644
|
||||
index 4f339be..0b5b3e6 100644
|
||||
--- a/test/core/data.wast
|
||||
+++ b/test/core/data.wast
|
||||
@@ -312,9 +312,10 @@
|
||||
@@ -306,9 +306,10 @@
|
||||
"\02\01\41\00\0b" ;; active data segment 0 for memory 1
|
||||
"\00" ;; empty vec(byte)
|
||||
)
|
||||
|
@ -85,7 +85,7 @@ index b1e1239..74a7b04 100644
|
|||
;; Data segment with memory index 0 (no memory section)
|
||||
(assert_invalid
|
||||
(module binary
|
||||
@@ -323,7 +324,7 @@
|
||||
@@ -317,7 +318,7 @@
|
||||
"\00\41\00\0b" ;; active data segment 0 for memory 0
|
||||
"\00" ;; empty vec(byte)
|
||||
)
|
||||
|
@ -94,7 +94,7 @@ index b1e1239..74a7b04 100644
|
|||
)
|
||||
|
||||
;; Data segment with memory index 1 (no memory section)
|
||||
@@ -334,7 +335,7 @@
|
||||
@@ -328,7 +329,7 @@
|
||||
"\02\01\41\00\0b" ;; active data segment 0 for memory 1
|
||||
"\00" ;; empty vec(byte)
|
||||
)
|
||||
|
@ -103,7 +103,7 @@ index b1e1239..74a7b04 100644
|
|||
)
|
||||
|
||||
;; Data segment with memory index 1 and vec(byte) as above,
|
||||
@@ -354,7 +355,7 @@
|
||||
@@ -348,7 +349,7 @@
|
||||
"\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f"
|
||||
"\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d"
|
||||
)
|
||||
|
@ -112,7 +112,7 @@ index b1e1239..74a7b04 100644
|
|||
)
|
||||
|
||||
;; Data segment with memory index 1 and specially crafted vec(byte) after.
|
||||
@@ -374,8 +375,9 @@
|
||||
@@ -368,8 +369,9 @@
|
||||
"\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f"
|
||||
"\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d"
|
||||
)
|
||||
|
@ -124,26 +124,28 @@ index b1e1239..74a7b04 100644
|
|||
|
||||
;; Invalid offsets
|
||||
diff --git a/test/core/elem.wast b/test/core/elem.wast
|
||||
index 575ecef..6eecab9 100644
|
||||
index 575ecef..dd1106c 100644
|
||||
--- a/test/core/elem.wast
|
||||
+++ b/test/core/elem.wast
|
||||
@@ -571,9 +571,11 @@
|
||||
(func $const-i32-d (type $out-i32) (i32.const 68))
|
||||
)
|
||||
@@ -562,6 +562,7 @@
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 65))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 66))
|
||||
|
||||
+(;
|
||||
(module $module2
|
||||
(type $out-i32 (func (result i32)))
|
||||
(import "module1" "shared-table" (table 10 funcref))
|
||||
@@ -574,7 +575,9 @@
|
||||
(assert_return (invoke $module1 "call-7") (i32.const 67))
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 68))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 66))
|
||||
+;)
|
||||
|
||||
+(;
|
||||
(module $module3
|
||||
(type $out-i32 (func (result i32)))
|
||||
@@ -584,6 +586,8 @@
|
||||
(func $const-i32-f (type $out-i32) (i32.const 70))
|
||||
)
|
||||
|
||||
+(;
|
||||
(import "module1" "shared-table" (table 10 funcref))
|
||||
@@ -587,3 +590,4 @@
|
||||
(assert_return (invoke $module1 "call-7") (i32.const 67))
|
||||
(assert_return (invoke $module1 "call-8") (i32.const 69))
|
||||
(assert_return (invoke $module1 "call-9") (i32.const 70))
|
||||
|
|
Loading…
Reference in New Issue
Block a user