passive-segs-nonboundary.js (48458B)
1 load(libdir + "wasm-binary.js"); 2 3 const v2vSig = {args:[], ret:VoidCode}; 4 const v2vSigSection = sigSection([v2vSig]); 5 6 const Module = WebAssembly.Module; 7 const Instance = WebAssembly.Instance; 8 9 // Some non-boundary tests for {table,memory}.{init,drop,copy}. The table 10 // case is more complex and appears first. The memory case is a simplified 11 // version of it. 12 13 // This module exports 5 functions .. 14 let tab_expmod_t = 15 `(module 16 (func (export "ef0") (result i32) (i32.const 0)) 17 (func (export "ef1") (result i32) (i32.const 1)) 18 (func (export "ef2") (result i32) (i32.const 2)) 19 (func (export "ef3") (result i32) (i32.const 3)) 20 (func (export "ef4") (result i32) (i32.const 4)) 21 )`; 22 23 // .. and this one imports those 5 functions. It adds 5 of its own, creates a 24 // 30 element table using both active and passive initialisers, with a mixture 25 // of the imported and local functions. |setup| and |check| are exported. 26 // |setup| uses the supplied |insn| to modify the table somehow. |check| will 27 // indirect-call the table entry number specified as a parameter. That will 28 // either return a value 0 to 9 indicating the function called, or will throw an 29 // exception if the table entry is empty. 30 function gen_tab_impmod_t(insn) 31 { 32 let t = 33 `(module 34 ;; -------- Types -------- 35 (type (func (result i32))) ;; type #0 36 ;; -------- Imports -------- 37 (import "a" "if0" (func (result i32))) ;; index 0 38 (import "a" "if1" (func (result i32))) 39 (import "a" "if2" (func (result i32))) 40 (import "a" "if3" (func (result i32))) 41 (import "a" "if4" (func (result i32))) ;; index 4 42 ;; -------- Tables -------- 43 (table 30 30 funcref) 44 ;; -------- Table initialisers -------- 45 (elem (i32.const 2) 3 1 4 1) 46 (elem func 2 7 1 8) 47 (elem (i32.const 12) 7 5 2 3 6) 48 (elem func 5 9 2 7 6) 49 ;; -------- Functions -------- 50 (func (result i32) (i32.const 5)) ;; index 5 51 (func (result i32) (i32.const 6)) 52 (func (result i32) (i32.const 7)) 53 (func (result i32) (i32.const 8)) 54 (func (result i32) (i32.const 9)) ;; index 9 55 56 (func (export "setup") 57 ${insn}) 58 (func (export "check") (param i32) (result i32) 59 ;; call the selected table entry, which will either return a value, 60 ;; or will cause an exception. 61 local.get 0 ;; callIx 62 call_indirect (type 0) ;; and its return value is our return value. 63 ) 64 )`; 65 return t; 66 }; 67 68 // This is the test driver. It constructs the abovementioned module, using 69 // the given |instruction| to modify the table, and then probes the table 70 // by making indirect calls, one for each element of |expected_result_vector|. 71 // The results are compared to those in the vector. 72 73 function tab_test(instruction, expected_result_vector) 74 { 75 let tab_expmod_b = wasmTextToBinary(tab_expmod_t); 76 let tab_expmod_i = new Instance(new Module(tab_expmod_b)); 77 78 let tab_impmod_t = gen_tab_impmod_t(instruction); 79 let tab_impmod_b = wasmTextToBinary(tab_impmod_t); 80 81 let inst = new Instance(new Module(tab_impmod_b), 82 {a:{if0:tab_expmod_i.exports.ef0, 83 if1:tab_expmod_i.exports.ef1, 84 if2:tab_expmod_i.exports.ef2, 85 if3:tab_expmod_i.exports.ef3, 86 if4:tab_expmod_i.exports.ef4 87 }}); 88 inst.exports.setup(); 89 90 for (let i = 0; i < expected_result_vector.length; i++) { 91 let expected = expected_result_vector[i]; 92 let actual = undefined; 93 try { 94 actual = inst.exports.check(i); 95 assertEq(actual !== null, true); 96 } catch (e) { 97 if (!(e instanceof Error && 98 e.message.match(/indirect call to null/))) 99 throw e; 100 // actual remains undefined 101 } 102 assertEq(actual, expected, 103 "tab_test fail: insn = '" + instruction + "', index = " + 104 i + ", expected = " + expected + ", actual = " + actual); 105 } 106 } 107 108 // Using 'e' for empty (undefined) spaces in the table, to make it easier 109 // to count through the vector entries when debugging. 110 let e = undefined; 111 112 // This just gives the initial state of the table, with its active 113 // initialisers applied 114 tab_test("nop", 115 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 116 117 // Copy non-null over non-null 118 tab_test("(table.copy (i32.const 13) (i32.const 2) (i32.const 3))", 119 [e,e,3,1,4, 1,e,e,e,e, e,e,7,3,1, 4,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 120 121 // Copy non-null over null 122 tab_test("(table.copy (i32.const 25) (i32.const 15) (i32.const 2))", 123 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, 3,6,e,e,e]); 124 125 // Copy null over non-null 126 tab_test("(table.copy (i32.const 13) (i32.const 25) (i32.const 3))", 127 [e,e,3,1,4, 1,e,e,e,e, e,e,7,e,e, e,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 128 129 // Copy null over null 130 tab_test("(table.copy (i32.const 20) (i32.const 22) (i32.const 4))", 131 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 132 133 // Copy null and non-null entries, non overlapping 134 tab_test("(table.copy (i32.const 25) (i32.const 1) (i32.const 3))", 135 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, e,3,1,e,e]); 136 137 // Copy null and non-null entries, overlapping, backwards 138 tab_test("(table.copy (i32.const 10) (i32.const 12) (i32.const 7))", 139 [e,e,3,1,4, 1,e,e,e,e, 7,5,2,3,6, e,e,e,e,e, e,e,e,e,e, e,e,e,e,e]); 140 141 // Copy null and non-null entries, overlapping, forwards 142 tab_test("(table.copy (i32.const 12) (i32.const 10) (i32.const 7))", 143 [e,e,3,1,4, 1,e,e,e,e, e,e,e,e,7, 5,2,3,6,e, e,e,e,e,e, e,e,e,e,e]); 144 145 // Passive init that overwrites all-null entries 146 tab_test("(table.init 1 (i32.const 7) (i32.const 0) (i32.const 4))", 147 [e,e,3,1,4, 1,e,2,7,1, 8,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 148 149 // Passive init that overwrites existing active-init-created entries 150 tab_test("(table.init 3 (i32.const 15) (i32.const 1) (i32.const 3))", 151 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 9,2,7,e,e, e,e,e,e,e, e,e,e,e,e]); 152 153 // Perform active and passive initialisation and then multiple copies 154 tab_test("(table.init 1 (i32.const 7) (i32.const 0) (i32.const 4)) \n" + 155 "elem.drop 1 \n" + 156 "(table.init 3 (i32.const 15) (i32.const 1) (i32.const 3)) \n" + 157 "elem.drop 3 \n" + 158 "(table.copy (i32.const 20) (i32.const 15) (i32.const 5)) \n" + 159 "(table.copy (i32.const 21) (i32.const 29) (i32.const 1)) \n" + 160 "(table.copy (i32.const 24) (i32.const 10) (i32.const 1)) \n" + 161 "(table.copy (i32.const 13) (i32.const 11) (i32.const 4)) \n" + 162 "(table.copy (i32.const 19) (i32.const 20) (i32.const 5))", 163 [e,e,3,1,4, 1,e,2,7,1, 8,e,7,e,7, 5,2,7,e,9, e,7,e,8,8, e,e,e,e,e]); 164 165 // And now a simplified version of the above, for memory.{init,drop,copy}. 166 167 function gen_mem_mod_t(insn) 168 { 169 let t = 170 `(module 171 ;; -------- Memories -------- 172 (memory (export "memory0") 1 1) 173 ;; -------- Memory initialisers -------- 174 (data (i32.const 2) "\\03\\01\\04\\01") 175 (data "\\02\\07\\01\\08") 176 (data (i32.const 12) "\\07\\05\\02\\03\\06") 177 (data "\\05\\09\\02\\07\\06") 178 179 (func (export "testfn") 180 ${insn} 181 ;; There's no return value. The JS driver can just pull out the 182 ;; final memory and examine it. 183 ) 184 )`; 185 return t; 186 }; 187 188 function mem_test(instruction, expected_result_vector) 189 { 190 let mem_mod_t = gen_mem_mod_t(instruction); 191 let mem_mod_b = wasmTextToBinary(mem_mod_t); 192 193 let inst = new Instance(new Module(mem_mod_b)); 194 inst.exports.testfn(); 195 let buf = new Uint8Array(inst.exports.memory0.buffer); 196 197 for (let i = 0; i < expected_result_vector.length; i++) { 198 let expected = expected_result_vector[i]; 199 let actual = buf[i]; 200 assertEq(actual, expected, 201 "mem_test fail: insn = '" + instruction + "', index = " + 202 i + ", expected = " + expected + ", actual = " + actual); 203 } 204 } 205 206 e = 0; 207 208 // This just gives the initial state of the memory, with its active 209 // initialisers applied. 210 mem_test("nop", 211 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 212 213 // Copy non-zero over non-zero 214 mem_test("(memory.copy (i32.const 13) (i32.const 2) (i32.const 3))", 215 [e,e,3,1,4, 1,e,e,e,e, e,e,7,3,1, 4,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 216 217 // Copy non-zero over zero 218 mem_test("(memory.copy (i32.const 25) (i32.const 15) (i32.const 2))", 219 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, 3,6,e,e,e]); 220 221 // Copy zero over non-zero 222 mem_test("(memory.copy (i32.const 13) (i32.const 25) (i32.const 3))", 223 [e,e,3,1,4, 1,e,e,e,e, e,e,7,e,e, e,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 224 225 // Copy zero over zero 226 mem_test("(memory.copy (i32.const 20) (i32.const 22) (i32.const 4))", 227 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 228 229 // Copy zero and non-zero entries, non overlapping 230 mem_test("(memory.copy (i32.const 25) (i32.const 1) (i32.const 3))", 231 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, e,3,1,e,e]); 232 233 // Copy zero and non-zero entries, overlapping, backwards 234 mem_test("(memory.copy (i32.const 10) (i32.const 12) (i32.const 7))", 235 [e,e,3,1,4, 1,e,e,e,e, 7,5,2,3,6, e,e,e,e,e, e,e,e,e,e, e,e,e,e,e]); 236 237 // Copy zero and non-zero entries, overlapping, forwards 238 mem_test("(memory.copy (i32.const 12) (i32.const 10) (i32.const 7))", 239 [e,e,3,1,4, 1,e,e,e,e, e,e,e,e,7, 5,2,3,6,e, e,e,e,e,e, e,e,e,e,e]); 240 241 // Passive init that overwrites all-zero entries 242 mem_test("(memory.init 1 (i32.const 7) (i32.const 0) (i32.const 4))", 243 [e,e,3,1,4, 1,e,2,7,1, 8,e,7,5,2, 3,6,e,e,e, e,e,e,e,e, e,e,e,e,e]); 244 245 // Passive init that overwrites existing active-init-created entries 246 mem_test("(memory.init 3 (i32.const 15) (i32.const 1) (i32.const 3))", 247 [e,e,3,1,4, 1,e,e,e,e, e,e,7,5,2, 9,2,7,e,e, e,e,e,e,e, e,e,e,e,e]); 248 249 // Perform active and passive initialisation and then multiple copies 250 mem_test("(memory.init 1 (i32.const 7) (i32.const 0) (i32.const 4)) \n" + 251 "data.drop 1 \n" + 252 "(memory.init 3 (i32.const 15) (i32.const 1) (i32.const 3)) \n" + 253 "data.drop 3 \n" + 254 "(memory.copy (i32.const 20) (i32.const 15) (i32.const 5)) \n" + 255 "(memory.copy (i32.const 21) (i32.const 29) (i32.const 1)) \n" + 256 "(memory.copy (i32.const 24) (i32.const 10) (i32.const 1)) \n" + 257 "(memory.copy (i32.const 13) (i32.const 11) (i32.const 4)) \n" + 258 "(memory.copy (i32.const 19) (i32.const 20) (i32.const 5))", 259 [e,e,3,1,4, 1,e,2,7,1, 8,e,7,e,7, 5,2,7,e,9, e,7,e,8,8, e,e,e,e,e]); 260 261 function checkDataCount(count, err) { 262 let binary = moduleWithSections( 263 [v2vSigSection, 264 dataCountSection(count), 265 dataSection([ 266 {offset: 0, elems: []}, 267 {offset: 0, elems: []}, 268 ]) 269 ]); 270 assertErrorMessage(() => new WebAssembly.Module(binary), 271 WebAssembly.CompileError, 272 err); 273 } 274 275 // DataCount section is present but value is too low for the number of data segments 276 checkDataCount(1, /number of data segments does not match declared count/); 277 // DataCount section is present but value is too high for the number of data segments 278 checkDataCount(3, /number of data segments does not match declared count/); 279 280 // DataCount section is not present but memory.init or data.drop uses it 281 function checkNoDataCount(body, err) { 282 let binary = moduleWithSections( 283 [v2vSigSection, 284 declSection([0]), 285 memorySection(1), 286 bodySection( 287 [funcBody({locals:[], body})])]); 288 assertErrorMessage(() => new WebAssembly.Module(binary), 289 WebAssembly.CompileError, 290 err); 291 } 292 293 checkNoDataCount([I32ConstCode, 0, 294 I32ConstCode, 0, 295 I32ConstCode, 0, 296 MiscPrefix, MemoryInitCode, 0, 0], 297 /(memory.init requires a DataCount section)|(unknown data segment)/); 298 299 checkNoDataCount([MiscPrefix, DataDropCode, 0], 300 /(data.drop requires a DataCount section)|(unknown data segment)/); 301 302 //---------------------------------------------------------------------// 303 //---------------------------------------------------------------------// 304 // Some further tests for memory.copy and memory.fill. First, validation 305 // tests. 306 307 // Prefixed opcodes 308 309 function checkMiscPrefixed(opcode, expect_failure) { 310 let binary = moduleWithSections( 311 [v2vSigSection, declSection([0]), memorySection(1), 312 bodySection( 313 [funcBody( 314 {locals:[], 315 body:[I32ConstCode, 0x0, 316 I32ConstCode, 0x0, 317 I32ConstCode, 0x0, 318 MiscPrefix, ...opcode]})])]); 319 if (expect_failure) { 320 assertErrorMessage(() => new WebAssembly.Module(binary), 321 WebAssembly.CompileError, /(unrecognized opcode)|(Unknown.*subopcode)/); 322 } else { 323 assertEq(WebAssembly.validate(binary), true); 324 } 325 } 326 327 //----------------------------------------------------------- 328 // Verification cases for memory.copy/fill opcode encodings 329 330 checkMiscPrefixed([MemoryCopyCode, 0x00, 0x00], false); // memory.copy src=0 dest=0 331 checkMiscPrefixed([MemoryFillCode, 0x00], false); // memory.fill mem=0 332 checkMiscPrefixed([0x13], true); // table.size+1, which is currently unassigned 333 334 //----------------------------------------------------------- 335 // Verification cases for memory.copy/fill arguments 336 337 // Invalid argument types 338 { 339 const tys = ['i32', 'f32', 'i64', 'f64']; 340 const ops = ['copy', 'fill']; 341 for (let ty1 of tys) { 342 for (let ty2 of tys) { 343 for (let ty3 of tys) { 344 for (let op of ops) { 345 if (ty1 == 'i32' && ty2 == 'i32' && ty3 == 'i32') 346 continue; // this is the only valid case 347 let text = 348 `(module 349 (memory (export "memory") 1 1) 350 (func (export "testfn") 351 (memory.${op} (${ty1}.const 10) (${ty2}.const 20) (${ty3}.const 30)) 352 ) 353 )`; 354 assertErrorMessage(() => wasmEvalText(text), 355 WebAssembly.CompileError, /type mismatch/); 356 }}}} 357 } 358 359 // Not enough, or too many, args 360 { 361 for (let op of ['copy', 'fill']) { 362 let text1 = 363 `(module 364 (memory (export "memory") 1 1) 365 (func (export "testfn") 366 (i32.const 10) 367 (i32.const 20) 368 memory.${op} 369 ) 370 )`; 371 assertErrorMessage(() => wasmEvalText(text1), 372 WebAssembly.CompileError, 373 /(popping value from empty stack)|(expected i32 but nothing on stack)/); 374 let text2 = 375 `(module 376 (memory (export "memory") 1 1) 377 (func (export "testfn") 378 (i32.const 10) 379 (i32.const 20) 380 (i32.const 30) 381 (i32.const 40) 382 memory.${op} 383 ) 384 )`; 385 assertErrorMessage(() => wasmEvalText(text2), 386 WebAssembly.CompileError, 387 /(unused values not explicitly dropped by end of block)|(values remaining on stack at end of block)/); 388 } 389 } 390 391 // Module doesn't have a memory 392 { 393 for (let op of ['copy', 'fill']) { 394 let text = 395 `(module 396 (func (export "testfn") 397 (memory.${op} (i32.const 10) (i32.const 20) (i32.const 30)) 398 ) 399 )`; 400 assertErrorMessage(() => wasmEvalText(text), 401 WebAssembly.CompileError, 402 /memory index/); 403 } 404 } 405 406 //---------------------------------------------------------------------// 407 //---------------------------------------------------------------------// 408 // Run tests 409 410 //----------------------------------------------------------- 411 // Test helpers 412 function checkRange(arr, minIx, maxIxPlusOne, expectedValue) 413 { 414 for (let i = minIx; i < maxIxPlusOne; i++) { 415 assertEq(arr[i], expectedValue); 416 } 417 } 418 419 //----------------------------------------------------------- 420 // Test cases for memory.fill 421 422 // Range valid 423 { 424 let inst = wasmEvalText( 425 `(module 426 (memory (export "memory") 1 1) 427 (func (export "testfn") 428 (memory.fill (i32.const 0xFF00) (i32.const 0x55) (i32.const 256)) 429 ) 430 )` 431 ); 432 inst.exports.testfn(); 433 let b = new Uint8Array(inst.exports.memory.buffer); 434 checkRange(b, 0x00000, 0x0FF00, 0x00); 435 checkRange(b, 0x0FF00, 0x10000, 0x55); 436 } 437 438 // Range invalid 439 { 440 let inst = wasmEvalText( 441 `(module 442 (memory (export "memory") 1 1) 443 (func (export "testfn") 444 (memory.fill (i32.const 0xFF00) (i32.const 0x55) (i32.const 257)) 445 ) 446 )` 447 ); 448 assertErrorMessage(() => inst.exports.testfn(), 449 WebAssembly.RuntimeError, /index out of bounds/); 450 } 451 452 // Wraparound the end of 32-bit offset space 453 { 454 let inst = wasmEvalText( 455 `(module 456 (memory (export "memory") 1 1) 457 (func (export "testfn") 458 (memory.fill (i32.const 0xFFFFFF00) (i32.const 0x55) (i32.const 257)) 459 ) 460 )` 461 ); 462 assertErrorMessage(() => inst.exports.testfn(), 463 WebAssembly.RuntimeError, /index out of bounds/); 464 } 465 466 // Zero len with offset in-bounds is a no-op 467 { 468 let inst = wasmEvalText( 469 `(module 470 (memory (export "memory") 1 1) 471 (func (export "testfn") 472 (memory.fill (i32.const 0x12) (i32.const 0x55) (i32.const 0)) 473 ) 474 )` 475 ); 476 inst.exports.testfn(); 477 let b = new Uint8Array(inst.exports.memory.buffer); 478 checkRange(b, 0x00000, 0x10000, 0x00); 479 } 480 481 // Zero len with offset out-of-bounds is OK 482 { 483 let inst = wasmEvalText( 484 `(module 485 (memory (export "memory") 1 1) 486 (func (export "testfn") 487 (memory.fill (i32.const 0x10000) (i32.const 0x55) (i32.const 0)) 488 ) 489 )` 490 ); 491 inst.exports.testfn(); 492 } 493 494 { 495 let inst = wasmEvalText( 496 `(module 497 (memory (export "memory") 1 1) 498 (func (export "testfn") 499 (memory.fill (i32.const 0x10001) (i32.const 0x55) (i32.const 0)) 500 ) 501 )` 502 ); 503 assertErrorMessage(() => inst.exports.testfn(), 504 WebAssembly.RuntimeError, /index out of bounds/); 505 } 506 507 // Very large range 508 { 509 let inst = wasmEvalText( 510 `(module 511 (memory (export "memory") 1 1) 512 (func (export "testfn") 513 (memory.fill (i32.const 0x1) (i32.const 0xAA) (i32.const 0xFFFE)) 514 ) 515 )` 516 ); 517 inst.exports.testfn(); 518 let b = new Uint8Array(inst.exports.memory.buffer); 519 checkRange(b, 0x00000, 0x00001, 0x00); 520 checkRange(b, 0x00001, 0x0FFFF, 0xAA); 521 checkRange(b, 0x0FFFF, 0x10000, 0x00); 522 } 523 524 // Sequencing 525 { 526 let i = wasmEvalText( 527 `(module 528 (memory (export "memory") 1 1) 529 (func (export "testfn") (result i32) 530 (memory.fill (i32.const 0x12) (i32.const 0x55) (i32.const 10)) 531 (memory.fill (i32.const 0x15) (i32.const 0xAA) (i32.const 4)) 532 i32.const 99 533 ) 534 )` 535 ); 536 i.exports.testfn(); 537 let b = new Uint8Array(i.exports.memory.buffer); 538 checkRange(b, 0x0, 0x12+0, 0x00); 539 checkRange(b, 0x12+0, 0x12+3, 0x55); 540 checkRange(b, 0x12+3, 0x12+7, 0xAA); 541 checkRange(b, 0x12+7, 0x12+10, 0x55); 542 checkRange(b, 0x12+10, 0x10000, 0x00); 543 } 544 545 546 //----------------------------------------------------------- 547 // Test cases for memory.copy 548 549 // Both ranges valid. Copy 5 bytes backwards by 1 (overlapping). 550 // result = 0x00--(09) 0x55--(11) 0x00--(pagesize-20) 551 { 552 let inst = wasmEvalText( 553 `(module 554 (memory (export "memory") 1 1) 555 (func (export "testfn") 556 (memory.fill (i32.const 10) (i32.const 0x55) (i32.const 10)) 557 (memory.copy (i32.const 9) (i32.const 10) (i32.const 5)) 558 ) 559 )` 560 ); 561 inst.exports.testfn(); 562 let b = new Uint8Array(inst.exports.memory.buffer); 563 checkRange(b, 0, 0+9, 0x00); 564 checkRange(b, 9, 9+11, 0x55); 565 checkRange(b, 9+11, 0x10000, 0x00); 566 } 567 568 // Both ranges valid. Copy 5 bytes forwards by 1 (overlapping). 569 // result = 0x00--(10) 0x55--(11) 0x00--(pagesize-19) 570 { 571 let inst = wasmEvalText( 572 `(module 573 (memory (export "memory") 1 1) 574 (func (export "testfn") 575 (memory.fill (i32.const 10) (i32.const 0x55) (i32.const 10)) 576 (memory.copy (i32.const 16) (i32.const 15) (i32.const 5)) 577 ) 578 )` 579 ); 580 inst.exports.testfn(); 581 let b = new Uint8Array(inst.exports.memory.buffer); 582 checkRange(b, 0, 0+10, 0x00); 583 checkRange(b, 10, 10+11, 0x55); 584 checkRange(b, 10+11, 0x10000, 0x00); 585 } 586 587 // Destination range invalid 588 { 589 let inst = wasmEvalText( 590 `(module 591 (memory (export "memory") 1 1) 592 (func (export "testfn") 593 (memory.copy (i32.const 0xFF00) (i32.const 0x8000) (i32.const 257)) 594 ) 595 )` 596 ); 597 assertErrorMessage(() => inst.exports.testfn(), 598 WebAssembly.RuntimeError, /index out of bounds/); 599 } 600 601 // Destination wraparound the end of 32-bit offset space 602 { 603 let inst = wasmEvalText( 604 `(module 605 (memory (export "memory") 1 1) 606 (func (export "testfn") 607 (memory.copy (i32.const 0xFFFFFF00) (i32.const 0x4000) (i32.const 257)) 608 ) 609 )` 610 ); 611 assertErrorMessage(() => inst.exports.testfn(), 612 WebAssembly.RuntimeError, /index out of bounds/); 613 } 614 615 // Source range invalid 616 { 617 let inst = wasmEvalText( 618 `(module 619 (memory (export "memory") 1 1) 620 (func (export "testfn") 621 (memory.copy (i32.const 0x8000) (i32.const 0xFF00) (i32.const 257)) 622 ) 623 )` 624 ); 625 assertErrorMessage(() => inst.exports.testfn(), 626 WebAssembly.RuntimeError, /index out of bounds/); 627 } 628 629 // Source wraparound the end of 32-bit offset space 630 { 631 let inst = wasmEvalText( 632 `(module 633 (memory (export "memory") 1 1) 634 (func (export "testfn") 635 (memory.copy (i32.const 0x4000) (i32.const 0xFFFFFF00) (i32.const 257)) 636 ) 637 )` 638 ); 639 assertErrorMessage(() => inst.exports.testfn(), 640 WebAssembly.RuntimeError, /index out of bounds/); 641 } 642 643 // Zero len with both offsets in-bounds is a no-op 644 { 645 let inst = wasmEvalText( 646 `(module 647 (memory (export "memory") 1 1) 648 (func (export "testfn") 649 (memory.fill (i32.const 0x0000) (i32.const 0x55) (i32.const 0x8000)) 650 (memory.fill (i32.const 0x8000) (i32.const 0xAA) (i32.const 0x8000)) 651 (memory.copy (i32.const 0x9000) (i32.const 0x7000) (i32.const 0)) 652 ) 653 )` 654 ); 655 inst.exports.testfn(); 656 let b = new Uint8Array(inst.exports.memory.buffer); 657 checkRange(b, 0x00000, 0x08000, 0x55); 658 checkRange(b, 0x08000, 0x10000, 0xAA); 659 } 660 661 // Zero len with dest offset out-of-bounds at the edge of memory 662 { 663 let inst = wasmEvalText( 664 `(module 665 (memory (export "memory") 1 1) 666 (func (export "testfn") 667 (memory.copy (i32.const 0x10000) (i32.const 0x7000) (i32.const 0)) 668 ) 669 )` 670 ); 671 inst.exports.testfn(); 672 } 673 674 // Ditto, but one element further out 675 { 676 let inst = wasmEvalText( 677 `(module 678 (memory (export "memory") 1 1) 679 (func (export "testfn") 680 (memory.copy (i32.const 0x10001) (i32.const 0x7000) (i32.const 0)) 681 ) 682 )` 683 ); 684 assertErrorMessage(() => inst.exports.testfn(), 685 WebAssembly.RuntimeError, /index out of bounds/); 686 } 687 688 // Zero len with src offset out-of-bounds at the edge of memory 689 { 690 let inst = wasmEvalText( 691 `(module 692 (memory (export "memory") 1 1) 693 (func (export "testfn") 694 (memory.copy (i32.const 0x9000) (i32.const 0x10000) (i32.const 0)) 695 ) 696 )` 697 ); 698 inst.exports.testfn(); 699 } 700 701 // Ditto, but one element further out 702 { 703 let inst = wasmEvalText( 704 `(module 705 (memory (export "memory") 1 1) 706 (func (export "testfn") 707 (memory.copy (i32.const 0x9000) (i32.const 0x10001) (i32.const 0)) 708 ) 709 )` 710 ); 711 assertErrorMessage(() => inst.exports.testfn(), 712 WebAssembly.RuntimeError, /index out of bounds/); 713 } 714 715 // 100 random fills followed by 100 random copies, in a single-page buffer, 716 // followed by verification of the (now heavily mashed-around) buffer. 717 { 718 let inst = wasmEvalText( 719 `(module 720 (memory (export "memory") 1 1) 721 (func (export "testfn") 722 (memory.fill (i32.const 17767) (i32.const 1) (i32.const 1344)) 723 (memory.fill (i32.const 39017) (i32.const 2) (i32.const 1055)) 724 (memory.fill (i32.const 56401) (i32.const 3) (i32.const 988)) 725 (memory.fill (i32.const 37962) (i32.const 4) (i32.const 322)) 726 (memory.fill (i32.const 7977) (i32.const 5) (i32.const 1994)) 727 (memory.fill (i32.const 22714) (i32.const 6) (i32.const 3036)) 728 (memory.fill (i32.const 16882) (i32.const 7) (i32.const 2372)) 729 (memory.fill (i32.const 43491) (i32.const 8) (i32.const 835)) 730 (memory.fill (i32.const 124) (i32.const 9) (i32.const 1393)) 731 (memory.fill (i32.const 2132) (i32.const 10) (i32.const 2758)) 732 (memory.fill (i32.const 8987) (i32.const 11) (i32.const 3098)) 733 (memory.fill (i32.const 52711) (i32.const 12) (i32.const 741)) 734 (memory.fill (i32.const 3958) (i32.const 13) (i32.const 2823)) 735 (memory.fill (i32.const 49715) (i32.const 14) (i32.const 1280)) 736 (memory.fill (i32.const 50377) (i32.const 15) (i32.const 1466)) 737 (memory.fill (i32.const 20493) (i32.const 16) (i32.const 3158)) 738 (memory.fill (i32.const 47665) (i32.const 17) (i32.const 544)) 739 (memory.fill (i32.const 12451) (i32.const 18) (i32.const 2669)) 740 (memory.fill (i32.const 24869) (i32.const 19) (i32.const 2651)) 741 (memory.fill (i32.const 45317) (i32.const 20) (i32.const 1570)) 742 (memory.fill (i32.const 43096) (i32.const 21) (i32.const 1691)) 743 (memory.fill (i32.const 33886) (i32.const 22) (i32.const 646)) 744 (memory.fill (i32.const 48555) (i32.const 23) (i32.const 1858)) 745 (memory.fill (i32.const 53453) (i32.const 24) (i32.const 2657)) 746 (memory.fill (i32.const 30363) (i32.const 25) (i32.const 981)) 747 (memory.fill (i32.const 9300) (i32.const 26) (i32.const 1807)) 748 (memory.fill (i32.const 50190) (i32.const 27) (i32.const 487)) 749 (memory.fill (i32.const 62753) (i32.const 28) (i32.const 530)) 750 (memory.fill (i32.const 36316) (i32.const 29) (i32.const 943)) 751 (memory.fill (i32.const 6768) (i32.const 30) (i32.const 381)) 752 (memory.fill (i32.const 51262) (i32.const 31) (i32.const 3089)) 753 (memory.fill (i32.const 49729) (i32.const 32) (i32.const 658)) 754 (memory.fill (i32.const 44540) (i32.const 33) (i32.const 1702)) 755 (memory.fill (i32.const 33342) (i32.const 34) (i32.const 1092)) 756 (memory.fill (i32.const 50814) (i32.const 35) (i32.const 1410)) 757 (memory.fill (i32.const 47594) (i32.const 36) (i32.const 2204)) 758 (memory.fill (i32.const 54123) (i32.const 37) (i32.const 2394)) 759 (memory.fill (i32.const 55183) (i32.const 38) (i32.const 250)) 760 (memory.fill (i32.const 22620) (i32.const 39) (i32.const 2097)) 761 (memory.fill (i32.const 17132) (i32.const 40) (i32.const 3264)) 762 (memory.fill (i32.const 54331) (i32.const 41) (i32.const 3299)) 763 (memory.fill (i32.const 39474) (i32.const 42) (i32.const 2796)) 764 (memory.fill (i32.const 36156) (i32.const 43) (i32.const 2070)) 765 (memory.fill (i32.const 35308) (i32.const 44) (i32.const 2763)) 766 (memory.fill (i32.const 32731) (i32.const 45) (i32.const 312)) 767 (memory.fill (i32.const 63746) (i32.const 46) (i32.const 192)) 768 (memory.fill (i32.const 30974) (i32.const 47) (i32.const 596)) 769 (memory.fill (i32.const 16635) (i32.const 48) (i32.const 501)) 770 (memory.fill (i32.const 57002) (i32.const 49) (i32.const 686)) 771 (memory.fill (i32.const 34299) (i32.const 50) (i32.const 385)) 772 (memory.fill (i32.const 60881) (i32.const 51) (i32.const 903)) 773 (memory.fill (i32.const 61445) (i32.const 52) (i32.const 2390)) 774 (memory.fill (i32.const 46972) (i32.const 53) (i32.const 1441)) 775 (memory.fill (i32.const 25973) (i32.const 54) (i32.const 3162)) 776 (memory.fill (i32.const 5566) (i32.const 55) (i32.const 2135)) 777 (memory.fill (i32.const 35977) (i32.const 56) (i32.const 519)) 778 (memory.fill (i32.const 44892) (i32.const 57) (i32.const 3280)) 779 (memory.fill (i32.const 46760) (i32.const 58) (i32.const 1678)) 780 (memory.fill (i32.const 46607) (i32.const 59) (i32.const 3168)) 781 (memory.fill (i32.const 22449) (i32.const 60) (i32.const 1441)) 782 (memory.fill (i32.const 58609) (i32.const 61) (i32.const 663)) 783 (memory.fill (i32.const 32261) (i32.const 62) (i32.const 1671)) 784 (memory.fill (i32.const 3063) (i32.const 63) (i32.const 721)) 785 (memory.fill (i32.const 34025) (i32.const 64) (i32.const 84)) 786 (memory.fill (i32.const 33338) (i32.const 65) (i32.const 2029)) 787 (memory.fill (i32.const 36810) (i32.const 66) (i32.const 29)) 788 (memory.fill (i32.const 19147) (i32.const 67) (i32.const 3034)) 789 (memory.fill (i32.const 12616) (i32.const 68) (i32.const 1043)) 790 (memory.fill (i32.const 18276) (i32.const 69) (i32.const 3324)) 791 (memory.fill (i32.const 4639) (i32.const 70) (i32.const 1091)) 792 (memory.fill (i32.const 16158) (i32.const 71) (i32.const 1997)) 793 (memory.fill (i32.const 18204) (i32.const 72) (i32.const 2259)) 794 (memory.fill (i32.const 50532) (i32.const 73) (i32.const 3189)) 795 (memory.fill (i32.const 11028) (i32.const 74) (i32.const 1968)) 796 (memory.fill (i32.const 15962) (i32.const 75) (i32.const 1455)) 797 (memory.fill (i32.const 45406) (i32.const 76) (i32.const 1177)) 798 (memory.fill (i32.const 54137) (i32.const 77) (i32.const 1568)) 799 (memory.fill (i32.const 33083) (i32.const 78) (i32.const 1642)) 800 (memory.fill (i32.const 61028) (i32.const 79) (i32.const 3284)) 801 (memory.fill (i32.const 51729) (i32.const 80) (i32.const 223)) 802 (memory.fill (i32.const 4361) (i32.const 81) (i32.const 2171)) 803 (memory.fill (i32.const 57514) (i32.const 82) (i32.const 1322)) 804 (memory.fill (i32.const 55724) (i32.const 83) (i32.const 2648)) 805 (memory.fill (i32.const 24091) (i32.const 84) (i32.const 1045)) 806 (memory.fill (i32.const 43183) (i32.const 85) (i32.const 3097)) 807 (memory.fill (i32.const 32307) (i32.const 86) (i32.const 2796)) 808 (memory.fill (i32.const 3811) (i32.const 87) (i32.const 2010)) 809 (memory.fill (i32.const 54856) (i32.const 88) (i32.const 0)) 810 (memory.fill (i32.const 49941) (i32.const 89) (i32.const 2069)) 811 (memory.fill (i32.const 20411) (i32.const 90) (i32.const 2896)) 812 (memory.fill (i32.const 33826) (i32.const 91) (i32.const 192)) 813 (memory.fill (i32.const 9402) (i32.const 92) (i32.const 2195)) 814 (memory.fill (i32.const 12413) (i32.const 93) (i32.const 24)) 815 (memory.fill (i32.const 14091) (i32.const 94) (i32.const 577)) 816 (memory.fill (i32.const 44058) (i32.const 95) (i32.const 2089)) 817 (memory.fill (i32.const 36735) (i32.const 96) (i32.const 3436)) 818 (memory.fill (i32.const 23288) (i32.const 97) (i32.const 2765)) 819 (memory.fill (i32.const 6392) (i32.const 98) (i32.const 830)) 820 (memory.fill (i32.const 33307) (i32.const 99) (i32.const 1938)) 821 (memory.fill (i32.const 21941) (i32.const 100) (i32.const 2750)) 822 (memory.copy (i32.const 59214) (i32.const 54248) (i32.const 2098)) 823 (memory.copy (i32.const 63026) (i32.const 39224) (i32.const 230)) 824 (memory.copy (i32.const 51833) (i32.const 23629) (i32.const 2300)) 825 (memory.copy (i32.const 6708) (i32.const 23996) (i32.const 639)) 826 (memory.copy (i32.const 6990) (i32.const 33399) (i32.const 1097)) 827 (memory.copy (i32.const 19403) (i32.const 10348) (i32.const 3197)) 828 (memory.copy (i32.const 27308) (i32.const 54406) (i32.const 100)) 829 (memory.copy (i32.const 27221) (i32.const 43682) (i32.const 1717)) 830 (memory.copy (i32.const 60528) (i32.const 8629) (i32.const 119)) 831 (memory.copy (i32.const 5947) (i32.const 2308) (i32.const 658)) 832 (memory.copy (i32.const 4787) (i32.const 51631) (i32.const 2269)) 833 (memory.copy (i32.const 12617) (i32.const 19197) (i32.const 833)) 834 (memory.copy (i32.const 11854) (i32.const 46505) (i32.const 3300)) 835 (memory.copy (i32.const 11376) (i32.const 45012) (i32.const 2281)) 836 (memory.copy (i32.const 34186) (i32.const 6697) (i32.const 2572)) 837 (memory.copy (i32.const 4936) (i32.const 1690) (i32.const 1328)) 838 (memory.copy (i32.const 63164) (i32.const 7637) (i32.const 1670)) 839 (memory.copy (i32.const 44568) (i32.const 18344) (i32.const 33)) 840 (memory.copy (i32.const 43918) (i32.const 22348) (i32.const 1427)) 841 (memory.copy (i32.const 46637) (i32.const 49819) (i32.const 1434)) 842 (memory.copy (i32.const 63684) (i32.const 8755) (i32.const 834)) 843 (memory.copy (i32.const 33485) (i32.const 20131) (i32.const 3317)) 844 (memory.copy (i32.const 40575) (i32.const 54317) (i32.const 3201)) 845 (memory.copy (i32.const 25812) (i32.const 59254) (i32.const 2452)) 846 (memory.copy (i32.const 19678) (i32.const 56882) (i32.const 346)) 847 (memory.copy (i32.const 15852) (i32.const 35914) (i32.const 2430)) 848 (memory.copy (i32.const 11824) (i32.const 35574) (i32.const 300)) 849 (memory.copy (i32.const 59427) (i32.const 13957) (i32.const 3153)) 850 (memory.copy (i32.const 34299) (i32.const 60594) (i32.const 1281)) 851 (memory.copy (i32.const 8964) (i32.const 12276) (i32.const 943)) 852 (memory.copy (i32.const 2827) (i32.const 10425) (i32.const 1887)) 853 (memory.copy (i32.const 43194) (i32.const 43910) (i32.const 738)) 854 (memory.copy (i32.const 63038) (i32.const 18949) (i32.const 122)) 855 (memory.copy (i32.const 24044) (i32.const 44761) (i32.const 1755)) 856 (memory.copy (i32.const 22608) (i32.const 14755) (i32.const 702)) 857 (memory.copy (i32.const 11284) (i32.const 26579) (i32.const 1830)) 858 (memory.copy (i32.const 23092) (i32.const 20471) (i32.const 1064)) 859 (memory.copy (i32.const 57248) (i32.const 54770) (i32.const 2631)) 860 (memory.copy (i32.const 25492) (i32.const 1025) (i32.const 3113)) 861 (memory.copy (i32.const 49588) (i32.const 44220) (i32.const 975)) 862 (memory.copy (i32.const 28280) (i32.const 41722) (i32.const 2336)) 863 (memory.copy (i32.const 61289) (i32.const 230) (i32.const 2872)) 864 (memory.copy (i32.const 22480) (i32.const 52506) (i32.const 2197)) 865 (memory.copy (i32.const 40553) (i32.const 9578) (i32.const 1958)) 866 (memory.copy (i32.const 29004) (i32.const 20862) (i32.const 2186)) 867 (memory.copy (i32.const 53029) (i32.const 43955) (i32.const 1037)) 868 (memory.copy (i32.const 25476) (i32.const 35667) (i32.const 1650)) 869 (memory.copy (i32.const 58516) (i32.const 45819) (i32.const 1986)) 870 (memory.copy (i32.const 38297) (i32.const 5776) (i32.const 1955)) 871 (memory.copy (i32.const 28503) (i32.const 55364) (i32.const 2368)) 872 (memory.copy (i32.const 62619) (i32.const 18108) (i32.const 1356)) 873 (memory.copy (i32.const 50149) (i32.const 13861) (i32.const 382)) 874 (memory.copy (i32.const 16904) (i32.const 36341) (i32.const 1900)) 875 (memory.copy (i32.const 48098) (i32.const 11358) (i32.const 2807)) 876 (memory.copy (i32.const 28512) (i32.const 40362) (i32.const 323)) 877 (memory.copy (i32.const 35506) (i32.const 27856) (i32.const 1670)) 878 (memory.copy (i32.const 62970) (i32.const 53332) (i32.const 1341)) 879 (memory.copy (i32.const 14133) (i32.const 46312) (i32.const 644)) 880 (memory.copy (i32.const 29030) (i32.const 19074) (i32.const 496)) 881 (memory.copy (i32.const 44952) (i32.const 47577) (i32.const 2784)) 882 (memory.copy (i32.const 39559) (i32.const 44661) (i32.const 1350)) 883 (memory.copy (i32.const 10352) (i32.const 29274) (i32.const 1475)) 884 (memory.copy (i32.const 46911) (i32.const 46178) (i32.const 1467)) 885 (memory.copy (i32.const 4905) (i32.const 28740) (i32.const 1895)) 886 (memory.copy (i32.const 38012) (i32.const 57253) (i32.const 1751)) 887 (memory.copy (i32.const 26446) (i32.const 27223) (i32.const 1127)) 888 (memory.copy (i32.const 58835) (i32.const 24657) (i32.const 1063)) 889 (memory.copy (i32.const 61356) (i32.const 38790) (i32.const 766)) 890 (memory.copy (i32.const 44160) (i32.const 2284) (i32.const 1520)) 891 (memory.copy (i32.const 32740) (i32.const 47237) (i32.const 3014)) 892 (memory.copy (i32.const 11148) (i32.const 21260) (i32.const 1011)) 893 (memory.copy (i32.const 7665) (i32.const 31612) (i32.const 3034)) 894 (memory.copy (i32.const 18044) (i32.const 12987) (i32.const 3320)) 895 (memory.copy (i32.const 57306) (i32.const 55905) (i32.const 308)) 896 (memory.copy (i32.const 24675) (i32.const 16815) (i32.const 1155)) 897 (memory.copy (i32.const 19900) (i32.const 10115) (i32.const 722)) 898 (memory.copy (i32.const 2921) (i32.const 5935) (i32.const 2370)) 899 (memory.copy (i32.const 32255) (i32.const 50095) (i32.const 2926)) 900 (memory.copy (i32.const 15126) (i32.const 17299) (i32.const 2607)) 901 (memory.copy (i32.const 45575) (i32.const 28447) (i32.const 2045)) 902 (memory.copy (i32.const 55149) (i32.const 36113) (i32.const 2596)) 903 (memory.copy (i32.const 28461) (i32.const 54157) (i32.const 1168)) 904 (memory.copy (i32.const 47951) (i32.const 53385) (i32.const 3137)) 905 (memory.copy (i32.const 30646) (i32.const 45155) (i32.const 2649)) 906 (memory.copy (i32.const 5057) (i32.const 4295) (i32.const 52)) 907 (memory.copy (i32.const 6692) (i32.const 24195) (i32.const 441)) 908 (memory.copy (i32.const 32984) (i32.const 27117) (i32.const 3445)) 909 (memory.copy (i32.const 32530) (i32.const 59372) (i32.const 2785)) 910 (memory.copy (i32.const 34361) (i32.const 8962) (i32.const 2406)) 911 (memory.copy (i32.const 17893) (i32.const 54538) (i32.const 3381)) 912 (memory.copy (i32.const 22685) (i32.const 44151) (i32.const 136)) 913 (memory.copy (i32.const 59089) (i32.const 7077) (i32.const 1045)) 914 (memory.copy (i32.const 42945) (i32.const 55028) (i32.const 2389)) 915 (memory.copy (i32.const 44693) (i32.const 20138) (i32.const 877)) 916 (memory.copy (i32.const 36810) (i32.const 25196) (i32.const 3447)) 917 (memory.copy (i32.const 45742) (i32.const 31888) (i32.const 854)) 918 (memory.copy (i32.const 24236) (i32.const 31866) (i32.const 1377)) 919 (memory.copy (i32.const 33778) (i32.const 692) (i32.const 1594)) 920 (memory.copy (i32.const 60618) (i32.const 18585) (i32.const 2987)) 921 (memory.copy (i32.const 50370) (i32.const 41271) (i32.const 1406)) 922 ) 923 )` 924 ); 925 inst.exports.testfn(); 926 let b = new Uint8Array(inst.exports.memory.buffer); 927 checkRange(b, 0, 124, 0); 928 checkRange(b, 124, 1517, 9); 929 checkRange(b, 1517, 2132, 0); 930 checkRange(b, 2132, 2827, 10); 931 checkRange(b, 2827, 2921, 92); 932 checkRange(b, 2921, 3538, 83); 933 checkRange(b, 3538, 3786, 77); 934 checkRange(b, 3786, 4042, 97); 935 checkRange(b, 4042, 4651, 99); 936 checkRange(b, 4651, 5057, 0); 937 checkRange(b, 5057, 5109, 99); 938 checkRange(b, 5109, 5291, 0); 939 checkRange(b, 5291, 5524, 72); 940 checkRange(b, 5524, 5691, 92); 941 checkRange(b, 5691, 6552, 83); 942 checkRange(b, 6552, 7133, 77); 943 checkRange(b, 7133, 7665, 99); 944 checkRange(b, 7665, 8314, 0); 945 checkRange(b, 8314, 8360, 62); 946 checkRange(b, 8360, 8793, 86); 947 checkRange(b, 8793, 8979, 83); 948 checkRange(b, 8979, 9373, 79); 949 checkRange(b, 9373, 9518, 95); 950 checkRange(b, 9518, 9934, 59); 951 checkRange(b, 9934, 10087, 77); 952 checkRange(b, 10087, 10206, 5); 953 checkRange(b, 10206, 10230, 77); 954 checkRange(b, 10230, 10249, 41); 955 checkRange(b, 10249, 11148, 83); 956 checkRange(b, 11148, 11356, 74); 957 checkRange(b, 11356, 11380, 93); 958 checkRange(b, 11380, 11939, 74); 959 checkRange(b, 11939, 12159, 68); 960 checkRange(b, 12159, 12575, 83); 961 checkRange(b, 12575, 12969, 79); 962 checkRange(b, 12969, 13114, 95); 963 checkRange(b, 13114, 14133, 59); 964 checkRange(b, 14133, 14404, 76); 965 checkRange(b, 14404, 14428, 57); 966 checkRange(b, 14428, 14458, 59); 967 checkRange(b, 14458, 14580, 32); 968 checkRange(b, 14580, 14777, 89); 969 checkRange(b, 14777, 15124, 59); 970 checkRange(b, 15124, 15126, 36); 971 checkRange(b, 15126, 15192, 100); 972 checkRange(b, 15192, 15871, 96); 973 checkRange(b, 15871, 15998, 95); 974 checkRange(b, 15998, 17017, 59); 975 checkRange(b, 17017, 17288, 76); 976 checkRange(b, 17288, 17312, 57); 977 checkRange(b, 17312, 17342, 59); 978 checkRange(b, 17342, 17464, 32); 979 checkRange(b, 17464, 17661, 89); 980 checkRange(b, 17661, 17727, 59); 981 checkRange(b, 17727, 17733, 5); 982 checkRange(b, 17733, 17893, 96); 983 checkRange(b, 17893, 18553, 77); 984 checkRange(b, 18553, 18744, 42); 985 checkRange(b, 18744, 18801, 76); 986 checkRange(b, 18801, 18825, 57); 987 checkRange(b, 18825, 18876, 59); 988 checkRange(b, 18876, 18885, 77); 989 checkRange(b, 18885, 18904, 41); 990 checkRange(b, 18904, 19567, 83); 991 checkRange(b, 19567, 20403, 96); 992 checkRange(b, 20403, 21274, 77); 993 checkRange(b, 21274, 21364, 100); 994 checkRange(b, 21364, 21468, 74); 995 checkRange(b, 21468, 21492, 93); 996 checkRange(b, 21492, 22051, 74); 997 checkRange(b, 22051, 22480, 68); 998 checkRange(b, 22480, 22685, 100); 999 checkRange(b, 22685, 22694, 68); 1000 checkRange(b, 22694, 22821, 10); 1001 checkRange(b, 22821, 22869, 100); 1002 checkRange(b, 22869, 24107, 97); 1003 checkRange(b, 24107, 24111, 37); 1004 checkRange(b, 24111, 24236, 77); 1005 checkRange(b, 24236, 24348, 72); 1006 checkRange(b, 24348, 24515, 92); 1007 checkRange(b, 24515, 24900, 83); 1008 checkRange(b, 24900, 25136, 95); 1009 checkRange(b, 25136, 25182, 85); 1010 checkRange(b, 25182, 25426, 68); 1011 checkRange(b, 25426, 25613, 89); 1012 checkRange(b, 25613, 25830, 96); 1013 checkRange(b, 25830, 26446, 100); 1014 checkRange(b, 26446, 26517, 10); 1015 checkRange(b, 26517, 27468, 92); 1016 checkRange(b, 27468, 27503, 95); 1017 checkRange(b, 27503, 27573, 77); 1018 checkRange(b, 27573, 28245, 92); 1019 checkRange(b, 28245, 28280, 95); 1020 checkRange(b, 28280, 29502, 77); 1021 checkRange(b, 29502, 29629, 42); 1022 checkRange(b, 29629, 30387, 83); 1023 checkRange(b, 30387, 30646, 77); 1024 checkRange(b, 30646, 31066, 92); 1025 checkRange(b, 31066, 31131, 77); 1026 checkRange(b, 31131, 31322, 42); 1027 checkRange(b, 31322, 31379, 76); 1028 checkRange(b, 31379, 31403, 57); 1029 checkRange(b, 31403, 31454, 59); 1030 checkRange(b, 31454, 31463, 77); 1031 checkRange(b, 31463, 31482, 41); 1032 checkRange(b, 31482, 31649, 83); 1033 checkRange(b, 31649, 31978, 72); 1034 checkRange(b, 31978, 32145, 92); 1035 checkRange(b, 32145, 32530, 83); 1036 checkRange(b, 32530, 32766, 95); 1037 checkRange(b, 32766, 32812, 85); 1038 checkRange(b, 32812, 33056, 68); 1039 checkRange(b, 33056, 33660, 89); 1040 checkRange(b, 33660, 33752, 59); 1041 checkRange(b, 33752, 33775, 36); 1042 checkRange(b, 33775, 33778, 32); 1043 checkRange(b, 33778, 34603, 9); 1044 checkRange(b, 34603, 35218, 0); 1045 checkRange(b, 35218, 35372, 10); 1046 checkRange(b, 35372, 35486, 77); 1047 checkRange(b, 35486, 35605, 5); 1048 checkRange(b, 35605, 35629, 77); 1049 checkRange(b, 35629, 35648, 41); 1050 checkRange(b, 35648, 36547, 83); 1051 checkRange(b, 36547, 36755, 74); 1052 checkRange(b, 36755, 36767, 93); 1053 checkRange(b, 36767, 36810, 83); 1054 checkRange(b, 36810, 36839, 100); 1055 checkRange(b, 36839, 37444, 96); 1056 checkRange(b, 37444, 38060, 100); 1057 checkRange(b, 38060, 38131, 10); 1058 checkRange(b, 38131, 39082, 92); 1059 checkRange(b, 39082, 39117, 95); 1060 checkRange(b, 39117, 39187, 77); 1061 checkRange(b, 39187, 39859, 92); 1062 checkRange(b, 39859, 39894, 95); 1063 checkRange(b, 39894, 40257, 77); 1064 checkRange(b, 40257, 40344, 89); 1065 checkRange(b, 40344, 40371, 59); 1066 checkRange(b, 40371, 40804, 77); 1067 checkRange(b, 40804, 40909, 5); 1068 checkRange(b, 40909, 42259, 92); 1069 checkRange(b, 42259, 42511, 77); 1070 checkRange(b, 42511, 42945, 83); 1071 checkRange(b, 42945, 43115, 77); 1072 checkRange(b, 43115, 43306, 42); 1073 checkRange(b, 43306, 43363, 76); 1074 checkRange(b, 43363, 43387, 57); 1075 checkRange(b, 43387, 43438, 59); 1076 checkRange(b, 43438, 43447, 77); 1077 checkRange(b, 43447, 43466, 41); 1078 checkRange(b, 43466, 44129, 83); 1079 checkRange(b, 44129, 44958, 96); 1080 checkRange(b, 44958, 45570, 77); 1081 checkRange(b, 45570, 45575, 92); 1082 checkRange(b, 45575, 45640, 77); 1083 checkRange(b, 45640, 45742, 42); 1084 checkRange(b, 45742, 45832, 72); 1085 checkRange(b, 45832, 45999, 92); 1086 checkRange(b, 45999, 46384, 83); 1087 checkRange(b, 46384, 46596, 95); 1088 checkRange(b, 46596, 46654, 92); 1089 checkRange(b, 46654, 47515, 83); 1090 checkRange(b, 47515, 47620, 77); 1091 checkRange(b, 47620, 47817, 79); 1092 checkRange(b, 47817, 47951, 95); 1093 checkRange(b, 47951, 48632, 100); 1094 checkRange(b, 48632, 48699, 97); 1095 checkRange(b, 48699, 48703, 37); 1096 checkRange(b, 48703, 49764, 77); 1097 checkRange(b, 49764, 49955, 42); 1098 checkRange(b, 49955, 50012, 76); 1099 checkRange(b, 50012, 50036, 57); 1100 checkRange(b, 50036, 50087, 59); 1101 checkRange(b, 50087, 50096, 77); 1102 checkRange(b, 50096, 50115, 41); 1103 checkRange(b, 50115, 50370, 83); 1104 checkRange(b, 50370, 51358, 92); 1105 checkRange(b, 51358, 51610, 77); 1106 checkRange(b, 51610, 51776, 83); 1107 checkRange(b, 51776, 51833, 89); 1108 checkRange(b, 51833, 52895, 100); 1109 checkRange(b, 52895, 53029, 97); 1110 checkRange(b, 53029, 53244, 68); 1111 checkRange(b, 53244, 54066, 100); 1112 checkRange(b, 54066, 54133, 97); 1113 checkRange(b, 54133, 54137, 37); 1114 checkRange(b, 54137, 55198, 77); 1115 checkRange(b, 55198, 55389, 42); 1116 checkRange(b, 55389, 55446, 76); 1117 checkRange(b, 55446, 55470, 57); 1118 checkRange(b, 55470, 55521, 59); 1119 checkRange(b, 55521, 55530, 77); 1120 checkRange(b, 55530, 55549, 41); 1121 checkRange(b, 55549, 56212, 83); 1122 checkRange(b, 56212, 57048, 96); 1123 checkRange(b, 57048, 58183, 77); 1124 checkRange(b, 58183, 58202, 41); 1125 checkRange(b, 58202, 58516, 83); 1126 checkRange(b, 58516, 58835, 95); 1127 checkRange(b, 58835, 58855, 77); 1128 checkRange(b, 58855, 59089, 95); 1129 checkRange(b, 59089, 59145, 77); 1130 checkRange(b, 59145, 59677, 99); 1131 checkRange(b, 59677, 60134, 0); 1132 checkRange(b, 60134, 60502, 89); 1133 checkRange(b, 60502, 60594, 59); 1134 checkRange(b, 60594, 60617, 36); 1135 checkRange(b, 60617, 60618, 32); 1136 checkRange(b, 60618, 60777, 42); 1137 checkRange(b, 60777, 60834, 76); 1138 checkRange(b, 60834, 60858, 57); 1139 checkRange(b, 60858, 60909, 59); 1140 checkRange(b, 60909, 60918, 77); 1141 checkRange(b, 60918, 60937, 41); 1142 checkRange(b, 60937, 61600, 83); 1143 checkRange(b, 61600, 62436, 96); 1144 checkRange(b, 62436, 63307, 77); 1145 checkRange(b, 63307, 63397, 100); 1146 checkRange(b, 63397, 63501, 74); 1147 checkRange(b, 63501, 63525, 93); 1148 checkRange(b, 63525, 63605, 74); 1149 checkRange(b, 63605, 63704, 100); 1150 checkRange(b, 63704, 63771, 97); 1151 checkRange(b, 63771, 63775, 37); 1152 checkRange(b, 63775, 64311, 77); 1153 checkRange(b, 64311, 64331, 26); 1154 checkRange(b, 64331, 64518, 92); 1155 checkRange(b, 64518, 64827, 11); 1156 checkRange(b, 64827, 64834, 26); 1157 checkRange(b, 64834, 65536, 0); 1158 } 1159 1160 // Make sure dead code doesn't prevent compilation. 1161 wasmEvalText( 1162 `(module 1163 (memory 0 10) 1164 (data (i32.const 0)) 1165 (func 1166 (return) 1167 (memory.init 0) 1168 ) 1169 )`); 1170 1171 wasmEvalText( 1172 `(module 1173 (memory 0 10) 1174 (func 1175 (return) 1176 (memory.fill) 1177 ) 1178 )`); 1179 1180 wasmEvalText( 1181 `(module 1182 (table (export "t") 10 funcref) 1183 (elem (i32.const 0) 0) 1184 (func 1185 (return) 1186 (elem.drop 0) 1187 ) 1188 )`);