Skip to content

Commit

Permalink
update repos
Browse files Browse the repository at this point in the history
  spec: 5a918f777e72c686cbad5e04074d565584670870
  mutable-global: 8d0db364064f99d5ac0439f7c3a3d0b8cd46d735
  • Loading branch information
binji committed May 26, 2018
1 parent 8958a44 commit c6a690f
Show file tree
Hide file tree
Showing 15 changed files with 577 additions and 41 deletions.
12 changes: 6 additions & 6 deletions binary.wast
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
"zero flag expected"
)

;; grow_memory reserved byte equal to zero.
;; memory.grow reserved byte equal to zero.
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
Expand All @@ -299,15 +299,15 @@
;; function 0
"\07\00"
"\41\00" ;; i32.const 0
"\40" ;; grow_memory
"\01" ;; grow_memory reserved byte is not equal to zero!
"\40" ;; memory.grow
"\01" ;; memory.grow reserved byte is not equal to zero!
"\1a" ;; drop
"\0b" ;; end
)
"zero flag expected"
)

;; current_memory reserved byte equal to zero.
;; memory.size reserved byte equal to zero.
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
Expand All @@ -318,8 +318,8 @@

;; function 0
"\05\00"
"\3f" ;; current_memory
"\01" ;; current_memory reserved byte is not equal to zero!
"\3f" ;; memory.size
"\01" ;; memory.size reserved byte is not equal to zero!
"\1a" ;; drop
"\0b" ;; end
)
Expand Down
6 changes: 3 additions & 3 deletions br.wast
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@
(block (result i32) (i32.wrap/i64 (br 0 (i32.const 41))))
)

(func (export "as-grow_memory-size") (result i32)
(block (result i32) (grow_memory (br 0 (i32.const 40))))
(func (export "as-memory.grow-size") (result i32)
(block (result i32) (memory.grow (br 0 (i32.const 40))))
)

(func (export "nested-block-value") (result i32)
Expand Down Expand Up @@ -398,7 +398,7 @@

(assert_return (invoke "as-convert-operand") (i32.const 41))

(assert_return (invoke "as-grow_memory-size") (i32.const 40))
(assert_return (invoke "as-memory.grow-size") (i32.const 40))

(assert_return (invoke "nested-block-value") (i32.const 9))
(assert_return (invoke "nested-br-value") (i32.const 9))
Expand Down
6 changes: 3 additions & 3 deletions br_table.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,8 @@
)
)

(func (export "as-grow_memory-size") (result i32)
(block (result i32) (grow_memory (br_table 0 (i32.const 40) (i32.const 0))))
(func (export "as-memory.grow-size") (result i32)
(block (result i32) (memory.grow (br_table 0 (i32.const 40) (i32.const 0))))
)

(func (export "nested-block-value") (param i32) (result i32)
Expand Down Expand Up @@ -1363,7 +1363,7 @@

(assert_return (invoke "as-convert-operand") (i32.const 41))

(assert_return (invoke "as-grow_memory-size") (i32.const 40))
(assert_return (invoke "as-memory.grow-size") (i32.const 40))

(assert_return (invoke "nested-block-value" (i32.const 0)) (i32.const 19))
(assert_return (invoke "nested-block-value" (i32.const 1)) (i32.const 17))
Expand Down
10 changes: 9 additions & 1 deletion imports.wast
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
(assert_return (invoke "print32" (i32.const 13)))
(assert_return (invoke "print64" (i64.const 24)))

(assert_invalid
(module
(type (func (result i32)))
(import "test" "func" (func (type 1)))
)
"unknown type"
)

(module (import "test" "func" (func)))
(module (import "test" "func-i32" (func (param i32))))
(module (import "test" "func-f32" (func (param f32))))
Expand Down Expand Up @@ -478,7 +486,7 @@

(module
(import "spectest" "memory" (memory 0 3)) ;; actual has max size 2
(func (export "grow") (param i32) (result i32) (grow_memory (get_local 0)))
(func (export "grow") (param i32) (result i32) (memory.grow (get_local 0)))
)
(assert_return (invoke "grow" (i32.const 0)) (i32.const 1))
(assert_return (invoke "grow" (i32.const 1)) (i32.const 1))
Expand Down
2 changes: 1 addition & 1 deletion linking.wast
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
(memory (import "Mm" "mem") 1 8)

(func (export "grow") (param $a i32) (result i32)
(grow_memory (get_local 0))
(memory.grow (get_local 0))
)
)

Expand Down
10 changes: 5 additions & 5 deletions memory.wast
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
(assert_invalid (module (memory 0) (memory 0)) "multiple memories")
(assert_invalid (module (memory (import "spectest" "memory") 0) (memory 0)) "multiple memories")

(module (memory (data)) (func (export "memsize") (result i32) (current_memory)))
(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))
(assert_return (invoke "memsize") (i32.const 0))
(module (memory (data "")) (func (export "memsize") (result i32) (current_memory)))
(module (memory (data "")) (func (export "memsize") (result i32) (memory.size)))
(assert_return (invoke "memsize") (i32.const 0))
(module (memory (data "x")) (func (export "memsize") (result i32) (current_memory)))
(module (memory (data "x")) (func (export "memsize") (result i32) (memory.size)))
(assert_return (invoke "memsize") (i32.const 1))

