skipping-inner-functions-bailout.js 2.18 KB
Newer Older
1 2 3 4
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
// Flags: --preparser-scope-analysis
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

// Tests for cases where PreParser must bail out of creating data for skipping
// inner functions, since it cannot replicate the Scope structure created by
// Parser.

function TestBailoutBecauseOfSloppyEvalInArrowParams() {
  let bailout = (a = function() {}, b = eval('')) => 0
  bailout();

  function not_skippable() {}
}
TestBailoutBecauseOfSloppyEvalInArrowParams();

function TestBailoutBecauseOfSloppyEvalInArrowParams2() {
  let bailout = (a = function() {}, b = eval('')) => {}
  bailout();

  function not_skippable() {}
}
TestBailoutBecauseOfSloppyEvalInArrowParams2();

function TestBailoutBecauseOfSloppyEvalInParams() {
  function bailout(a = function() {}, b = eval('')) {
    function not_skippable() {}
  }
  bailout();

  function not_skippable_either() {}
}
TestBailoutBecauseOfSloppyEvalInParams();

 // Test bailing out from 2 places.
function TestMultiBailout1() {
  function bailout(a = function() {}, b = eval('')) {
    function not_skippable() {}
  }
  bailout();

  function bailout_too(a = function() {}, b = eval('')) {
    function not_skippable_either() {}
  }
  bailout_too();
}
TestMultiBailout1();

function TestMultiBailout2() {
  function f(a = function() {}, b = eval('')) {
    function not_skippable() {}
  }
  f();

  function not_skippable_either() {
    function bailout_too(a = function() {}, b = eval('')) {
      function inner_not_skippable() {}
    }
    bailout_too();
  }
  not_skippable_either();
}
TestMultiBailout2();

function TestMultiBailout3() {
  function bailout(a = function() {}, b = eval('')) {
    function bailout_too(a = function() {}, b = eval('')) {
      function not_skippable() {}
    }
    bailout_too();
  }
  bailout();

  function not_skippable_either() {}
}
TestMultiBailout3();
79 80 81 82 83 84

// Regression test for
// https://bugs.chromium.org/p/chromium/issues/detail?id=761980. The conditions
// triggering a bailout occur in a context where we're not generating data
// anyway (inside an arrow function). (This needs to be at top level.)
x => { (y=eval()) => {} }