Support muti-module for AOT mode (#2482)

Support muti-module for AOT mode, currently only implement the
multi-module's function import feature for AOT, the memory/table/
global import are not implemented yet.

And update wamr-test-suites scripts, multi-module sample and some
CIs accordingly.
This commit is contained in:
dongsheng28849455
2023-09-28 08:56:11 +08:00
committed by GitHub
parent fff0e2ad1c
commit 79b27c1934
20 changed files with 1018 additions and 343 deletions

View File

@ -0,0 +1,174 @@
diff --git a/test/core/linking.wast b/test/core/linking.wast
index d0bfb5f..6617945 100644
--- a/test/core/linking.wast
+++ b/test/core/linking.wast
@@ -35,7 +35,7 @@
;; Globals
-
+(;
(module $Mg
(global $glob (export "glob") i32 (i32.const 42))
(func (export "get") (result i32) (global.get $glob))
@@ -63,7 +63,7 @@
(export "Mg.get_mut" (func $get_mut))
(export "Mg.set_mut" (func $set_mut))
)
-
+;)
(;
(assert_return (get $Mg "glob") (i32.const 42))
(assert_return (get $Ng "Mg.glob") (i32.const 42))
@@ -84,7 +84,7 @@
(assert_return (invoke $Ng "Mg.get_mut") (i32.const 241))
;)
-
+(;
(assert_unlinkable
(module (import "Mg" "mut_glob" (global i32)))
"incompatible import type"
@@ -166,7 +166,7 @@
(call_indirect (type 1) (local.get 0))
)
)
-
+;)
(;
(assert_return (invoke $Mt "call" (i32.const 2)) (i32.const 4))
(assert_return (invoke $Nt "Mt.call" (i32.const 2)) (i32.const 4))
@@ -191,7 +191,7 @@
(assert_return (invoke $Nt "call" (i32.const 3)) (i32.const -4))
(assert_trap (invoke $Nt "call" (i32.const 4)) "indirect call type mismatch")
;)
-
+(;
(module $Ot
(type (func (result i32)))
@@ -204,7 +204,7 @@
(call_indirect (type 0) (local.get 0))
)
)
-
+;)
(;
(assert_return (invoke $Mt "call" (i32.const 3)) (i32.const 4))
(assert_return (invoke $Nt "Mt.call" (i32.const 3)) (i32.const 4))
@@ -231,7 +231,7 @@
(assert_trap (invoke $Ot "call" (i32.const 20)) "undefined element")
;)
-
+(;
(module
(table (import "Mt" "tab") 0 funcref)
(elem (i32.const 9) $f)
@@ -266,7 +266,7 @@
"unknown import"
)
(assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized element")
-
+;)
;; Unlike in the v1 spec, active element segments stored before an
;; out-of-bounds access persist after the instantiation failure.
(;
@@ -297,7 +297,7 @@
(assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0))
;)
-
+(;
(module $Mtable_ex
(table $t1 (export "t-func") 1 funcref)
(table $t2 (export "t-extern") 1 externref)
@@ -308,7 +308,7 @@
(table (import "Mtable_ex" "t-func") 1 funcref)
(table (import "Mtable_ex" "t-extern") 1 externref)
)
-
+;)
(;
(assert_unlinkable
(module (table (import "Mtable_ex" "t-func") 1 externref))
@@ -322,7 +322,7 @@
;; Memories
-
+(;
(module $Mm
(memory (export "mem") 1 5)
(data (i32.const 10) "\00\01\02\03\04\05\06\07\08\09")
@@ -357,14 +357,14 @@
(i32.load8_u (local.get 0))
)
)
-
+;)
(;
(assert_return (invoke $Mm "load" (i32.const 12)) (i32.const 0xa7))
(assert_return (invoke $Nm "Mm.load" (i32.const 12)) (i32.const 0xa7))
(assert_return (invoke $Nm "load" (i32.const 12)) (i32.const 0xf2))
(assert_return (invoke $Om "load" (i32.const 12)) (i32.const 0xa7))
;)
-
+(;
(module
(memory (import "Mm" "mem") 0)
(data (i32.const 0xffff) "a")
@@ -385,7 +385,7 @@
(memory.grow (local.get 0))
)
)
-
+;)
(;
(assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 1))
(assert_return (invoke $Pm "grow" (i32.const 2)) (i32.const 1))
@@ -396,7 +396,7 @@
(assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const -1))
(assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5))
;)
-
+(;
(assert_unlinkable
(module
(func $host (import "spectest" "print"))
@@ -419,11 +419,12 @@
)
"out of bounds memory access"
)
+;)
(;
(assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97))
(assert_return (invoke $Mm "load" (i32.const 327670)) (i32.const 0))
;)
-
+(;
(assert_trap
(module
(memory (import "Mm" "mem") 1)
@@ -434,10 +435,11 @@
)
"out of bounds table access"
)
+;)
(;
(assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97))
;)
-
+(;
;; Store is modified if the start function traps.
(module $Ms
(type $t (func (result i32)))
@@ -451,7 +453,7 @@
)
)
(register "Ms" $Ms)
-
+;)
(;
(assert_trap
(module

View File

@ -1299,6 +1299,16 @@ if __name__ == "__main__":
# add new_module copied from the old into temp_file_repo[]
temp_file_repo.append(new_module)
if test_aot:
new_module_aot = os.path.join(tempfile.gettempdir(), name_new + ".aot")
r = compile_wasm_to_aot(new_module, new_module_aot, True, opts, r)
try:
assert_prompt(r, ['Compile success'], opts.start_timeout, True)
except:
raise Exception("compile wasm to aot failed")
# add aot module into temp_file_repo[]
temp_file_repo.append(new_module_aot)
else:
# there is no name defined in register cmd
raise Exception("can not find module name from the register")
@ -1341,3 +1351,4 @@ if __name__ == "__main__":
log("Leaving tempfiles: %s" % ([wast_tempfile, wasm_tempfile]))
sys.exit(ret_code)

View File

@ -333,6 +333,9 @@ function spec_test()
if [[ ${ENABLE_SIMD} == 1 ]]; then
git apply ../../spec-test-script/simd_ignore_cases.patch
fi
if [[ ${ENABLE_MULTI_MODULE} == 1 && $1 == 'aot' ]]; then
git apply ../../spec-test-script/muti_module_aot_ignore_cases.patch
fi
# udpate thread cases
if [ ${ENABLE_MULTI_THREAD} == 1 ]; then
@ -424,7 +427,7 @@ function spec_test()
# multi-module only enable in interp mode
if [[ 1 == ${ENABLE_MULTI_MODULE} ]]; then
if [[ $1 == 'classic-interp' || $1 == 'fast-interp' ]]; then
if [[ $1 == 'classic-interp' || $1 == 'fast-interp' || $1 == 'aot' ]]; then
ARGS_FOR_SPEC_TEST+="-M "
fi
fi
@ -897,4 +900,4 @@ fi
echo -e "Test finish. Reports are under ${REPORT_DIR}"
DEBUG set +xv pipefail
echo "TEST SUCCESSFUL"
exit 0
exit 0