Bug 1316554: Reimport spec tests; r=luke
authorBenjamin Bouvier <benj@benj.me>
Mon, 21 Nov 2016 15:53:33 +0100
changeset 324095 67ff8b138c460ae6d44a0e9f82f30ce9600729a1
parent 324094 e588418674e17f60dbde2240e6eb1b70763f52f5
child 324096 5f23873d0c91d0d2d647166d7d6491d388f4825e
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersluke
bugs1316554
milestone53.0a1
Bug 1316554: Reimport spec tests; r=luke MozReview-Commit-ID: D88MGedYaLs
js/src/jit-test/tests/wasm/spec/binary.wast
js/src/jit-test/tests/wasm/spec/imports.wast
js/src/jit-test/tests/wasm/spec/memory.wast
js/src/jit-test/tests/wasm/spec/stack.wast
--- a/js/src/jit-test/tests/wasm/spec/binary.wast
+++ b/js/src/jit-test/tests/wasm/spec/binary.wast
@@ -1,15 +1,18 @@
 (module "\00asm\0d\00\00\00")
 (module "\00asm" "\0d\00\00\00")
 (module $M1 "\00asm\0d\00\00\00")
 (module $M2 "\00asm" "\0d\00\00\00")
 
 (assert_malformed (module "") "unexpected end")
 (assert_malformed (module "\01") "unexpected end")
 (assert_malformed (module "\00as") "unexpected end")
-(assert_malformed (module "\01") "unexpected end")
 (assert_malformed (module "asm\00") "magic header not detected")
+(assert_malformed (module "msa\00") "magic header not detected")
+(assert_malformed (module "msa\00\0d\00\00\00") "magic header not detected")
+(assert_malformed (module "msa\00\00\00\00\0d") "magic header not detected")
 
 (assert_malformed (module "\00asm") "unexpected end")
 (assert_malformed (module "\00asm\0d") "unexpected end")
 (assert_malformed (module "\00asm\0d\00\00") "unexpected end")
 (assert_malformed (module "\00asm\0e\00\00\00") "unknown binary version")
