tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

codegen-arm64-test.js (1956B)


      1 // Scaffolding for testing arm64 Ion code generation patterns .  See
      2 // codegen-x64-test.js in this directory for more information.
      3 
      4 load(libdir + "codegen-test-common.js");
      5 
      6 // End of prologue
      7 var arm64_prefix = `
      8 mov     x29, sp
      9 mov     x28, sp(
     10 str     x23, \\[x29, #16\\])?
     11 `;
     12 
     13 // Start of epilogue
     14 var arm64_suffix = `
     15 ldr     x30, \\[sp, #8\\]
     16 ldr     x29, \\[sp\\]
     17 `;
     18 
     19 // For when nothing else applies: `module_text` is the complete source text of
     20 // the module, `export_name` is the name of the function to be tested,
     21 // `expected` is the non-preprocessed pattern, and options is an options bag,
     22 // described above.
     23 function codegenTestARM64_adhoc(module_text, export_name, expected, options = {}) {
     24    assertEq(hasDisassembler(), true);
     25 
     26    let ins = wasmEvalText(module_text, {}, options.features);
     27    if (options.instanceBox)
     28        options.instanceBox.value = ins;
     29    let output = wasmDis(ins.exports[export_name], {tier:"ion", asString:true});
     30 
     31    const expected_initial = expected;
     32    if (!options.no_prefix)
     33        expected = arm64_prefix + '\n' + expected;
     34    if (!options.no_suffix)
     35        expected = expected + '\n' + arm64_suffix;
     36    expected = fixlines(expected);
     37 
     38    const output_simple = stripencoding(output, `${HEX}{8}`);
     39    const output_matches_expected = output_simple.match(new RegExp(expected)) != null;
     40    if (!output_matches_expected) {
     41        print("---- codegen-arm64-test.js: TEST FAILED ----");
     42    }
     43    if (options.log && output_matches_expected) {
     44        print("---- codegen-arm64-test.js: TEST PASSED ----");
     45    }
     46    if (options.log || !output_matches_expected) {
     47        print("---- module text");
     48        print(module_text);
     49        print("---- actual");
     50        print(output);
     51        print("---- expected (initial)");
     52        print(expected_initial);
     53        print("---- expected (as used)");
     54        print(expected);
     55        print("----");
     56    }
     57 
     58    assertEq(output_matches_expected, true);
     59 }