tor-browser

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

stencil-can-lazily-parse-mismatch.js (2730B)


      1 // |jit-test| skip-if: isLcovEnabled()
      2 // Code coverage forces full-parse.
      3 
      4 load(libdir + 'asserts.js');
      5 
      6 const code = `var a = 10;`;
      7 
      8 function testCompile(sourceIsLazy1, sourceIsLazy2,
      9                     forceFullParse1, forceFullParse2) {
     10  const stencil = compileToStencil(code, { sourceIsLazy: sourceIsLazy1,
     11                                           forceFullParse: forceFullParse1 });
     12  // The laziness options are ignored for instantiation, and no error is thrown.
     13  evalStencil(stencil, { sourceIsLazy: sourceIsLazy2,
     14                         forceFullParse: forceFullParse2 });
     15 }
     16 
     17 function testOffThreadCompile(sourceIsLazy1, sourceIsLazy2,
     18                              forceFullParse1, forceFullParse2) {
     19  offThreadCompileToStencil(code, { sourceIsLazy: sourceIsLazy1,
     20                                    forceFullParse: forceFullParse1 });
     21  const stencil = finishOffThreadStencil();
     22  // The laziness options are ignored for instantiation, and no error is thrown.
     23  evalStencil(stencil, { sourceIsLazy: sourceIsLazy2,
     24                         forceFullParse: forceFullParse2 });
     25 }
     26 
     27 function testXDR(sourceIsLazy1, sourceIsLazy2,
     28                 forceFullParse1, forceFullParse2) {
     29  const xdr = compileToStencilXDR(code, { sourceIsLazy: sourceIsLazy1,
     30                                          forceFullParse: forceFullParse1 });
     31  // The compile options are ignored when decoding, and no error is thrown.
     32  evalStencilXDR(xdr, { sourceIsLazy: sourceIsLazy2,
     33                        forceFullParse: forceFullParse2 });
     34 }
     35 
     36 function testOffThreadXDR(sourceIsLazy1, sourceIsLazy2,
     37                          forceFullParse1, forceFullParse2) {
     38  const t = cacheEntry(code);
     39  evaluate(t, { sourceIsLazy: sourceIsLazy1,
     40                forceFullParse: forceFullParse1,
     41                saveBytecodeWithDelazifications: true });
     42 
     43  // The compile options are ignored when decoding, and no error is thrown.
     44  offThreadDecodeStencil(t, { sourceIsLazy: sourceIsLazy2,
     45                             forceFullParse: forceFullParse2 });
     46  const stencil = finishOffThreadStencil();
     47 
     48  // The laziness options are ignored for instantiation, and no error is thrown.
     49  evalStencil(stencil, { sourceIsLazy: sourceIsLazy2,
     50                         forceFullParse: forceFullParse2 });
     51 }
     52 
     53 const optionsList = [
     54  [true, false, false, false],
     55  [false, true, false, false],
     56  [false, false, true, false],
     57  [false, false, false, true],
     58  [true, false, true, false],
     59  [false, true, false, true],
     60 ];
     61 
     62 for (const options of optionsList) {
     63  testCompile(...options);
     64  if (helperThreadCount() > 0) {
     65    testOffThreadCompile(...options);
     66  }
     67  testXDR(...options);
     68  if (helperThreadCount() > 0) {
     69    testOffThreadXDR(...options);
     70  }
     71 }