瀏覽代碼

Update wasm internal tests

Michael Ferris 9 年之前
父節點
當前提交
02304ad7d8

二進制
test/wasm/basic.wasm


+ 8 - 10
test/wasm/basic.wast

@@ -6,12 +6,12 @@
     (type $t1 (func (result i32)))
     (type $t2 (func (param i32) (result i32)))
 
-    (memory 5000 5000)
-    (func (type $t1)
+    (memory (export "memory") 5000 5000)
+    (import "test" "foo" (func $foo (type $t2)))
+    (func $f1 (type $t1)
         (return (i32.const 2))
     )
-    (import $foo "test" "foo" (type $t2))
-    (func (type $t2) (local f32)
+    (func $f2 (export "a") (type $t2) (local f32)
         (if (i32.ge_s (i32.const 26) (i32.const 25))
             (set_local 0 (i32.add (get_local 0) (i32.const 4)))
         )
@@ -23,20 +23,18 @@
         (block
             (set_local 0 (i32.add (get_local 0) (i32.const 4)))
             (set_local 0 (i32.add (get_local 0) (i32.clz (get_local 0))))
-            (set_local 0 (i32.add (get_local 0) (call 0)))
+            (set_local 0 (i32.add (get_local 0) (call $f1)))
             (br_if 0 (select (f32.ne (get_local 1) (get_local 1)) (i32.const 0) (i32.const 1)))
             (set_local 0 (i32.add (get_local 0) (i32.const 4)))
         )
-        (call_import $foo (get_local 0))
+        (call $foo (get_local 0))
         (i32.store (get_local 0) (i32.add (get_local 0) (i32.const 7)))
         (set_local 0 (i32.load (get_local 0)))
         (set_local 1 (f32.convert_s/i32 (get_local 0)))
         (set_local 1 (f32.add (get_local 1) (get_local 1)))
         (set_local 0 (i32.reinterpret/f32 (get_local 1)))
-        (set_local 0 (i32.add (get_local 0) (call_import $foo (get_local 0))))
+        (set_local 0 (i32.add (get_local 0) (call $foo (get_local 0))))
         (return (i32.add (get_local 0) (i32.const 42)))
     )
-    (table 0 1)
-    (export "a" 1)
-    (export "memory" memory)
+    (table anyfunc (elem $f1 $f2))
 )

二進制
test/wasm/controlflow.wasm


+ 6 - 5
test/wasm/controlflow.wast

@@ -6,14 +6,15 @@
 (module
     (func $c (result f32)
       (return (f32.const 1001.2)))
-    (func $b (param i32) (result f32)
+
+    (func $b (export "a") (param i32) (result f32)
       (return
-        (if_else (i32.const 0) (f32.const 1)
+        (if_else f32 (i32.const 0) (f32.const 1)
           (f32.const 2))))
+
     (func $a (param i32) (result f32)
-      (block (call $b (i32.const 1)) (call $c)))
+      (block f32 (call $b (i32.const 1)) (call $c) (drop)))
+
     (func $e (param i32) (result i32)
       (i32.const 0))
-
-    (export "a" 1)
 )

二進制
test/wasm/dropteelocal.wasm


+ 2 - 3
test/wasm/dropteelocal.wast

@@ -5,18 +5,17 @@
 
 (module
 
-  (func $tee (param i32) (result i32)
+  (func $tee (export "tee") (param i32) (result i32)
     (local i32 i32)
     (set_local 1 (get_local 0))
     (set_local 2 (i32.const 1))
     (block
       (set_local 2 (i32.mul (get_local 1) (get_local 2)))
       (drop (get_local 2))
-      (if (i32.eqz (tee_local 1 (i32.sub (get_local 1) (i32.const 1))))  
+      (if (i32.eqz (tee_local 1 (i32.sub (get_local 1) (i32.const 1))))
           (set_local 2 (i32.const 100))
           (set_local 2 (i32.const 200)))
     )
     (get_local 2)
   )
-  (export "tee" $tee)
 )

二進制
test/wasm/f32.wasm


+ 3 - 4
test/wasm/f32.wast

@@ -4,12 +4,11 @@
 ;;-------------------------------------------------------------------------------------------------------
 
 (module
-  (func (param f32) (param f32) (result f32)
+  (func (export "min") (param f32) (param f32) (result f32)
     (return (f32.min (get_local 0) (get_local 1)))
   )
-  (func (param f32) (param f32) (result f32)
+
+  (func (export "max") (param f32) (param f32) (result f32)
     (return (f32.max (get_local 0) (get_local 1)))
     )
-  (export "min" 0)
-  (export "max" 1)
 )

二進制
test/wasm/f32address.wasm


+ 22 - 51
test/wasm/f32address.wast

@@ -3,56 +3,27 @@
 ;; Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 ;;-------------------------------------------------------------------------------------------------------
 (module
-  (memory 1 1 (segment 1 "\00\00\e0\7f"))
-
-  (func $f32.load (result f32) (f32.load offset=0 align=1 (i32.const 1)))
-  (export "f32.load" $f32.load)
-
-  (func $i32.load (result i32) (i32.load offset=0 align=2 (i32.const 1)))
-  (export "i32.load" $i32.load)
-
-  (func $f32.store (f32.store (i32.const 1) (f32.const 0x7fa00000)))
-  (export "f32.store" $f32.store)
-
-  (func $i32.store (i32.store (i32.const 1) (i32.const 0x7fa00000)))
-  (export "i32.store" $i32.store)
-
-  (func $reset (i32.store (i32.const 1) (i32.const 0)))
-  (export "reset" $reset)
-  
-  
-  
-  (func $f32.load1 (result f32) (f32.load offset=1 align=1 (i32.const 1)))
-  (export "f32.load1" $f32.load1)
-
-  (func $i32.load1 (result i32) (i32.load offset=1 align=2 (i32.const 1)))
-  (export "i32.load1" $i32.load1)
-
-  (func $f32.store1 (f32.store offset=1 (i32.const 1) (f32.const 0x7fa00000)))
-  (export "f32.store1" $f32.store1)
-
-  (func $i32.store1 (i32.store offset=1 (i32.const 1) (i32.const 0x7fa00000)))
-  (export "i32.store1" $i32.store1)
-  
-  (func $reset1 (i32.store offset=1 (i32.const 1) (i32.const 0)))
-  (export "reset1" $reset1)
-  
-  
-  (func $f32.load2 (result f32) (f32.load offset=2 align=1 (i32.const 1)))
-  (export "f32.load2" $f32.load2)
-
-  (func $i32.load2 (result i32) (i32.load offset=2 align=2 (i32.const 1)))
-  (export "i32.load2" $i32.load2)
-
-  (func $f32.store2 (f32.store offset=2 (i32.const 1) (f32.const 0x7fa00000)))
-  (export "f32.store2" $f32.store2)
-
-  (func $i32.store2 (i32.store offset=2 (i32.const 1) (i32.const 0x7fa00000)))
-  (export "i32.store2" $i32.store2)
-  
-  (func $reset2 (i32.store offset=2 (i32.const 1) (i32.const 0)))
-  (export "reset2" $reset2)
-  
+  (memory 1 1)
+  (data (i32.const 1) "\00\00\e0\7f")
+
+  (func (export "f32.load") (result f32) (f32.load offset=0 align=1 (i32.const 1)))
+  (func (export "i32.load") (result i32) (i32.load offset=0 align=2 (i32.const 1)))
+  (func (export "f32.store") (f32.store (i32.const 1) (f32.const 0x7fa00000)))
+  (func (export "i32.store") (i32.store (i32.const 1) (i32.const 0x7fa00000)))
+  (func (export "reset") (i32.store (i32.const 1) (i32.const 0)))
+
+
+  (func (export "f32.load1") (result f32) (f32.load offset=1 align=1 (i32.const 1)))
+  (func (export "i32.load1") (result i32) (i32.load offset=1 align=2 (i32.const 1)))
+  (func (export "f32.store1") (f32.store offset=1 (i32.const 1) (f32.const 0x7fa00000)))
+  (func (export "i32.store1") (i32.store offset=1 (i32.const 1) (i32.const 0x7fa00000)))
+  (func (export "reset1") (i32.store offset=1 (i32.const 1) (i32.const 0)))
+
+  (func (export "f32.load2") (result f32) (f32.load offset=2 align=1 (i32.const 1)))
+  (func (export "i32.load2") (result i32) (i32.load offset=2 align=2 (i32.const 1)))
+  (func (export "f32.store2") (f32.store offset=2 (i32.const 1) (f32.const 0x7fa00000)))
+  (func (export "i32.store2") (i32.store offset=2 (i32.const 1) (i32.const 0x7fa00000)))
+  (func (export "reset2") (i32.store offset=2 (i32.const 1) (i32.const 0)))
 )
 
 
@@ -69,4 +40,4 @@
 ;;(assert_return (invoke "f32.load") (f32.const 0.0))
 ;;(invoke "i32.store")
 ;;(assert_return (invoke "i32.load") (i32.const 0x7fa00000))
-;;(assert_return (invoke "f32.load") (f32.const nan:0x200000))
+;;(assert_return (invoke "f32.load") (f32.const nan:0x200000))

二進制
test/wasm/i32_popcnt.wasm


+ 1 - 2
test/wasm/i32_popcnt.wast

@@ -3,6 +3,5 @@
 ;; Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 ;;-------------------------------------------------------------------------------------------------------
 (module
-  (func (param i32) (result i32) (i32.popcnt (get_local 0)))
-  (export "popcount" 0)
+  (func (export "popcount") (param i32) (result i32) (i32.popcnt (get_local 0)))
 )

+ 3 - 4
test/wasm/math.wast

@@ -4,8 +4,7 @@
 ;;-------------------------------------------------------------------------------------------------------
 
 (module
-    (func $ctz (param $a i32) (result i32)
-      (return (i32.ctz (get_local $a)))
+    (func (export "ctz") (param $a i32) (result i32)
+      (i32.ctz (get_local $a))
     )
- (export "ctz" $ctz)
-)
+)

二進制
test/wasm/misc.wasm


+ 15 - 16
test/wasm/misc.wast

@@ -4,29 +4,28 @@
 ;;-------------------------------------------------------------------------------------------------------
 
 (module
-  (func $copysign32 (param f32) (param f32) (result f32)
+  (func (export "f32copysign") (param f32) (param f32) (result f32)
     (return (f32.copysign (get_local 0) (get_local 1))))
-  ;;(func $copysign64 (param f64) (param f64) (result f64)
+
+  ;;(func (export "f64copysign") (param f64) (param f64) (result f64)
   ;;  (return (f64.copysign (get_local 0) (get_local 1))))
-  (func $eqz32 (param i32) (result i32)
+
+  (func (export "eqz") (param i32) (result i32)
     (return (i32.eqz (get_local 0))))
-  (func $trunc32 (param f32) (result f32)
+
+  (func (export "trunc") (param f32) (result f32)
     (return (f32.trunc (get_local 0))))
-  (func $trunc64 (param f64) (result f64)
+
+  (func (export "f64trunc") (param f64) (result f64)
     (return (f64.trunc (get_local 0))))
-  (func $nearest32 (param f32) (result f32)
+
+  (func (export "nearest") (param f32) (result f32)
     (return (f32.nearest (get_local 0))))
-  (func $nearest64 (param f64) (result f64)
+
+  (func (export "f64nearest") (param f64) (result f64)
     (return (f64.nearest (get_local 0))))
-  (func $ifeqz (param i32) (result i32)
+
+  (func (export "ifeqz") (param i32) (result i32)
     (if (i32.eqz (get_local 0)) (return (i32.const 1)))
     (return (i32.const 0)))
-  (export "f32copysign" $copysign32)
-  ;;(export "f64copysign" $copysign64)
-  (export "eqz" $eqz32)
-  (export "trunc" $trunc32)
-  (export "f64trunc" $trunc64)
-  (export "nearest" $nearest32)
-  (export "f64nearest" $nearest64)
-  (export "ifeqz" $ifeqz)
 )

二進制
test/wasm/rot.wasm


+ 3 - 4
test/wasm/rot.wast

@@ -4,12 +4,11 @@
 ;;-------------------------------------------------------------------------------------------------------
 
 (module
-  (func (param i32) (param i32) (result i32)
+  (func (export "rotl") (param i32) (param i32) (result i32)
     (return (i32.rotl (get_local 0) (get_local 1)))
   )
-  (func (param i32) (param i32) (result i32)
+
+  (func (export "rotr") (param i32) (param i32) (result i32)
     (return (i32.rotr (get_local 0) (get_local 1)))
   )
-  (export "rotl" 0)
-  (export "rotr" 1)
 )

二進制
test/wasm/unreachable.wasm


+ 1 - 5
test/wasm/unreachable.wast

@@ -4,11 +4,7 @@
 ;;-------------------------------------------------------------------------------------------------------
 
 (module
-
-  (func $test_unreachable (result i32) (unreachable) (i32.const 1))
-  (export "test_unreachable" $test_unreachable)
-
-
+  (func (export "test_unreachable") (result i32) (unreachable) (i32.const 1))
 )
 
 (assert_return (invoke "test_unreachable") (i32.const 1))