Update spec cases to latest version (#1253)

Update spec cases of mvp/threads to latest version, update wabt
to 1.0.29. And enhance the wasm loader.
This commit is contained in:
Wenyong Huang 2022-06-28 16:05:16 +08:00 committed by GitHub
parent 5e238322c2
commit 625d59191d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 43 deletions

View File

@ -2171,6 +2171,15 @@ load_export_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
export = module->exports;
for (i = 0; i < export_count; i++, export ++) {
#if WASM_ENABLE_THREAD_MGR == 0
if (p == p_end) {
/* export section with inconsistent count:
n export declared, but less than n given */
set_error_buf(error_buf, error_buf_size,
"length out of bounds");
return false;
}
#endif
read_leb_uint32(p, p_end, str_len);
CHECK_BUF(p, p_end, str_len);
@ -9319,8 +9328,15 @@ re_scan:
}
if (loader_ctx->csp_num > 0) {
set_error_buf(error_buf, error_buf_size,
"function body must end with END opcode");
if (cur_func_idx < module->function_count - 1)
/* Function with missing end marker (between two functions) */
set_error_buf(error_buf, error_buf_size, "END opcode expected");
else
/* Function with missing end marker
(at EOF or end of code sections) */
set_error_buf(error_buf, error_buf_size,
"unexpected end of section or function, "
"or section size mismatch");
goto fail;
}

View File

@ -1491,8 +1491,8 @@ wasm_instantiate(WASMModule *module, bool is_sub_inst, uint32 stack_size,
if (stack_size == 0)
stack_size = DEFAULT_WASM_STACK_SIZE;
#if WASM_ENABLE_SPEC_TEST != 0
if (stack_size < 48 * 1024)
stack_size = 48 * 1024;
if (stack_size < 128 * 1024)
stack_size = 128 * 1024;
#endif
module_inst->default_wasm_stack_size = stack_size;

View File

@ -1,8 +1,8 @@
diff --git a/test/core/binary.wast b/test/core/binary.wast
index c6f9755..a479212 100644
index 891aad3..07356a3 100644
--- a/test/core/binary.wast
+++ b/test/core/binary.wast
@@ -161,7 +161,7 @@
@@ -206,7 +206,7 @@
)
;; Type section with signed LEB128 encoded type
@ -11,7 +11,7 @@ index c6f9755..a479212 100644
(module binary
"\00asm" "\01\00\00\00"
"\01" ;; Type section id
@@ -171,7 +171,7 @@
@@ -216,7 +216,7 @@
"\00\00"
)
"integer representation too long"
@ -20,7 +20,7 @@ index c6f9755..a479212 100644
;; Unsigned LEB128 must not be overlong
(assert_malformed
@@ -1582,7 +1582,7 @@
@@ -1683,7 +1683,7 @@
)
;; 2 elem segment declared, 1 given
@ -29,7 +29,7 @@ index c6f9755..a479212 100644
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01" ;; type section
@@ -1595,7 +1595,7 @@
@@ -1696,7 +1696,7 @@
;; "\00\41\00\0b\01\00" ;; elem 1 (missed)
)
"unexpected end"
@ -38,6 +38,24 @@ index c6f9755..a479212 100644
;; 2 elem segment declared, 1.5 given
(assert_malformed
@@ -1813,7 +1813,7 @@
)
;; 1 br_table target declared, 2 given
-(assert_malformed
+(;assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01" ;; type section
@@ -1832,7 +1832,7 @@
"\0b\0b\0b" ;; end
)
"unexpected end"
-)
+;)
;; Start section
(module binary
diff --git a/test/core/data.wast b/test/core/data.wast
index 4f339be..0b5b3e6 100644
--- a/test/core/data.wast
@ -93,26 +111,10 @@ index 4f339be..0b5b3e6 100644
;; Invalid offsets
diff --git a/test/core/elem.wast b/test/core/elem.wast
index 575ecef..204b748 100644
index 575ecef..6eecab9 100644
--- a/test/core/elem.wast
+++ b/test/core/elem.wast
@@ -467,6 +467,7 @@
"type mismatch"
)
+(; not supported by wat2wasm
(assert_invalid
(module
(table 1 funcref)
@@ -507,6 +508,7 @@
)
"constant expression required"
)
+;)
;; Two elements target the same slot
@@ -571,9 +573,11 @@
@@ -571,9 +571,11 @@
(func $const-i32-d (type $out-i32) (i32.const 68))
)
@ -124,7 +126,7 @@ index 575ecef..204b748 100644
(module $module3
(type $out-i32 (func (result i32)))
@@ -584,6 +588,8 @@
@@ -584,6 +586,8 @@
(func $const-i32-f (type $out-i32) (i32.const 70))
)
@ -785,7 +787,7 @@ index 0b2d26f..bdab6a0 100644
(table $t1 30 30 funcref)
(elem (table $t1) (i32.const 2) func 3 1 4 1)
diff --git a/test/core/unreached-valid.wast b/test/core/unreached-valid.wast
index 0025217..07d2788 100644
index b7ebabf..4f2abfb 100644
--- a/test/core/unreached-valid.wast
+++ b/test/core/unreached-valid.wast
@@ -46,6 +46,7 @@
@ -796,9 +798,8 @@ index 0025217..07d2788 100644
(module
(func (export "meet-bottom")
(block (result f64)
@@ -59,4 +60,5 @@
(drop)
)
@@ -61,3 +62,4 @@
)
+;)
(assert_trap (invoke "meet-bottom") "unreachable")
+;)

