|
| 1 | +;; RUN: wast --assert default --snapshot tests/snapshots % -f custom-page-sizes |
| 2 | + |
| 3 | +;; explicitly specifying the page size is ok |
| 4 | +(component |
| 5 | + (import "f" (func $f (param "x" string))) |
| 6 | + (core module $m |
| 7 | + (memory (export "m") 1 (pagesize 65536)) |
| 8 | + ) |
| 9 | + (core instance $i (instantiate $m)) |
| 10 | + (core func (canon lower (func $f) (memory $i "m"))) |
| 11 | +) |
| 12 | + |
| 13 | +;; currently the component model requires all memories are a subtype of |
| 14 | +;; `(memory 0)`, AKA no compat with custom page sizes. This has not yet been |
| 15 | +;; relaxed at the spec level. |
| 16 | +(assert_invalid |
| 17 | + (component |
| 18 | + (import "f" (func $f (param "x" string))) |
| 19 | + (core module $m |
| 20 | + (memory (export "m") 1 (pagesize 1)) |
| 21 | + ) |
| 22 | + (core instance $i (instantiate $m)) |
| 23 | + (core func (canon lower (func $f) (memory $i "m"))) |
| 24 | + ) |
| 25 | + "mismatch in page size for memories" |
| 26 | +) |
| 27 | + |
| 28 | +;; subtyping works with custom-page-sizes |
| 29 | +(component |
| 30 | + (core module $a (memory (export "m") 1 (pagesize 65536))) |
| 31 | + (core module $b (import "a" "m" (memory 1 (pagesize 65536)))) |
| 32 | + (core instance $a (instantiate $a)) |
| 33 | + (core instance $b (instantiate $b (with "a" (instance $a)))) |
| 34 | +) |
| 35 | + |
| 36 | +(component |
| 37 | + (core module $a (memory (export "m") 1 (pagesize 65536))) |
| 38 | + (core module $b (import "a" "m" (memory 1))) |
| 39 | + (core instance $a (instantiate $a)) |
| 40 | + (core instance $b (instantiate $b (with "a" (instance $a)))) |
| 41 | +) |
| 42 | + |
| 43 | +(component |
| 44 | + (core module $a (memory (export "m") 1)) |
| 45 | + (core module $b (import "a" "m" (memory 1 (pagesize 65536)))) |
| 46 | + (core instance $a (instantiate $a)) |
| 47 | + (core instance $b (instantiate $b (with "a" (instance $a)))) |
| 48 | +) |
| 49 | + |
| 50 | +(assert_invalid |
| 51 | + (component |
| 52 | + (core module $a (memory (export "m") 1 (pagesize 1))) |
| 53 | + (core module $b (import "a" "m" (memory 1 (pagesize 65536)))) |
| 54 | + (core instance $a (instantiate $a)) |
| 55 | + (core instance $b (instantiate $b (with "a" (instance $a)))) |
| 56 | + ) |
| 57 | + "mismatch in page size for memories") |
| 58 | + |
| 59 | +(assert_invalid |
| 60 | + (component |
| 61 | + (core module $a (memory (export "m") 1 (pagesize 65536))) |
| 62 | + (core module $b (import "a" "m" (memory 1 (pagesize 1)))) |
| 63 | + (core instance $a (instantiate $a)) |
| 64 | + (core instance $b (instantiate $b (with "a" (instance $a)))) |
| 65 | + ) |
| 66 | + "mismatch in page size for memories") |
| 67 | + |
| 68 | +(assert_invalid |
| 69 | + (component |
| 70 | + (core module $a (memory (export "m") 1 (pagesize 1))) |
| 71 | + (core module $b (import "a" "m" (memory 1))) |
| 72 | + (core instance $a (instantiate $a)) |
| 73 | + (core instance $b (instantiate $b (with "a" (instance $a)))) |
| 74 | + ) |
| 75 | + "mismatch in page size for memories") |
| 76 | + |
| 77 | +(assert_invalid |
| 78 | + (component |
| 79 | + (core module $a (memory (export "m") 1)) |
| 80 | + (core module $b (import "a" "m" (memory 1 (pagesize 1)))) |
| 81 | + (core instance $a (instantiate $a)) |
| 82 | + (core instance $b (instantiate $b (with "a" (instance $a)))) |
| 83 | + ) |
| 84 | + "mismatch in page size for memories") |
0 commit comments