wait_notify.wast.js (2208B)
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/threads/wait_notify.wast 17 18 // ./test/core/threads/wait_notify.wast:2 19 let $0 = instantiate(`(module \$Mem 20 (memory (export "shared") 1 1 shared) 21 )`); 22 let $Mem = $0; 23 24 // ./test/core/threads/wait_notify.wast:6 25 let $T1 = new Thread($Mem, "$Mem", ` 26 27 // ./test/core/threads/wait_notify.wast:7:3 28 register(\$Mem, \`mem\`); 29 30 // ./test/core/threads/wait_notify.wast:8:3 31 let \$1 = instantiate(\`(module 32 (memory (import "mem" "shared") 1 10 shared) 33 (func (export "run") (result i32) 34 (memory.atomic.wait32 (i32.const 0) (i32.const 0) (i64.const -1)) 35 ) 36 )\`); 37 38 // ./test/core/threads/wait_notify.wast:15:3 39 assert_return(() => invoke(\$1, \`run\`, []), [value("i32", 0)]); 40 `); 41 42 // ./test/core/threads/wait_notify.wast:18 43 let $T2 = new Thread($Mem, "$Mem", ` 44 45 // ./test/core/threads/wait_notify.wast:19:3 46 register(\$Mem, \`mem\`); 47 48 // ./test/core/threads/wait_notify.wast:20:3 49 let \$2 = instantiate(\`(module 50 (memory (import "mem" "shared") 1 1 shared) 51 (func (export "notify-0") (result i32) 52 (memory.atomic.notify (i32.const 0) (i32.const 0)) 53 ) 54 (func (export "notify-1-while") 55 (loop 56 (i32.const 1) 57 (memory.atomic.notify (i32.const 0) (i32.const 1)) 58 (i32.ne) 59 (br_if 0) 60 ) 61 ) 62 )\`); 63 64 // ./test/core/threads/wait_notify.wast:35:3 65 assert_return(() => invoke(\$2, \`notify-0\`, []), [value("i32", 0)]); 66 67 // ./test/core/threads/wait_notify.wast:37:3 68 assert_return(() => invoke(\$2, \`notify-1-while\`, []), []); 69 `); 70 71 // ./test/core/threads/wait_notify.wast:40 72 $T1.wait(); 73 74 // ./test/core/threads/wait_notify.wast:41 75 $T2.wait();