+(assert_malformed (module "\00asm\00\00\00\0d") "unknown binary version")
--- a/js/src/jit-test/tests/wasm/spec/imports.wast
+++ b/js/src/jit-test/tests/wasm/spec/imports.wast
@@ -2,76 +2,90 @@
 
 (module
   (func (export "func"))
   (func (export "func-i32") (param i32))
   (func (export "func-f32") (param f32))
   (func (export "func->i32") (result i32) (i32.const 22))
   (func (export "func->f32") (result f32) (f32.const 11))
   (func (export "func-i32->i32") (param i32) (result i32) (get_local 0))
+  (func (export "func-i64->i64") (param i64) (result i64) (get_local 0))
   (global (export "global-i32") i32 (i32.const 55))
   (global (export "global-f32") f32 (f32.const 44))
   (table (export "table-10-inf") 10 anyfunc)
   ;; (table (export "table-10-20") 10 20 anyfunc)
   (memory (export "memory-2-inf") 2)
   ;; (memory (export "memory-2-4") 2 4)
 )
 
 (register "test")
 
 
 ;; Functions
 
 (module
   (type $func_i32 (func (param i32)))
   (type $func_i64 (func (param i64)))
+  (type $func_f32 (func (param f32)))
+  (type $func_f64 (func (param f64)))
 
   (import "spectest" "print" (func (param i32)))
   (func (import "spectest" "print") (param i64))
   (import "spectest" "print" (func $print_i32 (param i32)))
   (import "spectest" "print" (func $print_i64 (param i64)))
+  (import "spectest" "print" (func $print_f32 (param f32)))
+  (import "spectest" "print" (func $print_f64 (param f64)))
   (import "spectest" "print" (func $print_i32_f32 (param i32 f32)))
-  (import "spectest" "print" (func $print_i64_f64 (param i64 f64)))
+  (import "spectest" "print" (func $print_f64_f64 (param f64 f64)))
   (func $print_i32-2 (import "spectest" "print") (param i32))
-  (func $print_i64-2 (import "spectest" "print") (param i64))
+  (func $print_f64-2 (import "spectest" "print") (param f64))
+  (import "test" "func-i64->i64" (func $i64->i64 (param i64) (result i64)))
 
-  (table anyfunc (elem $print_i32 $print_i64))
+  (table anyfunc (elem $print_i32 $print_f64))
 
   (func (export "print32") (param $i i32)
+    (local $x f32)
+    (set_local $x (f32.convert_s/i32 (get_local $i)))
     (call 0 (get_local $i))
     (call $print_i32_f32
       (i32.add (get_local $i) (i32.const 1))
       (f32.const 42)
     )
     (call $print_i32 (get_local $i))
     (call $print_i32-2 (get_local $i))
+    (call $print_f32 (get_local $x))
     (call_indirect $func_i32 (get_local $i) (i32.const 0))
   )
 
   (func (export "print64") (param $i i64)
+    (local $x f64)
+    (set_local $x (f64.convert_s/i64 (call $i64->i64 (get_local $i))))
     (call 1 (get_local $i))
-    (call $print_i64_f64
-      (i64.add (get_local $i) (i64.const 1))
+    (call $print_f64_f64
+      (f64.add (get_local $x) (f64.const 1))
       (f64.const 53)
     )
-    (call $print_i64 (get_local $i))
-    (call $print_i64-2 (get_local $i))
-    (call_indirect $func_i64 (get_local $i) (i32.const 1))
+    ;; JavaScript can't handle i64 yet.
+    ;; (call $print_i64 (get_local $i))
+    (call $print_f64 (get_local $x))
+    (call $print_f64-2 (get_local $x))
+    (call_indirect $func_f64 (get_local $x) (i32.const 1))
   )
 )
 
 (assert_return (invoke "print32" (i32.const 13)))
 (assert_return (invoke "print64" (i64.const 24)))
 
 (module (import "test" "func" (func)))
 (module (import "test" "func-i32" (func (param i32))))
 (module (import "test" "func-f32" (func (param f32))))
 (module (import "test" "func->i32" (func (result i32))))
 (module (import "test" "func->f32" (func (result f32))))
 (module (import "test" "func-i32->i32" (func (param i32) (result i32))))
+(module (import "test" "func-i64->i64" (func (param i64) (result i64))))
 
 (assert_unlinkable
   (module (import "test" "unknown" (func)))
   "unknown import"
 )
 (assert_unlinkable
   (module (import "spectest" "unknown" (func)))
   "unknown import"
--- a/js/src/jit-test/tests/wasm/spec/memory.wast
+++ b/js/src/jit-test/tests/wasm/spec/memory.wast
@@ -6,20 +6,21 @@
 ;; (module (memory 0 65536))
 (module (memory 0 0) (data (i32.const 0)))
 (module (memory 0 0) (data (i32.const 0) ""))
 (module (memory 1 1) (data (i32.const 0) "a"))
 (module (memory 1 2) (data (i32.const 0) "a") (data (i32.const 65535) "b"))
 (module (memory 1 2)
   (data (i32.const 0) "a") (data (i32.const 1) "b") (data (i32.const 2) "c")
 )
-(module (memory 1) (global i32 (i32.const 0)) (data (get_global 0) "a"))
-(module (memory 1) (global $g i32 (i32.const 0)) (data (get_global $g) "a"))
-(module (memory 1) (data (get_global 0) "a") (global i32 (i32.const 0)))
-(module (memory 1) (data (get_global $g) "a") (global $g i32 (i32.const 0)))
+(module (global (import "spectest" "global") i32) (memory 1) (data (get_global 0) "a"))
+(module (global $g (import "spectest" "global") i32) (memory 1) (data (get_global $g) "a"))
+;; Use of internal globals in constant expressions is not allowed in MVP.
+;; (module (memory 1) (data (get_global 0) "a") (global i32 (i32.const 0)))
+;; (module (memory 1) (data (get_global $g) "a") (global $g i32 (i32.const 0)))
 
 (module (memory (data)) (func (export "memsize") (result i32) (current_memory)))
 (assert_return (invoke "memsize") (i32.const 0))
 (module (memory (data "")) (func (export "memsize") (result i32) (current_memory)))
 (assert_return (invoke "memsize") (i32.const 0))
 (module (memory (data "x")) (func (export "memsize") (result i32) (current_memory)))
 (assert_return (invoke "memsize") (i32.const 1))
 
@@ -34,36 +35,37 @@
 (assert_invalid
   (module (memory 1) (data (i32.ctz (i32.const 0))))
   "constant expression required"
 )
 (assert_invalid
   (module (memory 1) (data (nop)))
   "constant expression required"
 )
-(assert_invalid
-  (module (memory 1) (data (get_global $g)) (global $g (mut i32) (i32.const 0)))
-  "constant expression required"
-)
+;; Use of internal globals in constant expressions is not allowed in MVP.
+;; (assert_invalid
+;;   (module (memory 1) (data (get_global $g)) (global $g (mut i32) (i32.const 0)))
+;;   "constant expression required"
+;; )
 
 (assert_unlinkable
   (module (memory 0 0) (data (i32.const 0) "a"))
   "data segment does not fit"
 )
 (assert_unlinkable
   (module (memory 1 2) (data (i32.const 0) "a") (data (i32.const 98304) "b"))
   "data segment does not fit"
 )
 ;; This seems to cause a time-out on Travis.
 (;assert_unlinkable
   (module (memory 0x10000) (data (i32.const 0xffffffff) "ab"))
   ""  ;; either out of memory or segment does not fit
 ;)
 (assert_unlinkable
-  (module (memory 1) (data (get_global 0) "a") (global i32 (i32.const 0x10000)))
+  (module (global (import "spectest" "global") i32) (memory 0) (data (get_global 0) "a"))
   "data segment does not fit"
 )
 
 (module (memory 0 0) (data (i32.const 0) ""))
 (module (memory 0 0) (data (i32.const 1) ""))
 (module (memory 1 2) (data (i32.const 0) "abc") (data (i32.const 0) "def"))
 (module (memory 1 2) (data (i32.const 3) "ab") (data (i32.const 0) "de"))
 (module
@@ -102,37 +104,16 @@
 
 ;; Test alignment annotation rules
 (module (memory 0) (func (drop (i32.load8_u align=1 (i32.const 0)))))
 (module (memory 0) (func (drop (i32.load16_u align=2 (i32.const 0)))))
 (module (memory 0) (func (drop (i32.load align=4 (i32.const 0)))))
 (module (memory 0) (func (drop (f32.load align=4 (i32.const 0)))))
 
 (assert_invalid
-  (module (memory 0) (func (drop (i64.load align=0 (i32.const 0)))))
-  "alignment must be a power of two"
-)
-(assert_invalid
-  (module (memory 0) (func (drop (i64.load align=3 (i32.const 0)))))
-  "alignment must be a power of two"
-)
-(assert_invalid
-  (module (memory 0) (func (drop (i64.load align=5 (i32.const 0)))))
-  "alignment must be a power of two"
-)
-(assert_invalid
-  (module (memory 0) (func (drop (i64.load align=6 (i32.const 0)))))
-  "alignment must be a power of two"
-)
-(assert_invalid
-  (module (memory 0) (func (drop (i64.load align=7 (i32.const 0)))))
-  "alignment must be a power of two"
-)
-
-(assert_invalid
   (module (memory 0) (func (drop (i64.load align=16 (i32.const 0)))))
   "alignment must not be larger than natural"
 )
 (assert_invalid
   (module (memory 0) (func (drop (i64.load align=32 (i32.const 0)))))
   "alignment must not be larger than natural"
 )
 (assert_invalid
--- a/js/src/jit-test/tests/wasm/spec/stack.wast
+++ b/js/src/jit-test/tests/wasm/spec/stack.wast
@@ -58,31 +58,31 @@
     set_local $i
     i64.const 1
     set_local $res
     block $done
       loop $loop
         get_local $i
         i64.const 0
         i64.eq
-        if
+        if $body
           br $done
-        else
+        else $body
           get_local $i
           get_local $res
           i64.mul
           set_local $res
           get_local $i
           i64.const 1
           i64.sub
           set_local $i
-        end
+        end $body
         br $loop
-      end
-    end
+      end $loop
+    end $done
     get_local $res
   )
 
   (func (export "fac-mixed") (param $n i64) (result i64)
     (local $i i64)
     (local $res i64)
     (set_local $i (get_local $n))
     (set_local $res (i64.const 1))