memory_copy.js (1080B)
1 // A simple test case for memory.copy between different memories. 2 // See bug 1861267. 3 4 let i = wasmEvalText( 5 `(module 6 (memory $$mem0 (data "staubfaenger")) 7 (memory $$mem1 (data "\\ee\\22\\55\\ff")) 8 (memory $$mem2 (data "\\dd\\33\\66\\00")) 9 (memory $$mem3 (data "schnickschnack")) 10 11 (func (export "copy0to3") (param i32 i32 i32) 12 (memory.copy $$mem3 $$mem0 13 (local.get 0) 14 (local.get 1) 15 (local.get 2)) 16 ) 17 (func (export "copy3to0") (param i32 i32 i32) 18 (memory.copy $$mem0 $$mem3 19 (local.get 0) 20 (local.get 1) 21 (local.get 2)) 22 ) 23 24 (func (export "read0") (param i32) (result i32) 25 (i32.load8_u $$mem0 (local.get 0)) 26 ) 27 (func (export "read3") (param i32) (result i32) 28 (i32.load8_u $$mem3 (local.get 0)) 29 ) 30 )`); 31 32 i.exports.copy0to3(4, 5, 6); 33 let s = ""; 34 for (let ix = 0; ix < 14; ix++) { 35 s = s + String.fromCharCode(i.exports.read3(ix)); 36 } 37 38 i.exports.copy3to0(8, 2, 7); 39 s = s + "_"; 40 for (let ix = 0; ix < 12; ix++) { 41 s = s + String.fromCharCode(i.exports.read0(ix)); 42 } 43 44 assertEq(s, "schnfaengenack_staubfaehnfa");