bce-x86-ion-codegen.js (1964B)
1 // |jit-test| --wasm-compiler=optimizing; --spectre-mitigations=off; skip-if: !hasDisassembler() || wasmCompileMode() != "ion" || !getBuildConfiguration("x86") || getBuildConfiguration("simulator") || getJitCompilerOptions()["ion.check-range-analysis"]; include:codegen-x86-test.js 2 3 // Spectre mitigation is disabled above to make the generated code simpler to 4 // match; ion.check-range-analysis makes a hash of the code and makes testing 5 // pointless. 6 7 // White-box testing of bounds check elimination on 32-bit systems. 8 // 9 // This is probably fairly brittle, but BCE (on 64-bit platforms) regressed (bug 10 // 1735207) without us noticing, so it's not like we can do without these tests. 11 // 12 // See also bce-x64-ion-codegen.js. 13 14 // Make sure the check for the second load is removed: the two load instructions 15 // should appear back-to-back in the output. 16 codegenTestX86_adhoc( 17 `(module 18 (memory 1) 19 (func (export "f") (param i32) (result i32) 20 (local i32) 21 (local.set 1 (i32.add (local.get 0) (i32.const 4))) 22 (i32.load (local.get 1)) 23 drop 24 (i32.load (local.get 1))))`, 25 'f', ` 26 (movl 0x04\\(%r..\\), %e..\ncmp %e.., %e..|cmpl 0x04\\(%r..\\), %e..) 27 jnb 0x00000000000000.. 28 movl \\(%r..,%r..,1\\), %e.. 29 movl \\(%r..,%r..,1\\), %eax`, 30 {no_prefix:true}); 31 32 // Make sure constant indices below the heap minimum do not require a bounds check. 33 // The first movl from *rsi below loads the heap base from Tls, an x86-ism. 34 codegenTestX86_adhoc( 35 `(module 36 (memory 1) 37 (func (export "f") (result i32) 38 (i32.load (i32.const 16))))`, 39 'f', ` 40 movl \\(%rsi\\), %e.. 41 movl 0x10\\(%r..\\), %eax`); 42 43 // Ditto, even at the very limit of the known heap, extending into the guard 44 // page. This is an OOB access, of course, but it needs no explicit bounds 45 // check. 46 codegenTestX86_adhoc( 47 `(module 48 (memory 1) 49 (func (export "f") (result i32) 50 (i32.load (i32.const 65535))))`, 51 'f', 52 ` 53 movl \\(%rsi\\), %e.. 54 movl 0xFFFF\\(%r..\\), %eax`);