(assert_invalid (module (data (i32.const 0))) "unknown memory")
Expand All @@ -36,11 +36,11 @@
"unknown memory"
)
(assert_invalid
(module (func (drop (current_memory))))
(module (func (drop (memory.size))))
"unknown memory"
)
(assert_invalid
(module (func (drop (grow_memory (i32.const 0)))))
(module (func (drop (memory.grow (i32.const 0)))))
"unknown memory"
)

Expand Down
8 changes: 4 additions & 4 deletions memory_trap.wast
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(memory 1)

(func $addr_limit (result i32)
(i32.mul (current_memory) (i32.const 0x10000))
(i32.mul (memory.size) (i32.const 0x10000))
)

(func (export "store") (param $i i32) (param $v i32)
Expand All @@ -13,8 +13,8 @@
(i32.load (i32.add (call $addr_limit) (get_local $i)))
)

(func (export "grow_memory") (param i32) (result i32)
(grow_memory (get_local 0))
(func (export "memory.grow") (param i32) (result i32)
(memory.grow (get_local 0))
)
)

Expand All @@ -30,7 +30,7 @@
(assert_trap (invoke "load" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "store" (i32.const 0x80000000) (i32.const 13)) "out of bounds memory access")
(assert_trap (invoke "load" (i32.const 0x80000000)) "out of bounds memory access")
(assert_return (invoke "grow_memory" (i32.const 0x10001)) (i32.const -1))
(assert_return (invoke "memory.grow" (i32.const 0x10001)) (i32.const -1))

(module
(memory 1)
Expand Down
12 changes: 6 additions & 6 deletions nop.wast
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@
(nop) (get_local 0) (nop) (nop) (get_local 0) (nop) (nop) (i32.le_s)
)