View File

@ -275,12 +275,12 @@ function spec_test()
# update basic test cases
echo "update spec test cases"
git fetch origin master
git fetch origin main
# restore from XX_ignore_cases.patch
# resotre branch
git checkout -B master
# [spec] Fix instruction table (#1402) Thu Dec 2 17:21:54 2021 +0100
git reset --hard 2460ad02b51fb5ed5824f44de287a8638b19a5f8
git checkout -B main
# [spec] Update note on module initialization trapping (#1493)
git reset --hard 044d0d2e77bdcbe891f7e0b9dd2ac01d56435f0b
git apply ../../spec-test-script/ignore_cases.patch
if [[ ${ENABLE_SIMD} == 1 ]]; then
git apply ../../spec-test-script/simd_ignore_cases.patch
@ -295,8 +295,8 @@ function spec_test()
# fetch spec for threads proposal
git fetch threads
# [interpreter] Threading (#179) Fri Aug 6 18:02:59 2021 +0200
git reset --hard 0d115b494d640eb0c1c352941fd14ca0bad926d3
# Fix error in Web embedding desc for atomic.notify (#185)
git reset --hard 85b562cd6805947876ec5e8b975ab0127c55a0a2
git checkout threads/main
git apply ../../spec-test-script/thread_proposal_ignore_cases.patch
@ -321,16 +321,16 @@ function spec_test()
exit 1
;;
esac
if [ ! -f /tmp/wabt-1.0.24-${WABT_PLATFORM}.tar.gz ]; then
if [ ! -f /tmp/wabt-1.0.29-${WABT_PLATFORM}.tar.gz ]; then
wget \
https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-${WABT_PLATFORM}.tar.gz \
https://github.com/WebAssembly/wabt/releases/download/1.0.29/wabt-1.0.29-${WABT_PLATFORM}.tar.gz \
-P /tmp
fi
cd /tmp \
&& tar zxf wabt-1.0.24-${WABT_PLATFORM}.tar.gz \
&& tar zxf wabt-1.0.29-${WABT_PLATFORM}.tar.gz \
&& mkdir -p ${WORK_DIR}/wabt/out/gcc/Release/ \
&& install wabt-1.0.24/bin/wa* ${WORK_DIR}/wabt/out/gcc/Release/ \
&& install wabt-1.0.29/bin/wa* ${WORK_DIR}/wabt/out/gcc/Release/ \
&& cd -
fi
else