memory_redundancy64.wast.js (3134B)
1 /* Copyright 2021 Mozilla Foundation 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 // ./test/core/memory64/memory_redundancy64.wast 17 18 // ./test/core/memory64/memory_redundancy64.wast:5 19 let $0 = instantiate(`(module 20 (memory i64 1 1) 21 22 (func (export "zero_everything") 23 (i32.store (i64.const 0) (i32.const 0)) 24 (i32.store (i64.const 4) (i32.const 0)) 25 (i32.store (i64.const 8) (i32.const 0)) 26 (i32.store (i64.const 12) (i32.const 0)) 27 ) 28 29 (func (export "test_store_to_load") (result i32) 30 (i32.store (i64.const 8) (i32.const 0)) 31 (f32.store (i64.const 5) (f32.const -0.0)) 32 (i32.load (i64.const 8)) 33 ) 34 35 (func (export "test_redundant_load") (result i32) 36 (local \$t i32) 37 (local \$s i32) 38 (local.set \$t (i32.load (i64.const 8))) 39 (i32.store (i64.const 5) (i32.const 0x80000000)) 40 (local.set \$s (i32.load (i64.const 8))) 41 (i32.add (local.get \$t) (local.get \$s)) 42 ) 43 44 (func (export "test_dead_store") (result f32) 45 (local \$t f32) 46 (i32.store (i64.const 8) (i32.const 0x23232323)) 47 (local.set \$t (f32.load (i64.const 11))) 48 (i32.store (i64.const 8) (i32.const 0)) 49 (local.get \$t) 50 ) 51 52 ;; A function named "malloc" which implementations nonetheless shouldn't 53 ;; assume behaves like C malloc. 54 (func \$malloc (export "malloc") 55 (param \$size i64) 56 (result i64) 57 (i64.const 16) 58 ) 59 60 ;; Call malloc twice, but unlike C malloc, we don't get non-aliasing pointers. 61 (func (export "malloc_aliasing") 62 (result i32) 63 (local \$x i64) 64 (local \$y i64) 65 (local.set \$x (call \$malloc (i64.const 4))) 66 (local.set \$y (call \$malloc (i64.const 4))) 67 (i32.store (local.get \$x) (i32.const 42)) 68 (i32.store (local.get \$y) (i32.const 43)) 69 (i32.load (local.get \$x)) 70 ) 71 )`); 72 73 // ./test/core/memory64/memory_redundancy64.wast:59 74 assert_return(() => invoke($0, `test_store_to_load`, []), [value("i32", 128)]); 75 76 // ./test/core/memory64/memory_redundancy64.wast:60 77 invoke($0, `zero_everything`, []); 78 79 // ./test/core/memory64/memory_redundancy64.wast:61 80 assert_return(() => invoke($0, `test_redundant_load`, []), [value("i32", 128)]); 81 82 // ./test/core/memory64/memory_redundancy64.wast:62 83 invoke($0, `zero_everything`, []); 84 85 // ./test/core/memory64/memory_redundancy64.wast:63 86 assert_return( 87 () => invoke($0, `test_dead_store`, []), 88 [value("f32", 0.000000000000000000000000000000000000000000049)], 89 ); 90 91 // ./test/core/memory64/memory_redundancy64.wast:64 92 invoke($0, `zero_everything`, []); 93 94 // ./test/core/memory64/memory_redundancy64.wast:65 95 assert_return(() => invoke($0, `malloc_aliasing`, []), [value("i32", 43)]);