(func (export "as-grow_memory-last") (param i32) (result i32)
(get_local 0) (nop) (grow_memory)
(func (export "as-memory.grow-last") (param i32) (result i32)
(get_local 0) (nop) (memory.grow)
)
(func (export "as-grow_memory-everywhere") (param i32) (result i32)
(nop) (nop) (get_local 0) (nop) (nop) (grow_memory)
(func (export "as-memory.grow-everywhere") (param i32) (result i32)
(nop) (nop) (get_local 0) (nop) (nop) (memory.grow)
)
)

Expand Down Expand Up @@ -243,8 +243,8 @@
(assert_return (invoke "as-compare-last" (i32.const 3)) (i32.const 0))
(assert_return (invoke "as-compare-everywhere" (i32.const 3)) (i32.const 1))

(assert_return (invoke "as-grow_memory-last" (i32.const 2)) (i32.const 1))
(assert_return (invoke "as-grow_memory-everywhere" (i32.const 12)) (i32.const 3))
(assert_return (invoke "as-memory.grow-last" (i32.const 2)) (i32.const 1))
(assert_return (invoke "as-memory.grow-everywhere" (i32.const 12)) (i32.const 3))

(assert_invalid
(module (func $type-i32 (result i32) (nop)))
Expand Down
164 changes: 164 additions & 0 deletions proposals/mutable-global/globals.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
;; Test globals

(module
(global $a i32 (i32.const -2))
(global (;1;) f32 (f32.const -3))
(global (;2;) f64 (f64.const -4))
(global $b i64 (i64.const -5))

(global $x (mut i32) (i32.const -12))
(global (;5;) (mut f32) (f32.const -13))
(global (;6;) (mut f64) (f64.const -14))
(global $y (mut i64) (i64.const -15))

(func (export "get-a") (result i32) (get_global $a))
(func (export "get-b") (result i64) (get_global $b))
(func (export "get-x") (result i32) (get_global $x))
(func (export "get-y") (result i64) (get_global $y))
(func (export "set-x") (param i32) (set_global $x (get_local 0)))
(func (export "set-y") (param i64) (set_global $y (get_local 0)))

(func (export "get-1") (result f32) (get_global 1))
(func (export "get-2") (result f64) (get_global 2))
(func (export "get-5") (result f32) (get_global 5))
(func (export "get-6") (result f64) (get_global 6))
(func (export "set-5") (param f32) (set_global 5 (get_local 0)))
(func (export "set-6") (param f64) (set_global 6 (get_local 0)))
)

(assert_return (invoke "get-a") (i32.const -2))
(assert_return (invoke "get-b") (i64.const -5))
(assert_return (invoke "get-x") (i32.const -12))
(assert_return (invoke "get-y") (i64.const -15))

(assert_return (invoke "get-1") (f32.const -3))
(assert_return (invoke "get-2") (f64.const -4))
(assert_return (invoke "get-5") (f32.const -13))
(assert_return (invoke "get-6") (f64.const -14))

(assert_return (invoke "set-x" (i32.const 6)))
(assert_return (invoke "set-y" (i64.const 7)))
(assert_return (invoke "set-5" (f32.const 8)))
(assert_return (invoke "set-6" (f64.const 9)))

(assert_return (invoke "get-x") (i32.const 6))
(assert_return (invoke "get-y") (i64.const 7))
(assert_return (invoke "get-5") (f32.const 8))
(assert_return (invoke "get-6") (f64.const 9))

(assert_invalid
(module (global f32 (f32.const 0)) (func (set_global 0 (i32.const 1))))
"global is immutable"
)

;; mutable globals can be exported
(module (global (mut f32) (f32.const 0)) (export "a" (global 0)))
(module (global (export "a") (mut f32) (f32.const 0)))

(assert_invalid
(module (global f32 (f32.neg (f32.const 0))))
"constant expression required"
)

(assert_invalid
(module (global f32 (get_local 0)))
"constant expression required"
)

(assert_invalid
(module (global f32 (f32.neg (f32.const 1))))
"constant expression required"
)

(assert_invalid
(module (global i32 (i32.const 0) (nop)))
"constant expression required"
)

(assert_invalid
(module (global i32 (nop)))
"constant expression required"
)

(assert_invalid
(module (global i32 (f32.const 0)))
"type mismatch"
)

(assert_invalid
(module (global i32 (i32.const 0) (i32.const 0)))
"type mismatch"
)

(assert_invalid
(module (global i32 (;empty instruction sequence;)))
"type mismatch"
)

(assert_invalid
(module (global i32 (get_global 0)))
"unknown global"
)

(assert_invalid
(module (global i32 (get_global 1)) (global i32 (i32.const 0)))
"unknown global"
)

(module
(import "spectest" "global_i32" (global i32))
)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\02\94\80\80\80\00" ;; import section
"\01" ;; length 1
"\08\73\70\65\63\74\65\73\74" ;; "spectest"
"\0a\67\6c\6f\62\61\6c\5f\69\33\32" ;; "global_i32"
"\03" ;; GlobalImport
"\7f" ;; i32
"\02" ;; invalid mutability
)
"invalid mutability"
)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\02\94\80\80\80\00" ;; import section
"\01" ;; length 1
"\08\73\70\65\63\74\65\73\74" ;; "spectest"
"\0a\67\6c\6f\62\61\6c\5f\69\33\32" ;; "global_i32"
"\03" ;; GlobalImport
"\7f" ;; i32
"\ff" ;; invalid mutability
)
"invalid mutability"
)

(module
(global i32 (i32.const 0))
)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\06\86\80\80\80\00" ;; global section
"\01" ;; length 1
"\7f" ;; i32
"\02" ;; invalid mutability
"\41\00" ;; i32.const 0
"\0b" ;; end
)
"invalid mutability"
)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\06\86\80\80\80\00" ;; global section
"\01" ;; length 1
"\7f" ;; i32
"\ff" ;; invalid mutability
"\41\00" ;; i32.const 0
"\0b" ;; end
)
"invalid mutability"
)
Loading

0 comments on commit c6a690f

Please sign in to comment.